[gnome-builder] launcher: add helper to reset argv array



commit e7bc804d5d297bd1a84375e9602993c417093a9d
Author: Christian Hergert <chergert redhat com>
Date:   Wed May 9 14:01:31 2018 -0700

    launcher: add helper to reset argv array
    
    This is useful in cases where you have to replace all of the items in the
    argv array.

 src/libide/subprocess/ide-subprocess-launcher.c | 19 +++++++++++++++++++
 src/libide/subprocess/ide-subprocess-launcher.h |  3 +++
 2 files changed, 22 insertions(+)
---
diff --git a/src/libide/subprocess/ide-subprocess-launcher.c b/src/libide/subprocess/ide-subprocess-launcher.c
index 69585bef3..e3be4160f 100644
--- a/src/libide/subprocess/ide-subprocess-launcher.c
+++ b/src/libide/subprocess/ide-subprocess-launcher.c
@@ -927,6 +927,25 @@ ide_subprocess_launcher_take_stderr_fd (IdeSubprocessLauncher *self,
     }
 }
 
+void
+ide_subprocess_launcher_set_argv (IdeSubprocessLauncher *self,
+                                  const gchar * const   *args)
+{
+  IdeSubprocessLauncherPrivate *priv = ide_subprocess_launcher_get_instance_private (self);
+
+  g_return_if_fail (IDE_IS_SUBPROCESS_LAUNCHER (self));
+
+  g_ptr_array_remove_range (priv->argv, 0, priv->argv->len);
+
+  if (args != NULL)
+    {
+      for (guint i = 0; args[i] != NULL; i++)
+        g_ptr_array_add (priv->argv, g_strdup (args[i]));
+    }
+
+  g_ptr_array_add (priv->argv, NULL);
+}
+
 const gchar * const *
 ide_subprocess_launcher_get_argv (IdeSubprocessLauncher *self)
 {
diff --git a/src/libide/subprocess/ide-subprocess-launcher.h b/src/libide/subprocess/ide-subprocess-launcher.h
index 85895c6a1..02f113455 100644
--- a/src/libide/subprocess/ide-subprocess-launcher.h
+++ b/src/libide/subprocess/ide-subprocess-launcher.h
@@ -109,6 +109,9 @@ void                   ide_subprocess_launcher_push_argv           (IdeSubproces
                                                                     const gchar            *argv);
 IDE_AVAILABLE_IN_ALL
 gchar                 *ide_subprocess_launcher_pop_argv            (IdeSubprocessLauncher  *self) 
G_GNUC_WARN_UNUSED_RESULT;
+IDE_AVAILABLE_IN_3_30
+void                   ide_subprocess_launcher_set_argv            (IdeSubprocessLauncher  *self,
+                                                                    const gchar * const    *argv);
 IDE_AVAILABLE_IN_ALL
 IdeSubprocess         *ide_subprocess_launcher_spawn               (IdeSubprocessLauncher  *self,
                                                                     GCancellable           *cancellable,


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