[Xfce4-commits] [xfce/exo] 06/21: Get rid of gdk_spawn_on_screen()

noreply at xfce.org noreply at xfce.org
Tue Jul 12 04:07:58 CEST 2016


This is an automated email from the git hooks/post-receive script.

bluesabre pushed a commit to branch master
in repository xfce/exo.

commit 9155cf5703c54f79e3bf76b6f5da2f4475ee7844
Author: Jonas Kümmerlin <rgcjonas at gmail.com>
Date:   Thu Aug 6 11:53:34 2015 +0200

    Get rid of gdk_spawn_on_screen()
---
 exo-helper/exo-helper.c | 11 ++++++++++-
 exo/exo-execute.c       | 19 +++++++++++++++----
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/exo-helper/exo-helper.c b/exo-helper/exo-helper.c
index 37d8901..ce5ef9e 100644
--- a/exo-helper/exo-helper.c
+++ b/exo-helper/exo-helper.c
@@ -352,7 +352,9 @@ exo_helper_execute (ExoHelper   *helper,
   GError       *err = NULL;
   gchar       **commands;
   gchar       **argv;
+  gchar       **envp;
   gchar        *command;
+  gchar        *display;
   guint         n;
   gint          status;
   gint          result;
@@ -398,11 +400,18 @@ exo_helper_execute (ExoHelper   *helper,
       if (G_UNLIKELY (!succeed))
         continue;
 
+      /* set the display variable */
+      envp = g_get_environ ();
+      display = gdk_screen_make_display_name (screen);
+      envp = g_environ_setenv (envp, "DISPLAY", display, TRUE);
+
       /* try to run the command */
-      succeed = gdk_spawn_on_screen (screen, NULL, argv, NULL, G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH, NULL, NULL, &pid, &err);
+      succeed = g_spawn_async (NULL, argv, envp, G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH, NULL, NULL, &pid, &err);
 
       /* cleanup */
       g_strfreev (argv);
+      g_strfreev (envp);
+      g_free (display);
 
       /* check if the execution was successful */
       if (G_LIKELY (succeed))
diff --git a/exo/exo-execute.c b/exo/exo-execute.c
index 31b199f..1fabf57 100644
--- a/exo/exo-execute.c
+++ b/exo/exo-execute.c
@@ -119,12 +119,15 @@ gboolean
 exo_execute_preferred_application_on_screen (const gchar *category,
                                              const gchar *parameter,
                                              const gchar *working_directory,
-                                             gchar      **envp,
+                                             gchar      **envp_in,
                                              GdkScreen   *screen,
                                              GError     **error)
 {
-  gchar *argv[5];
-  gint   argc = 0;
+  gchar   *argv[5];
+  gchar   *display;
+  gchar  **envp = g_strdupv (envp_in);
+  gint     argc = 0;
+  gboolean success;
 
   g_return_val_if_fail (category != NULL, FALSE);
   g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
@@ -142,8 +145,16 @@ exo_execute_preferred_application_on_screen (const gchar *category,
   /* null terminate the argument vector */
   argv[argc] = NULL;
 
+  /* set the display environment variable */
+  display = gdk_screen_make_display_name (screen);
+  envp = g_environ_setenv (envp, "DISPLAY", display, TRUE);
+
   /* launch the command */
-  return gdk_spawn_on_screen (screen, working_directory, argv, envp, 0, NULL, NULL, NULL, error);
+  success = g_spawn_async (working_directory, argv, envp, 0, NULL, NULL, NULL, error);
+
+  g_free (display);
+  g_strfreev (envp);
+  return success;
 }
 
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list