[gnome-builder] libide/foundry: add argv convenience wrappers
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide/foundry: add argv convenience wrappers
- Date: Thu, 15 Sep 2022 23:28:27 +0000 (UTC)
commit e7118aa307b8274cd1121d05a33fbf9d1c7d2c60
Author: Christian Hergert <chergert redhat com>
Date: Thu Sep 15 16:27:58 2022 -0700
libide/foundry: add argv convenience wrappers
This just makes it a bit easier to port launcher pipeline addins to use
commands instead.
src/libide/foundry/ide-run-command.c | 58 ++++++++++++++++++++++++++++++++++++
src/libide/foundry/ide-run-command.h | 6 ++++
2 files changed, 64 insertions(+)
---
diff --git a/src/libide/foundry/ide-run-command.c b/src/libide/foundry/ide-run-command.c
index eb798aa33..59c43be79 100644
--- a/src/libide/foundry/ide-run-command.c
+++ b/src/libide/foundry/ide-run-command.c
@@ -748,3 +748,61 @@ ide_run_command_setenv (IdeRunCommand *self,
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ENVIRON]);
}
+
+/**
+ * ide_run_command_append_argv:
+ * @self: a #IdeRunCommand
+ * @arg: the argument to append
+ *
+ * A convenience wrapper to append @arg to #IdeRunCommand:argv.
+ */
+void
+ide_run_command_append_argv (IdeRunCommand *self,
+ const char *arg)
+{
+ IdeRunCommandPrivate *priv = ide_run_command_get_instance_private (self);
+ g_autoptr(GStrvBuilder) builder = NULL;
+
+ g_return_if_fail (IDE_IS_RUN_COMMAND (self));
+
+ if (arg == NULL)
+ return;
+
+ builder = g_strv_builder_new ();
+ if (priv->argv != NULL && priv->argv[0] != NULL)
+ g_strv_builder_addv (builder, (const char **)priv->argv);
+ g_strv_builder_add (builder, arg);
+
+ g_clear_pointer (&priv->argv, g_strfreev);
+ priv->argv = g_strv_builder_end (builder);
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ARGV]);
+}
+
+/**
+ * ide_run_command_append_args:
+ * @self: a #IdeRunCommand
+ * @args: the arguments to append
+ *
+ * A convenience wrapper to append @args to #IdeRunCommand:argv.
+ */
+void
+ide_run_command_append_args (IdeRunCommand *self,
+ const char * const *args)
+{
+ IdeRunCommandPrivate *priv = ide_run_command_get_instance_private (self);
+ g_autoptr(GStrvBuilder) builder = NULL;
+
+ g_return_if_fail (IDE_IS_RUN_COMMAND (self));
+
+ if (args == NULL || args[0] == NULL)
+ return;
+
+ builder = g_strv_builder_new ();
+ if (priv->argv != NULL && priv->argv[0] != NULL)
+ g_strv_builder_addv (builder, (const char **)priv->argv);
+ g_strv_builder_addv (builder, (const char **)args);
+
+ g_clear_pointer (&priv->argv, g_strfreev);
+ priv->argv = g_strv_builder_end (builder);
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ARGV]);
+}
diff --git a/src/libide/foundry/ide-run-command.h b/src/libide/foundry/ide-run-command.h
index d529c93b1..3434e6f4c 100644
--- a/src/libide/foundry/ide-run-command.h
+++ b/src/libide/foundry/ide-run-command.h
@@ -77,6 +77,12 @@ IDE_AVAILABLE_IN_ALL
void ide_run_command_set_argv (IdeRunCommand *self,
const char * const *argv);
IDE_AVAILABLE_IN_ALL
+void ide_run_command_append_args (IdeRunCommand *self,
+ const char * const *args);
+IDE_AVAILABLE_IN_ALL
+void ide_run_command_append_argv (IdeRunCommand *self,
+ const char *arg);
+IDE_AVAILABLE_IN_ALL
const char * const *ide_run_command_get_environ (IdeRunCommand *self);
IDE_AVAILABLE_IN_ALL
void ide_run_command_set_environ (IdeRunCommand *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]