[evolution] EShellContent: Add a focus_search_results() method.



commit 71e92f3f2c45cd8dd9f44d8226e23603164974a5
Author: Matthew Barnes <mbarnes redhat com>
Date:   Thu Jun 24 20:23:07 2010 -0400

    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.

 modules/addressbook/e-book-shell-content.c |   13 +++++++++++++
 modules/calendar/e-cal-shell-content.c     |   21 +++++++++++++++++++++
 modules/calendar/e-memo-shell-content.c    |   11 +++++++++++
 modules/calendar/e-task-shell-content.c    |   11 +++++++++++
 modules/mail/e-mail-shell-content.c        |   11 +++++++++++
 shell/e-shell-content.c                    |   23 +++++++++++++++++++++++
 shell/e-shell-content.h                    |    3 +++
 shell/e-shell-searchbar.c                  |   13 +++++++------
 8 files changed, 100 insertions(+), 6 deletions(-)
---
diff --git a/modules/addressbook/e-book-shell-content.c b/modules/addressbook/e-book-shell-content.c
index 66cd6a4..bc37407 100644
--- a/modules/addressbook/e-book-shell-content.c
+++ b/modules/addressbook/e-book-shell-content.c
@@ -364,6 +364,18 @@ book_shell_content_check_state (EShellContent *shell_content)
 }
 
 static void
+book_shell_content_focus_search_results (EShellContent *shell_content)
+{
+	EBookShellContent *book_shell_content;
+	EAddressbookView *view;
+
+	book_shell_content = E_BOOK_SHELL_CONTENT (shell_content);
+	view = e_book_shell_content_get_current_view (book_shell_content);
+
+	gtk_widget_grab_focus (GTK_WIDGET (view));
+}
+
+static void
 book_shell_content_class_init (EBookShellContentClass *class)
 {
 	GObjectClass *object_class;
@@ -380,6 +392,7 @@ book_shell_content_class_init (EBookShellContentClass *class)
 
 	shell_content_class = E_SHELL_CONTENT_CLASS (class);
 	shell_content_class->check_state = book_shell_content_check_state;
+	shell_content_class->focus_search_results = book_shell_content_focus_search_results;
 
 	g_object_class_install_property (
 		object_class,
diff --git a/modules/calendar/e-cal-shell-content.c b/modules/calendar/e-cal-shell-content.c
index a51a072..146d9b9 100644
--- a/modules/calendar/e-cal-shell-content.c
+++ b/modules/calendar/e-cal-shell-content.c
@@ -357,6 +357,7 @@ cal_shell_content_constructed (GObject *object)
 		foreign_content = e_shell_view_get_shell_content (foreign_view);
 		g_object_get (foreign_content, "model", &task_model, NULL);
 	}
+
 	/* Build content widgets. */
 
 	container = GTK_WIDGET (object);
@@ -547,10 +548,27 @@ cal_shell_content_map (GtkWidget *widget)
 }
 
 static void
+cal_shell_content_focus_search_results (EShellContent *shell_content)
+{
+	ECalShellContent *cal_shell_content;
+	GnomeCalendar *calendar;
+	GnomeCalendarViewType view_type;
+	ECalendarView *calendar_view;
+
+	cal_shell_content = E_CAL_SHELL_CONTENT (shell_content);
+	calendar = e_cal_shell_content_get_calendar (cal_shell_content);
+	view_type = gnome_calendar_get_view (calendar);
+	calendar_view = gnome_calendar_get_calendar_view (calendar, view_type);
+
+	gtk_widget_grab_focus (GTK_WIDGET (calendar_view));
+}
+
+static void
 cal_shell_content_class_init (ECalShellContentClass *class)
 {
 	GObjectClass *object_class;
 	GtkWidgetClass *widget_class;
+	EShellContentClass *shell_content_class;
 
 	parent_class = g_type_class_peek_parent (class);
 	g_type_class_add_private (class, sizeof (ECalShellContentPrivate));
@@ -564,6 +582,9 @@ cal_shell_content_class_init (ECalShellContentClass *class)
 	widget_class = GTK_WIDGET_CLASS (class);
 	widget_class->map = cal_shell_content_map;
 
+	shell_content_class = E_SHELL_CONTENT_CLASS (class);
+	shell_content_class->focus_search_results = cal_shell_content_focus_search_results;
+
 	g_object_class_install_property (
 		object_class,
 		PROP_CALENDAR,
diff --git a/modules/calendar/e-memo-shell-content.c b/modules/calendar/e-memo-shell-content.c
index f9188de..6639200 100644
--- a/modules/calendar/e-memo-shell-content.c
+++ b/modules/calendar/e-memo-shell-content.c
@@ -601,6 +601,16 @@ memo_shell_content_check_state (EShellContent *shell_content)
 }
 
 static void
+memo_shell_content_focus_search_results (EShellContent *shell_content)
+{
+	EMemoShellContentPrivate *priv;
+
+	priv = E_MEMO_SHELL_CONTENT_GET_PRIVATE (shell_content);
+
+	gtk_widget_grab_focus (priv->memo_table);
+}
+
+static void
 memo_shell_content_class_init (EMemoShellContentClass *class)
 {
 	GObjectClass *object_class;
@@ -618,6 +628,7 @@ memo_shell_content_class_init (EMemoShellContentClass *class)
 
 	shell_content_class = E_SHELL_CONTENT_CLASS (class);
 	shell_content_class->check_state = memo_shell_content_check_state;
+	shell_content_class->focus_search_results = memo_shell_content_focus_search_results;
 
 	g_object_class_install_property (
 		object_class,
diff --git a/modules/calendar/e-task-shell-content.c b/modules/calendar/e-task-shell-content.c
index b2744a8..bb2017f 100644
--- a/modules/calendar/e-task-shell-content.c
+++ b/modules/calendar/e-task-shell-content.c
@@ -621,6 +621,16 @@ task_shell_content_check_state (EShellContent *shell_content)
 }
 
 static void
+task_shell_content_focus_search_results (EShellContent *shell_content)
+{
+	ETaskShellContentPrivate *priv;
+
+	priv = E_TASK_SHELL_CONTENT_GET_PRIVATE (shell_content);
+
+	gtk_widget_grab_focus (priv->task_table);
+}
+
+static void
 task_shell_content_class_init (ETaskShellContentClass *class)
 {
 	GObjectClass *object_class;
@@ -638,6 +648,7 @@ task_shell_content_class_init (ETaskShellContentClass *class)
 
 	shell_content_class = E_SHELL_CONTENT_CLASS (class);
 	shell_content_class->check_state = task_shell_content_check_state;
+	shell_content_class->focus_search_results = task_shell_content_focus_search_results;
 
 	g_object_class_install_property (
 		object_class,
diff --git a/modules/mail/e-mail-shell-content.c b/modules/mail/e-mail-shell-content.c
index d0e3ffa..e7fb20d 100644
--- a/modules/mail/e-mail-shell-content.c
+++ b/modules/mail/e-mail-shell-content.c
@@ -489,6 +489,16 @@ mail_shell_content_check_state (EShellContent *shell_content)
 	return e_mail_reader_check_state (E_MAIL_READER (shell_content));
 }
 
+static void
+mail_shell_content_focus_search_results (EShellContent *shell_content)
+{
+	EMailShellContentPrivate *priv;
+
+	priv = E_MAIL_SHELL_CONTENT_GET_PRIVATE (shell_content);
+
+	gtk_widget_grab_focus (priv->message_list);
+}
+
 static GtkActionGroup *
 mail_shell_content_get_action_group (EMailReader *reader)
 {
@@ -695,6 +705,7 @@ mail_shell_content_class_init (EMailShellContentClass *class)
 
 	shell_content_class = E_SHELL_CONTENT_CLASS (class);
 	shell_content_class->check_state = mail_shell_content_check_state;
+	shell_content_class->focus_search_results = mail_shell_content_focus_search_results;
 
 	/* Inherited from EMailReader */
 	g_object_class_override_property (
diff --git a/shell/e-shell-content.c b/shell/e-shell-content.c
index 515dfa8..d897e11 100644
--- a/shell/e-shell-content.c
+++ b/shell/e-shell-content.c
@@ -386,6 +386,29 @@ e_shell_content_check_state (EShellContent *shell_content)
 }
 
 /**
+ * e_shell_content_focus_search_results:
+ * @shell_content: an #EShellContent
+ *
+ * #EShellContent subclasses should implement the
+ * <structfield>focus_search_results</structfield> 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 e6a1129..a92ac34 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 e8e4fe2..d1f8f65 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.
 	 **/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]