[Xfce4-commits] [xfce/thunar] 24/46: Replace gdk_spawn_on_screen by g_spawn_async
noreply at xfce.org
noreply at xfce.org
Tue Aug 15 02:35:32 CEST 2017
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 e1865f4d7067c8ccef41a377896a89007b4222d4
Author: Andre Miranda <andre42m at gmail.com>
Date: Fri Apr 14 22:23:49 2017 -0300
Replace gdk_spawn_on_screen by g_spawn_async
Based on:
https://mail.gnome.org/archives/commits-list/2011-February/msg00684.html
---
thunar/thunar-application.c | 7 ++++++-
thunar/thunar-preferences-dialog.c | 15 ++++++++++++---
thunar/thunar-standard-view.c | 16 +++++++++++++---
thunar/thunar-util.c | 6 ++++++
thunar/thunar-util.h | 2 ++
5 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/thunar/thunar-application.c b/thunar/thunar-application.c
index 95e52b2..b9e99f0 100644
--- a/thunar/thunar-application.c
+++ b/thunar/thunar-application.c
@@ -859,6 +859,7 @@ thunar_application_volman_idle (gpointer user_data)
GError *err = NULL;
gchar **argv;
GPid pid;
+ char *display = NULL;
/* check if volume management is enabled (otherwise, we don't spawn anything, but clear the list here) */
g_object_get (G_OBJECT (application->preferences), "misc-volume-management", &misc_volume_management, NULL);
@@ -880,8 +881,11 @@ thunar_application_volman_idle (gpointer user_data)
/* locate the currently active screen (the one with the pointer) */
screen = xfce_gdk_screen_get_active (NULL);
+ if (screen != NULL)
+ display = gdk_screen_make_display_name (screen);
+
/* try to spawn the volman on the active screen */
- if (gdk_spawn_on_screen (screen, NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH, NULL, NULL, &pid, &err))
+ if (g_spawn_async (NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH, thunar_setup_display_cb, display, &pid, &err))
{
/* add a child watch for the volman handler */
application->volman_watch_id = g_child_watch_add_full (G_PRIORITY_LOW, pid, thunar_application_volman_watch,
@@ -895,6 +899,7 @@ thunar_application_volman_idle (gpointer user_data)
}
/* cleanup */
+ g_free (display);
g_strfreev (argv);
}
diff --git a/thunar/thunar-preferences-dialog.c b/thunar/thunar-preferences-dialog.c
index 6a4825a..bcbf6d7 100644
--- a/thunar/thunar-preferences-dialog.c
+++ b/thunar/thunar-preferences-dialog.c
@@ -698,8 +698,10 @@ thunar_preferences_dialog_response (GtkDialog *dialog,
static void
thunar_preferences_dialog_configure (ThunarPreferencesDialog *dialog)
{
- GError *err = NULL;
- gchar *argv[3];
+ GError *err = NULL;
+ gchar *argv[3];
+ GdkScreen *screen;
+ char *display = NULL;
_thunar_return_if_fail (THUNAR_IS_PREFERENCES_DIALOG (dialog));
@@ -708,13 +710,20 @@ thunar_preferences_dialog_configure (ThunarPreferencesDialog *dialog)
argv[1] = (gchar *) "--configure";
argv[2] = NULL;
+ screen = gtk_widget_get_screen (GTK_WIDGET (dialog));
+
+ if (screen != NULL)
+ display = gdk_screen_make_display_name (screen);
+
/* invoke the configuration interface of thunar-volman */
- if (!gdk_spawn_on_screen (gtk_widget_get_screen (GTK_WIDGET (dialog)), NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &err))
+ if (!g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, thunar_setup_display_cb, display, NULL, &err))
{
/* tell the user that we failed to come up with the thunar-volman configuration dialog */
thunar_dialogs_show_error (dialog, err, _("Failed to display the volume management settings"));
g_error_free (err);
}
+
+ g_free (display);
}
diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c
index 275a198..d3c6619 100644
--- a/thunar/thunar-standard-view.c
+++ b/thunar/thunar-standard-view.c
@@ -52,6 +52,7 @@
#include <thunar/thunar-templates-action.h>
#include <thunar/thunar-history.h>
#include <thunar/thunar-thumbnailer.h>
+#include <thunar/thunar-util.h>
#if defined(GDK_WINDOWING_X11)
#include <gdk/gdkx.h>
@@ -3280,6 +3281,8 @@ thunar_standard_view_drag_data_received (GtkWidget *view,
gint n = 0;
GtkWidget *source_widget;
GtkWidget *source_view = NULL;
+ GdkScreen *screen;
+ char *display = NULL;
/* check if we don't already know the drop data */
if (G_LIKELY (!standard_view->priv->drop_data_ready))
@@ -3374,10 +3377,16 @@ thunar_standard_view_drag_data_received (GtkWidget *view,
argv[n++] = working_directory;
argv[n++] = NULL;
+ screen = gtk_widget_get_screen (GTK_WIDGET (view));
+
+ if (screen != NULL)
+ display = gdk_screen_make_display_name (screen);
+
/* try to run exo-desktop-item-edit */
- succeed = gdk_spawn_on_screen (gtk_widget_get_screen (view), working_directory, argv, NULL,
- G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
- NULL, NULL, &pid, &error);
+ succeed = g_spawn_async (working_directory, argv, NULL,
+ G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
+ thunar_setup_display_cb, display, &pid, &error);
+
if (G_UNLIKELY (!succeed))
{
/* display an error dialog to the user */
@@ -3392,6 +3401,7 @@ thunar_standard_view_drag_data_received (GtkWidget *view,
}
/* cleanup */
+ g_free (display);
g_object_unref (G_OBJECT (file));
}
}
diff --git a/thunar/thunar-util.c b/thunar/thunar-util.c
index 3cb764e..8640249 100644
--- a/thunar/thunar-util.c
+++ b/thunar/thunar-util.c
@@ -603,3 +603,9 @@ thunar_util_change_working_directory (const gchar *new_directory)
return old_directory;
}
+
+void
+thunar_setup_display_cb (gpointer data)
+{
+ g_setenv ("DISPLAY", (char *) data, TRUE);
+}
diff --git a/thunar/thunar-util.h b/thunar/thunar-util.h
index b80f070..82cba4d 100644
--- a/thunar/thunar-util.h
+++ b/thunar/thunar-util.h
@@ -53,6 +53,8 @@ time_t thunar_util_time_from_rfc3339 (const gchar *date_string) G_
gchar *thunar_util_change_working_directory (const gchar *new_directory) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
+void thunar_setup_display_cb (gpointer data);
+
G_END_DECLS;
#endif /* !__THUNAR_UTIL_H__ */
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list