talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 3833e1f728822c2d9dffe02f8f9cc1ec76d2d930
parent 8adbf38cfec39c78c2560903614baa2873f63b85
Author: Andrej Kacian <ticho@claws-mail.org>
Date:   Sat, 12 Jan 2019 23:52:40 +0100

Fix image viewer resizing

For some reason, GTK3's GtkImage does not update its
size when new contents get set to it. We have to force
it by calling gtk_widget_size_allocate() on its parent
container.

Diffstat:
Msrc/image_viewer.c | 12+++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/image_viewer.c b/src/image_viewer.c @@ -87,7 +87,7 @@ static void image_viewer_load_file(ImageViewer *imageviewer, const gchar *imgfil if (imageviewer->resize_img) { gtk_widget_get_allocation( - gtk_widget_get_parent(imageviewer->notebook), &allocation); + gtk_widget_get_parent(imageviewer->image), &allocation); pixbuf = claws_load_pixbuf_fitting(pixbuf, allocation.width, allocation.height); @@ -108,17 +108,19 @@ static void image_viewer_load_file(ImageViewer *imageviewer, const gchar *imgfil return; } + g_signal_handlers_block_by_func(G_OBJECT(imageviewer->scrolledwin), + G_CALLBACK(scrolledwin_resize_cb), imageviewer); + if (animation) gtk_image_set_from_animation(GTK_IMAGE(imageviewer->image), animation); else gtk_image_set_from_pixbuf(GTK_IMAGE(imageviewer->image), pixbuf); - g_signal_handlers_block_by_func(G_OBJECT(imageviewer->scrolledwin), - G_CALLBACK(scrolledwin_resize_cb), imageviewer); - + gtk_widget_get_allocation(imageviewer->scrolledwin, &allocation); + gtk_widget_size_allocate(imageviewer->scrolledwin, &allocation); gtk_widget_show(imageviewer->image); - GTK_EVENTS_FLUSH(); + g_signal_handlers_unblock_by_func(G_OBJECT(imageviewer->scrolledwin), G_CALLBACK(scrolledwin_resize_cb), imageviewer);