[gnome-builder/wip/gtk4-port: 748/1774] plugins/buildui: Port GbpBuilduiTreeAddin to GTK4
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 748/1774] plugins/buildui: Port GbpBuilduiTreeAddin to GTK4
- Date: Mon, 11 Jul 2022 22:31:22 +0000 (UTC)
commit 25915c7d6ce7f433f3bae5107f83def77e57b1cd
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Tue Apr 26 19:49:03 2022 -0300
plugins/buildui: Port GbpBuilduiTreeAddin to GTK4
Minimal changes required.
src/plugins/buildui/buildui-plugin.c | 4 +--
src/plugins/buildui/gbp-buildui-tree-addin.c | 42 +++++++++++++++++-----------
src/plugins/buildui/meson.build | 2 +-
3 files changed, 27 insertions(+), 21 deletions(-)
---
diff --git a/src/plugins/buildui/buildui-plugin.c b/src/plugins/buildui/buildui-plugin.c
index 9451ee228..33f4f8c88 100644
--- a/src/plugins/buildui/buildui-plugin.c
+++ b/src/plugins/buildui/buildui-plugin.c
@@ -30,7 +30,7 @@
//#include "gbp-buildui-config-view-addin.h"
//#include "gbp-buildui-editor-page-addin.h"
#include "gbp-buildui-workspace-addin.h"
-//#include "gbp-buildui-tree-addin.h"
+#include "gbp-buildui-tree-addin.h"
_IDE_EXTERN void
_gbp_buildui_register_types (PeasObjectModule *module)
@@ -46,9 +46,7 @@ _gbp_buildui_register_types (PeasObjectModule *module)
peas_object_module_register_extension_type (module,
IDE_TYPE_WORKSPACE_ADDIN,
GBP_TYPE_BUILDUI_WORKSPACE_ADDIN);
-#if 0
peas_object_module_register_extension_type (module,
IDE_TYPE_TREE_ADDIN,
GBP_TYPE_BUILDUI_TREE_ADDIN);
-#endif
}
diff --git a/src/plugins/buildui/gbp-buildui-tree-addin.c b/src/plugins/buildui/gbp-buildui-tree-addin.c
index 883e9fd6a..cdab48de2 100644
--- a/src/plugins/buildui/gbp-buildui-tree-addin.c
+++ b/src/plugins/buildui/gbp-buildui-tree-addin.c
@@ -35,8 +35,13 @@
struct _GbpBuilduiTreeAddin
{
GObject parent_instance;
+
+ /* Borrowed references */
IdeTree *tree;
IdeTreeModel *model;
+
+ /* Owned references */
+ GActionGroup *group;
};
typedef struct
@@ -304,7 +309,6 @@ gbp_buildui_tree_addin_load (IdeTreeAddin *addin,
IdeTreeModel *model)
{
GbpBuilduiTreeAddin *self = (GbpBuilduiTreeAddin *)addin;
- g_autoptr(GSimpleActionGroup) group = NULL;
IdeContext *context;
static const GActionEntry actions[] = {
{ "build", gbp_buildui_tree_addin_action_build },
@@ -325,12 +329,12 @@ gbp_buildui_tree_addin_load (IdeTreeAddin *addin,
if (!ide_context_has_project (context))
return;
- group = g_simple_action_group_new ();
- g_action_map_add_action_entries (G_ACTION_MAP (group),
+ self->group = G_ACTION_GROUP (g_simple_action_group_new ());
+ g_action_map_add_action_entries (G_ACTION_MAP (self->group),
actions,
G_N_ELEMENTS (actions),
self);
- gtk_widget_insert_action_group (GTK_WIDGET (tree), "buildui", G_ACTION_GROUP (group));
+ gtk_widget_insert_action_group (GTK_WIDGET (tree), "buildui", self->group);
}
static void
@@ -347,6 +351,7 @@ gbp_buildui_tree_addin_unload (IdeTreeAddin *addin,
gtk_widget_insert_action_group (GTK_WIDGET (tree), "buildui", NULL);
+ g_clear_object (&self->group);
self->model = NULL;
self->tree = NULL;
}
@@ -358,6 +363,7 @@ gbp_buildui_tree_addin_selection_changed (IdeTreeAddin *addin,
GbpBuilduiTreeAddin *self = (GbpBuilduiTreeAddin *)addin;
IdeBuildTarget *target;
IdeContext *context;
+ GAction *action;
g_assert (IDE_IS_MAIN_THREAD ());
g_assert (GBP_IS_BUILDUI_TREE_ADDIN (self));
@@ -368,19 +374,21 @@ gbp_buildui_tree_addin_selection_changed (IdeTreeAddin *addin,
if (!ide_context_has_project (context))
return;
- dzl_gtk_widget_action_set (GTK_WIDGET (self->tree), "buildui", "build",
- "enabled", node && ide_tree_node_holds (node, IDE_TYPE_BUILD_TARGET),
- NULL);
- dzl_gtk_widget_action_set (GTK_WIDGET (self->tree), "buildui", "rebuild",
- "enabled", node && ide_tree_node_holds (node, IDE_TYPE_BUILD_TARGET),
- NULL);
- dzl_gtk_widget_action_set (GTK_WIDGET (self->tree), "buildui", "run-with-handler",
- "enabled", node &&
- ide_tree_node_holds (node, IDE_TYPE_BUILD_TARGET) &&
- (target = ide_tree_node_get_item (node)) &&
- ide_build_target_get_install (target) &&
- ide_build_target_get_kind (target) == IDE_ARTIFACT_KIND_EXECUTABLE,
- NULL);
+ action = g_action_map_lookup_action (G_ACTION_MAP (self->group), "build");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+ node && ide_tree_node_holds (node, IDE_TYPE_BUILD_TARGET));
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (self->group), "rebuild");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+ node && ide_tree_node_holds (node, IDE_TYPE_BUILD_TARGET));
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (self->group), "run-with-handler");
+ g_simple_action_set_enabled (G_SIMPLE_ACTION (action),
+ node &&
+ ide_tree_node_holds (node, IDE_TYPE_BUILD_TARGET) &&
+ (target = ide_tree_node_get_item (node)) &&
+ ide_build_target_get_install (target) &&
+ ide_build_target_get_kind (target) == IDE_ARTIFACT_KIND_EXECUTABLE);
}
static void
diff --git a/src/plugins/buildui/meson.build b/src/plugins/buildui/meson.build
index d3491335a..f5a4c8720 100644
--- a/src/plugins/buildui/meson.build
+++ b/src/plugins/buildui/meson.build
@@ -9,7 +9,7 @@ plugins_sources += files([
#'gbp-buildui-runtime-categories.c',
#'gbp-buildui-runtime-row.c',
'gbp-buildui-stage-row.c',
- #'gbp-buildui-tree-addin.c',
+ 'gbp-buildui-tree-addin.c',
'gbp-buildui-workspace-addin.c',
])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]