From f1bad7677ab2928638f8705873d7ab599b6c99cd Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Thu, 24 Jun 2010 08:13:46 -0400 Subject: Bug 622559 - Changing search option should focus search entry --- widgets/misc/e-hinted-entry.c | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'widgets/misc') diff --git a/widgets/misc/e-hinted-entry.c b/widgets/misc/e-hinted-entry.c index 51131cedcd..1d292a626c 100644 --- a/widgets/misc/e-hinted-entry.c +++ b/widgets/misc/e-hinted-entry.c @@ -38,18 +38,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) { @@ -69,6 +57,19 @@ hinted_entry_show_hint (EHintedEntry *entry) g_object_notify (G_OBJECT (entry), "hint-shown"); } +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, @@ -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 @@ -292,8 +295,6 @@ e_hinted_entry_set_text (EHintedEntry *entry, if (*text == '\0' && !gtk_widget_has_focus (GTK_WIDGET (entry))) 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); } -- cgit