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

Proposed by Michael Terry
Status: Merged
Merged at revision: 379
Proposed branch: lp:~mterry/indicator-applet/close-menus-if-requested
Merge into: lp:indicator-applet/0.4
Diff against target: 42 lines (+25/-0)
1 file modified
src/applet-main.c (+25/-0)
To merge this branch: bzr merge lp:~mterry/indicator-applet/close-menus-if-requested
Reviewer Review Type Date Requested Status
Ted Gould (community) Approve
Review via email: mp+48048@code.launchpad.net

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Ted Gould (ted) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/applet-main.c'
2--- src/applet-main.c 2011-01-26 23:41:18 +0000
3+++ src/applet-main.c 2011-01-31 20:33:53 +0000
4@@ -419,6 +419,30 @@
5 return;
6 }
7
8+static void
9+menu_show (IndicatorObject * io, IndicatorObjectEntry * entry,
10+ guint32 timestamp, gpointer user_data)
11+{
12+ GtkWidget * menubar = GTK_WIDGET(user_data);
13+
14+ if (entry == NULL) {
15+ /* Close any open menus instead of opening one */
16+ GList * entries = indicator_object_get_entries(io);
17+ GList * entry = NULL;
18+ for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
19+ IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
20+ gtk_menu_popdown(entrydata->menu);
21+ }
22+ g_list_free(entries);
23+
24+ /* And tell the menubar to exit activation mode too */
25+ gtk_menu_shell_cancel(GTK_MENU_SHELL(menubar));
26+ return;
27+ }
28+
29+ // TODO: do something sensible here
30+}
31+
32 static gboolean
33 load_module (const gchar * name, GtkWidget * menubar)
34 {
35@@ -443,6 +467,7 @@
36 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_ADDED, G_CALLBACK(entry_added), menubar);
37 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_REMOVED, G_CALLBACK(entry_removed), menubar);
38 g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ENTRY_MOVED, G_CALLBACK(entry_moved), menubar);
39+ g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar);
40
41 /* Work on the entries */
42 GList * entries = indicator_object_get_entries(io);

Subscribers

People subscribed via source and target branches

to status/vote changes: