[gnome-builder/wip/gtk4-port] libide/foundry: add run command kind
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] libide/foundry: add run command kind
- Date: Mon, 23 May 2022 22:16:21 +0000 (UTC)
commit 65a82bc8e8910d0a92ddc85c8a991d25dfe8d7b7
Author: Christian Hergert <chergert redhat com>
Date: Mon May 23 15:03:43 2022 -0700
libide/foundry: add run command kind
With kind, we can possibly remove IdeTestProvider and move those to using
this instead. Additionally, if we add a path to a command we might be
able to recreate the Unit Test project tree bits.
src/libide/foundry/ide-run-command.c | 54 ++++++++++++++++++++++++++++++++++++
src/libide/foundry/ide-run-command.h | 14 ++++++++++
src/libide/foundry/meson.build | 1 +
3 files changed, 69 insertions(+)
---
diff --git a/src/libide/foundry/ide-run-command.c b/src/libide/foundry/ide-run-command.c
index 729d75762..f06934d07 100644
--- a/src/libide/foundry/ide-run-command.c
+++ b/src/libide/foundry/ide-run-command.c
@@ -22,6 +22,7 @@
#include "config.h"
+#include "ide-foundry-enums.h"
#include "ide-run-command.h"
typedef struct
@@ -32,6 +33,7 @@ typedef struct
char **env;
char **argv;
int priority;
+ IdeRunCommandKind kind;
} IdeRunCommandPrivate;
enum {
@@ -41,6 +43,7 @@ enum {
PROP_DISPLAY_NAME,
PROP_ENV,
PROP_ID,
+ PROP_KIND,
PROP_PRIORITY,
N_PROPS
};
@@ -120,6 +123,10 @@ ide_run_command_get_property (GObject *object,
g_value_set_string (value, ide_run_command_get_id (self));
break;
+ case PROP_KIND:
+ g_value_set_enum (value, ide_run_command_get_kind (self));
+ break;
+
case PROP_PRIORITY:
g_value_set_int (value, ide_run_command_get_priority (self));
break;
@@ -159,6 +166,10 @@ ide_run_command_set_property (GObject *object,
ide_run_command_set_id (self, g_value_get_string (value));
break;
+ case PROP_KIND:
+ ide_run_command_set_kind (self, g_value_get_enum (value));
+ break;
+
case PROP_PRIORITY:
ide_run_command_set_priority (self, g_value_get_int (value));
break;
@@ -204,6 +215,12 @@ ide_run_command_class_init (IdeRunCommandClass *klass)
NULL,
(G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS));
+ properties [PROP_KIND] =
+ g_param_spec_enum ("kind", NULL, NULL,
+ IDE_TYPE_RUN_COMMAND_KIND,
+ IDE_RUN_COMMAND_KIND_UNKNOWN,
+ (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,
@@ -403,3 +420,40 @@ ide_run_command_get_arguments (IdeRunCommand *self,
return IDE_RUN_COMMAND_GET_CLASS (self)->get_arguments (self, wrapper);
}
+
+IdeRunCommandKind
+ide_run_command_get_kind (IdeRunCommand *self)
+{
+ IdeRunCommandPrivate *priv = ide_run_command_get_instance_private (self);
+
+ g_return_val_if_fail (IDE_IS_RUN_COMMAND (self), 0);
+
+ return priv->kind;
+}
+
+/**
+ * ide_run_command_set_kind:
+ * @self: a #IdeRunCommand
+ *
+ * Sets the kind of command.
+ *
+ * This is useful for #IdeRunCommandProvider that want to specify
+ * the type of command that is being provided. Doing so allows tooling
+ * in Builder to treat that information specially, such as showing tags
+ * next to the row in UI or including it in "Unit Test" browsers.
+ */
+void
+ide_run_command_set_kind (IdeRunCommand *self,
+ IdeRunCommandKind kind)
+{
+ IdeRunCommandPrivate *priv = ide_run_command_get_instance_private (self);
+
+ g_return_if_fail (IDE_IS_RUN_COMMAND (self));
+ g_return_if_fail (kind <= IDE_RUN_COMMAND_KIND_USER_DEFINED);
+
+ if (priv->kind != kind)
+ {
+ priv->kind = kind;
+ g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_KIND]);
+ }
+}
diff --git a/src/libide/foundry/ide-run-command.h b/src/libide/foundry/ide-run-command.h
index d91ca3b0c..7bbee2ede 100644
--- a/src/libide/foundry/ide-run-command.h
+++ b/src/libide/foundry/ide-run-command.h
@@ -30,6 +30,15 @@ G_BEGIN_DECLS
#define IDE_TYPE_RUN_COMMAND (ide_run_command_get_type())
+typedef enum
+{
+ IDE_RUN_COMMAND_KIND_UNKNOWN = 0,
+ IDE_RUN_COMMAND_KIND_APPLICATION,
+ IDE_RUN_COMMAND_KIND_UTILITY,
+ IDE_RUN_COMMAND_KIND_TEST_SUITE,
+ IDE_RUN_COMMAND_KIND_USER_DEFINED,
+} IdeRunCommandKind;
+
IDE_AVAILABLE_IN_ALL
G_DECLARE_DERIVABLE_TYPE (IdeRunCommand, ide_run_command, IDE, RUN_COMMAND, GObject)
@@ -76,5 +85,10 @@ void ide_run_command_set_priority (IdeRunCommand *self,
IDE_AVAILABLE_IN_ALL
char **ide_run_command_get_arguments (IdeRunCommand *self,
const char * const *wrapper);
+IDE_AVAILABLE_IN_ALL
+IdeRunCommandKind ide_run_command_get_kind (IdeRunCommand *self);
+IDE_AVAILABLE_IN_ALL
+void ide_run_command_set_kind (IdeRunCommand *self,
+ IdeRunCommandKind kind);
G_END_DECLS
diff --git a/src/libide/foundry/meson.build b/src/libide/foundry/meson.build
index 1167a13fd..ebfe90d7d 100644
--- a/src/libide/foundry/meson.build
+++ b/src/libide/foundry/meson.build
@@ -79,6 +79,7 @@ libide_foundry_enum_headers = [
'ide-device.h',
'ide-device-info.h',
'ide-pipeline-phase.h',
+ 'ide-run-command.h',
'ide-runtime.h',
'ide-test.h',
]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]