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

Stephan Arts stephan at xfce.org
Sat Sep 29 13:51:37 CEST 2007


Author: stephan
Date: 2007-09-29 11:51:37 +0000 (Sat, 29 Sep 2007)
New Revision: 3271

Modified:
   ristretto/trunk/src/picture_viewer.c
   ristretto/trunk/src/thumbnail_viewer.c
Log:
Improve scrolling :-)


Modified: ristretto/trunk/src/picture_viewer.c
===================================================================
--- ristretto/trunk/src/picture_viewer.c	2007-09-29 08:03:27 UTC (rev 3270)
+++ ristretto/trunk/src/picture_viewer.c	2007-09-29 11:51:37 UTC (rev 3271)
@@ -408,10 +408,25 @@
     {
         gint dst_width = gdk_pixbuf_get_width(tmp_pixbuf)*scale;
         gint dst_height = gdk_pixbuf_get_height(tmp_pixbuf)*scale;
-        viewer->priv->dst_pixbuf = gdk_pixbuf_scale_simple(tmp_pixbuf,
+        if (scale < 1.0)
+        {
+            viewer->priv->dst_pixbuf = gdk_pixbuf_scale_simple(tmp_pixbuf,
                                 dst_width>0?dst_width:1,
                                 dst_height>0?dst_height:1,
                                 GDK_INTERP_BILINEAR);
+        }
+        if (scale > 1.0)
+        {
+            viewer->priv->dst_pixbuf = gdk_pixbuf_scale_simple(tmp_pixbuf,
+                                dst_width>0?dst_width:1,
+                                dst_height>0?dst_height:1,
+                                GDK_INTERP_NEAREST);
+        }
+        if (scale == 1.0)
+        {
+            viewer->priv->dst_pixbuf = tmp_pixbuf;
+            g_object_ref(viewer->priv->dst_pixbuf);
+        }
         g_object_unref(tmp_pixbuf);
         tmp_pixbuf = NULL;
     }
@@ -638,10 +653,10 @@
 static gboolean
 cb_rstto_picture_viewer_update_image(RsttoPictureViewer *viewer)
 {
-    gulong millisec = 0;
+    gdouble sec;
 
-    g_timer_elapsed(viewer->priv->timer, &millisec);
-    if (millisec >= 300)
+    sec = g_timer_elapsed(viewer->priv->timer, NULL);
+    if (sec >= 0.250)
     {
         g_timer_stop(viewer->priv->timer);
         viewer->priv->timeout_id = 0;
@@ -663,16 +678,29 @@
             gdk_window_set_cursor(widget->window, cursor);
             gdk_cursor_unref(cursor);
         }
+        if (viewer->priv->timeout_id == 0)
+        {
+            if (viewer->priv->dst_pixbuf)
+            {
+                gdk_pixbuf_saturate_and_pixelate(viewer->priv->dst_pixbuf, viewer->priv->dst_pixbuf, 0.8, TRUE);
+                rstto_picture_viewer_paint(GTK_WIDGET(viewer));
+            }
+            viewer->priv->timeout_id = g_timeout_add(100, (GSourceFunc)cb_rstto_picture_viewer_update_image, viewer);
+        }
         g_timer_start(viewer->priv->timer);
-        if (viewer->priv->timeout_id == 0)
-            viewer->priv->timeout_id = g_timeout_add(200, (GSourceFunc)cb_rstto_picture_viewer_update_image, viewer);
     }
     else
     {
-        g_object_unref(viewer->priv->src_pixbuf);
-        viewer->priv->src_pixbuf = NULL;
-        g_object_unref(viewer->priv->dst_pixbuf);
-        viewer->priv->dst_pixbuf = NULL;
+        if (viewer->priv->src_pixbuf)
+        {
+            g_object_unref(viewer->priv->src_pixbuf);
+            viewer->priv->src_pixbuf = NULL;
+        }
+        if (viewer->priv->dst_pixbuf)
+        {
+            g_object_unref(viewer->priv->dst_pixbuf);
+            viewer->priv->dst_pixbuf = NULL;
+        }
         if (GTK_WIDGET_REALIZED(widget))
         {
             rstto_picture_viewer_paint(GTK_WIDGET(viewer));

Modified: ristretto/trunk/src/thumbnail_viewer.c
===================================================================
--- ristretto/trunk/src/thumbnail_viewer.c	2007-09-29 08:03:27 UTC (rev 3270)
+++ ristretto/trunk/src/thumbnail_viewer.c	2007-09-29 11:51:37 UTC (rev 3271)
@@ -235,6 +235,24 @@
         gint max = nr + (((widget->allocation.width - viewer->priv->dimension) / 2) / viewer->priv->dimension) + 1;
         viewer->priv->begin = min < 0? 0 : min;
         viewer->priv->end = max > n_entries? n_entries: max;
+    }
+    else
+    {
+        offset  = (((widget->allocation.height - viewer->priv->dimension) / 2) - nr * viewer->priv->dimension);
+        gint min = nr - (((widget->allocation.height - viewer->priv->dimension) / 2) / viewer->priv->dimension) - 1;
+        gint max = nr + (((widget->allocation.height - viewer->priv->dimension) / 2) / viewer->priv->dimension) + 1;
+        viewer->priv->begin = min < 0? 0 : min;
+        viewer->priv->end = max > n_entries? n_entries: max;
+    }
+
+    viewer->priv->offset = offset;
+    for (i = viewer->priv->begin; i <= viewer->priv->end; ++i)
+    {
+        rstto_thumbnail_viewer_paint_entry(viewer, i, nr == i);
+    }
+
+    if (viewer->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
+    {
         if (offset > 0)
         {
             gdk_window_clear_area(widget->window, 
@@ -243,10 +261,10 @@
                                 offset,
                                 widget->allocation.height);
         }
-        if ((offset + (viewer->priv->end* viewer->priv->dimension)) < widget->allocation.width)
+        if ((offset + ((viewer->priv->end + 1) * viewer->priv->dimension)) < widget->allocation.width)
         {
             gdk_window_clear_area(widget->window, 
-                                offset + (viewer->priv->end * viewer->priv->dimension),
+                                offset + ((viewer->priv->end + 1) * viewer->priv->dimension),
                                 0,
                                 widget->allocation.width - (offset + (viewer->priv->end * viewer->priv->dimension)),
                                 widget->allocation.height);
@@ -255,11 +273,6 @@
     }
     else
     {
-        offset  = (((widget->allocation.height - viewer->priv->dimension) / 2) - nr * viewer->priv->dimension);
-        gint min = nr - (((widget->allocation.height - viewer->priv->dimension) / 2) / viewer->priv->dimension) - 1;
-        gint max = nr + (((widget->allocation.height - viewer->priv->dimension) / 2) / viewer->priv->dimension) + 1;
-        viewer->priv->begin = min < 0? 0 : min;
-        viewer->priv->end = max > n_entries? n_entries: max;
         if (offset > 0)
         {
             gdk_window_clear_area(widget->window, 
@@ -268,21 +281,15 @@
                                 widget->allocation.width,
                                 offset);
         }
-        if ((offset + (viewer->priv->end* viewer->priv->dimension)) < widget->allocation.height)
+        if ((offset + ((viewer->priv->end + 1) * viewer->priv->dimension)) < widget->allocation.height)
         {
             gdk_window_clear_area(widget->window, 
                                 0,
-                                offset + (viewer->priv->end * viewer->priv->dimension),
+                                offset + ((viewer->priv->end+1) * viewer->priv->dimension),
                                 widget->allocation.width,
                                 widget->allocation.height - (offset + (viewer->priv->end * viewer->priv->dimension)));
-
         }
     }
-    viewer->priv->offset = offset;
-    for (i = viewer->priv->begin; i <= viewer->priv->end; ++i)
-    {
-        rstto_thumbnail_viewer_paint_entry(viewer, i, nr == i);
-    }
 }
 
 static void




More information about the Goodies-commits mailing list