summaryrefslogtreecommitdiff
path: root/thunar/thunar-dbus-service.c
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis@xfce.org>2010-10-24 23:33:03 +0200
committerJannis Pohlmann <jannis@xfce.org>2010-10-24 23:33:03 +0200
commit2b5856e4d38e23a7a0711c2448c3421ce49208ad (patch)
tree785c7e2cb528abea2037b78b81db3678eba7d376 /thunar/thunar-dbus-service.c
parent6140f346f0d772d841c0c0a03d2cd26a1f4d6481 (diff)
downloadthunar-2b5856e4d38e23a7a0711c2448c3421ce49208ad.tar.gz
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.
Diffstat (limited to 'thunar/thunar-dbus-service.c')
-rw-r--r--thunar/thunar-dbus-service.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/thunar/thunar-dbus-service.c b/thunar/thunar-dbus-service.c
index 8a864a9c..202b06cb 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,