[gnome-builder] shellcmd: add API to copy a GbpShellcmdCommand
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] shellcmd: add API to copy a GbpShellcmdCommand
- Date: Thu, 8 Aug 2019 20:16:59 +0000 (UTC)
commit d13603f0e2a49fed2a7d53379b028d8bf298f66d
Author: Christian Hergert <chergert redhat com>
Date: Thu Aug 8 13:10:15 2019 -0700
shellcmd: add API to copy a GbpShellcmdCommand
This is useful so that we can discard the commands after they have been
executed by the command manager.
src/plugins/shellcmd/gbp-shellcmd-command.c | 25 +++++++++++++++++++++++++
src/plugins/shellcmd/gbp-shellcmd-command.h | 1 +
2 files changed, 26 insertions(+)
---
diff --git a/src/plugins/shellcmd/gbp-shellcmd-command.c b/src/plugins/shellcmd/gbp-shellcmd-command.c
index f0e4f323c..aa327dfb9 100644
--- a/src/plugins/shellcmd/gbp-shellcmd-command.c
+++ b/src/plugins/shellcmd/gbp-shellcmd-command.c
@@ -819,3 +819,28 @@ gbp_shellcmd_command_get_id (GbpShellcmdCommand *self)
return self->id;
}
+GbpShellcmdCommand *
+gbp_shellcmd_command_copy (GbpShellcmdCommand *self)
+{
+ GbpShellcmdCommand *ret;
+
+ g_return_val_if_fail (GBP_IS_SHELLCMD_COMMAND (self), NULL);
+
+ ret = g_object_new (GBP_TYPE_SHELLCMD_COMMAND, NULL);
+ ret->locality = self->locality;
+ ret->id = g_strdup (self->id);
+ ret->shortcut = g_strdup (self->shortcut);
+ ret->title = g_strdup (self->title);
+ ret->subtitle = g_strdup (self->subtitle);
+ ret->command = g_strdup (self->command);
+ ret->cwd = g_strdup (self->cwd);
+
+ if (self->environment != NULL)
+ {
+ g_auto(GStrv) env = ide_environment_get_environ (self->environment);
+ ret->environment = ide_environment_new ();
+ ide_environment_set_environ (ret->environment, (const gchar * const *)env);
+ }
+
+ return g_steal_pointer (&ret);
+}
diff --git a/src/plugins/shellcmd/gbp-shellcmd-command.h b/src/plugins/shellcmd/gbp-shellcmd-command.h
index fd6dce8de..ad078d089 100644
--- a/src/plugins/shellcmd/gbp-shellcmd-command.h
+++ b/src/plugins/shellcmd/gbp-shellcmd-command.h
@@ -37,6 +37,7 @@ typedef enum
G_DECLARE_FINAL_TYPE (GbpShellcmdCommand, gbp_shellcmd_command, GBP, SHELLCMD_COMMAND, IdeObject)
+GbpShellcmdCommand *gbp_shellcmd_command_copy (GbpShellcmdCommand *self);
const gchar *gbp_shellcmd_command_get_id (GbpShellcmdCommand *self);
GbpShellcmdCommandLocality gbp_shellcmd_command_get_locality (GbpShellcmdCommand *self);
void gbp_shellcmd_command_set_locality (GbpShellcmdCommand *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]