[gnome-builder] plugins/buildui: add delete/duplicate/make-active buttons
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] plugins/buildui: add delete/duplicate/make-active buttons
- Date: Sun, 28 Aug 2022 05:01:44 +0000 (UTC)
commit f0f37d13667a8fc3acc7fecd7685b675f452fea2
Author: Christian Hergert <chergert redhat com>
Date: Sat Aug 27 21:58:49 2022 -0700
plugins/buildui: add delete/duplicate/make-active buttons
src/plugins/buildui/gbp-buildui-tweaks-addin.c | 124 +++++++++++++++++++++++++
src/plugins/buildui/tweaks.ui | 16 ++++
2 files changed, 140 insertions(+)
---
diff --git a/src/plugins/buildui/gbp-buildui-tweaks-addin.c b/src/plugins/buildui/gbp-buildui-tweaks-addin.c
index e6c2eefdb..073eb09c7 100644
--- a/src/plugins/buildui/gbp-buildui-tweaks-addin.c
+++ b/src/plugins/buildui/gbp-buildui-tweaks-addin.c
@@ -118,6 +118,129 @@ create_environ_editor_cb (GbpBuilduiTweaksAddin *self,
return gbp_buildui_environment_editor_new (binding);
}
+static void
+on_duplicate_cb (GtkButton *button,
+ IdeConfig *config)
+{
+ IdeConfigManager *config_manager;
+ IdeTweaksWindow *window;
+ IdeContext *context;
+
+ g_assert (GTK_IS_BUTTON (button));
+ g_assert (IDE_IS_CONFIG (config));
+
+ window = IDE_TWEAKS_WINDOW (gtk_widget_get_root (GTK_WIDGET (button)));
+
+ context = ide_object_get_context (IDE_OBJECT (config));
+ config_manager = ide_config_manager_from_context (context);
+ ide_config_manager_duplicate (config_manager, config);
+
+ ide_tweaks_window_navigate_initial (window);
+}
+
+static void
+on_delete_cb (GtkButton *button,
+ IdeConfig *config)
+{
+ IdeConfigManager *config_manager;
+ IdeTweaksWindow *window;
+ IdeContext *context;
+
+ g_assert (GTK_IS_BUTTON (button));
+ g_assert (IDE_IS_CONFIG (config));
+
+ window = IDE_TWEAKS_WINDOW (gtk_widget_get_root (GTK_WIDGET (button)));
+
+ context = ide_object_get_context (IDE_OBJECT (config));
+ config_manager = ide_config_manager_from_context (context);
+ ide_config_manager_delete (config_manager, config);
+
+ ide_tweaks_window_navigate_initial (window);
+}
+
+static void
+on_make_active_cb (GtkButton *button,
+ IdeConfig *config)
+{
+ IdeConfigManager *config_manager;
+ IdeContext *context;
+
+ g_assert (GTK_IS_BUTTON (button));
+ g_assert (IDE_IS_CONFIG (config));
+
+ context = ide_object_get_context (IDE_OBJECT (config));
+ config_manager = ide_config_manager_from_context (context);
+ ide_config_manager_set_current (config_manager, config);
+}
+
+static GtkWidget *
+create_config_buttons_cb (GbpBuilduiTweaksAddin *self,
+ IdeTweaksWidget *widget,
+ IdeTweaksWidget *instance)
+{
+ g_autoptr(IdeConfig) config = NULL;
+ IdeTweaksBinding *binding;
+ GtkButton *duplicate;
+ GtkButton *delete;
+ GtkButton *make_active;
+ GtkBox *box;
+
+ g_assert (GBP_IS_BUILDUI_TWEAKS_ADDIN (self));
+ g_assert (IDE_IS_TWEAKS_WIDGET (widget));
+ g_assert (IDE_IS_TWEAKS_WIDGET (instance));
+
+ if (!(binding = ide_tweaks_widget_get_binding (widget)))
+ return NULL;
+
+ if (!(config = IDE_CONFIG (ide_tweaks_property_dup_object (IDE_TWEAKS_PROPERTY (binding)))))
+ return NULL;
+
+ box = g_object_new (GTK_TYPE_BOX,
+ "orientation", GTK_ORIENTATION_HORIZONTAL,
+ "spacing", 12,
+ "homogeneous", TRUE,
+ NULL);
+
+ duplicate = g_object_new (GTK_TYPE_BUTTON,
+ "label", _("Duplicate"),
+ "tooltip-text", _("Duplicate into new configuration"),
+ "hexpand", TRUE,
+ NULL);
+ g_signal_connect_object (duplicate,
+ "clicked",
+ G_CALLBACK (on_duplicate_cb),
+ config,
+ 0);
+ gtk_box_append (GTK_BOX (box), GTK_WIDGET (duplicate));
+
+ make_active = g_object_new (GTK_TYPE_BUTTON,
+ "label", _("Make Active"),
+ "tooltip-text", _("Make configuration active and reload build pipeline"),
+ "hexpand", TRUE,
+ NULL);
+ g_signal_connect_object (make_active,
+ "clicked",
+ G_CALLBACK (on_make_active_cb),
+ config,
+ 0);
+ gtk_box_append (GTK_BOX (box), GTK_WIDGET (make_active));
+
+ delete = g_object_new (GTK_TYPE_BUTTON,
+ "css-classes", IDE_STRV_INIT ("destructive-action"),
+ "label", _("Delete"),
+ "tooltip-text", _("Delete configuration"),
+ "hexpand", TRUE,
+ NULL);
+ g_signal_connect_object (delete,
+ "clicked",
+ G_CALLBACK (on_delete_cb),
+ config,
+ 0);
+ gtk_box_append (GTK_BOX (box), GTK_WIDGET (delete));
+
+ return GTK_WIDGET (box);
+}
+
static void
gbp_buildui_tweaks_addin_load (IdeTweaksAddin *addin,
IdeTweaks *tweaks)
@@ -145,6 +268,7 @@ gbp_buildui_tweaks_addin_load (IdeTweaksAddin *addin,
ide_tweaks_addin_bind_callback (IDE_TWEAKS_ADDIN (self), create_runtime_list_cb);
ide_tweaks_addin_bind_callback (IDE_TWEAKS_ADDIN (self), create_environ_editor_cb);
+ ide_tweaks_addin_bind_callback (IDE_TWEAKS_ADDIN (self), create_config_buttons_cb);
ide_tweaks_addin_set_resource_paths (IDE_TWEAKS_ADDIN (self),
IDE_STRV_INIT ("/plugins/buildui/tweaks.ui"));
diff --git a/src/plugins/buildui/tweaks.ui b/src/plugins/buildui/tweaks.ui
index 925a417a8..f4b48b455 100644
--- a/src/plugins/buildui/tweaks.ui
+++ b/src/plugins/buildui/tweaks.ui
@@ -324,6 +324,22 @@
<object class="IdeTweaksFactory">
<child internal-child="config_page">
<object class="IdeTweaksPage">
+ <child>
+ <object class="IdeTweaksGroup">
+ <child>
+ <object class="IdeTweaksWidget">
+ <signal name="create-for-item" handler="create_config_buttons_cb" swapped="true"
object="GbpBuilduiTweaksAddin"/>
+ <property name="binding">
+ <object class="IdeTweaksProperty">
+ <binding name="object">
+ <lookup name="item">config_factory</lookup>
+ </binding>
+ </object>
+ </property>
+ </object>
+ </child>
+ </object>
+ </child>
<child>
<object class="IdeTweaksGroup">
<property name="title" translatable="yes">General</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]