cairo-dock-team team mailing list archive
-
cairo-dock-team team
-
Mailing list archive
-
Message #04362
[Merge] lp:~cairo-dock-team/cairo-dock-plug-ins/menus_workaround into lp:cairo-dock-plug-ins
Matthieu Baerts has proposed merging lp:~cairo-dock-team/cairo-dock-plug-ins/menus_workaround into lp:cairo-dock-plug-ins.
Requested reviews:
Fabounet (fabounet03)
For more details, see:
https://code.launchpad.net/~cairo-dock-team/cairo-dock-plug-ins/menus_workaround/+merge/108817
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` ;) )
--
https://code.launchpad.net/~cairo-dock-team/cairo-dock-plug-ins/menus_workaround/+merge/108817
Your team Cairo-Dock Team is subscribed to branch lp:cairo-dock-plug-ins.
=== modified file 'GMenu/src/applet-menu.c'
--- GMenu/src/applet-menu.c 2012-06-03 23:51:48 +0000
+++ GMenu/src/applet-menu.c 2012-06-05 19:42:29 +0000
@@ -261,12 +261,14 @@
icon->fallback_image = g_strdup (fallback_image_filename);
icon->icon_size = icon_size;
- gtk_widget_show (image);
-
/**g_object_set_data_full (G_OBJECT (image_menu_item),
"Panel:Image",
g_object_ref (image),
(GDestroyNotify) g_object_unref);*/
+
+ g_signal_connect_data (image, "map",
+ G_CALLBACK (image_menu_shown), icon,
+ (GClosureNotify) icon_to_load_free, 0);
if (myConfig.bHasIcons)
{
@@ -274,9 +276,7 @@
GTK_IMAGE_MENU_ITEM (image_menu_item), image);
}
- g_signal_connect_data (image, "map",
- G_CALLBACK (image_menu_shown), icon,
- (GClosureNotify) icon_to_load_free, 0);
+ gtk_widget_show (image);
g_signal_connect (image, "destroy",
G_CALLBACK (image_menu_destroy), NULL);
=== modified file 'Global-Menu/src/applet-notifications.c'
--- Global-Menu/src/applet-notifications.c 2012-02-12 03:42:50 +0000
+++ Global-Menu/src/applet-notifications.c 2012-06-05 19:42:29 +0000
@@ -27,10 +27,51 @@
#include "applet-notifications.h"
+/// REMOVE ME WHEN IT'S POSSIBLE! :)
+static void _remove_double_separators (GtkWidget *pWidget)
+{
+ if (pWidget == NULL)
+ return;
+
+ gboolean bPrevIsSeparator = TRUE; // to remove the first entry if it's a separator
+ GList *ic;
+ GtkWidget *pCurrentWidget;
+ GtkWidget *pSubMenu;
+ GtkContainer *pContainer = GTK_CONTAINER (pWidget);
+ for (ic = gtk_container_get_children (pContainer); ic != NULL; ic = ic->next)
+ {
+ pCurrentWidget = ic->data;
+ if (GTK_IS_SEPARATOR_MENU_ITEM (pCurrentWidget))
+ {
+ if (bPrevIsSeparator)
+ gtk_widget_destroy (pCurrentWidget); // or ? gtk_container_remove (pContainer, pCurrentWidget);
+ bPrevIsSeparator = TRUE;
+ }
+ else if (GTK_IS_MENU_ITEM (pCurrentWidget))
+ {
+ pSubMenu = gtk_menu_item_get_submenu (GTK_MENU_ITEM (pCurrentWidget));
+ if (pSubMenu != NULL)
+ {
+ bPrevIsSeparator = TRUE;
+ _remove_double_separators (pSubMenu);
+ }
+ else
+ bPrevIsSeparator = FALSE;
+ }
+ else
+ bPrevIsSeparator = FALSE;
+ }
+ g_list_free (ic);
+}
+
static void _show_menu (gboolean bOnMouse)
{
+ if (! myConfig.bDisplayMenu)
+ return;
+
if (myData.pMenu != NULL)
{
+ _remove_double_separators (GTK_WIDGET (myData.pMenu));
if (bOnMouse)
{
gtk_widget_show_all (GTK_WIDGET (myData.pMenu));
=== modified file 'Messaging-Menu/src/applet-menu.c'
--- Messaging-Menu/src/applet-menu.c 2012-05-02 23:27:39 +0000
+++ Messaging-Menu/src/applet-menu.c 2012-06-05 19:42:29 +0000
@@ -39,7 +39,9 @@
#define RIGHT_LABEL_FONT_SIZE 12
#define RIGHT_LABEL_RADIUS 20
+#if (INDICATOR_MESSAGES_HAS_LOZENGE != 1)
static GtkSizeGroup * indicator_right_group = NULL; /// TODO: check if it needs to be freed...
+#endif
//////////////////////
// APPLICATION ITEM //
@@ -281,12 +283,18 @@
new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client)
{
gchar *cName = g_strdup (dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_NAME));
+ const gchar *sIconName = dbusmenu_menuitem_property_get (newitem, APPLICATION_MENUITEM_PROP_ICON);
cd_debug ("%s (\"%s\")", __func__, cName);
-#if (INDICATOR_OLD_NAMES == 0 && INDICATOR_MESSAGES_HAS_LOZENGE != 1)
- if (newitem == NULL || !dbusmenu_menuitem_property_get_bool(newitem, DBUSMENU_MENUITEM_PROP_VISIBLE))
+#if (INDICATOR_OLD_NAMES == 0)
+ if (newitem == NULL || !dbusmenu_menuitem_property_get_bool(newitem, DBUSMENU_MENUITEM_PROP_VISIBLE)
+ #if (GTK_MAJOR_VERSION > 2 && INDICATOR_MESSAGES_HAS_LOZENGE == 1)
+ && sIconName != NULL && *sIconName != '\0' // these menu
+ #endif
+ )
{
+ dbusmenu_menuitem_child_delete (parent, newitem);
cd_debug ("Not visible: %s", cName);
g_free (cName);
return TRUE;
@@ -301,7 +309,6 @@
GtkWidget * hbox = _gtk_hbox_new(padding);
// Added for Cairo-Dock
- const gchar *sIconName = dbusmenu_menuitem_property_get (newitem, APPLICATION_MENUITEM_PROP_ICON);
#if (GTK_MAJOR_VERSION > 2 && INDICATOR_MESSAGES_HAS_LOZENGE == 1) // we add a left margin
if (! dbusmenu_menuitem_property_get_bool(newitem, DBUSMENU_MENUITEM_PROP_VISIBLE)
&& (sIconName == NULL || *sIconName == '\0'))
@@ -550,7 +557,9 @@
void cd_messaging_add_menu_handler (DbusmenuGtkClient * client)
{
+ #if (INDICATOR_MESSAGES_HAS_LOZENGE != 1)
indicator_right_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+ #endif
dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), INDICATOR_MENUITEM_TYPE, (DbusmenuClientTypeHandler) new_indicator_item);
dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(client), APPLICATION_MENUITEM_TYPE, (DbusmenuClientTypeHandler) new_application_item);
=== modified file 'Messaging-Menu/src/applet-notifications.c'
--- Messaging-Menu/src/applet-notifications.c 2011-11-28 01:03:02 +0000
+++ Messaging-Menu/src/applet-notifications.c 2012-06-05 19:42:29 +0000
@@ -24,9 +24,38 @@
#include "applet-menu.h"
#include "applet-notifications.h"
+/*
+ * An horrible hack to remove double separators in the menu.
+ * I don't know why we have this bug... hope we'll remove it soon!
+ */
+/// REMOVE ME WHEN IT'S POSSIBLE! :)
+static void _remove_double_separators (GtkContainer *pContainer)
+{
+ if (pContainer == NULL)
+ return;
+
+ gboolean bPrevIsSeparator = TRUE; // to remove the first entry if it's a separator
+ GList *ic;
+ GtkWidget *pIcon;
+ for (ic = gtk_container_get_children (pContainer); ic != NULL; ic = ic->next)
+ {
+ pIcon = ic->data;
+ if (GTK_IS_SEPARATOR_MENU_ITEM (pIcon))
+ {
+ if (bPrevIsSeparator)
+ gtk_widget_destroy (pIcon);
+ bPrevIsSeparator = TRUE;
+ }
+ else
+ bPrevIsSeparator = FALSE;
+ }
+ g_list_free (ic);
+}
static inline void _show_menu (void)
{
+ _remove_double_separators (GTK_CONTAINER (myData.pIndicator->pMenu));
+
if (! cd_indicator_show_menu (myData.pIndicator))
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");
}
Follow ups