← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~dbarth/indicator-me/fix-hint-on-missed-focus-changes into lp:indicator-me

 

David Barth has proposed merging lp:~dbarth/indicator-me/fix-hint-on-missed-focus-changes into lp:indicator-me.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)
Related bugs:
  #655252 Hint not always hidden when the broadcast field is in use
  https://bugs.launchpad.net/bugs/655252


Fix entry focus issue. See related bug.
-- 
https://code.launchpad.net/~dbarth/indicator-me/fix-hint-on-missed-focus-changes/+merge/37639
Your team ayatana-commits is subscribed to branch lp:indicator-me.
=== modified file 'src/indicator-me.c'
--- src/indicator-me.c	2010-09-22 10:45:47 +0000
+++ src/indicator-me.c	2010-10-05 17:02:46 +0000
@@ -298,6 +298,19 @@
     gtk_widget_queue_draw (GTK_WIDGET (entry));
 }
 
+/* unconditionnaly show the hint in the entry */
+static void
+entry_hint_show_hint (GtkEntry *entry)
+{
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+
+  const gchar *hint = g_object_get_data (G_OBJECT (entry),
+                                         DBUSMENU_ENTRY_MENUITEM_PROP_HINT);
+  gtk_entry_set_text (entry, hint);
+  entry_set_style (entry, GTK_STATE_INSENSITIVE);
+  entry_hint_set_shown (GTK_WIDGET (entry), TRUE);
+}
+
 static void
 entry_maybe_show_hint (GtkEntry *entry)
 {
@@ -322,9 +335,7 @@
   } else {
     g_debug ("%s, nothing in the entry or not focused, so setting the hint to: %s", __func__, hint);
 
-    gtk_entry_set_text (entry, hint);
-    entry_set_style (entry, GTK_STATE_INSENSITIVE);
-    entry_hint_set_shown (GTK_WIDGET (entry), TRUE);
+    entry_hint_show_hint (entry);
   }
 }
 
@@ -375,11 +386,18 @@
 static gboolean
 entry_focus_out_cb (GtkWidget *widget, GdkEventFocus *event)
 {
+  g_return_val_if_fail (GTK_IS_ENTRY (widget), FALSE);
+
   GtkEntry *entry = GTK_ENTRY (widget);
 
   g_debug ("%s", __func__);
 
-  entry_maybe_show_hint (entry);
+  if (! entry_hint_is_shown (GTK_WIDGET (entry)))
+    if (gtk_entry_get_text_length (entry) == 0)
+      /* show the hint unconditionnaly, as the focus change
+         may not have propagated already and entry_maybe_show_hint
+         could get confused */
+      entry_hint_show_hint (entry);
 
   return FALSE;
 }


Follow ups