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

Stephan Arts stephan at xfce.org
Sat Nov 24 14:45:09 CET 2007


Author: stephan
Date: 2007-11-24 13:45:07 +0000 (Sat, 24 Nov 2007)
New Revision: 3627

Modified:
   ristretto/trunk/src/main_window.c
   ristretto/trunk/src/navigator.c
   ristretto/trunk/src/navigator.h
Log:
Fix rotation



Modified: ristretto/trunk/src/main_window.c
===================================================================
--- ristretto/trunk/src/main_window.c	2007-11-23 22:47:19 UTC (rev 3626)
+++ ristretto/trunk/src/main_window.c	2007-11-24 13:45:07 UTC (rev 3627)
@@ -215,6 +215,11 @@
 cb_rstto_main_window_zoom_fit(GtkWidget *widget, RsttoMainWindow *window);
 
 static void
+cb_rstto_main_window_rotate_cw(GtkWidget *widget, RsttoMainWindow *window);
+static void
+cb_rstto_main_window_rotate_ccw(GtkWidget *widget, RsttoMainWindow *window);
+
+static void
 cb_rstto_main_window_open_file(GtkWidget *widget, RsttoMainWindow *window);
 static void
 cb_rstto_main_window_open_folder(GtkWidget *widget, RsttoMainWindow *window);
@@ -613,10 +618,13 @@
 /* D-Bus stuff */
 
     window->priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
-    window->priv->filemanager_proxy = dbus_g_proxy_new_for_name(window->priv->connection,
+    if (window->priv->connection)
+    {
+        window->priv->filemanager_proxy = dbus_g_proxy_new_for_name(window->priv->connection,
                                                                 "org.xfce.FileManager",
                                                                 "/org/xfce/FileManager",
                                                                 "org.xfce.FileManager");
+    }
 
 /* Connect signals */
     
@@ -700,7 +708,15 @@
     g_signal_connect(window->priv->menus.view.zooming.menu_item_zoom_fit,
             "activate",
             G_CALLBACK(cb_rstto_main_window_zoom_fit), window);
+/* rotate menu items */
+    g_signal_connect(window->priv->menus.view.rotate.menu_item_rotate_cw,
+            "activate",
+            G_CALLBACK(cb_rstto_main_window_rotate_cw), window);
+    g_signal_connect(window->priv->menus.view.rotate.menu_item_rotate_ccw,
+            "activate",
+            G_CALLBACK(cb_rstto_main_window_rotate_ccw), window);
 
+/* go menu items */
     g_signal_connect(window->priv->menus.go.menu_item_next,
             "activate",
             G_CALLBACK(cb_rstto_main_window_next), window);
@@ -1660,6 +1676,64 @@
 }
 
 static void
+cb_rstto_main_window_rotate_cw(GtkWidget *widget, RsttoMainWindow *window)
+{
+    RsttoNavigatorEntry *entry = rstto_navigator_get_file(window->priv->navigator);
+    if (entry)
+    {
+        GdkPixbufRotation rotation = rstto_navigator_entry_get_rotation(entry);
+        switch (rotation)
+        {
+            case GDK_PIXBUF_ROTATE_NONE:
+                rotation = GDK_PIXBUF_ROTATE_CLOCKWISE;
+                break;
+            case GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE:
+                rotation = GDK_PIXBUF_ROTATE_NONE;
+                break;
+            case GDK_PIXBUF_ROTATE_UPSIDEDOWN:
+                rotation = GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE;
+                break;
+            case GDK_PIXBUF_ROTATE_CLOCKWISE:
+                rotation = GDK_PIXBUF_ROTATE_UPSIDEDOWN;
+                break;
+            default:
+                g_warning("Unable to rotate, rotation unknown");
+                break;
+        }
+        rstto_navigator_entry_set_rotation(entry, rotation);
+    }
+}
+
+static void
+cb_rstto_main_window_rotate_ccw(GtkWidget *widget, RsttoMainWindow *window)
+{
+    RsttoNavigatorEntry *entry = rstto_navigator_get_file(window->priv->navigator);
+    if (entry)
+    {
+        GdkPixbufRotation rotation = rstto_navigator_entry_get_rotation(entry);
+        switch (rotation)
+        {
+            case GDK_PIXBUF_ROTATE_NONE:
+                rotation = GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE;
+                break;
+            case GDK_PIXBUF_ROTATE_COUNTERCLOCKWISE:
+                rotation = GDK_PIXBUF_ROTATE_UPSIDEDOWN;
+                break;
+            case GDK_PIXBUF_ROTATE_UPSIDEDOWN:
+                rotation = GDK_PIXBUF_ROTATE_CLOCKWISE;
+                break;
+            case GDK_PIXBUF_ROTATE_CLOCKWISE:
+                rotation = GDK_PIXBUF_ROTATE_NONE;
+                break;
+            default:
+                g_warning("Unable to rotate, rotation unknown");
+                break;
+        }
+        rstto_navigator_entry_set_rotation(entry, rotation);
+    }
+}
+
+static void
 cb_rstto_main_window_spawn_app(GtkWidget *widget, ThunarVfsMimeApplication *app)
 {
     ThunarVfsInfo *info = rstto_navigator_entry_get_info(g_object_get_data(G_OBJECT(app), "entry"));

Modified: ristretto/trunk/src/navigator.c
===================================================================
--- ristretto/trunk/src/navigator.c	2007-11-23 22:47:19 UTC (rev 3626)
+++ ristretto/trunk/src/navigator.c	2007-11-24 13:45:07 UTC (rev 3627)
@@ -856,7 +856,19 @@
     entry->fit_to_screen = fts;
 }
 
+void
+rstto_navigator_entry_set_rotation (RsttoNavigatorEntry *entry, GdkPixbufRotation rotation)
+{
+    GdkPixbuf *pixbuf = entry->src_pixbuf;
+    if (pixbuf)
+    {
+        entry->src_pixbuf = gdk_pixbuf_rotate_simple(pixbuf, (360+(rotation-entry->rotation))%360);
+    }
+    entry->rotation = rotation;
+    g_signal_emit(G_OBJECT(entry->navigator), rstto_navigator_signals[RSTTO_NAVIGATOR_SIGNAL_ENTRY_MODIFIED], 0, entry, NULL);
+}
 
+
 ExifData *
 rstto_navigator_entry_get_exif_data (RsttoNavigatorEntry *entry)
 {

Modified: ristretto/trunk/src/navigator.h
===================================================================
--- ristretto/trunk/src/navigator.h	2007-11-23 22:47:19 UTC (rev 3626)
+++ ristretto/trunk/src/navigator.h	2007-11-24 13:45:07 UTC (rev 3627)
@@ -123,6 +123,8 @@
 rstto_navigator_entry_set_fit_to_screen (RsttoNavigatorEntry *entry, gboolean);
 void
 rstto_navigator_entry_set_scale (RsttoNavigatorEntry *entry, gdouble);
+void
+rstto_navigator_entry_set_rotation (RsttoNavigatorEntry *entry, GdkPixbufRotation rotation);
 
 GdkPixbufRotation
 rstto_navigator_entry_get_rotation (RsttoNavigatorEntry *entry);




More information about the Goodies-commits mailing list