[gnome-builder] plugins/symbol-tree: use action group for workspace actions
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] plugins/symbol-tree: use action group for workspace actions
- Date: Fri, 29 Jul 2022 20:39:41 +0000 (UTC)
commit f4ab2d6012d19192df5db5d22734b924b40a407d
Author: Christian Hergert <chergert redhat com>
Date: Fri Jul 29 13:39:37 2022 -0700
plugins/symbol-tree: use action group for workspace actions
.../symbol-tree/gbp-symbol-workspace-addin.c | 47 +++++++++-------------
src/plugins/symbol-tree/gtk/keybindings.json | 2 +-
src/plugins/symbol-tree/gtk/menus.ui | 2 +-
3 files changed, 20 insertions(+), 31 deletions(-)
---
diff --git a/src/plugins/symbol-tree/gbp-symbol-workspace-addin.c
b/src/plugins/symbol-tree/gbp-symbol-workspace-addin.c
index 3441a3896..bc3fc9ad4 100644
--- a/src/plugins/symbol-tree/gbp-symbol-workspace-addin.c
+++ b/src/plugins/symbol-tree/gbp-symbol-workspace-addin.c
@@ -52,6 +52,23 @@ struct _GbpSymbolWorkspaceAddin
guint symbol_tree_timeout_source;
};
+static void
+focus_action (GbpSymbolWorkspaceAddin *self,
+ GVariant *param)
+{
+ g_assert (GBP_IS_SYMBOL_WORKSPACE_ADDIN (self));
+
+ if (gtk_widget_get_visible (GTK_WIDGET (self->menu_button)))
+ {
+ gtk_menu_button_popup (self->menu_button);
+ gtk_widget_grab_focus (GTK_WIDGET (self->popover));
+ }
+}
+
+IDE_DEFINE_ACTION_GROUP (GbpSymbolWorkspaceAddin, gbp_symbol_workspace_addin, {
+ { "focus", focus_action },
+});
+
static void
gbp_symbol_workspace_addin_set_symbol (GbpSymbolWorkspaceAddin *self,
IdeSymbol *symbol)
@@ -298,27 +315,6 @@ gbp_symbol_workspace_addin_buffer_changed_cb (GbpSymbolWorkspaceAddin *self,
self);
}
-static void
-focus_symbol_tree (GSimpleAction *action,
- GVariant *param,
- gpointer user_data)
-{
- GbpSymbolWorkspaceAddin *self = user_data;
-
- g_assert (G_IS_SIMPLE_ACTION (action));
- g_assert (GBP_IS_SYMBOL_WORKSPACE_ADDIN (self));
-
- if (gtk_widget_get_visible (GTK_WIDGET (self->menu_button)))
- {
- gtk_menu_button_popup (self->menu_button);
- gtk_widget_grab_focus (GTK_WIDGET (self->popover));
- }
-}
-
-static const GActionEntry actions[] = {
- { "focus-symbol-tree", focus_symbol_tree },
-};
-
static void
gbp_symbol_workspace_addin_load (IdeWorkspaceAddin *addin,
IdeWorkspace *workspace)
@@ -334,11 +330,6 @@ gbp_symbol_workspace_addin_load (IdeWorkspaceAddin *addin,
self->workspace = workspace;
self->statusbar = ide_workspace_get_statusbar (workspace);
- g_action_map_add_action_entries (G_ACTION_MAP (workspace),
- actions,
- G_N_ELEMENTS (actions),
- self);
-
box = g_object_new (GTK_TYPE_BOX,
"orientation", GTK_ORIENTATION_HORIZONTAL,
"spacing", 6,
@@ -380,9 +371,6 @@ gbp_symbol_workspace_addin_unload (IdeWorkspaceAddin *addin,
g_assert (PANEL_IS_STATUSBAR (self->statusbar));
g_assert (workspace == self->workspace);
- for (guint i = 0; i < G_N_ELEMENTS (actions); i++)
- g_action_map_remove_action (G_ACTION_MAP (workspace), actions[i].name);
-
ide_signal_group_set_target (self->buffer_signals, NULL);
g_clear_handle_id (&self->nearest_scope_timeout_source, g_source_remove);
@@ -432,6 +420,7 @@ workspace_addin_iface_init (IdeWorkspaceAddinInterface *iface)
}
G_DEFINE_FINAL_TYPE_WITH_CODE (GbpSymbolWorkspaceAddin, gbp_symbol_workspace_addin, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (G_TYPE_ACTION_GROUP,
gbp_symbol_workspace_addin_init_action_group)
G_IMPLEMENT_INTERFACE (IDE_TYPE_WORKSPACE_ADDIN, workspace_addin_iface_init))
static void
diff --git a/src/plugins/symbol-tree/gtk/keybindings.json b/src/plugins/symbol-tree/gtk/keybindings.json
index 00758dae5..9d97561e1 100644
--- a/src/plugins/symbol-tree/gtk/keybindings.json
+++ b/src/plugins/symbol-tree/gtk/keybindings.json
@@ -1 +1 @@
-{ "trigger" : "<Control><Shift>k", "action" : "win.focus-symbol-tree", "when" : "canEdit()", "phase" :
"capture" },
+{ "trigger" : "<Control><Shift>k", "action" : "workspace.symbol-tree.focus", "when" : "canEdit()", "phase" :
"capture" },
diff --git a/src/plugins/symbol-tree/gtk/menus.ui b/src/plugins/symbol-tree/gtk/menus.ui
index 87597d52e..0e7eda925 100644
--- a/src/plugins/symbol-tree/gtk/menus.ui
+++ b/src/plugins/symbol-tree/gtk/menus.ui
@@ -5,7 +5,7 @@
<attribute name="label" translatable="yes">Select Symbol…</attribute>
<attribute name="description" translatable="yes">Navigate to a symbol within the current
page</attribute>
<attribute name="verb-icon">lang-function-symbolic</attribute>
- <attribute name="action">win.focus-symbol-tree</attribute>
+ <attribute name="action">workspace.symbol-tree.focus</attribute>
<attribute name="accel"><control><shift>k</attribute>
</item>
</menu>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]