[Xfce4-commits] <ristretto:stephan/properties-dialog> Add properties-dialog d-bus interface to thunar again.

Stephan Arts noreply at xfce.org
Wed Sep 21 21:16:02 CEST 2011


Updating branch refs/heads/stephan/properties-dialog
         to 5553970f2182cc5831e00de7c4750bbe82578546 (commit)
       from c8fbb5a46307dcfe7e4ffd8f69cdee18864c2b2f (commit)

commit 5553970f2182cc5831e00de7c4750bbe82578546
Author: Stephan Arts <stephan at xfce.org>
Date:   Wed Sep 21 21:09:13 2011 +0200

    Add properties-dialog d-bus interface to thunar again.

 src/main_window.c      |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/main_window_ui.xml |    1 +
 2 files changed, 49 insertions(+), 0 deletions(-)

diff --git a/src/main_window.c b/src/main_window.c
index ebca286..99b54dc 100644
--- a/src/main_window.c
+++ b/src/main_window.c
@@ -27,6 +27,8 @@
 #include <libxfce4ui/libxfce4ui.h>
 #include <libexif/exif-data.h>
 
+#include <dbus/dbus-glib.h>
+
 #include <cairo/cairo.h>
 
 #include "settings.h"
@@ -62,6 +64,9 @@ struct _RsttoMainWindowPriv
         gboolean        toolbar_visible;
     } props;
 
+    DBusGConnection *connection;
+    DBusGProxy *filemanager_proxy;
+
     guint show_fs_toolbar_timeout_id;
     gint window_save_geometry_timer_id;
     gint open_image_timer_id;
@@ -189,6 +194,8 @@ cb_rstto_main_window_open_folder (GtkWidget *widget, RsttoMainWindow *window);
 static void
 cb_rstto_main_window_open_recent(GtkRecentChooser *chooser, RsttoMainWindow *window);
 static void
+cb_rstto_main_window_properties (GtkWidget *widget, RsttoMainWindow *window);
+static void
 cb_rstto_main_window_close (GtkWidget *widget, RsttoMainWindow *window);
 static void
 cb_rstto_main_window_close_all (GtkWidget *widget, RsttoMainWindow *window);
@@ -272,6 +279,7 @@ static GtkActionEntry action_entries[] =
   { "open", "document-open", N_ ("_Open"), "<control>O", N_ ("Open an image"), G_CALLBACK (cb_rstto_main_window_open_image), },
   { "open-folder", "folder-open", N_ ("Open _Folder"), NULL, N_ ("Open a folder"), G_CALLBACK (cb_rstto_main_window_open_folder), },
   { "save-copy", GTK_STOCK_SAVE_AS, N_ ("_Save copy"), "<control>s", N_ ("Save a copy of the image"), G_CALLBACK (cb_rstto_main_window_save_copy), },
+  { "properties", GTK_STOCK_PROPERTIES, N_ ("_Properties"), NULL, N_ ("Show file properties"), G_CALLBACK (cb_rstto_main_window_properties), },
   { "close", GTK_STOCK_CLOSE, N_ ("_Close"), "<control>W", N_ ("Close this image"), G_CALLBACK (cb_rstto_main_window_close), },
   { "close-all", NULL, N_ ("_Close All"), NULL, N_ ("Close all images"), G_CALLBACK (cb_rstto_main_window_close_all), },
   { "quit", GTK_STOCK_QUIT, N_ ("_Quit"), "<control>Q", N_ ("Quit Ristretto"), G_CALLBACK (cb_rstto_main_window_quit), },
@@ -411,6 +419,19 @@ rstto_main_window_init (RsttoMainWindow *window)
     window->priv->recent_manager = gtk_recent_manager_get_default();
     window->priv->settings_manager = rstto_settings_new();
 
+    /* D-Bus stuff */
+
+    window->priv->connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
+    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");
+    }
+
     desktop_type = rstto_settings_get_string_property (window->priv->settings_manager, "desktop-type");
     if (desktop_type)
     {
@@ -921,6 +942,7 @@ rstto_main_window_update_buttons (RsttoMainWindow *window)
             /*
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/print"), FALSE);
             */
+            gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/properties"), FALSE);
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/close"), FALSE);
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/close-all"), FALSE);
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/edit-menu/delete"), FALSE);
@@ -981,6 +1003,7 @@ rstto_main_window_update_buttons (RsttoMainWindow *window)
             /*
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/print"), TRUE);
             */
+            gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/properties"), TRUE);
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/close"), TRUE);
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/close-all"), FALSE);
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/edit-menu/delete"), TRUE);
@@ -1043,6 +1066,7 @@ rstto_main_window_update_buttons (RsttoMainWindow *window)
             /*
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/print"), TRUE);
             */
+            gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/properties"), TRUE);
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/close"), TRUE);
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/file-menu/close-all"), TRUE);
             gtk_widget_set_sensitive ( gtk_ui_manager_get_widget ( window->priv->ui_manager, "/main-menu/edit-menu/delete"), TRUE);
@@ -2316,6 +2340,30 @@ cb_rstto_main_window_save_copy (GtkWidget *widget, RsttoMainWindow *window)
 
 }
 
+static void
+cb_rstto_main_window_properties (GtkWidget *widget, RsttoMainWindow *window)
+{
+    /* The display object is owned by gdk, do not unref it */
+    GdkDisplay *display = gdk_display_get_default();
+    GError *error = NULL;
+    GFile *file = rstto_image_list_iter_get_file (window->priv->iter);
+    if (file)
+    {
+        gchar *uri = g_file_get_uri(file);
+        if(dbus_g_proxy_call(window->priv->filemanager_proxy,
+                             "DisplayFileProperties",
+                             &error,
+                             G_TYPE_STRING, uri,
+                             G_TYPE_STRING, gdk_display_get_name(display),
+                             G_TYPE_STRING, "",
+                             G_TYPE_INVALID,
+                             G_TYPE_INVALID) == FALSE)
+        {
+            g_warning("DBUS CALL FAILED: '%s'", error->message);
+        }
+        g_free(uri);
+    }
+}
 /**
  * cb_rstto_main_window_close:
  * @widget:
diff --git a/src/main_window_ui.xml b/src/main_window_ui.xml
index ed76f3c..279843e 100644
--- a/src/main_window_ui.xml
+++ b/src/main_window_ui.xml
@@ -15,6 +15,7 @@
             <menuitem action="print"/>
             -->
             <separator/>
+            <menuitem action="properties"/>
             <menuitem action="close"/>
             <menuitem action="close-all"/>
             <menuitem action="quit"/>


More information about the Xfce4-commits mailing list