[gnome-builder/wip/gtk4-port] libide/foundry: add ide_run_context_append_formatted()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] libide/foundry: add ide_run_context_append_formatted()
- Date: Wed, 22 Jun 2022 18:58:37 +0000 (UTC)
commit 886b7745aa84df6cafde30237afc81013cc51ee3
Author: Christian Hergert <chergert redhat com>
Date: Wed Jun 22 11:55:23 2022 -0700
libide/foundry: add ide_run_context_append_formatted()
A convenience wrapper for IdeRunContext that can append an argument from
a format string and parameters.
src/libide/foundry/ide-run-context.c | 18 ++++++++++++++++++
src/libide/foundry/ide-run-context.h | 4 ++++
2 files changed, 22 insertions(+)
---
diff --git a/src/libide/foundry/ide-run-context.c b/src/libide/foundry/ide-run-context.c
index 1782b0d61..26e9b0228 100644
--- a/src/libide/foundry/ide-run-context.c
+++ b/src/libide/foundry/ide-run-context.c
@@ -377,6 +377,24 @@ ide_run_context_append_argv (IdeRunContext *self,
g_array_append_val (layer->argv, copy);
}
+void
+ide_run_context_append_formatted (IdeRunContext *self,
+ const char *format,
+ ...)
+{
+ g_autofree char *arg = NULL;
+ va_list args;
+
+ g_return_if_fail (IDE_IS_RUN_CONTEXT (self));
+ g_return_if_fail (format != NULL);
+
+ va_start (args, format);
+ arg = g_strdup_vprintf (format, args);
+ va_end (args);
+
+ ide_run_context_append_argv (self, arg);
+}
+
void
ide_run_context_append_args (IdeRunContext *self,
const char * const *args)
diff --git a/src/libide/foundry/ide-run-context.h b/src/libide/foundry/ide-run-context.h
index 4fe1e4701..8ad40a3d4 100644
--- a/src/libide/foundry/ide-run-context.h
+++ b/src/libide/foundry/ide-run-context.h
@@ -106,6 +106,10 @@ gboolean ide_run_context_append_args_parsed (IdeRunContext
const char *args,
GError **error);
IDE_AVAILABLE_IN_ALL
+void ide_run_context_append_formatted (IdeRunContext *self,
+ const char *format,
+ ...) G_GNUC_PRINTF (2, 3);
+IDE_AVAILABLE_IN_ALL
const char *ide_run_context_getenv (IdeRunContext *self,
const char *key);
IDE_AVAILABLE_IN_ALL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]