From dddec5fcd50f15eb03a95e0369b418b5b8ce131f Mon Sep 17 00:00:00 2001 From: raveit65 Date: Wed, 12 Apr 2017 19:45:30 +0200 Subject: eel: Queue resizes on the canvas as elements change visibility Not queueing resizes may play oddly with the size request caches in GTK+, resulting in gtk_widget_get_preferred_width/height returning 0 even after the canvas was populated. https://bugzilla.gnome.org/show_bug.cgi?id=667831 Taken from: https://git.gnome.org/browse/nautilus/commit/?id=8c77821 --- eel/eel-canvas.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'eel/eel-canvas.c') diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c index d88aeecb..97a6a2f0 100644 --- a/eel/eel-canvas.c +++ b/eel/eel-canvas.c @@ -557,6 +557,13 @@ eel_canvas_item_move (EelCanvasItem *item, double dx, double dy) } +static void +eel_canvas_queue_resize (EelCanvas *canvas) +{ + if (gtk_widget_is_drawable (GTK_WIDGET (canvas))) + gtk_widget_queue_resize (GTK_WIDGET (canvas)); +} + /* Convenience function to reorder items in a group's child list. This puts the * specified link after the "before" link. Returns TRUE if the list was changed. */ @@ -830,6 +837,7 @@ eel_canvas_item_show (EelCanvasItem *item) } redraw_and_repick_if_mapped (item); + eel_canvas_queue_resize (item->canvas); } } @@ -855,6 +863,8 @@ eel_canvas_item_hide (EelCanvasItem *item) if (item->flags & EEL_CANVAS_ITEM_MAPPED) (* EEL_CANVAS_ITEM_GET_CLASS (item)->unmap) (item); + eel_canvas_queue_resize (item->canvas); + /* No need to unrealize when we just want to hide */ } } @@ -1832,6 +1842,9 @@ group_add (EelCanvasGroup *group, EelCanvasItem *item) if (!(item->flags & EEL_CANVAS_ITEM_MAPPED)) (* EEL_CANVAS_ITEM_GET_CLASS (item)->map) (item); } + + if (item->flags & EEL_CANVAS_ITEM_VISIBLE) + eel_canvas_queue_resize (EEL_CANVAS_ITEM (group)->canvas); } /* Removes an item from a group */ @@ -1846,12 +1859,16 @@ group_remove (EelCanvasGroup *group, EelCanvasItem *item) for (children = group->item_list; children; children = children->next) if (children->data == item) { - if (item->flags & EEL_CANVAS_ITEM_MAPPED) + if (item->flags & EEL_CANVAS_ITEM_MAPPED) { (* EEL_CANVAS_ITEM_GET_CLASS (item)->unmap) (item); + } if (item->flags & EEL_CANVAS_ITEM_REALIZED) (* EEL_CANVAS_ITEM_GET_CLASS (item)->unrealize) (item); + if (item->flags & EEL_CANVAS_ITEM_VISIBLE) + eel_canvas_queue_resize (item->canvas); + /* Unparent the child */ item->parent = NULL; -- cgit v1.2.1