[Goodies-commits] r3020 - ristretto/trunk/src

Stephan Arts stephan at xfce.org
Mon Aug 20 23:12:38 CEST 2007


Author: stephan
Date: 2007-08-20 21:12:38 +0000 (Mon, 20 Aug 2007)
New Revision: 3020

Modified:
   ristretto/trunk/src/picture_viewer.c
Log:
check if there is a src_pixbuf in the adjustment-value changed callback

Modified: ristretto/trunk/src/picture_viewer.c
===================================================================
--- ristretto/trunk/src/picture_viewer.c	2007-08-20 11:00:11 UTC (rev 3019)
+++ ristretto/trunk/src/picture_viewer.c	2007-08-20 21:12:38 UTC (rev 3020)
@@ -365,30 +365,33 @@
 static void
 cb_rstto_picture_viewer_value_changed(GtkAdjustment *adjustment, RsttoPictureViewer *viewer)
 {
-    gdouble width = (gdouble)gdk_pixbuf_get_width(viewer->priv->src_pixbuf);
-    gdouble height = (gdouble)gdk_pixbuf_get_height(viewer->priv->src_pixbuf);
+    if (viewer->priv->src_pixbuf)
+    {
+        gdouble width = (gdouble)gdk_pixbuf_get_width(viewer->priv->src_pixbuf);
+        gdouble height = (gdouble)gdk_pixbuf_get_height(viewer->priv->src_pixbuf);
 
-    GdkPixbuf *tmp_pixbuf = NULL;
-    tmp_pixbuf = gdk_pixbuf_new_subpixbuf(viewer->priv->src_pixbuf,
-    viewer->hadjustment->value / viewer->priv->scale >= 0? viewer->hadjustment->value / viewer->priv->scale : 0,
-    viewer->vadjustment->value / viewer->priv->scale >= 0? viewer->vadjustment->value / viewer->priv->scale : 0,
-    ((GTK_WIDGET(viewer)->allocation.width/viewer->priv->scale)) < width?GTK_WIDGET(viewer)->allocation.width/viewer->priv->scale:width,
-    ((GTK_WIDGET(viewer)->allocation.height/viewer->priv->scale)) < height?GTK_WIDGET(viewer)->allocation.height/viewer->priv->scale:height);
+        GdkPixbuf *tmp_pixbuf = NULL;
+        tmp_pixbuf = gdk_pixbuf_new_subpixbuf(viewer->priv->src_pixbuf,
+        viewer->hadjustment->value / viewer->priv->scale >= 0? viewer->hadjustment->value / viewer->priv->scale : 0,
+        viewer->vadjustment->value / viewer->priv->scale >= 0? viewer->vadjustment->value / viewer->priv->scale : 0,
+        ((GTK_WIDGET(viewer)->allocation.width/viewer->priv->scale)) < width?GTK_WIDGET(viewer)->allocation.width/viewer->priv->scale:width,
+        ((GTK_WIDGET(viewer)->allocation.height/viewer->priv->scale)) < height?GTK_WIDGET(viewer)->allocation.height/viewer->priv->scale:height);
 
-    if(viewer->priv->dst_pixbuf)
-    {
-        g_object_unref(viewer->priv->dst_pixbuf);
-        viewer->priv->dst_pixbuf = NULL;
-    }
+        if(viewer->priv->dst_pixbuf)
+        {
+            g_object_unref(viewer->priv->dst_pixbuf);
+            viewer->priv->dst_pixbuf = NULL;
+        }
 
-    viewer->priv->dst_pixbuf = gdk_pixbuf_scale_simple(tmp_pixbuf,
-                                gdk_pixbuf_get_width(tmp_pixbuf)*viewer->priv->scale,
-                                gdk_pixbuf_get_height(tmp_pixbuf)*viewer->priv->scale,
-                                GDK_INTERP_BILINEAR);
-    if(tmp_pixbuf)
-    {
-        g_object_unref(tmp_pixbuf);
-        tmp_pixbuf = NULL;
+        viewer->priv->dst_pixbuf = gdk_pixbuf_scale_simple(tmp_pixbuf,
+                                    gdk_pixbuf_get_width(tmp_pixbuf)*viewer->priv->scale,
+                                    gdk_pixbuf_get_height(tmp_pixbuf)*viewer->priv->scale,
+                                    GDK_INTERP_BILINEAR);
+        if(tmp_pixbuf)
+        {
+            g_object_unref(tmp_pixbuf);
+            tmp_pixbuf = NULL;
+        }
     }
     rstto_picture_viewer_paint((GtkWidget *)viewer);
 }




More information about the Goodies-commits mailing list