[gtk+/wip/matthiasc/help-overlay] shortcuts: Add a shortcut for search
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/matthiasc/help-overlay] shortcuts: Add a shortcut for search
- Date: Wed, 21 Oct 2015 17:18:44 +0000 (UTC)
commit 7bc710ea321859163eaf70bee0211913d0cff451
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Oct 21 13:17:28 2015 -0400
shortcuts: Add a shortcut for search
Make Ctrl-F in the help overlay start search.
gtk/gtkshortcutswindow.c | 34 ++++++++++++++++++++++++++++++++--
gtk/gtkshortcutswindow.h | 3 ++-
2 files changed, 34 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkshortcutswindow.c b/gtk/gtkshortcutswindow.c
index 0c977b5..5e274ec 100644
--- a/gtk/gtkshortcutswindow.c
+++ b/gtk/gtkshortcutswindow.c
@@ -114,6 +114,7 @@ G_DEFINE_TYPE_WITH_PRIVATE (GtkShortcutsWindow, gtk_shortcuts_window, GTK_TYPE_W
enum {
CLOSE,
+ SEARCH,
LAST_SIGNAL
};
@@ -447,12 +448,20 @@ gtk_shortcuts_window__search_mode__changed (GtkShortcutsWindow *self)
}
static void
-gtk_shortcuts_window_real_close (GtkShortcutsWindow *self)
+gtk_shortcuts_window_close (GtkShortcutsWindow *self)
{
gtk_window_close (GTK_WINDOW (self));
}
static void
+gtk_shortcuts_window_search (GtkShortcutsWindow *self)
+{
+ GtkShortcutsWindowPrivate *priv = gtk_shortcuts_window_get_instance_private (self);
+
+ gtk_search_bar_set_search_mode (priv->search_bar, TRUE);
+}
+
+static void
gtk_shortcuts_window_constructed (GObject *object)
{
GtkShortcutsWindow *self = (GtkShortcutsWindow *)object;
@@ -575,7 +584,8 @@ gtk_shortcuts_window_class_init (GtkShortcutsWindowClass *klass)
container_class->add = gtk_shortcuts_window_add;
container_class->child_type = gtk_shortcuts_window_child_type;
- klass->close = gtk_shortcuts_window_real_close;
+ klass->close = gtk_shortcuts_window_close;
+ klass->search = gtk_shortcuts_window_search;
/**
* GtkShortcutsWindow:section-name:
@@ -624,9 +634,29 @@ gtk_shortcuts_window_class_init (GtkShortcutsWindowClass *klass)
NULL, NULL, NULL,
G_TYPE_NONE,
0);
+
+ /**
+ * GtkShortcutsWindow::search:
+ *
+ * The ::search signal is a
+ * [keybinding signal][GtkBindingSignal]
+ * which gets emitted when the user uses a keybinding to start a search.
+ *
+ * The default binding for this signal is Control-F.
+ */
+ signals[SEARCH] = g_signal_new (I_("search"),
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GtkShortcutsWindowClass, search),
+ NULL, NULL, NULL,
+ G_TYPE_NONE,
+ 0);
+
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "close", 0);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_f, GDK_CONTROL_MASK, "search", 0);
g_type_ensure (GTK_TYPE_SHORTCUTS_GROUP);
+ g_type_ensure (GTK_TYPE_SHORTCUTS_GROUP);
g_type_ensure (GTK_TYPE_SHORTCUTS_GESTURE);
g_type_ensure (GTK_TYPE_SHORTCUTS_SHORTCUT);
}
diff --git a/gtk/gtkshortcutswindow.h b/gtk/gtkshortcutswindow.h
index 00a1022..ca2ded8 100644
--- a/gtk/gtkshortcutswindow.h
+++ b/gtk/gtkshortcutswindow.h
@@ -44,7 +44,8 @@ struct _GtkShortcutsWindowClass
{
GtkWindowClass parent_class;
- void (*close) (GtkShortcutsWindow *self);
+ void (*close) (GtkShortcutsWindow *self);
+ void (*search) (GtkShortcutsWindow *self);
};
GDK_AVAILABLE_IN_3_20
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]