summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAutomeris naranja <104251-automerisnaranja@users.noreply.gitlab.gnome.org>2023-02-11 19:58:31 -0300
committerChristopher Davis <christopherdavis@gnome.org>2023-02-11 19:23:57 -0500
commit024f702109df6e92e16ff63e0af12f645d5dc192 (patch)
treeda3c1dfbc4d241cab0645adae50e313cef470830
parent2498fa83345f6fc4504a67a30d9a474182d250c1 (diff)
downloadgnome-font-viewer-024f702109df6e92e16ff63e0af12f645d5dc192.tar.gz
font-view-window: Add search shortcut
-rw-r--r--src/font-view-window.c12
-rw-r--r--src/font-view-window.ui8
2 files changed, 19 insertions, 1 deletions
diff --git a/src/font-view-window.c b/src/font-view-window.c
index 393984b..1352ab3 100644
--- a/src/font-view-window.c
+++ b/src/font-view-window.c
@@ -54,6 +54,7 @@ struct _FontViewWindow
AdwLeaflet *leaflet;
/* Overview */
+ GtkToggleButton *search_button;
GtkSearchBar *search_bar;
GtkSearchEntry *search_entry;
GtkGridView *grid_view;
@@ -766,6 +767,14 @@ font_view_window_show_overview (FontViewWindow *self)
adw_leaflet_set_visible_child_name (self->leaflet, "overview");
}
+static void
+action_toggle_search_cb (FontViewWindow *self)
+{
+
+ gtk_toggle_button_set_active (self->search_button,
+ !gtk_toggle_button_get_active (self->search_button));
+}
+
void
font_view_window_show_preview (FontViewWindow *self,
GFile *file,
@@ -840,6 +849,7 @@ font_view_window_class_init (FontViewWindowClass *klass)
gtk_widget_class_bind_template_child (widget_class, FontViewWindow, leaflet);
gtk_widget_class_bind_template_child (widget_class, FontViewWindow, search_bar);
+ gtk_widget_class_bind_template_child (widget_class, FontViewWindow, search_button);
gtk_widget_class_bind_template_child (widget_class, FontViewWindow, search_entry);
gtk_widget_class_bind_template_child (widget_class, FontViewWindow, grid_view);
gtk_widget_class_bind_template_child (widget_class, FontViewWindow, font_title);
@@ -856,11 +866,13 @@ font_view_window_class_init (FontViewWindowClass *klass)
gtk_widget_class_bind_template_callback (widget_class, font_widget_loaded_cb);
gtk_widget_class_bind_template_callback (widget_class, view_child_activated_cb);
+ gtk_widget_class_bind_template_callback (widget_class, action_toggle_search_cb);
gtk_widget_class_bind_template_callback (widget_class, font_attribute_closure);
gtk_widget_class_bind_template_callback (widget_class, font_name_closure);
gtk_widget_class_bind_template_callback (widget_class, preview_visible_child_closure);
gtk_widget_class_install_action (widget_class, "win.back", NULL, action_overview_cb);
+ gtk_widget_class_install_action (widget_class, "win.toggle-search", NULL, action_toggle_search_cb);
gtk_widget_class_install_action (widget_class, "win.install-font", NULL, action_install_font_cb);
}
diff --git a/src/font-view-window.ui b/src/font-view-window.ui
index babb01d..851b738 100644
--- a/src/font-view-window.ui
+++ b/src/font-view-window.ui
@@ -11,6 +11,12 @@
<property name="scope">managed</property>
<child>
<object class="GtkShortcut">
+ <property name="trigger">&lt;Control&gt;F</property>
+ <property name="action">action(win.toggle-search)</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcut">
<property name="trigger">&lt;Control&gt;Q</property>
<property name="action">action(app.quit)</property>
</object>
@@ -35,7 +41,7 @@
</object>
</property>
<child type="start">
- <object class="GtkToggleButton">
+ <object class="GtkToggleButton" id="search_button">
<property name="icon-name">edit-find-symbolic</property>
<property name="tooltip-text" translatable="yes">Search</property>
<property name="active" bind-source="search_bar" bind-property="search-mode-enabled" bind-flags="bidirectional|sync-create"/>