← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~dbarth/indicator-me/hint-fixes into lp:indicator-me

 

David Barth has proposed merging lp:~dbarth/indicator-me/hint-fixes into lp:indicator-me.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)


- style the hint consistently, even across service restarts
- forgot to add me-service-gwibber.c for translations
-- 
https://code.launchpad.net/~dbarth/indicator-me/hint-fixes/+merge/36170
Your team ayatana-commits is subscribed to branch lp:indicator-me.
=== modified file 'po/POTFILES.in'
--- po/POTFILES.in	2010-01-06 05:30:46 +0000
+++ po/POTFILES.in	2010-09-21 17:01:07 +0000
@@ -5,3 +5,4 @@
 src/status-provider-telepathy.c
 src/me-service.c
 src/me-service-dbus.c
+src/me-service-gwibber.c

=== modified file 'src/indicator-me.c'
--- src/indicator-me.c	2010-09-16 14:49:20 +0000
+++ src/indicator-me.c	2010-09-21 17:01:07 +0000
@@ -90,6 +90,7 @@
 static gboolean new_entry_item (DbusmenuMenuitem * newitem,
                                 DbusmenuMenuitem * parent,
                                 DbusmenuClient   * client);
+static gboolean entry_hint_is_shown (GtkWidget *widget);
 
 G_DEFINE_TYPE (IndicatorMe, indicator_me, INDICATOR_OBJECT_TYPE);
 
@@ -277,9 +278,9 @@
 
   const gchar *hint = g_object_get_data (G_OBJECT (entry),
                                          DBUSMENU_ENTRY_MENUITEM_PROP_HINT);
-  if (gtk_entry_get_text_length (entry) > 0 ||
-      GTK_WIDGET_HAS_FOCUS (entry)) {
-    g_debug ("%s, the hint shouldn't be shown atm", __func__);
+  if ((gtk_entry_get_text_length (entry) > 0 &&
+       ! entry_hint_is_shown (GTK_WIDGET (entry)))
+      || GTK_WIDGET_HAS_FOCUS (entry)) {
 
     entry_set_style (entry, GTK_STATE_NORMAL);
     entry_hint_set_shown (GTK_WIDGET (entry), FALSE);
@@ -294,10 +295,11 @@
   }
 }
 
-
 static void
 entry_set_hint (GtkEntry *entry, const char *hint)
 {
+    g_return_if_fail (GTK_IS_ENTRY (entry));
+
     g_debug ("entry hint: %s", hint);
 		g_object_set_data_full (G_OBJECT (entry), DBUSMENU_ENTRY_MENUITEM_PROP_HINT,
                             g_strdup (hint), (GDestroyNotify) g_free);
@@ -377,6 +379,57 @@
 	dbusmenu_menuitem_handle_event (mi, "send", &value, gtk_get_current_event_time());
 }
 
+static void
+finalized_dbusmenuitem_cb (gpointer udata, GObject * dbusmenuitem)
+{
+  /* disconnect signals we previously installed to avoid
+     crashing on outdated data structures */
+
+	g_debug("DbusmenuMenuitem was destroyed");
+
+  int i = 0;
+
+  g_return_if_fail (IDO_IS_ENTRY_MENU_ITEM (udata));
+
+  g_debug ("1");
+
+  IdoEntryMenuItem *ido = IDO_ENTRY_MENU_ITEM (udata);
+
+  g_debug ("2");
+
+	GtkEntry *entry = GTK_ENTRY(ido_entry_menu_item_get_entry (ido));
+
+  g_debug ("3");
+
+	i += 
+    g_signal_handlers_disconnect_by_func (DBUSMENU_MENUITEM (dbusmenuitem),
+                                          G_CALLBACK (entry_prop_change_cb),
+                                          entry);
+
+  g_return_if_fail (GTK_IS_ENTRY (entry));
+
+  g_debug ("%s", __func__);
+
+  i += 
+  g_signal_handlers_disconnect_by_func (entry,
+                                        G_CALLBACK (entry_activate_cb),
+                                        dbusmenuitem);
+  i += 
+  g_signal_handlers_disconnect_by_func (entry,
+                                        G_CALLBACK (entry_focus_grab_cb),
+                                        entry);
+  i += 
+  g_signal_handlers_disconnect_by_func (entry,
+                                        G_CALLBACK (entry_focus_ungrab_cb),
+                                        entry);
+
+  g_debug ("%s: %d signals disconnected", __func__, i);
+
+  return;
+}
+
+
+
 static gboolean
 new_entry_item (DbusmenuMenuitem * newitem,
                 DbusmenuMenuitem * parent,
@@ -413,6 +466,8 @@
 #endif
 
 	dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, GTK_MENU_ITEM(ido), parent);
+	g_object_weak_ref(G_OBJECT(newitem), finalized_dbusmenuitem_cb, ido);
+
 	/* disconnect the activate signal that newitem_base connected with the wrong
 	   widget, ie menuitem, and re-connect it with the /entry/ instead */
 	gulong signal_id = g_signal_handler_find (GTK_MENU_ITEM (ido), G_SIGNAL_MATCH_DATA, 0, 0, 0, 0, parent);
@@ -420,6 +475,7 @@
     g_signal_handler_disconnect(GTK_MENU_ITEM (ido), signal_id);
 
 	g_signal_connect (DBUSMENU_MENUITEM (newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK (entry_prop_change_cb), entry);
+
 	g_signal_connect (GTK_ENTRY (entry), "activate", G_CALLBACK (entry_activate_cb), newitem);
 
   g_signal_connect (entry,


Follow ups