[Xfce4-commits] <thunar:master> Add Execute() D-Bus method to org.xfce.FileManager.
Jannis Pohlmann
noreply at xfce.org
Sun Oct 24 23:36:02 CEST 2010
Updating branch refs/heads/master
to 2b5856e4d38e23a7a0711c2448c3421ce49208ad (commit)
from 6140f346f0d772d841c0c0a03d2cd26a1f4d6481 (commit)
commit 2b5856e4d38e23a7a0711c2448c3421ce49208ad
Author: Jannis Pohlmann <jannis at xfce.org>
Date: Sun Oct 24 23:33:03 2010 +0200
Add Execute() D-Bus method to org.xfce.FileManager.
This function takes a working directory, a URI or relative or absolute
path of a file to execute, an array of URIs, relative or absolute paths
of files to supply to the executed file, as well as a display name and a
startup ID.
In its essence, it's a simple wrapper around thunar_file_execute() so
this method can be re-used by other processes.
thunar/thunar-dbus-service-infos.xml | 23 ++++++++++++-
thunar/thunar-dbus-service.c | 60 ++++++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+), 1 deletions(-)
diff --git a/thunar/thunar-dbus-service-infos.xml b/thunar/thunar-dbus-service-infos.xml
index 0a8dba8..9322e29 100644
--- a/thunar/thunar-dbus-service-infos.xml
+++ b/thunar/thunar-dbus-service-infos.xml
@@ -115,7 +115,7 @@
<!--
- Launch (uri : STRING, display : STRING) : VOID
+ Launch (uri : STRING, display : STRING, startup_id : STRING) : VOID
uri : either a file:-URI or an absolute path.
display : the screen on which to launch the file or ""
@@ -131,6 +131,27 @@
<!--
+ Execute (working_directory : STRING, uri : STRING, files : ARRAY OF STRING, display : STRING, startup_id : STRING) : VOID
+
+ working_directory : working directory used to resolve relative filenames.
+ uri : either a file:-URI or an relative or absolute path.
+ files : an array of file:-URIs, relative or absolute paths to supply to
+ the executed URI on execution.
+ display : the screen on which to launch the file or ""
+ to use the default screen of the file manager.
+ startup_id : the DESKTOP_STARTUP_ID environment variable for properly
+ handling startup notification and focus stealing.
+ -->
+ <method name="Execute">
+ <arg direction="in" name="working_directory" type="s" />
+ <arg direction="in" name="uri" type="s" />
+ <arg direction="in" name="files" type="as" />
+ <arg direction="in" name="display" type="s" />
+ <arg direction="in" name="startup_id" type="s" />
+ </method>
+
+
+ <!--
DisplayPreferencesDialog (display : STRING) : VOID
display : the screen on which to display the preferences dialog
diff --git a/thunar/thunar-dbus-service.c b/thunar/thunar-dbus-service.c
index 8a864a9..202b06c 100644
--- a/thunar/thunar-dbus-service.c
+++ b/thunar/thunar-dbus-service.c
@@ -103,6 +103,13 @@ static gboolean thunar_dbus_service_launch (ThunarDBusServi
const gchar *display,
const gchar *startup_id,
GError **error);
+static gboolean thunar_dbus_service_execute (ThunarDBusService *dbus_service,
+ const gchar *working_directory,
+ const gchar *uri,
+ const gchar **files,
+ const gchar *display,
+ const gchar *startup_id,
+ GError **error);
static gboolean thunar_dbus_service_display_preferences_dialog (ThunarDBusService *dbus_service,
const gchar *display,
const gchar *startup_id,
@@ -553,6 +560,59 @@ thunar_dbus_service_launch (ThunarDBusService *dbus_service,
static gboolean
+thunar_dbus_service_execute (ThunarDBusService *dbus_service,
+ const gchar *working_directory,
+ const gchar *uri,
+ const gchar **files,
+ const gchar *display,
+ const gchar *startup_id,
+ GError **error)
+{
+ ThunarFile *file;
+ GdkScreen *screen;
+ gboolean result = FALSE;
+ GFile *working_dir;
+ GList *file_list = NULL;
+ gchar *tmp_working_dir = NULL;
+ gchar *old_working_dir = NULL;
+ guint n;
+
+ /* parse uri and display parameters */
+ if (thunar_dbus_service_parse_uri_and_display (dbus_service, uri, display, &file, &screen, error))
+ {
+ if (working_directory != NULL && *working_directory != '\0')
+ old_working_dir = thunar_util_change_working_directory (working_directory);
+
+ for (n = 0; files != NULL && files[n] != NULL; ++n)
+ file_list = g_list_prepend (file_list, g_file_new_for_commandline_arg (files[n]));
+
+ file_list = g_list_reverse (file_list);
+
+ if (old_working_dir != NULL)
+ {
+ tmp_working_dir = thunar_util_change_working_directory (old_working_dir);
+ g_free (tmp_working_dir);
+ g_free (old_working_dir);
+ }
+
+ /* try to launch the file on the given screen */
+ working_dir = g_file_new_for_commandline_arg (working_directory);
+ result = thunar_file_execute (file, working_dir, screen, file_list, error);
+ g_object_unref (working_dir);
+
+ /* cleanup */
+ g_list_foreach (file_list, (GFunc) g_object_unref, NULL);
+ g_list_free (file_list);
+ g_object_unref (screen);
+ g_object_unref (file);
+ }
+
+ return result;
+}
+
+
+
+static gboolean
thunar_dbus_service_display_preferences_dialog (ThunarDBusService *dbus_service,
const gchar *display,
const gchar *startup_id,
More information about the Xfce4-commits
mailing list