If a font size is specified for the sheet, popup size may be wrong

When you specify a font size for the sheet, the popup will inherit this
but when first popped it will use the minimum height value and so may
be different resulting in not being in the right position. So check on
allocation and if different remove and pop again.
This commit is contained in:
Robert Fewell 2017-11-23 13:53:25 +00:00
parent 67e4b35294
commit 78ec2e339e
2 changed files with 25 additions and 0 deletions

View File

@ -739,6 +739,25 @@ gnc_item_edit_new (GnucashSheet *sheet)
return GTK_WIDGET(item_edit);
}
static void
check_popup_height_is_true (GtkWidget *widget,
GdkRectangle *allocation,
gpointer user_data)
{
GncItemEdit *item_edit = GNC_ITEM_EDIT(user_data);
GnucashSheet *sheet = item_edit->sheet;
// if a larger font is specified in css for the sheet, the popup returned height value
// on first pop does not reflect the true height but the minimum height so just to be
// sure check this value against the allocated one.
if (allocation->height != item_edit->popup_returned_height)
{
gtk_container_remove (GTK_CONTAINER(item_edit->sheet), item_edit->popup_item);
g_idle_add_full (G_PRIORITY_HIGH_IDLE,
(GSourceFunc) gnc_item_edit_update, item_edit, NULL);
}
}
void
gnc_item_edit_show_popup (GncItemEdit *item_edit)
@ -807,6 +826,11 @@ gnc_item_edit_show_popup (GncItemEdit *item_edit)
if (!gtk_widget_get_parent (item_edit->popup_item))
gtk_layout_put (GTK_LAYOUT(sheet), item_edit->popup_item, popup_x, popup_y);
// Lets check popup height is the true height
item_edit->popup_returned_height = popup_h;
g_signal_connect_after (item_edit->popup_item, "size-allocate",
G_CALLBACK(check_popup_height_is_true), item_edit);
gtk_widget_set_size_request (item_edit->popup_item, popup_w - 1, popup_h);
toggle = GTK_TOGGLE_BUTTON(item_edit->popup_toggle.tbutton);

View File

@ -85,6 +85,7 @@ typedef struct
PopupPostShow popup_post_show;
PopupGetWidth popup_get_width;
gpointer popup_user_data;
gint popup_returned_height;
GtkBorder padding;
GtkBorder margin;