[gnome-settings-daemon] mouse: Simplify syndaemon command-line building



commit 8fe3ad021968f117f37634a74e5a63575cb818d7
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Jun 18 11:50:29 2012 +0100

    mouse: Simplify syndaemon command-line building

 plugins/mouse/gsd-mouse-manager.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)
---
diff --git a/plugins/mouse/gsd-mouse-manager.c b/plugins/mouse/gsd-mouse-manager.c
index b96f714..ce10807 100644
--- a/plugins/mouse/gsd-mouse-manager.c
+++ b/plugins/mouse/gsd-mouse-manager.c
@@ -567,30 +567,33 @@ set_disable_w_typing (GsdMouseManager *manager, gboolean state)
 {
         if (state && touchpad_is_present ()) {
                 GError *error = NULL;
-                char *args[6];
+                GPtrArray *args;
 
                 if (manager->priv->syndaemon_spawned)
                         return 0;
 
-                args[0] = "syndaemon";
-                args[1] = "-i";
-                args[2] = "1.0";
-                args[3] = "-K";
-                args[4] = "-R";
-                args[5] = NULL;
-
-                if (!have_program_in_path (args[0]))
+                if (!have_program_in_path ("syndaemon"))
                         return 0;
 
+                args = g_ptr_array_new ();
+
+                g_ptr_array_add (args, "syndaemon");
+                g_ptr_array_add (args, "-i");
+                g_ptr_array_add (args, "1.0");
+                g_ptr_array_add (args, "-K");
+                g_ptr_array_add (args, "-R");
+                g_ptr_array_add (args, NULL);
+
                 /* we must use G_SPAWN_DO_NOT_REAP_CHILD to avoid
                  * double-forking, otherwise syndaemon will immediately get
                  * killed again through (PR_SET_PDEATHSIG when the intermediate
                  * process dies */
-                g_spawn_async (g_get_home_dir (), args, NULL,
+                g_spawn_async (g_get_home_dir (), (char **) args->pdata, NULL,
                                 G_SPAWN_SEARCH_PATH|G_SPAWN_DO_NOT_REAP_CHILD, setup_syndaemon, NULL,
                                 &manager->priv->syndaemon_pid, &error);
 
                 manager->priv->syndaemon_spawned = (error == NULL);
+                g_ptr_array_free (args, FALSE);
 
                 if (error) {
                         g_warning ("Failed to launch syndaemon: %s", error->message);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]