From de74036cc420a94e5999da54f17ec6572d0a97f1 Mon Sep 17 00:00:00 2001 From: infirit Date: Thu, 24 Jul 2014 14:51:08 +0200 Subject: Factor out the code to store a pixbuf in EomScrollView Based on eog commit 4f432e981a956cd157ae3f190b9c7850a6f180d9 From Claudio Saavedra --- src/eom-scroll-view.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/eom-scroll-view.c b/src/eom-scroll-view.c index a82fc75..c83471c 100644 --- a/src/eom-scroll-view.c +++ b/src/eom-scroll-view.c @@ -1831,19 +1831,32 @@ image_loading_cancelled_cb (EomImage *img, gpointer data) } } */ + +/* Use when the pixbuf in the view is changed, to keep a + reference to it and create its cairo surface. */ static void -image_changed_cb (EomImage *img, gpointer data) +update_pixbuf (EomScrollView *view, GdkPixbuf *pixbuf) { EomScrollViewPrivate *priv; - priv = EOM_SCROLL_VIEW (data)->priv; + priv = view->priv; if (priv->pixbuf != NULL) { g_object_unref (priv->pixbuf); priv->pixbuf = NULL; } - priv->pixbuf = eom_image_get_pixbuf (img); + priv->pixbuf = pixbuf; +} + +static void +image_changed_cb (EomImage *img, gpointer data) +{ + EomScrollViewPrivate *priv; + + priv = EOM_SCROLL_VIEW (data)->priv; + + update_pixbuf (EOM_SCROLL_VIEW (data), eom_image_get_pixbuf (img)); set_zoom_fit (EOM_SCROLL_VIEW (data)); check_scrollbar_visibility (EOM_SCROLL_VIEW (data), NULL); @@ -2099,12 +2112,7 @@ display_next_frame_cb (EomImage *image, gint delay, gpointer data) view = EOM_SCROLL_VIEW (data); priv = view->priv; - if (priv->pixbuf != NULL) { - g_object_unref (priv->pixbuf); - priv->pixbuf = NULL; - } - - priv->pixbuf = eom_image_get_pixbuf (image); + update_pixbuf (view, eom_image_get_pixbuf (image)); gtk_widget_queue_draw (GTK_WIDGET (priv->display)); } @@ -2137,7 +2145,7 @@ eom_scroll_view_set_image (EomScrollView *view, EomImage *image) eom_image_data_ref (image); if (priv->pixbuf == NULL) { - priv->pixbuf = eom_image_get_pixbuf (image); + update_pixbuf (view, eom_image_get_pixbuf (image)); priv->progressive_state = PROGRESSIVE_NONE; set_zoom_fit (view); check_scrollbar_visibility (view, NULL); -- cgit v1.2.1