[devhelp] window: ctrl+K focuses the search entry
- From: Aleksander Morgado <aleksm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp] window: ctrl+K focuses the search entry
- Date: Tue, 5 Feb 2013 18:49:27 +0000 (UTC)
commit fcca646f9fce4ddca9a706e96dc6c52e862a6d29
Author: Aleksander Morgado <aleksander lanedo com>
Date: Tue Feb 5 19:35:46 2013 +0100
window: ctrl+K focuses the search entry
Recover the focus-search action in the window; just to make sure we focus in the
search entry.
This action also changes to be ctrl+K instead of the original ctrl+S that we had
when switching to the 'Search' tab before. See:
https://bugzilla.gnome.org/show_bug.cgi?id=665531
src/dh-app.c | 1 +
src/dh-sidebar.c | 8 ++++++++
src/dh-sidebar.h | 1 +
src/dh-window.c | 14 ++++++++++++++
4 files changed, 24 insertions(+), 0 deletions(-)
---
diff --git a/src/dh-app.c b/src/dh-app.c
index a882154..0728c16 100644
--- a/src/dh-app.c
+++ b/src/dh-app.c
@@ -277,6 +277,7 @@ setup_accelerators (DhApp *self)
gtk_application_add_accelerator (GTK_APPLICATION (self), "<Primary>0", "win.zoom-default", NULL);
gtk_application_add_accelerator (GTK_APPLICATION (self), "<Primary>minus", "win.zoom-out", NULL);
gtk_application_add_accelerator (GTK_APPLICATION (self), "<Primary>plus", "win.zoom-in", NULL);
+ gtk_application_add_accelerator (GTK_APPLICATION (self), "<Primary>k", "win.focus-search", NULL);
gtk_application_add_accelerator (GTK_APPLICATION (self), "<Primary>f", "win.find", NULL);
gtk_application_add_accelerator (GTK_APPLICATION (self), "<Primary>c", "win.copy", NULL);
gtk_application_add_accelerator (GTK_APPLICATION (self), "<Primary>p", "win.print", NULL);
diff --git a/src/dh-sidebar.c b/src/dh-sidebar.c
index 650489e..19d9854 100644
--- a/src/dh-sidebar.c
+++ b/src/dh-sidebar.c
@@ -345,6 +345,14 @@ dh_sidebar_set_search_string (DhSidebar *self,
/******************************************************************************/
+void
+dh_sidebar_set_search_focus (DhSidebar *self)
+{
+ gtk_widget_grab_focus (self->priv->entry);
+}
+
+/******************************************************************************/
+
static void
search_cell_data_func (GtkTreeViewColumn *tree_column,
GtkCellRenderer *cell,
diff --git a/src/dh-sidebar.h b/src/dh-sidebar.h
index 8245e79..773a431 100644
--- a/src/dh-sidebar.h
+++ b/src/dh-sidebar.h
@@ -60,6 +60,7 @@ void dh_sidebar_select_uri (DhSidebar *self,
const gchar *uri);
void dh_sidebar_set_search_string (DhSidebar *self,
const gchar *str);
+void dh_sidebar_set_search_focus (DhSidebar *self);
G_END_DECLS
diff --git a/src/dh-window.c b/src/dh-window.c
index 4821489..4295771 100644
--- a/src/dh-window.c
+++ b/src/dh-window.c
@@ -386,6 +386,16 @@ zoom_default_cb (GSimpleAction *action,
}
static void
+focus_search_cb (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ DhWindow *window = user_data;
+
+ dh_sidebar_set_search_focus (DH_SIDEBAR (window->priv->sidebar));
+}
+
+static void
go_back_cb (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
@@ -451,6 +461,7 @@ static GActionEntry win_entries[] = {
{ "zoom-in", zoom_in_cb, NULL, NULL, NULL },
{ "zoom-out", zoom_out_cb, NULL, NULL, NULL },
{ "zoom-default", zoom_default_cb, NULL, NULL, NULL },
+ { "focus-search", focus_search_cb, NULL, NULL, NULL },
/* go */
{ "go-back", go_back_cb, NULL, "false", NULL },
{ "go-forward", go_forward_cb, NULL, "false", NULL },
@@ -734,6 +745,9 @@ window_populate (DhWindow *window)
gtk_widget_show_all (priv->hpaned);
+ /* Focus search in sidebar by default */
+ dh_sidebar_set_search_focus (priv->sidebar);
+
window_update_zoom_actions_state (window);
window_open_new_tab (window, NULL, TRUE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]