From 71e92f3f2c45cd8dd9f44d8226e23603164974a5 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 24 Jun 2010 20:23:07 -0400 Subject: EShellContent: Add a focus_search_results() method. This gives EShellSearchbar something concrete to call to direct focus away from itself instead of tabbing forward and hoping for the best. --- shell/e-shell-content.c | 23 +++++++++++++++++++++++ shell/e-shell-content.h | 3 +++ shell/e-shell-searchbar.c | 13 +++++++------ 3 files changed, 33 insertions(+), 6 deletions(-) (limited to 'shell') diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c index 515dfa83bf..d897e110ad 100644 --- a/shell/e-shell-content.c +++ b/shell/e-shell-content.c @@ -385,6 +385,29 @@ e_shell_content_check_state (EShellContent *shell_content) return shell_content_class->check_state (shell_content); } +/** + * e_shell_content_focus_search_results: + * @shell_content: an #EShellContent + * + * #EShellContent subclasses should implement the + * focus_search_results method in + * #EShellContentClass to direct input focus to the widget + * displaying search results. This is usually called during + * e_shell_view_execute_search(). + **/ +void +e_shell_content_focus_search_results (EShellContent *shell_content) +{ + EShellContentClass *shell_content_class; + + g_return_if_fail (E_IS_SHELL_CONTENT (shell_content)); + + shell_content_class = E_SHELL_CONTENT_GET_CLASS (shell_content); + + if (shell_content_class->focus_search_results != NULL) + shell_content_class->focus_search_results (shell_content); +} + /** * e_shell_content_get_shell_view: * @shell_content: an #EShellContent diff --git a/shell/e-shell-content.h b/shell/e-shell-content.h index e6a11291a7..a92ac346b8 100644 --- a/shell/e-shell-content.h +++ b/shell/e-shell-content.h @@ -68,6 +68,7 @@ struct _EShellContentClass { /* Methods */ guint32 (*check_state) (EShellContent *shell_content); + void (*focus_search_results) (EShellContent *shell_content); }; GType e_shell_content_get_type (void); @@ -75,6 +76,8 @@ GtkWidget * e_shell_content_new (struct _EShellView *shell_view); void e_shell_content_set_searchbar (EShellContent *shell_content, GtkWidget *searchbar); guint32 e_shell_content_check_state (EShellContent *shell_content); +void e_shell_content_focus_search_results + (EShellContent *shell_content); struct _EShellView * e_shell_content_get_shell_view (EShellContent *shell_content); const gchar * e_shell_content_get_view_id (EShellContent *shell_content); diff --git a/shell/e-shell-searchbar.c b/shell/e-shell-searchbar.c index e8e4fe230d..d1f8f65d62 100644 --- a/shell/e-shell-searchbar.c +++ b/shell/e-shell-searchbar.c @@ -300,7 +300,7 @@ static void shell_searchbar_execute_search_cb (EShellView *shell_view, EShellSearchbar *searchbar) { - GtkWidget *widget; + EShellContent *shell_content; shell_searchbar_update_search_widgets (searchbar); @@ -312,9 +312,10 @@ shell_searchbar_execute_search_cb (EShellView *shell_view, /* Direct the focus away from the search entry, so that a * focus-in event is required before the text can be changed. * This will reset the entry to the appropriate visual state. */ - widget = searchbar->priv->search_entry; - if (gtk_widget_is_focus (widget)) - gtk_widget_child_focus (widget, GTK_DIR_TAB_FORWARD); + if (gtk_widget_is_focus (searchbar->priv->search_entry)) { + shell_content = e_shell_view_get_shell_content (shell_view); + e_shell_content_focus_search_results (shell_content); + } } static void @@ -857,7 +858,7 @@ e_shell_searchbar_class_init (EShellSearchbarClass *class) G_PARAM_CONSTRUCT)); /** - * EShellContent:shell-view + * EShellSearchbar:shell-view * * The #EShellView to which the searchbar widget belongs. **/ @@ -873,7 +874,7 @@ e_shell_searchbar_class_init (EShellSearchbarClass *class) G_PARAM_CONSTRUCT_ONLY)); /** - * EShellContent:state-group + * EShellSearchbar:state-group * * Key file group name to read and write search bar state. **/ -- cgit v1.2.3