Skip to content

Commit a2e99bd

Browse files
committed
Bug 798995 - Keystrokes ignored during ledger entry
Some themes add additional pixels to list rows and dialogs, in this case with 'TraditionalOK' 2 pixels are added to each entry in the list and 2 to the popup. This make the calculation for the pop up height wrong and so when compared to the allocation height it is different so tries to resolve by re-poping the list and this cuases an endless loop. To fix this, use the calculated height which works for Adwaita but if this is different to the popup allocation height use that.
1 parent 891e393 commit a2e99bd

File tree

6 files changed

+48
-39
lines changed

6 files changed

+48
-39
lines changed

gnucash/register/register-gnome/combocell-gnome.c

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -920,29 +920,20 @@ gnc_combo_cell_gui_move (BasicCell* bcell)
920920
}
921921

922922
static int
923-
popup_get_height (G_GNUC_UNUSED GtkWidget* widget,
923+
popup_get_height (GtkWidget* widget,
924924
int space_available,
925-
int row_height,
925+
G_GNUC_UNUSED int row_height,
926926
gpointer user_data)
927927
{
928928
PopBox* box = user_data;
929929
GtkScrolledWindow* scrollwin = GNC_ITEM_LIST(widget)->scrollwin;
930-
GtkWidget *hsbar = gtk_scrolled_window_get_hscrollbar (scrollwin);
931-
GtkStyleContext *context = gtk_widget_get_style_context (hsbar);
932-
/* Note: gtk_scrolled_window_get_overlay_scrolling (scrollwin) always returns
933-
TRUE so look for style class "overlay-indicator" on the scrollbar. */
934-
gboolean overlay = gtk_style_context_has_class (context, "overlay-indicator");
935-
int count, height;
930+
int height;
936931

937-
count = gnc_item_list_num_entries (box->item_list);
938-
height = count * (gnc_item_list_get_cell_height (box->item_list) + 2);
939-
940-
if (!overlay)
941-
{
942-
gint minh, nath;
943-
gtk_widget_get_preferred_height (hsbar, &minh, &nath);
944-
height = height + minh;
945-
}
932+
// if popup_allocation_height set use that
933+
if (box->item_edit->popup_allocation_height != -1)
934+
height = box->item_edit->popup_allocation_height;
935+
else
936+
height = gnc_item_list_get_popup_height (GNC_ITEM_LIST(widget));
946937

947938
if (height < space_available)
948939
{

gnucash/register/register-gnome/completioncell-gnome.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ populate_list_store (CompletionCell* cell, const gchar* str)
644644
PopBox* box = cell->cell.gui_private;
645645

646646
box->in_list_select = FALSE;
647+
box->item_edit->popup_allocation_height = -1;
647648

648649
if (box->stop_searching)
649650
return;
@@ -904,27 +905,20 @@ gnc_completion_cell_gui_move (BasicCell* bcell)
904905
}
905906

906907
static int
907-
popup_get_height (G_GNUC_UNUSED GtkWidget* widget,
908+
popup_get_height (GtkWidget* widget,
908909
int space_available,
909-
int row_height,
910+
G_GNUC_UNUSED int row_height,
910911
gpointer user_data)
911912
{
912913
PopBox* box = user_data;
913914
GtkScrolledWindow* scrollwin = GNC_ITEM_LIST(widget)->scrollwin;
914-
GtkWidget *hsbar = gtk_scrolled_window_get_hscrollbar (scrollwin);
915-
GtkStyleContext *context = gtk_widget_get_style_context (hsbar);
916-
/* Note: gtk_scrolled_window_get_overlay_scrolling (scrollwin) always returns
917-
TRUE so look for style class "overlay-indicator" on the scrollbar. */
918-
gboolean overlay = gtk_style_context_has_class (context, "overlay-indicator");
919-
int count = gnc_item_list_num_entries (box->item_list);
920-
int height = count * (gnc_item_list_get_cell_height (box->item_list) + 2);
921-
922-
if (!overlay)
923-
{
924-
gint minh, nath;
925-
gtk_widget_get_preferred_height (hsbar, &minh, &nath);
926-
height = height + minh;
927-
}
915+
int height;
916+
917+
// if popup_allocation_height set use that
918+
if (box->item_edit->popup_allocation_height != -1)
919+
height = box->item_edit->popup_allocation_height;
920+
else
921+
height = gnc_item_list_get_popup_height (GNC_ITEM_LIST(widget));
928922

929923
if (height < space_available)
930924
{

gnucash/register/register-gnome/gnucash-item-edit.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,7 @@ gnc_item_edit_init (GncItemEdit *item_edit)
319319
item_edit->popup_user_data = NULL;
320320
item_edit->popup_returned_height = 0;
321321
item_edit->popup_height_signal_id = 0;
322+
item_edit->popup_allocation_height = -1;
322323

323324
item_edit->style = NULL;
324325
item_edit->button_width = MIN_BUTT_WIDTH;
@@ -944,15 +945,15 @@ gnc_item_edit_destroying (GtkWidget *item_edit, gpointer data)
944945
static void
945946
check_popup_height_is_true (GtkWidget *widget,
946947
GdkRectangle *allocation,
947-
gpointer user_data)
948+
gpointer user_data)
948949
{
949950
GncItemEdit *item_edit = GNC_ITEM_EDIT(user_data);
950951

951-
// if a larger font is specified in css for the sheet, the popup returned height value
952-
// on first pop does not reflect the true height but the minimum height so just to be
953-
// sure check this value against the allocated one.
952+
// the popup returned height value on first pop sometimes does not reflect the true height
953+
// but the minimum height so just to be sure check this value against the allocated one.
954954
if (allocation->height != item_edit->popup_returned_height)
955955
{
956+
item_edit->popup_allocation_height = allocation->height;
956957
gtk_container_remove (GTK_CONTAINER(item_edit->sheet), item_edit->popup_item);
957958

958959
g_idle_add_full (G_PRIORITY_HIGH_IDLE,
@@ -1105,6 +1106,8 @@ gnc_item_edit_hide_popup (GncItemEdit *item_edit)
11051106
gtk_toggle_button_set_active
11061107
(GTK_TOGGLE_BUTTON(item_edit->popup_toggle.tbutton), FALSE);
11071108

1109+
item_edit->popup_allocation_height = -1;
1110+
11081111
gtk_widget_grab_focus (GTK_WIDGET(item_edit->sheet));
11091112
}
11101113

gnucash/register/register-gnome/gnucash-item-edit.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ typedef struct
9191
PopupGetWidth popup_get_width;
9292
gpointer popup_user_data;
9393
gint popup_returned_height;
94+
gint popup_allocation_height;
9495
gulong popup_height_signal_id;
9596

9697
GtkBorder padding;

gnucash/register/register-gnome/gnucash-item-list.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ tree_view_selection_changed (GtkTreeSelection* selection,
468468
}
469469

470470

471-
gint
471+
static gint
472472
gnc_item_list_get_cell_height (GncItemList *item_list)
473473
{
474474

@@ -481,6 +481,26 @@ gnc_item_list_get_cell_height (GncItemList *item_list)
481481
return min_height;
482482
}
483483

484+
gint
485+
gnc_item_list_get_popup_height (GncItemList *item_list)
486+
{
487+
GtkWidget *hsbar = gtk_scrolled_window_get_hscrollbar (GTK_SCROLLED_WINDOW(item_list->scrollwin));
488+
GtkStyleContext *context = gtk_widget_get_style_context (hsbar);
489+
/* Note: gtk_scrolled_window_get_overlay_scrolling (scrollwin) always returns
490+
TRUE so look for style class "overlay-indicator" on the scrollbar. */
491+
gboolean overlay = gtk_style_context_has_class (context, "overlay-indicator");
492+
int count = gnc_item_list_num_entries (item_list);
493+
int height = count * (gnc_item_list_get_cell_height (item_list) + 2);
494+
495+
if (!overlay)
496+
{
497+
gint minh, nath;
498+
gtk_widget_get_preferred_height (hsbar, &minh, &nath);
499+
height = height + minh;
500+
}
501+
return height;
502+
}
503+
484504

485505
GtkWidget*
486506
gnc_item_list_new (GtkListStore* list_store)

gnucash/register/register-gnome/gnucash-item-list.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ GtkWidget *gnc_item_list_new (GtkListStore *shared_store);
7171

7272
gint gnc_item_list_num_entries (GncItemList *item_list);
7373

74-
gint gnc_item_list_get_cell_height (GncItemList *item_list);
74+
gint gnc_item_list_get_popup_height (GncItemList *item_list);
7575

7676
void gnc_item_list_clear (GncItemList *item_list);
7777

0 commit comments

Comments
 (0)