summaryrefslogtreecommitdiff
path: root/src/eom-scroll-view.c
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-07-24 14:51:08 +0200
committerinfirit <[email protected]>2014-07-24 20:17:46 +0200
commitde74036cc420a94e5999da54f17ec6572d0a97f1 (patch)
tree4001813a8a539b26a2cfe9e74dca572ed2b55b65 /src/eom-scroll-view.c
parentf8490e5ac710bc925f1e3c77e706846ffb7c76e9 (diff)
downloadeom-de74036cc420a94e5999da54f17ec6572d0a97f1.tar.bz2
eom-de74036cc420a94e5999da54f17ec6572d0a97f1.tar.xz
Factor out the code to store a pixbuf in EomScrollView
Based on eog commit 4f432e981a956cd157ae3f190b9c7850a6f180d9 From Claudio Saavedra <[email protected]>
Diffstat (limited to 'src/eom-scroll-view.c')
-rw-r--r--src/eom-scroll-view.c28
1 files 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);