[eog] Factor out the code to store a pixbuf in EogScrollView



commit 4f432e981a956cd157ae3f190b9c7850a6f180d9
Author: Claudio Saavedra <csaavedra igalia com>
Date:   Fri Aug 13 00:27:50 2010 +0300

    Factor out the code to store a pixbuf in EogScrollView
    
    https://bugzilla.gnome.org/show_bug.cgi?id=626795

 src/eog-scroll-view.c |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)
---
diff --git a/src/eog-scroll-view.c b/src/eog-scroll-view.c
index 663a85b..e66ba68 100644
--- a/src/eog-scroll-view.c
+++ b/src/eog-scroll-view.c
@@ -1839,19 +1839,33 @@ image_loading_cancelled_cb (EogImage *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 (EogImage *img, gpointer data)
+update_pixbuf (EogScrollView *view, GdkPixbuf *pixbuf)
 {
 	EogScrollViewPrivate *priv;
 
-	priv = EOG_SCROLL_VIEW (data)->priv;
+	priv = view->priv;
 
 	if (priv->pixbuf != NULL) {
 		g_object_unref (priv->pixbuf);
 		priv->pixbuf = NULL;
 	}
 
-	priv->pixbuf = eog_image_get_pixbuf (img);
+	priv->pixbuf = pixbuf;
+
+}
+
+static void
+image_changed_cb (EogImage *img, gpointer data)
+{
+	EogScrollViewPrivate *priv;
+
+	priv = EOG_SCROLL_VIEW (data)->priv;
+
+	update_pixbuf (EOG_SCROLL_VIEW (data), eog_image_get_pixbuf (img));
 
 	set_zoom_fit (EOG_SCROLL_VIEW (data));
 	check_scrollbar_visibility (EOG_SCROLL_VIEW (data), NULL);
@@ -2130,12 +2144,8 @@ display_next_frame_cb (EogImage *image, gint delay, gpointer data)
 	view = EOG_SCROLL_VIEW (data);
 	priv = view->priv;
 
-	if (priv->pixbuf != NULL) {
-		g_object_unref (priv->pixbuf);
-		priv->pixbuf = NULL;
-	}
+	update_pixbuf (view, eog_image_get_pixbuf (image));
 
-	priv->pixbuf = eog_image_get_pixbuf (image);
 	gtk_widget_queue_draw (GTK_WIDGET (priv->display)); 
 }
 
@@ -2166,7 +2176,7 @@ eog_scroll_view_set_image (EogScrollView *view, EogImage *image)
 		eog_image_data_ref (image);
 
 		if (priv->pixbuf == NULL) {
-			priv->pixbuf = eog_image_get_pixbuf (image);
+			update_pixbuf (view, eog_image_get_pixbuf (image));
 			priv->progressive_state = PROGRESSIVE_NONE;
 			set_zoom_fit (view);
 			check_scrollbar_visibility (view, NULL);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]