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

Stephan Arts stephan at xfce.org
Mon Aug 27 00:56:42 CEST 2007


Author: stephan
Date: 2007-08-26 22:56:42 +0000 (Sun, 26 Aug 2007)
New Revision: 3082

Modified:
   ristretto/trunk/src/main.c
   ristretto/trunk/src/thumbnail_viewer.c
Log:
Fixed image-navigation with mouse-wheel.
Fixed backward-scrolling in thumbnail-viewer.
Fixed image-navigation with space / backspace. (does not work well with the toolbar buttons though)



Modified: ristretto/trunk/src/main.c
===================================================================
--- ristretto/trunk/src/main.c	2007-08-26 17:08:30 UTC (rev 3081)
+++ ristretto/trunk/src/main.c	2007-08-26 22:56:42 UTC (rev 3082)
@@ -673,9 +673,11 @@
                 rstto_navigator_jump_last(navigator);
                 break;
             case GDK_Page_Down:
+            case GDK_space:
                 rstto_navigator_jump_forward(navigator);
                 break;
             case GDK_Page_Up:
+            case GDK_BackSpace:
                 rstto_navigator_jump_back(navigator);
                 break;
         }
@@ -763,6 +765,7 @@
                 g_free(path_name);
                 filename = g_dir_read_name(dir);
             }
+            rstto_navigator_jump_first(navigator);
             gchar *uri = gtk_file_chooser_get_uri(GTK_FILE_CHOOSER(dialog));
             gtk_recent_manager_add_item(recent_manager, uri);
             g_free(uri);
@@ -813,6 +816,7 @@
                     g_free(path_name);
                     filename = g_dir_read_name(dir);
                 }
+                rstto_navigator_jump_first(navigator);
                 g_free(dir_path);
             }
             gchar *uri = thunar_vfs_path_dup_uri(info->path);

Modified: ristretto/trunk/src/thumbnail_viewer.c
===================================================================
--- ristretto/trunk/src/thumbnail_viewer.c	2007-08-26 17:08:30 UTC (rev 3081)
+++ ristretto/trunk/src/thumbnail_viewer.c	2007-08-26 22:56:42 UTC (rev 3082)
@@ -79,6 +79,8 @@
 
 static void
 cb_rstto_thumbnailer_button_press_event (RsttoThumbnailViewer *viewer, GdkEventButton *event);
+static void
+cb_rstto_thumbnailer_scroll_event (RsttoThumbnailViewer *viewer, GdkEventScroll *event);
 
 GType
 rstto_thumbnail_viewer_get_type ()
@@ -118,6 +120,7 @@
     gtk_widget_set_events (GTK_WIDGET(viewer),
                            GDK_BUTTON_PRESS_MASK);
     g_signal_connect(G_OBJECT(viewer), "button_press_event", G_CALLBACK(cb_rstto_thumbnailer_button_press_event), NULL);
+    g_signal_connect(G_OBJECT(viewer), "scroll_event", G_CALLBACK(cb_rstto_thumbnailer_scroll_event), NULL);
     viewer->priv->orientation = GTK_ORIENTATION_HORIZONTAL;
 
 }
@@ -381,84 +384,108 @@
     GtkWidget *widget = GTK_WIDGET(viewer);
     gint n = 0;
     gint old_offset = viewer->priv->offset;
-    switch(viewer->priv->orientation)
+    if (event->button == 1)
     {
-        case GTK_ORIENTATION_HORIZONTAL:
-            if(event->button == 1)
-            {
-                if ((event->x < 20) || ((widget->allocation.width - event->x) < 20))
-                    n = -1;
-                else
-                    n = (event->x - 20 + viewer->priv->offset) / viewer->priv->dimension;
-            }
-            break;
-        case GTK_ORIENTATION_VERTICAL:
-            if(event->button == 1)
-            {
-                if ((event->y < 20) || ((widget->allocation.height - event->y) < 20))
-                    n = -1;
-                else
-                    n = (event->y - 20 + viewer->priv->offset) / viewer->priv->dimension;
+        switch(viewer->priv->orientation)
+        {
+            case GTK_ORIENTATION_HORIZONTAL:
+                if(event->button == 1)
+                {
+                    if ((event->x < 20) || ((widget->allocation.width - event->x) < 20))
+                        n = -1;
+                    else
+                        n = (event->x - 20 + viewer->priv->offset) / viewer->priv->dimension;
+                }
+                break;
+            case GTK_ORIENTATION_VERTICAL:
+                if(event->button == 1)
+                {
+                    if ((event->y < 20) || ((widget->allocation.height - event->y) < 20))
+                        n = -1;
+                    else
+                        n = (event->y - 20 + viewer->priv->offset) / viewer->priv->dimension;
 
-            }
-            break;
+                }
+                break;
 
-    }
-    if (n < 0)
-    {
-        if (((viewer->priv->orientation == GTK_ORIENTATION_HORIZONTAL) && (event->x < 20)) ||
-            ((viewer->priv->orientation == GTK_ORIENTATION_VERTICAL) && (event->y < 20)))
+        }
+        if (n < 0)
         {
-            viewer->priv->offset -= viewer->priv->dimension;
-            if(viewer->priv->offset < 0)
+            if (((viewer->priv->orientation == GTK_ORIENTATION_HORIZONTAL) && (event->x < 20)) ||
+                ((viewer->priv->orientation == GTK_ORIENTATION_VERTICAL) && (event->y < 20)))
             {
-                viewer->priv->offset = 0;
+                viewer->priv->offset -= viewer->priv->dimension;
+                if(viewer->priv->offset < 0)
+                {
+                    viewer->priv->offset = 0;
+                }
+                viewer->priv->begin = viewer->priv->offset / viewer->priv->dimension;
+                if (viewer->priv->orientation == GTK_ORIENTATION_VERTICAL)
+                    viewer->priv->end = widget->allocation.height / viewer->priv->dimension + viewer->priv->begin;
+                else 
+                    viewer->priv->end = widget->allocation.width / viewer->priv->dimension + viewer->priv->begin;
             }
-        }
-        else
-        {
-            if(rstto_navigator_get_n_files(viewer->priv->navigator) == 0)
-                viewer->priv->offset = 0;
             else
             {
-                if(viewer->priv->orientation == GTK_ORIENTATION_VERTICAL)
+                if(rstto_navigator_get_n_files(viewer->priv->navigator) == 0)
+                    viewer->priv->offset = 0;
+                else
                 {
-                    if((rstto_navigator_get_n_files(viewer->priv->navigator) * viewer->priv->dimension - viewer->priv->offset) > widget->allocation.height)
+                    if(viewer->priv->orientation == GTK_ORIENTATION_VERTICAL)
                     {
-                        viewer->priv->offset += viewer->priv->dimension / 2;
-                        viewer->priv->begin = viewer->priv->offset / viewer->priv->dimension;
-                        viewer->priv->end = widget->allocation.height / viewer->priv->dimension + viewer->priv->begin;
+                        if((rstto_navigator_get_n_files(viewer->priv->navigator) * viewer->priv->dimension - viewer->priv->offset) > widget->allocation.height)
+                        {
+                            viewer->priv->offset += viewer->priv->dimension / 2;
+                            viewer->priv->begin = viewer->priv->offset / viewer->priv->dimension;
+                            viewer->priv->end = widget->allocation.height / viewer->priv->dimension + viewer->priv->begin;
+                        }
                     }
-                }
-                if(viewer->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
-                {
-                    if((rstto_navigator_get_n_files(viewer->priv->navigator) * viewer->priv->dimension - viewer->priv->offset) > widget->allocation.width)
+                    if(viewer->priv->orientation == GTK_ORIENTATION_HORIZONTAL)
                     {
-                        viewer->priv->offset += viewer->priv->dimension / 2;
-                        viewer->priv->begin = viewer->priv->offset / viewer->priv->dimension;
-                        viewer->priv->end = widget->allocation.width / viewer->priv->dimension + viewer->priv->begin;
+                        if((rstto_navigator_get_n_files(viewer->priv->navigator) * viewer->priv->dimension - viewer->priv->offset) > widget->allocation.width)
+                        {
+                            viewer->priv->offset += viewer->priv->dimension / 2;
+                            viewer->priv->begin = viewer->priv->offset / viewer->priv->dimension;
+                            viewer->priv->end = widget->allocation.width / viewer->priv->dimension + viewer->priv->begin;
+                        }
                     }
                 }
             }
+            if(old_offset != viewer->priv->offset)
+                rstto_thumbnail_viewer_paint(viewer);
         }
-        if(old_offset != viewer->priv->offset)
-            rstto_thumbnail_viewer_paint(viewer);
-    }
-    else
-    {
-        if ( n < rstto_navigator_get_n_files(viewer->priv->navigator))
+        else
         {
-            if(GTK_WIDGET_REALIZED(widget))
+            if ( n < rstto_navigator_get_n_files(viewer->priv->navigator))
             {
-                GdkCursor *cursor = gdk_cursor_new(GDK_WATCH);
-                gdk_window_set_cursor(widget->window, cursor);
-                gdk_cursor_unref(cursor);
+                if(GTK_WIDGET_REALIZED(widget))
+                {
+                    GdkCursor *cursor = gdk_cursor_new(GDK_WATCH);
+                    gdk_window_set_cursor(widget->window, cursor);
+                    gdk_cursor_unref(cursor);
+                }
+                rstto_navigator_set_file(viewer->priv->navigator, n);
             }
-            rstto_navigator_set_file(viewer->priv->navigator, n);
         }
     }
 }
 
+static void
+cb_rstto_thumbnailer_scroll_event (RsttoThumbnailViewer *viewer, GdkEventScroll *event)
+{
+    switch(event->direction)
+    {
+        case GDK_SCROLL_UP:
+        case GDK_SCROLL_LEFT:
+            rstto_navigator_jump_back(viewer->priv->navigator);
+            break;
+        case GDK_SCROLL_DOWN:
+        case GDK_SCROLL_RIGHT:
+            rstto_navigator_jump_forward(viewer->priv->navigator);
+            break;
+    }
+}
+
 void
 rstto_thumbnail_viewer_set_orientation (RsttoThumbnailViewer *viewer, GtkOrientation orientation)
 {




More information about the Goodies-commits mailing list