[evolution/gnome-2-30] Bug 622559 - Changing search option should focus search entry



commit dd3ea7d670be1c1dcdf38816e7a4b1ba2bd52fca
Author: Matthew Barnes <mbarnes redhat com>
Date:   Thu Jun 24 08:13:46 2010 -0400

    Bug 622559 - Changing search option should focus search entry

 shell/e-shell-searchbar.c     |    4 +++-
 widgets/misc/e-hinted-entry.c |   41 +++++++++++++++++++++--------------------
 2 files changed, 24 insertions(+), 21 deletions(-)
---
diff --git a/shell/e-shell-searchbar.c b/shell/e-shell-searchbar.c
index 272ba0e..a8de5ba 100644
--- a/shell/e-shell-searchbar.c
+++ b/shell/e-shell-searchbar.c
@@ -436,8 +436,10 @@ shell_searchbar_option_changed_cb (GtkRadioAction *action,
 		e_shell_searchbar_set_search_text (searchbar, search_text);
 		if (search_text != NULL && *search_text != '\0')
 			e_shell_view_execute_search (shell_view);
-		else
+		else {
 			shell_searchbar_save_search_option (searchbar);
+			gtk_widget_grab_focus (searchbar->priv->search_entry);
+		}
 
 	} else if (search_text != NULL)
 		e_shell_searchbar_set_search_text (searchbar, NULL);
diff --git a/widgets/misc/e-hinted-entry.c b/widgets/misc/e-hinted-entry.c
index 24bac00..9bfcb05 100644
--- a/widgets/misc/e-hinted-entry.c
+++ b/widgets/misc/e-hinted-entry.c
@@ -39,18 +39,6 @@ enum {
 static gpointer parent_class;
 
 static void
-hinted_entry_hide_hint (EHintedEntry *entry)
-{
-	entry->priv->hint_shown = FALSE;
-
-	gtk_entry_set_text (GTK_ENTRY (entry), "");
-
-	gtk_widget_modify_text (GTK_WIDGET (entry), GTK_STATE_NORMAL, NULL);
-
-	g_object_notify (G_OBJECT (entry), "hint-shown");
-}
-
-static void
 hinted_entry_show_hint (EHintedEntry *entry)
 {
 	GtkStyle *style;
@@ -70,6 +58,19 @@ hinted_entry_show_hint (EHintedEntry *entry)
 }
 
 static void
+hinted_entry_show_text (EHintedEntry *entry,
+                        const gchar *text)
+{
+	entry->priv->hint_shown = FALSE;
+
+	gtk_entry_set_text (GTK_ENTRY (entry), text);
+
+	gtk_widget_modify_text (GTK_WIDGET (entry), GTK_STATE_NORMAL, NULL);
+
+	g_object_notify (G_OBJECT (entry), "hint-shown");
+}
+
+static void
 hinted_entry_set_property (GObject *object,
                            guint property_id,
                            const GValue *value,
@@ -129,7 +130,7 @@ hinted_entry_focus_in_event (GtkWidget *widget,
 	EHintedEntry *entry = E_HINTED_ENTRY (widget);
 
 	if (e_hinted_entry_get_hint_shown (entry))
-		hinted_entry_hide_hint (entry);
+		hinted_entry_show_text (entry, "");
 
 	/* Chain up to parent's focus_in_event() method. */
 	return GTK_WIDGET_CLASS (parent_class)->
@@ -269,14 +270,16 @@ e_hinted_entry_get_hint_shown (EHintedEntry *entry)
 const gchar *
 e_hinted_entry_get_text (EHintedEntry *entry)
 {
+	const gchar *text = "";
+
 	/* XXX This clumsily overrides gtk_entry_get_text(). */
 
 	g_return_val_if_fail (E_IS_HINTED_ENTRY (entry), NULL);
 
-	if (e_hinted_entry_get_hint_shown (entry))
-		return "";
+	if (!e_hinted_entry_get_hint_shown (entry))
+		text = gtk_entry_get_text (GTK_ENTRY (entry));
 
-	return gtk_entry_get_text (GTK_ENTRY (entry));
+	return text;
 }
 
 void
@@ -296,8 +299,6 @@ e_hinted_entry_set_text (EHintedEntry *entry,
 	if (*text == '\0' && !GTK_WIDGET_HAS_FOCUS (entry))
 #endif
 		hinted_entry_show_hint (entry);
-	else {
-		hinted_entry_hide_hint (entry);
-		gtk_entry_set_text (GTK_ENTRY (entry), text);
-	}
+	else
+		hinted_entry_show_text (entry, text);
 }



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