Skip to content
Snippets Groups Projects
Commit 2b5856e4 authored by Jannis Pohlmann's avatar Jannis Pohlmann
Browse files

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.
parent 6140f346
No related branches found
No related tags found
No related merge requests found
......@@ -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 ""
......@@ -130,6 +130,27 @@
</method>
<!--
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
......
......@@ -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,
......@@ -552,6 +559,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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment