[gnome-builder/wip/gtk4-port: 997/1774] plugins/symbol-tree: wire up keybindings for symbol tree
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port: 997/1774] plugins/symbol-tree: wire up keybindings for symbol tree
- Date: Mon, 11 Jul 2022 22:31:31 +0000 (UTC)
commit ece696e837c255b10db5b32be07e75520813a87b
Author: Christian Hergert <chergert redhat com>
Date: Fri May 13 07:22:30 2022 -0700
plugins/symbol-tree: wire up keybindings for symbol tree
src/plugins/symbol-tree/gbp-symbol-popover.c | 8 ++++++
.../symbol-tree/gbp-symbol-workspace-addin.c | 29 ++++++++++++++++++++++
src/plugins/symbol-tree/gtk/keybindings.json | 1 +
src/plugins/symbol-tree/symbol-tree.gresource.xml | 1 +
4 files changed, 39 insertions(+)
---
diff --git a/src/plugins/symbol-tree/gbp-symbol-popover.c b/src/plugins/symbol-tree/gbp-symbol-popover.c
index 66445a50f..035318044 100644
--- a/src/plugins/symbol-tree/gbp-symbol-popover.c
+++ b/src/plugins/symbol-tree/gbp-symbol-popover.c
@@ -129,6 +129,12 @@ gbp_symbol_popover_search_changed_cb (GbpSymbolPopover *self,
gtk_filter_changed (self->filter, GTK_FILTER_CHANGE_DIFFERENT);
}
+static gboolean
+gbp_symbol_popover_grab_focus (GtkWidget *widget)
+{
+ return gtk_widget_grab_focus (GTK_WIDGET (GBP_SYMBOL_POPOVER (widget)->search_entry));
+}
+
static void
gbp_symbol_popover_dispose (GObject *object)
{
@@ -189,6 +195,8 @@ gbp_symbol_popover_class_init (GbpSymbolPopoverClass *klass)
object_class->get_property = gbp_symbol_popover_get_property;
object_class->set_property = gbp_symbol_popover_set_property;
+ widget_class->grab_focus = gbp_symbol_popover_grab_focus;
+
properties [PROP_SYMBOL_TREE] =
g_param_spec_object ("symbol-tree",
"Symbol Tree",
diff --git a/src/plugins/symbol-tree/gbp-symbol-workspace-addin.c
b/src/plugins/symbol-tree/gbp-symbol-workspace-addin.c
index 093031a21..2737b2bb2 100644
--- a/src/plugins/symbol-tree/gbp-symbol-workspace-addin.c
+++ b/src/plugins/symbol-tree/gbp-symbol-workspace-addin.c
@@ -298,6 +298,27 @@ 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)
@@ -313,6 +334,11 @@ 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,
@@ -353,6 +379,9 @@ 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);
diff --git a/src/plugins/symbol-tree/gtk/keybindings.json b/src/plugins/symbol-tree/gtk/keybindings.json
new file mode 100644
index 000000000..00758dae5
--- /dev/null
+++ b/src/plugins/symbol-tree/gtk/keybindings.json
@@ -0,0 +1 @@
+{ "trigger" : "<Control><Shift>k", "action" : "win.focus-symbol-tree", "when" : "canEdit()", "phase" :
"capture" },
diff --git a/src/plugins/symbol-tree/symbol-tree.gresource.xml
b/src/plugins/symbol-tree/symbol-tree.gresource.xml
index f13c770b1..63075fa12 100644
--- a/src/plugins/symbol-tree/symbol-tree.gresource.xml
+++ b/src/plugins/symbol-tree/symbol-tree.gresource.xml
@@ -2,6 +2,7 @@
<gresources>
<gresource prefix="/plugins/symbol-tree">
<file>symbol-tree.plugin</file>
+ <file>gtk/keybindings.json</file>
<file preprocess="xml-stripblanks">gbp-symbol-popover.ui</file>
<file preprocess="xml-stripblanks">gbp-symbol-popover-row.ui</file>
</gresource>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]