← Back to team overview

ayatana-commits team mailing list archive

[Merge] lp:~mterry/indicator-applet/close-menus-if-requested into lp:indicator-applet

 

Michael Terry has proposed merging lp:~mterry/indicator-applet/close-menus-if-requested into lp:indicator-applet.

Requested reviews:
  Indicator Applet Developers (indicator-applet-developers)
Related bugs:
  #603482 Desktop freezes if new window takes focus while menu is open
  https://bugs.launchpad.net/bugs/603482

For more details, see:
https://code.launchpad.net/~mterry/indicator-applet/close-menus-if-requested/+merge/48048

This will close any open menus if MENU_SHOW is emitted for a NULL entry.

I didn't add support for opening an entry actually specified by MENU_SHOW, because when I tried (using gtk_menu_shell_select_item), it didn't quite work right.  The menu would open, but wouldn't go away.  There were weird grabbing issues.  So I left that alone for now.

I don't make things worse with this patch, but it's only a partial handling of the MENU_SHOW signal.  Enough to fix this hang bug.

This requires lp:~mterry/indicator-appmenu/close-menu-when-switching to be merged into indicator-appmenu to work.
-- 
https://code.launchpad.net/~mterry/indicator-applet/close-menus-if-requested/+merge/48048
Your team ayatana-commits is subscribed to branch lp:indicator-applet.
=== modified file 'src/applet-main.c'
--- src/applet-main.c	2011-01-26 23:41:18 +0000
+++ src/applet-main.c	2011-01-31 20:33:53 +0000
@@ -419,6 +419,30 @@
 	return;
 }
 
+static void
+menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
+           guint32 timestamp, gpointer user_data)
+{
+	GtkWidget * menubar = GTK_WIDGET(user_data);
+
+	if (entry == NULL) {
+		/* Close any open menus instead of opening one */
+		GList * entries = indicator_object_get_entries(io);
+		GList * entry = NULL;
+		for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
+			IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
+			gtk_menu_popdown(entrydata->menu);
+		}
+		g_list_free(entries);
+
+		/* And tell the menubar to exit activation mode too */
+		gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar));
+		return;
+	}
+
+	// TODO: do something sensible here
+}
+
 static gboolean
 load_module (const gchar * name, GtkWidget * menubar)
 {
@@ -443,6 +467,7 @@
 	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED,   G_CALLBACK(entry_added),    menubar);
 	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed),  menubar);
 	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED,   G_CALLBACK(entry_moved),    menubar);
+	g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW,     G_CALLBACK(menu_show),      menubar);
 
 	/* Work on the entries */
 	GList * entries = indicator_object_get_entries(io);


Follow ups