[Xfce4-commits] [xfce/thunar] 01/01: Add support for org.freedesktop.FileManager1 (Bug #12414)

noreply at xfce.org noreply at xfce.org
Sun Jan 13 22:21:10 CET 2019


This is an automated email from the git hooks/post-receive script.

a   n   d   r   e       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository xfce/thunar.

commit ec15879865962489c29043c7e4908d500e4220d9
Author: Andre Miranda <andreldm at xfce.org>
Date:   Sun Jan 13 18:19:49 2019 -0300

    Add support for org.freedesktop.FileManager1 (Bug #12414)
---
 .gitignore                                    |   2 +-
 Makefile.am                                   |   4 +-
 org.freedesktop.FileManager1.service.in       |   4 +
 thunar/Makefile.am                            |   6 +
 thunar/thunar-application.c                   |  28 ++--
 thunar/thunar-dbus-freedesktop-interfaces.xml |  36 +++++
 thunar/thunar-dbus-service.c                  | 183 +++++++++++++++++++++++++-
 7 files changed, 246 insertions(+), 17 deletions(-)

diff --git a/.gitignore b/.gitignore
index 63ab3bc..cf6ed0e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -105,6 +105,7 @@ tests/data/.*.swp
 thunar/*.loT
 thunar/.*.swp
 thunar/thunar
+thunar/thunar-dbus-freedesktop-interfaces.[ch]
 thunar/thunar-dbus-service-infos.[ch]
 thunar/thunar-fallback-icon.c
 thunar/thunar-thumbnail-cache-proxy.[ch]
@@ -117,7 +118,6 @@ thunar/core.*
 thunar/*.core
 thunar/thunar-*-ui.h
 thunar/stamp-thunar-*.*
-thunar/thunar-dbus-service-infos.h
 thunarx/.*.swp
 thunarx/*.pc
 thunarx/*.gir
diff --git a/Makefile.am b/Makefile.am
index 94c8f3e..bd2a6e9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -79,7 +79,9 @@ appdata_DATA = $(appdata_in_files:.xml.in=.xml)
 appdata_in_files = org.xfce.thunar.appdata.xml.in
 
 servicedir = $(datadir)/dbus-1/services
-service_in_files = org.xfce.FileManager.service.in org.xfce.Thunar.service.in
+service_in_files = org.xfce.FileManager.service.in	\
+	org.xfce.Thunar.service.in						\
+	org.freedesktop.FileManager1.service.in
 service_DATA = $(service_in_files:.service.in=.service)
 
 systemd_userdir = $(prefix)/lib/systemd/user
diff --git a/org.freedesktop.FileManager1.service.in b/org.freedesktop.FileManager1.service.in
new file mode 100644
index 0000000..e0b3fad
--- /dev/null
+++ b/org.freedesktop.FileManager1.service.in
@@ -0,0 +1,4 @@
+[D-BUS Service]
+Name=org.freedesktop.FileManager1
+Exec=@bindir@/Thunar --gapplication-service
+SystemdService=thunar.service
diff --git a/thunar/Makefile.am b/thunar/Makefile.am
index cd74726..a92ae74 100644
--- a/thunar/Makefile.am
+++ b/thunar/Makefile.am
@@ -30,6 +30,8 @@ thunar_built_sources =							\
 	thunar-shortcuts-pane-ui.h					\
 	thunar-renamer-dialog-ui.h					\
 	thunar-standard-view-ui.h					\
+	thunar-dbus-freedesktop-interfaces.h		\
+	thunar-dbus-freedesktop-interfaces.c		\
 	thunar-dbus-service-infos.h					\
 	thunar-dbus-service-infos.c					\
 	thunar-thumbnailer-proxy.c					\
@@ -289,6 +291,9 @@ DISTCLEANFILES +=							\
 BUILT_SOURCES =								\
 	$(thunar_built_sources)
 
+thunar-dbus-freedesktop-interfaces.h thunar-dbus-freedesktop-interfaces.c: $(srcdir)/thunar-dbus-freedesktop-interfaces.xml Makefile
+	$(AM_V_GEN) gdbus-codegen --c-namespace Thunar --generate-c-code=thunar-dbus-freedesktop-interfaces $(srcdir)/thunar-dbus-freedesktop-interfaces.xml
+
 thunar-dbus-service-infos.h thunar-dbus-service-infos.c: $(srcdir)/thunar-dbus-service-infos.xml Makefile
 	$(AM_V_GEN) gdbus-codegen --c-namespace Thunar --generate-c-code=thunar-dbus-service-infos $(srcdir)/thunar-dbus-service-infos.xml
 
@@ -356,6 +361,7 @@ endif
 
 EXTRA_DIST =								\
 	thunar-abstract-icon-view-ui.xml		\
+	thunar-dbus-freedesktop-interfaces.xml	\
 	thunar-dbus-service-infos.xml			\
 	thunar-details-view-ui.xml				\
 	thunar-launcher-ui.xml					\
diff --git a/thunar/thunar-application.c b/thunar/thunar-application.c
index 71a1594..4e27360 100644
--- a/thunar/thunar-application.c
+++ b/thunar/thunar-application.c
@@ -208,7 +208,8 @@ struct _ThunarApplication
 
   GList                 *files_to_launch;
 
-  guint                  dbus_owner_id;
+  guint                  dbus_owner_id_xfce;
+  guint                  dbus_owner_id_fdo;
 };
 
 
@@ -324,14 +325,23 @@ thunar_application_dbus_init (ThunarApplication *application)
     if (geteuid() == 0)
       return;
 
-    application->dbus_owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
-                               "org.xfce.FileManager",
-                               G_BUS_NAME_OWNER_FLAGS_NONE,
-                               thunar_application_dbus_acquired_cb,
-                               thunar_application_name_acquired_cb,
-                               thunar_application_dbus_name_lost_cb,
-                               application,
-                               NULL);
+    application->dbus_owner_id_xfce = g_bus_own_name (G_BUS_TYPE_SESSION,
+                                      "org.xfce.FileManager",
+                                      G_BUS_NAME_OWNER_FLAGS_NONE,
+                                      thunar_application_dbus_acquired_cb,
+                                      thunar_application_name_acquired_cb,
+                                      thunar_application_dbus_name_lost_cb,
+                                      application,
+                                      NULL);
+
+    application->dbus_owner_id_fdo = g_bus_own_name (G_BUS_TYPE_SESSION,
+                                     "org.freedesktop.FileManager1",
+                                     G_BUS_NAME_OWNER_FLAGS_NONE,
+                                     thunar_application_dbus_acquired_cb,
+                                     thunar_application_name_acquired_cb,
+                                     thunar_application_dbus_name_lost_cb,
+                                     application,
+                                     NULL);
 }
 
 
diff --git a/thunar/thunar-dbus-freedesktop-interfaces.xml b/thunar/thunar-dbus-freedesktop-interfaces.xml
new file mode 100644
index 0000000..598afb7
--- /dev/null
+++ b/thunar/thunar-dbus-freedesktop-interfaces.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+   Copyright (c) 2019 Andre Miranda <andreldm at xfce.org>
+
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by the Free
+   Software Foundation; either version 2 of the License, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful, but WITHOUT
+   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+   more details.
+
+   You should have received a copy of the GNU General Public License along with
+   this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+   Place, Suite 330, Boston, MA  02111-1307  USA
+-->
+
+<node name="/org/freedesktop/FileManager1">
+  <interface name="org.freedesktop.FileManager1">
+    <method name="ShowFolders">
+      <arg direction="in" name="URIs" type="as"/>
+      <arg direction="in" name="StartupId" type="s"/>
+    </method>
+    <method name="ShowItems">
+      <arg direction="in" name="URIs" type="as"/>
+      <arg direction="in" name="StartupId" type="s"/>
+    </method>
+    <method name="ShowItemProperties">
+      <arg direction="in" name="URIs" type="as"/>
+      <arg direction="in" name="StartupId" type="s"/>
+    </method>
+  </interface>
+</node>
diff --git a/thunar/thunar-dbus-service.c b/thunar/thunar-dbus-service.c
index 66c104b..2d27642 100644
--- a/thunar/thunar-dbus-service.c
+++ b/thunar/thunar-dbus-service.c
@@ -47,6 +47,7 @@
 
 
 /* include generate dbus infos */
+#include <thunar/thunar-dbus-freedesktop-interfaces.h>
 #include <thunar/thunar-dbus-service-infos.h>
 
 
@@ -220,6 +221,21 @@ static gboolean thunar_dbus_service_terminate                   (ThunarDBusThuna
                                                                  GDBusMethodInvocation  *invocation,
                                                                  ThunarDBusService      *dbus_service);
 
+static gboolean thunar_dbus_freedesktop_show_folders            (ThunarOrgFreedesktopFileManager1 *object,
+                                                                 GDBusMethodInvocation            *invocation,
+                                                                 gchar                           **uris,
+                                                                 const gchar                      *startup_id,
+                                                                 ThunarDBusService                *dbus_service);
+static gboolean thunar_dbus_freedesktop_show_items              (ThunarOrgFreedesktopFileManager1 *object,
+                                                                 GDBusMethodInvocation            *invocation,
+                                                                 gchar                           **uris,
+                                                                 const gchar                      *startup_id,
+                                                                 ThunarDBusService                *dbus_service);
+static gboolean thunar_dbus_freedesktop_show_item_properties    (ThunarOrgFreedesktopFileManager1 *object,
+                                                                 GDBusMethodInvocation            *invocation,
+                                                                 gchar                           **uris,
+                                                                 const gchar                      *startup_id,
+                                                                 ThunarDBusService                *dbus_service);
 
 
 struct _ThunarDBusServiceClass
@@ -231,9 +247,10 @@ struct _ThunarDBusService
 {
   GObject __parent__;
 
-  ThunarDBusFileManager *file_manager;
-  ThunarDBusTrash       *trash;
-  ThunarDBusThunar      *thunar;
+  ThunarDBusFileManager            *file_manager;
+  ThunarDBusTrash                  *trash;
+  ThunarDBusThunar                 *thunar;
+  ThunarOrgFreedesktopFileManager1 *file_manager_fdo;
 
   ThunarFile      *trash_bin;
 };
@@ -281,9 +298,10 @@ static void connect_signals_multiple (gpointer object,
 static void
 thunar_dbus_service_init (ThunarDBusService *dbus_service)
 {
-  dbus_service->file_manager = thunar_dbus_file_manager_skeleton_new ();
-  dbus_service->trash        = thunar_dbus_trash_skeleton_new ();
-  dbus_service->thunar       = thunar_dbus_thunar_skeleton_new ();
+  dbus_service->file_manager      = thunar_dbus_file_manager_skeleton_new ();
+  dbus_service->trash             = thunar_dbus_trash_skeleton_new ();
+  dbus_service->thunar            = thunar_dbus_thunar_skeleton_new ();
+  dbus_service->file_manager_fdo  = thunar_org_freedesktop_file_manager1_skeleton_new ();
 
   connect_signals_multiple (dbus_service->file_manager, dbus_service,
                             "handle-display-chooser-dialog", thunar_dbus_service_display_chooser_dialog,
@@ -315,6 +333,12 @@ thunar_dbus_service_init (ThunarDBusService *dbus_service)
                             "handle-bulk-rename", thunar_dbus_service_bulk_rename,
                             "handle-terminate", thunar_dbus_service_terminate,
                             NULL);
+
+  connect_signals_multiple (dbus_service->file_manager_fdo, dbus_service,
+                            "handle-show-folders", thunar_dbus_freedesktop_show_folders,
+                            "handle-show-items", thunar_dbus_freedesktop_show_items,
+                            "handle-show-item-properties", thunar_dbus_freedesktop_show_item_properties,
+                            NULL);
 }
 
 
@@ -327,6 +351,7 @@ thunar_dbus_service_finalize (GObject *object)
   g_object_unref (dbus_service->file_manager);
   g_object_unref (dbus_service->trash);
   g_object_unref (dbus_service->thunar);
+  g_object_unref (dbus_service->file_manager_fdo);
 
   if (dbus_service->trash_bin)
     g_object_unref (dbus_service->trash_bin);
@@ -1475,6 +1500,145 @@ thunar_dbus_service_terminate (ThunarDBusThunar       *object,
 
 
 
+static gboolean
+thunar_dbus_freedesktop_show_folders (ThunarOrgFreedesktopFileManager1 *object,
+                                      GDBusMethodInvocation            *invocation,
+                                      gchar                           **uris,
+                                      const gchar                      *startup_id,
+                                      ThunarDBusService                *dbus_service)
+{
+  ThunarApplication *application;
+  GdkScreen         *screen;
+  gint               n;
+  GFile             *file;
+  ThunarFile        *thunar_file;
+
+  screen = gdk_screen_get_default ();
+  application = thunar_application_get ();
+
+  for (n = 0; uris[n] != NULL; ++n)
+    {
+      file = g_file_new_for_uri (uris[n]);
+      thunar_file = thunar_file_get (file, NULL);
+
+      g_object_unref (G_OBJECT (file));
+      if (thunar_file == NULL)
+        continue;
+
+      if (thunar_file_is_directory (thunar_file))
+        thunar_application_open_window (application, thunar_file, screen,
+                                        startup_id, FALSE);
+
+      g_object_unref (G_OBJECT (thunar_file));
+    }
+
+  g_object_unref (G_OBJECT (application));
+
+  thunar_org_freedesktop_file_manager1_complete_show_folders (object, invocation);
+
+  return TRUE;
+}
+
+
+
+static gboolean
+thunar_dbus_freedesktop_show_items (ThunarOrgFreedesktopFileManager1 *object,
+                                    GDBusMethodInvocation            *invocation,
+                                    gchar                           **uris,
+                                    const gchar                      *startup_id,
+                                    ThunarDBusService                *dbus_service)
+{
+  ThunarApplication *application;
+  GtkWidget         *window;
+  GdkScreen         *screen;
+  gint               n;
+  GFile             *file;
+  ThunarFile        *thunar_folder, *thunar_file = NULL;
+
+  screen = gdk_screen_get_default ();
+  application = thunar_application_get ();
+
+  for (n = 0; uris[n] != NULL; ++n)
+    {
+      file = g_file_new_for_uri (uris[n]);
+      thunar_folder = thunar_file_get (file, NULL);
+
+      g_object_unref (G_OBJECT (file));
+      if (thunar_folder == NULL)
+        continue;
+
+      if (G_LIKELY (thunar_file_has_parent (thunar_folder)))
+        {
+          thunar_file = thunar_folder;
+          thunar_folder = thunar_file_get_parent (thunar_folder, NULL);
+        }
+
+      window = thunar_application_open_window (application, thunar_folder,
+                                               screen, startup_id, FALSE);
+
+      if (G_LIKELY (thunar_file != NULL))
+        {
+          thunar_window_scroll_to_file (THUNAR_WINDOW (window), thunar_file,
+                                        TRUE, TRUE, 0.5f, 0.5f);
+          g_object_unref (G_OBJECT (thunar_file));
+        }
+
+      g_object_unref (G_OBJECT (thunar_folder));
+    }
+
+  g_object_unref (G_OBJECT (application));
+
+  thunar_org_freedesktop_file_manager1_complete_show_items (object, invocation);
+  return TRUE;
+}
+
+
+
+static gboolean
+thunar_dbus_freedesktop_show_item_properties (ThunarOrgFreedesktopFileManager1 *object,
+                                              GDBusMethodInvocation            *invocation,
+                                              gchar                           **uris,
+                                              const gchar                      *startup_id,
+                                              ThunarDBusService                *dbus_service)
+{
+  ThunarApplication *application;
+  GdkScreen         *screen;
+  gint               n;
+  GFile             *file;
+  GtkWidget         *dialog;
+  ThunarFile        *thunar_file;
+
+  screen = gdk_screen_get_default ();
+  application = thunar_application_get ();
+
+  for (n = 0; uris[n] != NULL; ++n)
+    {
+      file = g_file_new_for_uri (uris[n]);
+      thunar_file = thunar_file_get (file, NULL);
+
+      g_object_unref (G_OBJECT (file));
+      if (thunar_file == NULL)
+        continue;
+
+      dialog = thunar_properties_dialog_new (NULL);
+      gtk_window_set_screen (GTK_WINDOW (dialog), screen);
+      gtk_window_set_startup_id (GTK_WINDOW (dialog), startup_id);
+      thunar_properties_dialog_set_file (THUNAR_PROPERTIES_DIALOG (dialog),
+                                         thunar_file);
+      gtk_window_present (GTK_WINDOW (dialog));
+      thunar_application_take_window (application, GTK_WINDOW (dialog));
+
+      g_object_unref (G_OBJECT (thunar_file));
+    }
+
+  g_object_unref (G_OBJECT (application));
+
+  thunar_org_freedesktop_file_manager1_complete_show_item_properties (object, invocation);
+  return TRUE;
+}
+
+
+
 gboolean thunar_dbus_service_export_on_connection (ThunarDBusService *service,
                                                    GDBusConnection   *connection,
                                                    GError           **error)
@@ -1497,6 +1661,12 @@ gboolean thunar_dbus_service_export_on_connection (ThunarDBusService *service,
                                          error))
     goto fail;
 
+  if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (service->file_manager_fdo),
+                                         connection,
+                                         "/org/freedesktop/FileManager1",
+                                         error))
+    goto fail;
+
   return TRUE;
 
 fail:
@@ -1504,5 +1674,6 @@ fail:
   g_dbus_interface_skeleton_unexport_from_connection (G_DBUS_INTERFACE_SKELETON (service->file_manager), connection);
   g_dbus_interface_skeleton_unexport_from_connection (G_DBUS_INTERFACE_SKELETON (service->trash), connection);
   g_dbus_interface_skeleton_unexport_from_connection (G_DBUS_INTERFACE_SKELETON (service->thunar), connection);
+  g_dbus_interface_skeleton_unexport_from_connection (G_DBUS_INTERFACE_SKELETON (service->file_manager_fdo), connection);
   return FALSE;
 }

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list