[gnome-builder] libide/foundry: store default run command in project settings
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide/foundry: store default run command in project settings
- Date: Wed, 20 Jul 2022 04:34:39 +0000 (UTC)
commit bdad014a0101b631d7abee317c938f8f6bcb3d21
Author: Christian Hergert <chergert redhat com>
Date: Tue Jul 19 21:32:42 2022 -0700
libide/foundry: store default run command in project settings
.../org.gnome.builder.project.gschema.xml | 6 +++
src/libide/foundry/ide-run-manager-private.h | 5 +-
src/libide/foundry/ide-run-manager.c | 56 ++++++++++++++++++----
3 files changed, 58 insertions(+), 9 deletions(-)
---
diff --git a/data/gsettings/org.gnome.builder.project.gschema.xml
b/data/gsettings/org.gnome.builder.project.gschema.xml
index a3fbe2c3c..b20e727a4 100644
--- a/data/gsettings/org.gnome.builder.project.gschema.xml
+++ b/data/gsettings/org.gnome.builder.project.gschema.xml
@@ -14,6 +14,12 @@
<description>Run the pipelines install phase before running the project. Only use this if you know
what you're doing with your project.</description>
</key>
+ <key name="default-run-command" type="s">
+ <default>''</default>
+ <summary>Default Run Command</summary>
+ <description>The id of the default run command</description>
+ </key>
+
<key name="stop-signal" type="s">
<choices>
<choice value="SIGKILL"/>
diff --git a/src/libide/foundry/ide-run-manager-private.h b/src/libide/foundry/ide-run-manager-private.h
index 8b2e7c762..cfc93e2fe 100644
--- a/src/libide/foundry/ide-run-manager-private.h
+++ b/src/libide/foundry/ide-run-manager-private.h
@@ -24,6 +24,9 @@
G_BEGIN_DECLS
-void _ide_run_manager_drop_caches (IdeRunManager *self);
+void _ide_run_manager_drop_caches (IdeRunManager *self);
+const char *_ide_run_manager_get_default_id (IdeRunManager *self);
+void _ide_run_manager_set_default_id (IdeRunManager *self,
+ const char *run_command_id);
G_END_DECLS
diff --git a/src/libide/foundry/ide-run-manager.c b/src/libide/foundry/ide-run-manager.c
index 232d44b80..10031422c 100644
--- a/src/libide/foundry/ide-run-manager.c
+++ b/src/libide/foundry/ide-run-manager.c
@@ -248,14 +248,7 @@ ide_run_manager_actions_default_run_command (IdeRunManager *self,
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 : ""));
- }
+ _ide_run_manager_set_default_id (self, str);
}
static void
@@ -366,6 +359,7 @@ initable_init (GInitable *initable,
GError **error)
{
IdeRunManager *self = (IdeRunManager *)initable;
+ g_autoptr(GSettings) settings = NULL;
IdeBuildManager *build_manager;
IdeContext *context;
@@ -376,6 +370,13 @@ initable_init (GInitable *initable,
context = ide_object_get_context (IDE_OBJECT (self));
build_manager = ide_build_manager_from_context (context);
+ settings = ide_context_ref_project_settings (context);
+
+ g_clear_pointer (&self->default_run_command, g_free);
+ self->default_run_command = g_settings_get_string (settings, "default-run-command");
+ ide_run_manager_set_action_state (self,
+ "default-run-command",
+ g_variant_new_string (self->default_run_command));
g_signal_connect_object (build_manager,
"notify::can-build",
@@ -1304,6 +1305,7 @@ ide_run_manager_init (IdeRunManager *self)
self->cancellable = g_cancellable_new ();
self->run_tool = ide_no_tool_new ();
+ self->default_run_command = g_strdup ("");
/* Setup initial text direction state */
text_dir = gtk_widget_get_default_direction ();
@@ -1616,3 +1618,41 @@ ide_run_manager_discover_run_command_finish (IdeRunManager *self,
IDE_RETURN (run_command);
}
+
+const char *
+_ide_run_manager_get_default_id (IdeRunManager *self)
+{
+ g_return_val_if_fail (IDE_IS_RUN_MANAGER (self), NULL);
+
+ return self->default_run_command;
+}
+
+void
+_ide_run_manager_set_default_id (IdeRunManager *self,
+ const char *run_command_id)
+{
+ g_return_if_fail (IDE_IS_RUN_MANAGER (self));
+
+ if (run_command_id == NULL)
+ run_command_id = "";
+
+ if (g_strcmp0 (run_command_id, self->default_run_command) != 0)
+ {
+ IdeContext *context = ide_object_get_context (IDE_OBJECT (self));
+ g_autoptr(GSettings) settings = ide_context_ref_project_settings (context);
+
+ g_debug ("Setting default run command to \"%s\"",
+ run_command_id);
+
+ g_free (self->default_run_command);
+ self->default_run_command = g_strdup (run_command_id);
+
+ g_settings_set_string (settings,
+ "default-run-command",
+ run_command_id);
+
+ ide_run_manager_set_action_state (self,
+ "default-run-command",
+ g_variant_new_string (run_command_id));
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]