From d3ef2b3a5dfd9a8f7f5a99be184df287898d6cc1 Mon Sep 17 00:00:00 2001 From: raveit65 Date: Fri, 14 Apr 2017 12:43:39 +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 | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'eel') diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c index da39007c..81dafc43 100644 --- a/eel/eel-canvas.c +++ b/eel/eel-canvas.c @@ -578,6 +578,15 @@ eel_canvas_item_move (EelCanvasItem *item, double dx, double dy) } +#if GTK_CHECK_VERSION (3, 0, 0) +static void +eel_canvas_queue_resize (EelCanvas *canvas) +{ + if (gtk_widget_is_drawable (GTK_WIDGET (canvas))) + gtk_widget_queue_resize (GTK_WIDGET (canvas)); +} +#endif + /* 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. */ @@ -851,6 +860,9 @@ eel_canvas_item_show (EelCanvasItem *item) } redraw_and_repick_if_mapped (item); +#if GTK_CHECK_VERSION (3, 0, 0) + eel_canvas_queue_resize (item->canvas); +#endif } } @@ -876,6 +888,10 @@ eel_canvas_item_hide (EelCanvasItem *item) if (item->flags & EEL_CANVAS_ITEM_MAPPED) (* EEL_CANVAS_ITEM_GET_CLASS (item)->unmap) (item); +#if GTK_CHECK_VERSION (3, 0, 0) + eel_canvas_queue_resize (item->canvas); +#endif + /* No need to unrealize when we just want to hide */ } } @@ -1909,6 +1925,11 @@ group_add (EelCanvasGroup *group, EelCanvasItem *item) if (!(item->flags & EEL_CANVAS_ITEM_MAPPED)) (* EEL_CANVAS_ITEM_GET_CLASS (item)->map) (item); } + +#if GTK_CHECK_VERSION (3, 0, 0) + if (item->flags & EEL_CANVAS_ITEM_VISIBLE) + eel_canvas_queue_resize (EEL_CANVAS_ITEM (group)->canvas); +#endif } /* Removes an item from a group */ @@ -1929,6 +1950,11 @@ group_remove (EelCanvasGroup *group, EelCanvasItem *item) if (item->flags & EEL_CANVAS_ITEM_REALIZED) (* EEL_CANVAS_ITEM_GET_CLASS (item)->unrealize) (item); +#if GTK_CHECK_VERSION (3, 0, 0) + if (item->flags & EEL_CANVAS_ITEM_VISIBLE) + eel_canvas_queue_resize (item->canvas); +#endif + /* Unparent the child */ item->parent = NULL; -- cgit v1.2.1