Merge lp:~cairo-dock-team/cairo-dock-plug-ins/menus_workaround into lp:~cairo-dock-team/cairo-dock-plug-ins/plug-ins

Proposed by Matthieu Baerts
Status: Merged
Merged at revision: 2416
Proposed branch: lp:~cairo-dock-team/cairo-dock-plug-ins/menus_workaround
Merge into: lp:~cairo-dock-team/cairo-dock-plug-ins/plug-ins
Diff against target: 183 lines (+87/-8)
4 files modified
GMenu/src/applet-menu.c (+5/-5)
Global-Menu/src/applet-notifications.c (+41/-0)
Messaging-Menu/src/applet-menu.c (+12/-3)
Messaging-Menu/src/applet-notifications.c (+29/-0)
To merge this branch: bzr merge lp:~cairo-dock-team/cairo-dock-plug-ins/menus_workaround
Reviewer Review Type Date Requested Status
Fabounet Pending
Review via email: mp+108817@code.launchpad.net

Description of the change

Hello

Here I'm proposing 3 commits... 3 workarounds!
* rev 2413: GMenu: try to load icons sooner
It's hard to know if it's better but I hope so ;) (maybe we can load all menus and icons before but it will take time at startup...)

* rev 2414: Messaging-Menu: removed double entries in the menu and double separators. Yes, it's just a wonderful workaround :D
As you can see... it's a workaround! It's just a hack to fix this (stupid and a bit ugly/annoying) bug. About this bug (double entries/separators), it's a bit strange because it seems in indicator-messages (from Unity project) the menu is not modify... It seems it directly receives the right menu. Or do we miss an option?

* rev 2415: Global-Menu: removed double separators in the menu (workaround)
+ removed a wrong error message when we click on the main icon if we don't steal window menus
A bit more ugly to remove these double separators in submenu too... Yes, it's possible :D
Without that we can see that Gedit menu contains a lot of useless separators. (but it's maybe due to appmenu-registrar?)

I know these modifications are not very well but I think it's currently the only solution...
Can I merge it into the trunk? :)

(note that you can use `bzr merge --pull` instead of just `bzr merge` ;) )

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'GMenu/src/applet-menu.c'
2--- GMenu/src/applet-menu.c 2012-06-03 23:51:48 +0000
3+++ GMenu/src/applet-menu.c 2012-06-05 19:42:29 +0000
4@@ -261,12 +261,14 @@
5 icon->fallback_image = g_strdup (fallback_image_filename);
6 icon->icon_size = icon_size;
7
8- gtk_widget_show (image);
9-
10 /**g_object_set_data_full (G_OBJECT (image_menu_item),
11 "Panel:Image",
12 g_object_ref (image),
13 (GDestroyNotify) g_object_unref);*/
14+
15+ g_signal_connect_data (image, "map",
16+ G_CALLBACK (image_menu_shown), icon,
17+ (GClosureNotify) icon_to_load_free, 0);
18
19 if (myConfig.bHasIcons)
20 {
21@@ -274,9 +276,7 @@
22 GTK_IMAGE_MENU_ITEM (image_menu_item), image);
23 }
24
25- g_signal_connect_data (image, "map",
26- G_CALLBACK (image_menu_shown), icon,
27- (GClosureNotify) icon_to_load_free, 0);
28+ gtk_widget_show (image);
29
30 g_signal_connect (image, "destroy",
31 G_CALLBACK (image_menu_destroy), NULL);
32
33=== modified file 'Global-Menu/src/applet-notifications.c'
34--- Global-Menu/src/applet-notifications.c 2012-02-12 03:42:50 +0000
35+++ Global-Menu/src/applet-notifications.c 2012-06-05 19:42:29 +0000
36@@ -27,10 +27,51 @@
37 #include "applet-notifications.h"
38
39
40+/// REMOVE ME WHEN IT'S POSSIBLE! :)
41+static void _remove_double_separators (GtkWidget *pWidget)
42+{
43+ if (pWidget == NULL)
44+ return;
45+
46+ gboolean bPrevIsSeparator = TRUE; // to remove the first entry if it's a separator
47+ GList *ic;
48+ GtkWidget *pCurrentWidget;
49+ GtkWidget *pSubMenu;
50+ GtkContainer *pContainer = GTK_CONTAINER (pWidget);
51+ for (ic = gtk_container_get_children (pContainer); ic != NULL; ic = ic->next)
52+ {
53+ pCurrentWidget = ic->data;
54+ if (GTK_IS_SEPARATOR_MENU_ITEM (pCurrentWidget))
55+ {
56+ if (bPrevIsSeparator)
57+ gtk_widget_destroy (pCurrentWidget); // or ? gtk_container_remove (pContainer, pCurrentWidget);
58+ bPrevIsSeparator = TRUE;
59+ }
60+ else if (GTK_IS_MENU_ITEM (pCurrentWidget))
61+ {
62+ pSubMenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (pCurrentWidget));
63+ if (pSubMenu != NULL)
64+ {
65+ bPrevIsSeparator = TRUE;
66+ _remove_double_separators (pSubMenu);
67+ }
68+ else
69+ bPrevIsSeparator = FALSE;
70+ }
71+ else
72+ bPrevIsSeparator = FALSE;
73+ }
74+ g_list_free (ic);
75+}
76+
77 static void _show_menu (gboolean bOnMouse)
78 {
79+ if (! myConfig.bDisplayMenu)
80+ return;
81+
82 if (myData.pMenu != NULL)
83 {
84+ _remove_double_separators (GTK_WIDGET (myData.pMenu));
85 if (bOnMouse)
86 {
87 gtk_widget_show_all (GTK_WIDGET (myData.pMenu));
88
89=== modified file 'Messaging-Menu/src/applet-menu.c'
90--- Messaging-Menu/src/applet-menu.c 2012-05-02 23:27:39 +0000
91+++ Messaging-Menu/src/applet-menu.c 2012-06-05 19:42:29 +0000
92@@ -39,7 +39,9 @@
93 #define RIGHT_LABEL_FONT_SIZE 12
94 #define RIGHT_LABEL_RADIUS 20
95
96+#if (INDICATOR_MESSAGES_HAS_LOZENGE != 1)
97 static GtkSizeGroup * indicator_right_group = NULL; /// TODO: check if it needs to be freed...
98+#endif
99
100 //////////////////////
101 // APPLICATION ITEM //
102@@ -281,12 +283,18 @@
103 new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
104 {
105 gchar *cName = g_strdup (dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_NAME));
106+ const gchar *sIconName = dbusmenu_menuitem_property_get (newitem, APPLICATION_MENUITEM_PROP_ICON);
107
108 cd_debug ("%s (\"%s\")", __func__, cName);
109
110-#if (INDICATOR_OLD_NAMES == 0 && INDICATOR_MESSAGES_HAS_LOZENGE != 1)
111- if (newitem == NULL || !dbusmenu_menuitem_property_get_bool(newitem, DBUSMENU_MENUITEM_PROP_VISIBLE))
112+#if (INDICATOR_OLD_NAMES == 0)
113+ if (newitem == NULL || !dbusmenu_menuitem_property_get_bool(newitem, DBUSMENU_MENUITEM_PROP_VISIBLE)
114+ #if (GTK_MAJOR_VERSION > 2 && INDICATOR_MESSAGES_HAS_LOZENGE == 1)
115+ && sIconName != NULL && *sIconName != '\0' // these menu
116+ #endif
117+ )
118 {
119+ dbusmenu_menuitem_child_delete (parent, newitem);
120 cd_debug ("Not visible: %s", cName);
121 g_free (cName);
122 return TRUE;
123@@ -301,7 +309,6 @@
124 GtkWidget * hbox = _gtk_hbox_new(padding);
125
126 // Added for Cairo-Dock
127- const gchar *sIconName = dbusmenu_menuitem_property_get (newitem, APPLICATION_MENUITEM_PROP_ICON);
128 #if (GTK_MAJOR_VERSION > 2 && INDICATOR_MESSAGES_HAS_LOZENGE == 1) // we add a left margin
129 if (! dbusmenu_menuitem_property_get_bool(newitem, DBUSMENU_MENUITEM_PROP_VISIBLE)
130 && (sIconName == NULL || *sIconName == '\0'))
131@@ -550,7 +557,9 @@
132
133 void cd_messaging_add_menu_handler (DbusmenuGtkClient * client)
134 {
135+ #if (INDICATOR_MESSAGES_HAS_LOZENGE != 1)
136 indicator_right_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
137+ #endif
138
139 dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), INDICATOR_MENUITEM_TYPE, (DbusmenuClientTypeHandler) new_indicator_item);
140 dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), APPLICATION_MENUITEM_TYPE, (DbusmenuClientTypeHandler) new_application_item);
141
142=== modified file 'Messaging-Menu/src/applet-notifications.c'
143--- Messaging-Menu/src/applet-notifications.c 2011-11-28 01:03:02 +0000
144+++ Messaging-Menu/src/applet-notifications.c 2012-06-05 19:42:29 +0000
145@@ -24,9 +24,38 @@
146 #include "applet-menu.h"
147 #include "applet-notifications.h"
148
149+/*
150+ * An horrible hack to remove double separators in the menu.
151+ * I don't know why we have this bug... hope we'll remove it soon!
152+ */
153+/// REMOVE ME WHEN IT'S POSSIBLE! :)
154+static void _remove_double_separators (GtkContainer *pContainer)
155+{
156+ if (pContainer == NULL)
157+ return;
158+
159+ gboolean bPrevIsSeparator = TRUE; // to remove the first entry if it's a separator
160+ GList *ic;
161+ GtkWidget *pIcon;
162+ for (ic = gtk_container_get_children (pContainer); ic != NULL; ic = ic->next)
163+ {
164+ pIcon = ic->data;
165+ if (GTK_IS_SEPARATOR_MENU_ITEM (pIcon))
166+ {
167+ if (bPrevIsSeparator)
168+ gtk_widget_destroy (pIcon);
169+ bPrevIsSeparator = TRUE;
170+ }
171+ else
172+ bPrevIsSeparator = FALSE;
173+ }
174+ g_list_free (ic);
175+}
176
177 static inline void _show_menu (void)
178 {
179+ _remove_double_separators (GTK_CONTAINER (myData.pIndicator->pMenu));
180+
181 if (! cd_indicator_show_menu (myData.pIndicator))
182 cairo_dock_show_temporary_dialog_with_icon (D_("The Messaging service did not reply.\nPlease check that it is correctly installed."), myIcon, myContainer, 4000., "same icon");
183 }

Subscribers

People subscribed via source and target branches