[gnome-builder] shellcmd: add helper to set environment by gchar**
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] shellcmd: add helper to set environment by gchar**
- Date: Thu, 8 Aug 2019 20:17:04 +0000 (UTC)
commit eb897d9a7fc1ccf7d2540f1308c2c0ba8c7d826c
Author: Christian Hergert <chergert redhat com>
Date: Thu Aug 8 13:10:56 2019 -0700
shellcmd: add helper to set environment by gchar**
src/plugins/shellcmd/gbp-shellcmd-command.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
---
diff --git a/src/plugins/shellcmd/gbp-shellcmd-command.c b/src/plugins/shellcmd/gbp-shellcmd-command.c
index aa327dfb9..935acab6b 100644
--- a/src/plugins/shellcmd/gbp-shellcmd-command.c
+++ b/src/plugins/shellcmd/gbp-shellcmd-command.c
@@ -51,6 +51,7 @@ enum {
PROP_ID,
PROP_COMMAND,
PROP_CWD,
+ PROP_ENV,
PROP_ENVIRONMENT,
PROP_LOCALITY,
PROP_SHORTCUT,
@@ -66,6 +67,23 @@ G_DEFINE_TYPE_WITH_CODE (GbpShellcmdCommand, gbp_shellcmd_command, IDE_TYPE_OBJE
static GParamSpec *properties [N_PROPS];
+static void
+gbp_shellcmd_command_set_env (GbpShellcmdCommand *self,
+ const gchar * const *env)
+{
+ g_return_if_fail (GBP_IS_SHELLCMD_COMMAND (self));
+
+ if (self->environment == NULL)
+ {
+ if (env == NULL || env[0] == NULL)
+ return;
+
+ self->environment = ide_environment_new ();
+ }
+
+ ide_environment_set_environ (self->environment, env);
+}
+
static void
gbp_shellcmd_command_finalize (GObject *object)
{
@@ -150,6 +168,10 @@ gbp_shellcmd_command_set_property (GObject *object,
gbp_shellcmd_command_set_cwd (self, g_value_get_string (value));
break;
+ case PROP_ENV:
+ gbp_shellcmd_command_set_env (self, g_value_get_boxed (value));
+ break;
+
case PROP_LOCALITY:
gbp_shellcmd_command_set_locality (self, g_value_get_enum (value));
break;
@@ -201,6 +223,11 @@ gbp_shellcmd_command_class_init (GbpShellcmdCommandClass *klass)
NULL,
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
+ properties [PROP_ENV] =
+ g_param_spec_boxed ("env", NULL, NULL,
+ G_TYPE_STRV,
+ (G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS));
+
properties [PROP_ENVIRONMENT] =
g_param_spec_object ("environment",
"Environment",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]