Fix a problem with the arrows when register first loads

After the register is loaded, when you first click on a arrow button
the popup appears but the arrow disappears, subsequent pressing and the
arrow toggles as expected. To fix this pack both arrows on the button
and hide the one not active.
This commit is contained in:
Robert Fewell 2017-08-01 10:38:21 +01:00
parent 4bef3a59e0
commit a2fa9eeff3
2 changed files with 18 additions and 13 deletions

View File

@ -175,7 +175,8 @@ gnc_item_edit_init (GncItemEdit *item_edit)
item_edit->popup_toggle.ebox = NULL;
item_edit->popup_toggle.tbutton = NULL;
item_edit->popup_toggle.arrow = NULL;
item_edit->popup_toggle.arrow_up = NULL;
item_edit->popup_toggle.arrow_down = NULL;
item_edit->popup_toggle.signals_connected = FALSE;
item_edit->popup_item = NULL;
@ -510,6 +511,7 @@ GtkWidget *
gnc_item_edit_new (GnucashSheet *sheet)
{
char *hpad_str, *vpad_str, *entry_css;
GtkWidget *box;
GtkStyleContext *stylecontext;
GtkCssProvider *provider;
GncItemEdit *item_edit =
@ -545,13 +547,17 @@ gnc_item_edit_new (GnucashSheet *sheet)
/* Create the popup button
It will only be displayed when the cell being edited provides
a popup item (like a calendar or account list) */
item_edit->popup_toggle.arrow = gtk_image_new_from_icon_name ("go-down", GTK_ICON_SIZE_BUTTON);
item_edit->popup_toggle.arrow_down = gtk_image_new_from_icon_name ("go-down", GTK_ICON_SIZE_BUTTON);
item_edit->popup_toggle.arrow_up = gtk_image_new_from_icon_name ("go-up", GTK_ICON_SIZE_BUTTON);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_pack_start (GTK_BOX(box), GTK_WIDGET(item_edit->popup_toggle.arrow_down), FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX(box), GTK_WIDGET(item_edit->popup_toggle.arrow_up),FALSE, FALSE, 0);
item_edit->popup_toggle.tbutton = gtk_toggle_button_new();
gtk_toggle_button_set_mode (
GTK_TOGGLE_BUTTON (item_edit->popup_toggle.tbutton), FALSE);
gtk_container_add(GTK_CONTAINER(item_edit->popup_toggle.tbutton),
GTK_WIDGET(item_edit->popup_toggle.arrow));
gtk_container_add(GTK_CONTAINER(item_edit->popup_toggle.tbutton), GTK_WIDGET(box));
/* Force padding on the button to
1. keep it small
@ -574,6 +580,8 @@ gnc_item_edit_new (GnucashSheet *sheet)
FALSE, TRUE, 0);
gtk_widget_show_all(GTK_WIDGET(item_edit));
gtk_widget_hide (GTK_WIDGET(item_edit->popup_toggle.arrow_up));
return GTK_WIDGET(item_edit);
}
@ -663,10 +671,8 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit)
unblock_toggle_signals (item_edit);
}
gtk_container_remove (GTK_CONTAINER(item_edit->popup_toggle.tbutton), GTK_WIDGET(item_edit->popup_toggle.arrow));
item_edit->popup_toggle.arrow = gtk_image_new_from_icon_name ("go-up", GTK_ICON_SIZE_BUTTON);
gtk_container_add (GTK_CONTAINER(item_edit->popup_toggle.tbutton), GTK_WIDGET(item_edit->popup_toggle.arrow));
gtk_widget_show (item_edit->popup_toggle.arrow);
gtk_widget_hide (item_edit->popup_toggle.arrow_down);
gtk_widget_show (item_edit->popup_toggle.arrow_up);
if (item_edit->popup_set_focus)
item_edit->popup_set_focus (item_edit->popup_item,
@ -711,10 +717,8 @@ gnc_item_edit_hide_popup (GncItemEdit *item_edit)
gtk_container_remove (GTK_CONTAINER(item_edit->sheet), item_edit->popup_item);
gtk_container_remove (GTK_CONTAINER(item_edit->popup_toggle.tbutton), GTK_WIDGET(item_edit->popup_toggle.arrow));
item_edit->popup_toggle.arrow = gtk_image_new_from_icon_name ("go-down", GTK_ICON_SIZE_BUTTON);
gtk_container_add (GTK_CONTAINER(item_edit->popup_toggle.tbutton), GTK_WIDGET(item_edit->popup_toggle.arrow));
gtk_widget_show (item_edit->popup_toggle.arrow);
gtk_widget_hide (item_edit->popup_toggle.arrow_up);
gtk_widget_show (item_edit->popup_toggle.arrow_down);
gtk_toggle_button_set_active
(GTK_TOGGLE_BUTTON(item_edit->popup_toggle.tbutton), FALSE);

View File

@ -61,7 +61,8 @@ struct _PopupToggle
{
GtkWidget *ebox;
GtkWidget *tbutton;
GtkWidget *arrow;
GtkWidget *arrow_up;
GtkWidget *arrow_down;
gboolean signals_connected;
};