From 7ac87e8939eabab399c33bada6ab29c48ad9b986 Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Wed, 27 Apr 2011 15:20:10 -0400 Subject: toggle visibility of menus to fix Eclipse RCP apps --- libdbusmenu-gtk/parser.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index 4708a64..b6423ca 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -270,6 +270,15 @@ new_menuitem (GtkWidget * widget) return item; } +static gboolean +toggle_widget_visibility (GtkWidget * widget) +{ + gboolean vis = gtk_widget_get_visible (widget); + gtk_widget_set_visible (widget, !vis); + gtk_widget_set_visible (widget, vis); + return FALSE; +} + static void watch_submenu(DbusmenuMenuitem * mi, GtkWidget * menu) { @@ -285,6 +294,13 @@ watch_submenu(DbusmenuMenuitem * mi, GtkWidget * menu) G_CALLBACK (child_removed_cb), mi); g_object_add_weak_pointer(G_OBJECT (menu), (gpointer*)&pdata->shell); + + /* Some apps (notably Eclipse RCP apps) don't fill contents of submenus + until the menu is shown. So we fake that by toggling the visibility of + any submenus we come across. Further, these apps need it done with a + delay while they finish initializing, so we put the call in the idle + queue. */ + g_idle_add((GSourceFunc)toggle_widget_visibility, menu); } static void -- cgit v1.2.3 From d75107a47c7fbf87f370cca0134a848d35c60eae Mon Sep 17 00:00:00 2001 From: Michael Terry Date: Wed, 18 May 2011 14:19:49 -0400 Subject: ref menu until we're done toggling its visibility --- libdbusmenu-gtk/parser.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libdbusmenu-gtk') diff --git a/libdbusmenu-gtk/parser.c b/libdbusmenu-gtk/parser.c index b6423ca..7b27f4f 100644 --- a/libdbusmenu-gtk/parser.c +++ b/libdbusmenu-gtk/parser.c @@ -276,6 +276,7 @@ toggle_widget_visibility (GtkWidget * widget) gboolean vis = gtk_widget_get_visible (widget); gtk_widget_set_visible (widget, !vis); gtk_widget_set_visible (widget, vis); + g_object_unref (G_OBJECT (widget)); return FALSE; } @@ -300,7 +301,8 @@ watch_submenu(DbusmenuMenuitem * mi, GtkWidget * menu) any submenus we come across. Further, these apps need it done with a delay while they finish initializing, so we put the call in the idle queue. */ - g_idle_add((GSourceFunc)toggle_widget_visibility, menu); + g_idle_add((GSourceFunc)toggle_widget_visibility, + g_object_ref (G_OBJECT (menu))); } static void -- cgit v1.2.3