[gnome-builder/wip/gtk4-port: 1105/1774] libide/foundry: give run commands an id
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 1105/1774] libide/foundry: give run commands an id
- Date: Mon, 11 Jul 2022 22:31:34 +0000 (UTC)
commit 89ef5382d5b737da06e3d18623d54e47f8767f58
Author: Christian Hergert <chergert redhat com>
Date: Sat May 21 00:06:55 2022 -0700
libide/foundry: give run commands an id
So that we can reference them using actions and pull them out later.
src/libide/foundry/ide-run-command.c | 41 ++++++++++++++++++++++++++++++++++++
src/libide/foundry/ide-run-command.h | 5 +++++
2 files changed, 46 insertions(+)
---
diff --git a/src/libide/foundry/ide-run-command.c b/src/libide/foundry/ide-run-command.c
index ad0fc41a9..1b38fcb87 100644
--- a/src/libide/foundry/ide-run-command.c
+++ b/src/libide/foundry/ide-run-command.c
@@ -26,6 +26,7 @@
typedef struct
{
+ char *id;
char *display_name;
char **env;
char **argv;
@@ -37,6 +38,7 @@ enum {
PROP_ARGV,
PROP_DISPLAY_NAME,
PROP_ENV,
+ PROP_ID,
PROP_PRIORITY,
N_PROPS
};
@@ -80,6 +82,10 @@ ide_run_command_get_property (GObject *object,
g_value_set_boxed (value, ide_run_command_get_env (self));
break;
+ case PROP_ID:
+ g_value_set_string (value, ide_run_command_get_id (self));
+ break;
+
case PROP_PRIORITY:
g_value_set_int (value, ide_run_command_get_priority (self));
break;
@@ -111,6 +117,10 @@ ide_run_command_set_property (GObject *object,
ide_run_command_set_env (self, g_value_get_boxed (value));
break;
+ case PROP_ID:
+ ide_run_command_set_id (self, g_value_get_string (value));
+ break;
+
case PROP_PRIORITY:
ide_run_command_set_priority (self, g_value_get_int (value));
break;
@@ -144,6 +154,11 @@ ide_run_command_class_init (IdeRunCommandClass *klass)
G_TYPE_STRV,
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
+ properties [PROP_ID] =
+ g_param_spec_string ("id", NULL, NULL,
+ NULL,
+ (G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
+
properties [PROP_PRIORITY] =
g_param_spec_int ("priority", NULL, NULL,
G_MININT, G_MAXINT, 0,
@@ -157,6 +172,32 @@ ide_run_command_init (IdeRunCommand *self)
{
}
+const char *
+ide_run_command_get_id (IdeRunCommand *self)
+{
+ IdeRunCommandPrivate *priv = ide_run_command_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_RUN_COMMAND (self), NULL);
+
+ return priv->id;
+}
+
+void
+ide_run_command_set_id (IdeRunCommand *self,
+ const char *id)
+{
+ IdeRunCommandPrivate *priv = ide_run_command_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_RUN_COMMAND (self));
+
+ if (g_strcmp0 (priv->id, id) != 0)
+ {
+ g_free (priv->id);
+ priv->id = g_strdup (id);
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_ID]);
+ }
+}
+
const char *
ide_run_command_get_display_name (IdeRunCommand *self)
{
diff --git a/src/libide/foundry/ide-run-command.h b/src/libide/foundry/ide-run-command.h
index a863dc5cd..2d4e84784 100644
--- a/src/libide/foundry/ide-run-command.h
+++ b/src/libide/foundry/ide-run-command.h
@@ -38,6 +38,11 @@ struct _IdeRunCommandClass
GObjectClass parent_class;
};
+IDE_AVAILABLE_IN_ALL
+const char *ide_run_command_get_id (IdeRunCommand *self);
+IDE_AVAILABLE_IN_ALL
+void ide_run_command_set_id (IdeRunCommand *self,
+ const char *id);
IDE_AVAILABLE_IN_ALL
const char *ide_run_command_get_display_name (IdeRunCommand *self);
IDE_AVAILABLE_IN_ALL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]