[gnome-builder] symbol-tree: jump to first match on entry activate
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] symbol-tree: jump to first match on entry activate
- Date: Tue, 27 Mar 2018 22:22:45 +0000 (UTC)
commit 5c9badc8ba482adad00f2b622024b1263973c7dd
Author: Christian Hergert <chergert redhat com>
Date: Tue Mar 27 15:22:42 2018 -0700
symbol-tree: jump to first match on entry activate
This jumps to the first item in the tree when Enter is pressed within the
search entry. You can now ctrl+shift+k, type, Enter to jump to a symbol
very similar to using global search.
src/plugins/symbol-tree/gbp-symbol-menu-button.c | 25 +++++++++++++++++++++++
src/plugins/symbol-tree/gbp-symbol-menu-button.ui | 1 +
2 files changed, 26 insertions(+)
---
diff --git a/src/plugins/symbol-tree/gbp-symbol-menu-button.c
b/src/plugins/symbol-tree/gbp-symbol-menu-button.c
index 9d74f14e7..22c3787fe 100644
--- a/src/plugins/symbol-tree/gbp-symbol-menu-button.c
+++ b/src/plugins/symbol-tree/gbp-symbol-menu-button.c
@@ -112,6 +112,30 @@ gbp_symbol_menu_button_get_icon_cell (GbpSymbolMenuButton *self)
return cell;
}
+static void
+on_entry_activate (GbpSymbolMenuButton *self,
+ GtkSearchEntry *entry)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ g_assert (GBP_IS_SYMBOL_MENU_BUTTON (self));
+ g_assert (GTK_IS_SEARCH_ENTRY (entry));
+
+ model = gtk_tree_view_get_model (GTK_TREE_VIEW (self->tree));
+
+ if (gtk_tree_model_get_iter_first (model, &iter))
+ {
+ GtkTreePath *path;
+ GtkTreeViewColumn *column;
+
+ path = gtk_tree_path_new_first ();
+ column = gtk_tree_view_get_column (GTK_TREE_VIEW (self->tree), 0);
+ gtk_tree_view_row_activated (GTK_TREE_VIEW (self->tree), path, column);
+ gtk_tree_path_free (path);
+ }
+}
+
static void
gbp_symbol_menu_button_destroy (GtkWidget *widget)
{
@@ -181,6 +205,7 @@ gbp_symbol_menu_button_class_init (GbpSymbolMenuButtonClass *klass)
gtk_widget_class_bind_template_child (widget_class, GbpSymbolMenuButton, symbol_title);
gtk_widget_class_bind_template_child (widget_class, GbpSymbolMenuButton, tree);
gtk_widget_class_bind_template_child (widget_class, GbpSymbolMenuButton, tree_builder);
+ gtk_widget_class_bind_template_callback (widget_class, on_entry_activate);
properties [PROP_SYMBOL_TREE] =
g_param_spec_object ("symbol-tree",
diff --git a/src/plugins/symbol-tree/gbp-symbol-menu-button.ui
b/src/plugins/symbol-tree/gbp-symbol-menu-button.ui
index 5ae48666d..cc425d04a 100644
--- a/src/plugins/symbol-tree/gbp-symbol-menu-button.ui
+++ b/src/plugins/symbol-tree/gbp-symbol-menu-button.ui
@@ -26,6 +26,7 @@
<object class="GtkSearchEntry" id="search_entry">
<property name="margin-bottom">6</property>
<property name="visible">true</property>
+ <signal name="activate" handler="on_entry_activate" swapped="yes" object="GbpSymbolMenuButton"/>
</object>
</child>
<child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]