summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2015-10-21 13:17:28 -0400
committerMatthias Clasen <mclasen@redhat.com>2015-10-21 13:17:28 -0400
commit7bc710ea321859163eaf70bee0211913d0cff451 (patch)
treec4ec11f30a98566ebd404df027c1fa006ed91363
parent6e5b81aebffe160392823aec451b855b9d68bc5d (diff)
downloadgtk+-wip/matthiasc/help-overlay.tar.gz
shortcuts: Add a shortcut for searchwip/matthiasc/help-overlay
Make Ctrl-F in the help overlay start search.
-rw-r--r--gtk/gtkshortcutswindow.c34
-rw-r--r--gtk/gtkshortcutswindow.h3
2 files changed, 34 insertions, 3 deletions
diff --git a/gtk/gtkshortcutswindow.c b/gtk/gtkshortcutswindow.c
index 0c977b599e..5e274ec1b6 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 00a1022d8f..ca2ded8317 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