[gnome-builder/wip/gtk4-port] libide/foundry: add default-run-command action
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] libide/foundry: add default-run-command action
- Date: Sat, 21 May 2022 07:19:54 +0000 (UTC)
commit 7acb6b7110fe152226084265c646bbd677c114d6
Author: Christian Hergert <chergert redhat com>
Date: Sat May 21 00:19:20 2022 -0700
libide/foundry: add default-run-command action
This allows specifying the action value so that we can use it from
dialogs.
Work still needs to be done as to actually use that run command when
building IdeRunners (as we have no RunCommandProvider yet to test).
src/libide/foundry/ide-run-manager.c | 56 ++++++++++++++++++++++++++++++------
1 file changed, 47 insertions(+), 9 deletions(-)
---
diff --git a/src/libide/foundry/ide-run-manager.c b/src/libide/foundry/ide-run-manager.c
index c333b9730..e559f9acd 100644
--- a/src/libide/foundry/ide-run-manager.c
+++ b/src/libide/foundry/ide-run-manager.c
@@ -68,6 +68,15 @@ struct _IdeRunManager
guint64 last_change_seq;
guint64 pending_last_change_seq;
+ /* The id of the default run command to execute or NULL if we should
+ * discover it each time we try to run.
+ *
+ * TODO: We probably need a way to determine if an install is required
+ * to run a particular command, as for some that may not be necessary
+ * (like running tests).
+ */
+ char *default_run_command;
+
guint busy : 1;
guint messages_debug_all : 1;
};
@@ -79,21 +88,24 @@ typedef struct
guint active;
} DiscoverState;
-static void initable_iface_init (GInitableIface *iface);
-static void ide_run_manager_actions_run (IdeRunManager *self,
- GVariant *param);
-static void ide_run_manager_actions_run_with_handler (IdeRunManager *self,
- GVariant *param);
-static void ide_run_manager_actions_stop (IdeRunManager *self,
- GVariant *param);
-static void ide_run_manager_actions_messages_debug_all (IdeRunManager *self,
- GVariant *param);
+static void initable_iface_init (GInitableIface *iface);
+static void ide_run_manager_actions_run (IdeRunManager *self,
+ GVariant *param);
+static void ide_run_manager_actions_run_with_handler (IdeRunManager *self,
+ GVariant *param);
+static void ide_run_manager_actions_stop (IdeRunManager *self,
+ GVariant *param);
+static void ide_run_manager_actions_messages_debug_all (IdeRunManager *self,
+ GVariant *param);
+static void ide_run_manager_actions_default_run_command (IdeRunManager *self,
+ GVariant *param);
IDE_DEFINE_ACTION_GROUP (IdeRunManager, ide_run_manager, {
{ "run", ide_run_manager_actions_run },
{ "run-with-handler", ide_run_manager_actions_run_with_handler, "s" },
{ "stop", ide_run_manager_actions_stop },
{ "messages-debug-all", ide_run_manager_actions_messages_debug_all, NULL, "false" },
+ { "default-run-command", ide_run_manager_actions_default_run_command, "s", "''" },
})
G_DEFINE_TYPE_EXTENDED (IdeRunManager, ide_run_manager, IDE_TYPE_OBJECT, G_TYPE_FLAG_FINAL,
@@ -130,6 +142,30 @@ discover_state_free (gpointer data)
g_slice_free (DiscoverState, state);
}
+static void
+ide_run_manager_actions_default_run_command (IdeRunManager *self,
+ GVariant *param)
+{
+ const char *str;
+
+ g_assert (IDE_IS_BUILD_MANAGER (self));
+ g_assert (param != NULL);
+ g_assert (g_variant_is_of_type (param, G_VARIANT_TYPE_STRING));
+
+ str = g_variant_get_string (param, NULL);
+ if (ide_str_empty0 (str))
+ str = NULL;
+
+ if (g_strcmp0 (str, self->default_run_command) != 0)
+ {
+ g_free (self->default_run_command);
+ self->default_run_command = g_strdup (str);
+ ide_run_manager_set_action_state (self,
+ "default-run-command",
+ g_variant_new_string (str ? str : ""));
+ }
+}
+
static void
ide_run_manager_real_run (IdeRunManager *self,
IdeRunner *runner)
@@ -179,6 +215,8 @@ ide_run_manager_dispose (GObject *object)
self->handler = NULL;
+ g_clear_pointer (&self->default_run_command, g_free);
+
g_clear_object (&self->cancellable);
ide_clear_and_destroy_object (&self->build_target);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]