[Xfce4-commits] [xfce/thunar] 01/01: Fix startup id handling for launch requests over D-Bus (bug #9646)
noreply at xfce.org
noreply at xfce.org
Fri Mar 6 19:02:39 CET 2015
This is an automated email from the git hooks/post-receive script.
hjudt pushed a commit to branch master
in repository xfce/thunar.
commit 03ed0b6fff9a740f2f8971770ba03d0d4f6af718
Author: Thaddaeus Tintenfisch <thad.fisch at gmail.com>
Date: Sun Mar 1 19:54:27 2015 +0100
Fix startup id handling for launch requests over D-Bus (bug #9646)
---
thunar/thunar-dbus-service.c | 2 +-
thunar/thunar-dnd.c | 2 +-
thunar/thunar-file.c | 31 +++++++++++++++++++++++++++++--
thunar/thunar-file.h | 1 +
thunar/thunar-launcher.c | 2 +-
5 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/thunar/thunar-dbus-service.c b/thunar/thunar-dbus-service.c
index b908a7a..2f26f98 100644
--- a/thunar/thunar-dbus-service.c
+++ b/thunar/thunar-dbus-service.c
@@ -625,7 +625,7 @@ thunar_dbus_service_execute (ThunarDBusService *dbus_service,
/* 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);
+ result = thunar_file_execute (file, working_dir, screen, file_list, startup_id, error);
g_object_unref (working_dir);
/* cleanup */
diff --git a/thunar/thunar-dnd.c b/thunar/thunar-dnd.c
index 6eb07ad..dbbbe41 100644
--- a/thunar/thunar-dnd.c
+++ b/thunar/thunar-dnd.c
@@ -247,7 +247,7 @@ thunar_dnd_perform (GtkWidget *widget,
else if (thunar_file_is_executable (file))
{
/* TODO any chance to determine the working dir here? */
- succeed = thunar_file_execute (file, NULL, widget, file_list, &error);
+ succeed = thunar_file_execute (file, NULL, widget, file_list, NULL, &error);
if (G_UNLIKELY (!succeed))
{
/* display an error to the user */
diff --git a/thunar/thunar-file.c b/thunar/thunar-file.c
index 9dedf47..0d6e14d 100644
--- a/thunar/thunar-file.c
+++ b/thunar/thunar-file.c
@@ -1476,6 +1476,7 @@ thunar_file_check_loaded (ThunarFile *file)
* in @file_list.
* @parent : %NULL, a #GdkScreen or #GtkWidget.
* @file_list : the list of #GFile<!---->s to supply to @file on execution.
+ * @startup_id : startup id for the new window (send over for dbus) or %NULL.
* @error : return location for errors or %NULL.
*
* Tries to execute @file on the specified @screen. If @file is executable
@@ -1489,6 +1490,7 @@ thunar_file_execute (ThunarFile *file,
GFile *working_directory,
gpointer parent,
GList *file_list,
+ const gchar *startup_id,
GError **error)
{
gboolean snotify = FALSE;
@@ -1507,6 +1509,7 @@ thunar_file_execute (ThunarFile *file,
gchar *exec;
gchar *directory = NULL;
gboolean is_secure = FALSE;
+ guint32 stimestamp = 0;
_thunar_return_val_if_fail (THUNAR_IS_FILE (file), FALSE);
_thunar_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -1630,10 +1633,34 @@ thunar_file_execute (ThunarFile *file,
}
}
+ /* check if a startup id was passed (launch request over dbus) */
+ if (startup_id != NULL && *startup_id != '\0')
+ {
+ /* parse startup_id string and extract timestamp
+ * format: <unique>_TIME<timestamp>) */
+ gchar *time_str = g_strrstr (startup_id, "_TIME");
+ if (time_str != NULL)
+ {
+ gchar *end;
+
+ /* ignore the "_TIME" part */
+ time_str += 5;
+
+ stimestamp = strtoul (time_str, &end, 0);
+ if (end == time_str)
+ stimestamp = 0;
+ }
+ }
+ else
+ {
+ /* use current event time */
+ stimestamp = gtk_get_current_event_time ();
+ }
+
/* execute the command */
result = xfce_spawn_on_screen (thunar_util_parse_parent (parent, NULL),
directory, argv, NULL, G_SPAWN_SEARCH_PATH,
- snotify, gtk_get_current_event_time (), icon_name, error);
+ snotify, stimestamp, icon_name, error);
}
/* clean up */
@@ -1698,7 +1725,7 @@ thunar_file_launch (ThunarFile *file,
/* check if we should execute the file */
if (thunar_file_is_executable (file))
- return thunar_file_execute (file, NULL, parent, NULL, error);
+ return thunar_file_execute (file, NULL, parent, NULL, NULL, error);
/* determine the default application to open the file */
/* TODO We should probably add a cancellable argument to thunar_file_launch() */
diff --git a/thunar/thunar-file.h b/thunar/thunar-file.h
index 0576874..f0302e3 100644
--- a/thunar/thunar-file.h
+++ b/thunar/thunar-file.h
@@ -141,6 +141,7 @@ gboolean thunar_file_execute (ThunarFile
GFile *working_directory,
gpointer parent,
GList *path_list,
+ const gchar *startup_id,
GError **error);
gboolean thunar_file_launch (ThunarFile *file,
diff --git a/thunar/thunar-launcher.c b/thunar/thunar-launcher.c
index 2db5d14..b1eff7a 100644
--- a/thunar/thunar-launcher.c
+++ b/thunar/thunar-launcher.c
@@ -561,7 +561,7 @@ thunar_launcher_execute_files (ThunarLauncher *launcher,
{
working_directory = thunar_file_get_file (launcher->current_directory);
- if (!thunar_file_execute (lp->data, working_directory, launcher->widget, NULL, &error))
+ if (!thunar_file_execute (lp->data, working_directory, launcher->widget, NULL, NULL, &error))
{
/* display an error message to the user */
thunar_dialogs_show_error (launcher->widget, error, _("Failed to execute file \"%s\""), thunar_file_get_display_name (lp->data));
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list