From 7c83491f5a7691f6a768670febfa9b4c9f428c2d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 15 Apr 2010 15:13:19 -0500 Subject: Removing the shortcuts when removing the application entry. --- src/messages-service.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index 88da0e0..53532dd 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -756,11 +756,19 @@ server_removed (IndicateListener * listener, IndicateListenerServer * server, gc /* If there is a menu item, let's get rid of it. */ if (sltp->menuitem != NULL) { - dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(sltp->menuitem), DBUSMENU_MENUITEM_PROP_VISIBLE, TRUE); + /* If there are shortcuts remove them */ + GList * shortcuts = app_menu_item_get_items(sltp->menuitem); + while (shortcuts != NULL) { + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(shortcuts->data), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + dbusmenu_menuitem_child_delete(DBUSMENU_MENUITEM(data), DBUSMENU_MENUITEM(shortcuts->data)); + shortcuts = g_list_next(shortcuts); + } + + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(sltp->menuitem), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); dbusmenu_menuitem_child_delete(DBUSMENU_MENUITEM(data), DBUSMENU_MENUITEM(sltp->menuitem)); g_object_unref(G_OBJECT(sltp->menuitem)); } - + /* If there is a separator, let's get rid of it. */ if (sltp->separator != NULL) { dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(sltp->separator), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); -- cgit v1.2.3 From 497db3688f51985369e47f72ef283c4c085637d6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 15 Apr 2010 15:31:53 -0500 Subject: Killing hte launcher shortcuts on exit as well. --- src/messages-service.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 53532dd..da5b49c 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -1271,6 +1271,14 @@ destroy_launcher (gpointer data) g_list_free(li->appdiritems); if (li->menuitem != NULL) { + /* If there are shortcuts remove them */ + GList * shortcuts = launcher_menu_item_get_items(li->menuitem); + while (shortcuts != NULL) { + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(shortcuts->data), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); + dbusmenu_menuitem_child_delete(DBUSMENU_MENUITEM(data), DBUSMENU_MENUITEM(shortcuts->data)); + shortcuts = g_list_next(shortcuts); + } + dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(li->menuitem), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); dbusmenu_menuitem_child_delete(root_menuitem, DBUSMENU_MENUITEM(li->menuitem)); g_object_unref(G_OBJECT(li->menuitem)); -- cgit v1.2.3 From 292ef7667393edf5611ff24814b822ca736bd6ef Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 15 Apr 2010 15:47:33 -0500 Subject: Deleteing shortcuts on update if they need to be --- src/messages-service.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index da5b49c..c56016e 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -623,11 +623,17 @@ server_shortcuts_changed (AppMenuItem * appitem, gpointer data) } appitemfound = TRUE; + if (children->data == appitem) { + children = g_list_next(children); + continue; + } + if (!DBUSMENU_IS_MENUITEM_PROXY(children->data)) { break; } removelist = g_list_prepend(removelist, children->data); + children = g_list_next(children); } GList * removeitem; -- cgit v1.2.3 From cb9d4b2785340cc00a0c08f46c6afc3176d0641d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 15 Apr 2010 16:46:43 -0500 Subject: Some debugging messages --- src/messages-service.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index c56016e..059ec89 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -765,11 +765,13 @@ server_removed (IndicateListener * listener, IndicateListenerServer * server, gc /* If there are shortcuts remove them */ GList * shortcuts = app_menu_item_get_items(sltp->menuitem); while (shortcuts != NULL) { + g_debug("\tRemoving shortcut: %s", dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(shortcuts->data), DBUSMENU_MENUITEM_PROP_LABEL)); dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(shortcuts->data), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); dbusmenu_menuitem_child_delete(DBUSMENU_MENUITEM(data), DBUSMENU_MENUITEM(shortcuts->data)); shortcuts = g_list_next(shortcuts); } + g_debug("\tRemoving item"); dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(sltp->menuitem), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); dbusmenu_menuitem_child_delete(DBUSMENU_MENUITEM(data), DBUSMENU_MENUITEM(sltp->menuitem)); g_object_unref(G_OBJECT(sltp->menuitem)); @@ -777,6 +779,7 @@ server_removed (IndicateListener * listener, IndicateListenerServer * server, gc /* If there is a separator, let's get rid of it. */ if (sltp->separator != NULL) { + g_debug("\tRemoving separator"); dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(sltp->separator), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); dbusmenu_menuitem_child_delete(DBUSMENU_MENUITEM(data), DBUSMENU_MENUITEM(sltp->separator)); g_object_unref(G_OBJECT(sltp->separator)); -- cgit v1.2.3 From 8f37e4fd529da2b5648dbc73c3737e9e956efbd6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 15 Apr 2010 16:57:55 -0500 Subject: Negative debugging --- src/messages-service.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 059ec89..5f36479 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -775,6 +775,8 @@ server_removed (IndicateListener * listener, IndicateListenerServer * server, gc dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(sltp->menuitem), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); dbusmenu_menuitem_child_delete(DBUSMENU_MENUITEM(data), DBUSMENU_MENUITEM(sltp->menuitem)); g_object_unref(G_OBJECT(sltp->menuitem)); + } else { + g_debug("\tNo menuitem"); } /* If there is a separator, let's get rid of it. */ @@ -783,6 +785,8 @@ server_removed (IndicateListener * listener, IndicateListenerServer * server, gc dbusmenu_menuitem_property_set_bool(DBUSMENU_MENUITEM(sltp->separator), DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); dbusmenu_menuitem_child_delete(DBUSMENU_MENUITEM(data), DBUSMENU_MENUITEM(sltp->separator)); g_object_unref(G_OBJECT(sltp->separator)); + } else { + g_debug("\tNo separator"); } if (sltp->attention) { -- cgit v1.2.3 From 4501008d5045499981c0b4bdefcd05a4b28b3659 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 15 Apr 2010 20:47:58 -0500 Subject: It's possible the newroot could be NULL, and that's okay. --- src/app-menu-item.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index ef30333..fd9aa62 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -436,22 +436,25 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data /* We need to proxy the new root across to the old world of indicator land. */ priv->root = newroot; - g_object_ref(priv->root); - g_signal_connect(G_OBJECT(priv->root), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(child_added_cb), self); - g_signal_connect(G_OBJECT(priv->root), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(child_removed_cb), self); - g_signal_connect(G_OBJECT(priv->root), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(child_moved_cb), self); - - /* See if we have any menuitems to worry about, - otherwise we'll just move along. */ - GList * children = dbusmenu_menuitem_get_children(DBUSMENU_MENUITEM(priv->root)); - if (children != NULL) { - change_time = TRUE; - g_debug("\tProcessing %d children", g_list_length(children)); - while (children != NULL) { - DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(DBUSMENU_MENUITEM(children->data)); - dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(mip), DBUSMENU_MENUITEM_PROP_ICON_NAME, DBUSMENU_MENUITEM_ICON_NAME_BLANK); - priv->shortcuts = g_list_append(priv->shortcuts, mip); - children = g_list_next(children); + + if (priv->root != NULL) { + g_object_ref(priv->root); + g_signal_connect(G_OBJECT(priv->root), DBUSMENU_MENUITEM_SIGNAL_CHILD_ADDED, G_CALLBACK(child_added_cb), self); + g_signal_connect(G_OBJECT(priv->root), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(child_removed_cb), self); + g_signal_connect(G_OBJECT(priv->root), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(child_moved_cb), self); + + /* See if we have any menuitems to worry about, + otherwise we'll just move along. */ + GList * children = dbusmenu_menuitem_get_children(DBUSMENU_MENUITEM(priv->root)); + if (children != NULL) { + change_time = TRUE; + g_debug("\tProcessing %d children", g_list_length(children)); + while (children != NULL) { + DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(DBUSMENU_MENUITEM(children->data)); + dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(mip), DBUSMENU_MENUITEM_PROP_ICON_NAME, DBUSMENU_MENUITEM_ICON_NAME_BLANK); + priv->shortcuts = g_list_append(priv->shortcuts, mip); + children = g_list_next(children); + } } } -- cgit v1.2.3 From 30b853eaf97907008044d5a7fb052359eef59b49 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 15 Apr 2010 20:52:20 -0500 Subject: Some debug messages when removing shortcuts --- src/messages-service.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 5f36479..2e85faa 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -636,8 +636,11 @@ server_shortcuts_changed (AppMenuItem * appitem, gpointer data) children = g_list_next(children); } + g_debug("\tRemoving %d shortcuts", g_list_length(removelist)); + GList * removeitem; for (removeitem = removelist; removeitem != NULL; removeitem = g_list_next(removeitem)) { + g_debug("\tRemoving shortcut: %s", dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(removeitem->data), DBUSMENU_MENUITEM_PROP_LABEL)); dbusmenu_menuitem_child_delete(shell, DBUSMENU_MENUITEM(removeitem->data)); } g_list_free(removeitem); -- cgit v1.2.3 From 5f4f845baf5171e73bd38d33cfd503f7200f162b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 15 Apr 2010 21:59:41 -0500 Subject: Minor refactoring to make the logic clearer --- src/messages-service.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index 2e85faa..bd69d7b 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -615,20 +615,24 @@ server_shortcuts_changed (AppMenuItem * appitem, gpointer data) gboolean appitemfound = FALSE; GList * children = dbusmenu_menuitem_get_children(shell); GList * removelist = NULL; + guint position = -1; while (children != NULL) { - if (!appitemfound && children->data != appitem) { + position++; + if (children->data == appitem) { + g_debug("\tApp entry found at position %d", position); children = g_list_next(children); + appitemfound = TRUE; continue; } - appitemfound = TRUE; - if (children->data == appitem) { + if (!appitemfound) { children = g_list_next(children); continue; } if (!DBUSMENU_IS_MENUITEM_PROXY(children->data)) { + g_debug("\tNon-proxy item (%s) found at %d: %s", G_OBJECT_TYPE_NAME(children->data), position, dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(children->data), DBUSMENU_MENUITEM_PROP_LABEL)); break; } -- cgit v1.2.3 From 5271a3e64e853d774d2684b27675678457e1cfd1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 16 Apr 2010 09:52:41 -0500 Subject: Changing the changed signal to be added/removed so that we can make things even more fun. --- src/app-menu-item.c | 38 ++++++++++++++++++++------------------ src/app-menu-item.h | 6 ++++-- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index fd9aa62..5ffe74f 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -36,7 +36,8 @@ with this program. If not, see . enum { COUNT_CHANGED, NAME_CHANGED, - SHORTCUTS_CHANGED, + SHORTCUT_ADDED, + SHORTCUT_REMOVED, LAST_SIGNAL }; @@ -100,13 +101,20 @@ app_menu_item_class_init (AppMenuItemClass *klass) NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); - signals[SHORTCUTS_CHANGED] = g_signal_new(APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, + signals[SHORTCUT_ADDED] = g_signal_new(APP_MENU_ITEM_SIGNAL_SHORTCUT_ADDED, G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (AppMenuItemClass, shortcuts_changed), + G_STRUCT_OFFSET (AppMenuItemClass, shortcut_added), NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0, G_TYPE_NONE); + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, G_TYPE_OBJECT); + signals[SHORTCUT_REMOVED] = g_signal_new(APP_MENU_ITEM_SIGNAL_SHORTCUT_REMOVED, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (AppMenuItemClass, shortcut_removed), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, G_TYPE_OBJECT); return; } @@ -137,6 +145,7 @@ app_menu_item_init (AppMenuItem *self) static void func_unref (gpointer data, gpointer user_data) { + g_signal_emit(user_data, signals[SHORTCUT_REMOVED], 0, data, TRUE); g_object_unref(G_OBJECT(data)); return; } @@ -155,10 +164,9 @@ app_menu_item_dispose (GObject *object) } if (priv->shortcuts != NULL) { - g_list_foreach(priv->shortcuts, func_unref, NULL); + g_list_foreach(priv->shortcuts, func_unref, object); g_list_free(priv->shortcuts); priv->shortcuts = NULL; - g_signal_emit(object, signals[SHORTCUTS_CHANGED], 0, TRUE); } if (priv->root != NULL) { @@ -351,7 +359,7 @@ child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint positio priv->shortcuts = g_list_insert(priv->shortcuts, mip, position); - g_signal_emit(G_OBJECT(data), signals[SHORTCUTS_CHANGED], 0, TRUE); + g_signal_emit(G_OBJECT(data), signals[SHORTCUT_ADDED], 0, mip, TRUE); return; } @@ -377,10 +385,10 @@ child_removed_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer da if (pitems != NULL) { DbusmenuMenuitemProxy * mip = DBUSMENU_MENUITEM_PROXY(pitems->data); - g_object_unref(mip); priv->shortcuts = g_list_remove(priv->shortcuts, mip); - g_signal_emit(G_OBJECT(data), signals[SHORTCUTS_CHANGED], 0, TRUE); + g_signal_emit(G_OBJECT(data), signals[SHORTCUT_REMOVED], 0, mip, TRUE); + g_object_unref(mip); } return; @@ -406,7 +414,7 @@ child_moved_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newpos, if (mip != NULL) { priv->shortcuts = g_list_remove(priv->shortcuts, mip); priv->shortcuts = g_list_insert(priv->shortcuts, mip, newpos); - g_signal_emit(G_OBJECT(data), signals[SHORTCUTS_CHANGED], 0, TRUE); + g_signal_emit(G_OBJECT(data), signals[SHORTCUT_ADDED], 0, NULL, TRUE); } return; @@ -420,11 +428,9 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data g_debug("Root Changed"); AppMenuItem * self = APP_MENU_ITEM(data); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); - gboolean change_time = FALSE; if (priv->root != NULL) { if (dbusmenu_menuitem_get_children(DBUSMENU_MENUITEM(priv->root)) != NULL) { - change_time = TRUE; g_list_foreach(priv->shortcuts, func_unref, NULL); g_list_free(priv->shortcuts); priv->shortcuts = NULL; @@ -447,21 +453,17 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data otherwise we'll just move along. */ GList * children = dbusmenu_menuitem_get_children(DBUSMENU_MENUITEM(priv->root)); if (children != NULL) { - change_time = TRUE; g_debug("\tProcessing %d children", g_list_length(children)); while (children != NULL) { DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(DBUSMENU_MENUITEM(children->data)); dbusmenu_menuitem_property_set(DBUSMENU_MENUITEM(mip), DBUSMENU_MENUITEM_PROP_ICON_NAME, DBUSMENU_MENUITEM_ICON_NAME_BLANK); priv->shortcuts = g_list_append(priv->shortcuts, mip); + g_signal_emit(G_OBJECT(self), signals[SHORTCUT_ADDED], 0, mip, TRUE); children = g_list_next(children); } } } - if (change_time) { - g_signal_emit(G_OBJECT(self), signals[SHORTCUTS_CHANGED], 0, TRUE); - } - return; } diff --git a/src/app-menu-item.h b/src/app-menu-item.h index 48a7cfa..d616856 100644 --- a/src/app-menu-item.h +++ b/src/app-menu-item.h @@ -39,7 +39,8 @@ G_BEGIN_DECLS #define APP_MENU_ITEM_SIGNAL_COUNT_CHANGED "count-changed" #define APP_MENU_ITEM_SIGNAL_NAME_CHANGED "name-changed" -#define APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED "shortcuts-changed" +#define APP_MENU_ITEM_SIGNAL_SHORTCUT_ADDED "shortcut-added" +#define APP_MENU_ITEM_SIGNAL_SHORTCUT_REMOVED "shortcut-removed" typedef struct _AppMenuItem AppMenuItem; typedef struct _AppMenuItemClass AppMenuItemClass; @@ -49,7 +50,8 @@ struct _AppMenuItemClass { void (* count_changed) (guint count); void (* name_changed) (gchar * name); - void (* shortcuts_changed) (void); + void (* shortcut_added) (DbusmenuMenuitem * mi); + void (* shortcut_removed) (DbusmenuMenuitem * mi); }; struct _AppMenuItem { -- cgit v1.2.3 From 76042f59f0f26647a1b7ab645da5f51ce17ce3d2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 16 Apr 2010 10:05:43 -0500 Subject: Handling the remove and add in separate functions. --- src/messages-service.c | 66 +++++++++++++------------------------------------- 1 file changed, 17 insertions(+), 49 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index bd69d7b..99e907a 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -55,7 +55,8 @@ static MessageServiceDbus * dbus_interface = NULL; #define DESKTOP_FILE_GROUP "Messaging Menu" #define DESKTOP_FILE_KEY_DESKTOP "DesktopFile" -static void server_shortcuts_changed (AppMenuItem * appitem, gpointer data); +static void server_shortcut_added (AppMenuItem * appitem, DbusmenuMenuitem * mi, gpointer data); +static void server_shortcut_removed (AppMenuItem * appitem, DbusmenuMenuitem * mi, gpointer data); static void server_count_changed (AppMenuItem * appitem, guint count, gpointer data); static void server_name_changed (AppMenuItem * appitem, gchar * name, gpointer data); static void im_time_changed (ImMenuItem * imitem, glong seconds, gpointer data); @@ -582,7 +583,8 @@ server_added (IndicateListener * listener, IndicateListenerServer * server, gcha /* Connect the signals up to the menu item */ g_signal_connect(G_OBJECT(menuitem), APP_MENU_ITEM_SIGNAL_COUNT_CHANGED, G_CALLBACK(server_count_changed), sl_item); g_signal_connect(G_OBJECT(menuitem), APP_MENU_ITEM_SIGNAL_NAME_CHANGED, G_CALLBACK(server_name_changed), menushell); - g_signal_connect(G_OBJECT(menuitem), APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, G_CALLBACK(server_shortcuts_changed), menushell); + g_signal_connect(G_OBJECT(menuitem), APP_MENU_ITEM_SIGNAL_SHORTCUT_ADDED, G_CALLBACK(server_shortcut_added), menushell); + g_signal_connect(G_OBJECT(menuitem), APP_MENU_ITEM_SIGNAL_SHORTCUT_REMOVED, G_CALLBACK(server_shortcut_removed), menushell); /* Put our new menu item in, with the separator behind it. resort_menu will take care of whether it should be hidden @@ -605,60 +607,26 @@ server_added (IndicateListener * listener, IndicateListenerServer * server, gcha return; } -/* The shortcuts have changed, let's just remove them and put - the back. */ +/* Server shortcut has been added */ static void -server_shortcuts_changed (AppMenuItem * appitem, gpointer data) +server_shortcut_added (AppMenuItem * appitem, DbusmenuMenuitem * mi, gpointer data) { - g_debug("Application Shortcuts changed"); + g_debug("Application Shortcut added: %s", mi != NULL ? dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_LABEL) : "none"); DbusmenuMenuitem * shell = DBUSMENU_MENUITEM(data); - gboolean appitemfound = FALSE; - GList * children = dbusmenu_menuitem_get_children(shell); - GList * removelist = NULL; - guint position = -1; - - while (children != NULL) { - position++; - if (children->data == appitem) { - g_debug("\tApp entry found at position %d", position); - children = g_list_next(children); - appitemfound = TRUE; - continue; - } - - if (!appitemfound) { - children = g_list_next(children); - continue; - } - - if (!DBUSMENU_IS_MENUITEM_PROXY(children->data)) { - g_debug("\tNon-proxy item (%s) found at %d: %s", G_OBJECT_TYPE_NAME(children->data), position, dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(children->data), DBUSMENU_MENUITEM_PROP_LABEL)); - break; - } - - removelist = g_list_prepend(removelist, children->data); - children = g_list_next(children); - } - - g_debug("\tRemoving %d shortcuts", g_list_length(removelist)); - - GList * removeitem; - for (removeitem = removelist; removeitem != NULL; removeitem = g_list_next(removeitem)) { - g_debug("\tRemoving shortcut: %s", dbusmenu_menuitem_property_get(DBUSMENU_MENUITEM(removeitem->data), DBUSMENU_MENUITEM_PROP_LABEL)); - dbusmenu_menuitem_child_delete(shell, DBUSMENU_MENUITEM(removeitem->data)); - } - g_list_free(removeitem); - - GList * shortcuts = app_menu_item_get_items(appitem); - while (shortcuts != NULL) { - DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(shortcuts->data); - g_debug("\tAdding shortcut: %s", dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_LABEL)); + if (mi != NULL) { dbusmenu_menuitem_child_append(shell, mi); - shortcuts = g_list_next(shortcuts); } - resort_menu(shell); + return; +} +/* Server shortcut has been removed */ +static void +server_shortcut_removed (AppMenuItem * appitem, DbusmenuMenuitem * mi, gpointer data) +{ + g_debug("Application Shortcut removed: %s", mi != NULL ? dbusmenu_menuitem_property_get(mi, DBUSMENU_MENUITEM_PROP_LABEL) : "none"); + DbusmenuMenuitem * shell = DBUSMENU_MENUITEM(data); + dbusmenu_menuitem_child_delete(shell, mi); return; } -- cgit v1.2.3 From e879cc91687bded6248f806ee711c73bfc57fb8b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 16 Apr 2010 10:12:11 -0500 Subject: Forgot to pass the object here. --- src/app-menu-item.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 5ffe74f..c276a90 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -431,7 +431,7 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data if (priv->root != NULL) { if (dbusmenu_menuitem_get_children(DBUSMENU_MENUITEM(priv->root)) != NULL) { - g_list_foreach(priv->shortcuts, func_unref, NULL); + g_list_foreach(priv->shortcuts, func_unref, data); g_list_free(priv->shortcuts); priv->shortcuts = NULL; } -- cgit v1.2.3 From e5e8f387af4718ae58a575dc46649d0e03d01bd3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 16 Apr 2010 23:20:36 -0500 Subject: When adding a desktop file look through teh applications we have to check for eclipsing --- src/messages-service.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/messages-service.c b/src/messages-service.c index 88da0e0..253a7c4 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -1358,6 +1358,14 @@ build_launcher_core (const gchar * desktop) dbusmenu_menuitem_property_set_bool(ll->separator, DBUSMENU_MENUITEM_PROP_VISIBLE, FALSE); } + /* Check to see if any of the current applications should + be eclipsing us. */ + GList * server; + for (server = serverList; server != NULL; server = g_list_next(server)) { + serverList_t * slt = (serverList_t *)server->data; + check_eclipses(slt->menuitem); + } + resort_menu(root_menuitem); check_hidden(); } else { -- cgit v1.2.3 From 70e5dbeec4e69f9de4679893f4d5753830b3a1ff Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Wed, 28 Apr 2010 03:33:57 -0700 Subject: Allocate memory for hash table items (LP: #533021) --- src/messages-service.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/messages-service.c b/src/messages-service.c index 54b4055..0783d91 100644 --- a/src/messages-service.c +++ b/src/messages-service.c @@ -315,7 +315,7 @@ desktop_file_from_keyfile (const gchar * definition_file) } /* Add a definition file into the black list and eclipse - and launchers that have the same file. */ + any launchers that have the same file. */ static gboolean blacklist_add (gpointer udata) { @@ -359,7 +359,7 @@ blacklist_add_core (gchar * desktop, gchar * definition) } /* Actually blacklist this thing */ - g_hash_table_insert(blacklist, desktop, definition); + g_hash_table_insert(blacklist, g_strdup(desktop), g_strdup(definition)); g_debug("Adding Blacklist item '%s' for desktop '%s'", definition, desktop); /* Go through and eclipse folks */ -- cgit v1.2.3 From 2265824db3e7849f1b95df8a1f282771db4bf909 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 21 May 2010 14:45:55 -0500 Subject: 0.3.7 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 1e3ba01..2f95071 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_INIT(src/indicator-messages.c) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-messages, 0.3.6) +AM_INIT_AUTOMAKE(indicator-messages, 0.3.7) AM_MAINTAINER_MODE -- cgit v1.2.3 -- cgit v1.2.3 From e77cd1f8cb84fa071b386fecde846bff24d15452 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Thu, 22 Jul 2010 12:19:47 +0200 Subject: Added triangles on the left and new label design on the right. We still need to align not-active services but I don't have any clue on how to do this --- src/indicator-messages.c | 176 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 159 insertions(+), 17 deletions(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index f47eccd..adfba93 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -44,6 +44,11 @@ with this program. If not, see . #define IS_INDICATOR_MESSAGES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), INDICATOR_MESSAGES_TYPE)) #define INDICATOR_MESSAGES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), INDICATOR_MESSAGES_TYPE, IndicatorMessagesClass)) +#define M_PI 3.1415926535897932384626433832795028841971693993751 + +#define RIGHT_LABEL_FONT_SIZE 12 +#define TRIANGLE_PADDING 10 + typedef struct _IndicatorMessages IndicatorMessages; typedef struct _IndicatorMessagesClass IndicatorMessagesClass; @@ -285,27 +290,141 @@ application_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, return; } +/* Draws a triangle on the left, using fg[STATE_TYPE] color. */ +static gboolean +application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) +{ + GtkStyle *style; + cairo_t *cr; + int x, y, arrow_width, arrow_height; + + /* get style */ + style = gtk_widget_get_style (widget); + + /* set arrow position / dimensions */ + arrow_width = widget->allocation.height/5.0; + arrow_height = widget->allocation.height/3.0; + x = widget->allocation.x; + y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0; + + /* initialize cairo drawing area */ + cr = (cairo_t*) gdk_cairo_create (widget->window); + + /* set line width */ + cairo_set_line_width (cr, 1.0); + + /* cairo drawing code */ + cairo_move_to (cr, x, y); + cairo_line_to (cr, x, y + arrow_height); + cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); + cairo_close_path (cr); + cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, + style->fg[gtk_widget_get_state(widget)].green/65535.0, + style->fg[gtk_widget_get_state(widget)].blue/65535.0); + cairo_fill (cr); + + /* remember to destroy cairo context to avoid leaks */ + cairo_destroy (cr); + + return FALSE; +} + +static void +custom_cairo_rounded_rectangle (cairo_t *cr, + double x, double y, double w, double h, + int radius) +{ + radius = MIN (radius, MIN (w/2.0, h/2.0)); + + cairo_move_to (cr, x+radius, y); + cairo_arc (cr, x+w-radius, y+radius, radius, M_PI*1.5, M_PI*2); + cairo_arc (cr, x+w-radius, y+h-radius, radius, 0, M_PI*0.5); + cairo_arc (cr, x+radius, y+h-radius, radius, M_PI*0.5, M_PI); + cairo_arc (cr, x+radius, y+radius, radius, M_PI, M_PI*1.5); +} + +/* Draws a rounded rectangle with text inside. */ +static gboolean +numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) +{ + GtkStyle *style; + cairo_t *cr; + double x, y, w, h; + PangoLayout * layout; + gint font_size = RIGHT_LABEL_FONT_SIZE; + + /* get style */ + style = gtk_widget_get_style (widget); + + /* set arrow position / dimensions */ + w = widget->allocation.width; + h = widget->allocation.height; + x = widget->allocation.x; + y = widget->allocation.y; + + layout = gtk_label_get_layout (GTK_LABEL(widget)); + + /* This does not work, don't ask me why but font_size is 0. + * I wanted to use a dynamic font size to adjust the padding on left/right edges + * of the rounded rectangle. Andrea Cimitan */ + /* const PangoFontDescription * font_description = pango_layout_get_font_description (layout); + font_size = pango_font_description_get_size (font_description); */ + + /* initialize cairo drawing area */ + cr = (cairo_t*) gdk_cairo_create (widget->window); + + /* set line width */ + cairo_set_line_width (cr, 1.0); + + cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); + + /* cairo drawing code */ + custom_cairo_rounded_rectangle (cr, x - font_size/2.0, y, w + font_size, h, 30); + + cairo_set_source_rgba (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, + style->fg[gtk_widget_get_state(widget)].green/65535.0, + style->fg[gtk_widget_get_state(widget)].blue/65535.0, 0.5); + + cairo_move_to (cr, x, y); + pango_cairo_layout_path (cr, layout); + cairo_fill (cr); + + /* remember to destroy cairo context to avoid leaks */ + cairo_destroy (cr); + + return TRUE; +} + /* Builds a menu item representing a running application in the messaging menu */ static gboolean new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new()); - + gchar buf[1024]; gint padding = 4; + gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL); + g_snprintf (buf, sizeof (buf), "idomessage-%p", gmi); + gtk_widget_set_name (GTK_WIDGET (gmi), buf); + + g_snprintf (buf, sizeof (buf), + "style \"ido-message\" {\n" + " GtkMenuItem::horizontal-padding = %d\n" + "} widget \"*.idomessage-%p\" style \"ido-message\"\n", + TRIANGLE_PADDING, gmi); + gtk_rc_parse_string (buf); + GtkWidget * hbox = gtk_hbox_new(FALSE, 0); /* Set the minimum size, we always want it to take space */ gint width, height; gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); - GtkWidget * icon = gtk_image_new_from_icon_name(dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_ICON), GTK_ICON_SIZE_MENU); + GtkWidget * icon = gtk_image_new_from_icon_name(dbusmenu_menuitem_property_get(newitem, + APPLICATION_MENUITEM_PROP_ICON), GTK_ICON_SIZE_MENU); gtk_widget_set_size_request(icon, width, height); - gtk_misc_set_alignment(GTK_MISC(icon), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, padding); - gtk_widget_show(icon); /* Application name in a label */ GtkWidget * label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_NAME)); @@ -313,29 +432,27 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, padding); gtk_widget_show(label); - /* Insert the hbox */ - gtk_container_add(GTK_CONTAINER(gmi), hbox); - gtk_widget_show(hbox); - /* Build up the running icon */ - GtkWidget * running_icon = gtk_image_new_from_icon_name("application-running", GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), running_icon); - gtk_widget_show(running_icon); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), icon); /* Make sure it always appears */ gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(gmi), TRUE); + /* Insert the hbox */ + gtk_container_add(GTK_CONTAINER(gmi), hbox); + gtk_widget_show(hbox); + /* Attach some of the standard GTK stuff */ dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); /* Make sure we can handle the label changing */ g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_prop_change_cb), label); g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_icon_change_cb), icon); + g_signal_connect_after (G_OBJECT (gmi), "expose_event", G_CALLBACK (application_triangle_draw_cb), NULL); return TRUE; } - typedef struct _indicator_item_t indicator_item_t; struct _indicator_item_t { GtkWidget * icon; @@ -402,11 +519,24 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm indicator_item_t * mi_data = g_new0(indicator_item_t, 1); - GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); + GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new()); + gchar buf[1024]; gint padding = 4; + gint font_size = RIGHT_LABEL_FONT_SIZE; + gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL); + g_snprintf (buf, sizeof (buf), "idomessage-%p", gmi); + gtk_widget_set_name (GTK_WIDGET (gmi), buf); + + g_snprintf (buf, sizeof (buf), + "style \"ido-message\" {\n" + " GtkMenuItem::horizontal-padding = %d\n" + "} widget \"*.idomessage-%p\" style \"ido-message\"\n", + TRIANGLE_PADDING, gmi); + gtk_rc_parse_string (buf); + GtkWidget * hbox = gtk_hbox_new(FALSE, 0); /* Icon, probably someone's face or avatar on an IM */ @@ -441,8 +571,6 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm g_object_unref(resized_pixbuf); } } - gtk_misc_set_alignment(GTK_MISC(mi_data->icon), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(hbox), mi_data->icon, FALSE, FALSE, padding); gtk_widget_show(mi_data->icon); /* Label, probably a username, chat room or mailbox name */ @@ -455,10 +583,24 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm item. */ mi_data->right = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_RIGHT)); gtk_size_group_add_widget(indicator_right_group, mi_data->right); + + /* Doesn't work, look numbers_draw_cb. */ + /* PangoLayout * right_layout = gtk_label_get_layout (GTK_LABEL(mi_data->right)); + gint font_size = pango_font_description_get_size (pango_layout_get_font_description (right_layout)); */ + + g_signal_connect (G_OBJECT (mi_data->right), "expose_event", + G_CALLBACK (numbers_draw_cb), NULL); + gtk_misc_set_alignment(GTK_MISC(mi_data->right), 1.0, 0.5); - gtk_box_pack_start(GTK_BOX(hbox), mi_data->right, FALSE, FALSE, padding); + gtk_box_pack_start(GTK_BOX(hbox), mi_data->right, FALSE, FALSE, padding + font_size/2.0); gtk_widget_show(mi_data->right); + /* Build up the running icon */ + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), mi_data->icon); + + /* Make sure it always appears */ + gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(gmi), TRUE); + gtk_container_add(GTK_CONTAINER(gmi), hbox); gtk_widget_show(hbox); -- cgit v1.2.3 From 27df2717d21625ebde66fba258896513567810c5 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Thu, 22 Jul 2010 19:20:43 +0200 Subject: Fixed position of sub menu indicators (the one with the counter on the right) --- src/indicator-messages.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index adfba93..dd90318 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -570,8 +570,12 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm if (resized_pixbuf != pixbuf) { g_object_unref(resized_pixbuf); } + + /* Add the icon only if present. */ + gtk_misc_set_alignment(GTK_MISC(mi_data->icon), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), mi_data->icon, FALSE, FALSE, padding); + gtk_widget_show(mi_data->icon); } - gtk_widget_show(mi_data->icon); /* Label, probably a username, chat room or mailbox name */ mi_data->label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_LABEL)); @@ -595,12 +599,6 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm gtk_box_pack_start(GTK_BOX(hbox), mi_data->right, FALSE, FALSE, padding + font_size/2.0); gtk_widget_show(mi_data->right); - /* Build up the running icon */ - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), mi_data->icon); - - /* Make sure it always appears */ - gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(gmi), TRUE); - gtk_container_add(GTK_CONTAINER(gmi), hbox); gtk_widget_show(hbox); -- cgit v1.2.3 From 8712e709c76ca99f71680dd5ade66c03c45c8dd1 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Thu, 29 Jul 2010 12:55:42 +0200 Subject: Added rounded rectangles on the right --- src/indicator-messages.c | 111 ++++++++++------------------------------------- 1 file changed, 22 insertions(+), 89 deletions(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index dd90318..a4299dc 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -47,7 +47,7 @@ with this program. If not, see . #define M_PI 3.1415926535897932384626433832795028841971693993751 #define RIGHT_LABEL_FONT_SIZE 12 -#define TRIANGLE_PADDING 10 +#define RIGHT_LABEL_RADIUS 20 typedef struct _IndicatorMessages IndicatorMessages; typedef struct _IndicatorMessagesClass IndicatorMessagesClass; @@ -290,51 +290,12 @@ application_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, return; } -/* Draws a triangle on the left, using fg[STATE_TYPE] color. */ -static gboolean -application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) -{ - GtkStyle *style; - cairo_t *cr; - int x, y, arrow_width, arrow_height; - - /* get style */ - style = gtk_widget_get_style (widget); - - /* set arrow position / dimensions */ - arrow_width = widget->allocation.height/5.0; - arrow_height = widget->allocation.height/3.0; - x = widget->allocation.x; - y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0; - - /* initialize cairo drawing area */ - cr = (cairo_t*) gdk_cairo_create (widget->window); - - /* set line width */ - cairo_set_line_width (cr, 1.0); - - /* cairo drawing code */ - cairo_move_to (cr, x, y); - cairo_line_to (cr, x, y + arrow_height); - cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); - cairo_close_path (cr); - cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, - style->fg[gtk_widget_get_state(widget)].green/65535.0, - style->fg[gtk_widget_get_state(widget)].blue/65535.0); - cairo_fill (cr); - - /* remember to destroy cairo context to avoid leaks */ - cairo_destroy (cr); - - return FALSE; -} - +/* Custom function to draw rounded rectangle with max radius */ static void custom_cairo_rounded_rectangle (cairo_t *cr, - double x, double y, double w, double h, - int radius) + double x, double y, double w, double h) { - radius = MIN (radius, MIN (w/2.0, h/2.0)); + double radius = MIN (w/2.0, h/2.0); cairo_move_to (cr, x+radius, y); cairo_arc (cr, x+w-radius, y+radius, radius, M_PI*1.5, M_PI*2); @@ -379,7 +340,7 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) cairo_set_fill_rule (cr, CAIRO_FILL_RULE_EVEN_ODD); /* cairo drawing code */ - custom_cairo_rounded_rectangle (cr, x - font_size/2.0, y, w + font_size, h, 30); + custom_cairo_rounded_rectangle (cr, x - font_size/2.0, y, w + font_size, h); cairo_set_source_rgba (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, style->fg[gtk_widget_get_state(widget)].green/65535.0, @@ -401,30 +362,21 @@ static gboolean new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) { GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new()); - gchar buf[1024]; - gint padding = 4; + gint padding = 4; gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL); - g_snprintf (buf, sizeof (buf), "idomessage-%p", gmi); - gtk_widget_set_name (GTK_WIDGET (gmi), buf); - - g_snprintf (buf, sizeof (buf), - "style \"ido-message\" {\n" - " GtkMenuItem::horizontal-padding = %d\n" - "} widget \"*.idomessage-%p\" style \"ido-message\"\n", - TRIANGLE_PADDING, gmi); - gtk_rc_parse_string (buf); - GtkWidget * hbox = gtk_hbox_new(FALSE, 0); /* Set the minimum size, we always want it to take space */ gint width, height; gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &width, &height); - GtkWidget * icon = gtk_image_new_from_icon_name(dbusmenu_menuitem_property_get(newitem, - APPLICATION_MENUITEM_PROP_ICON), GTK_ICON_SIZE_MENU); + GtkWidget * icon = gtk_image_new_from_icon_name(dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_ICON), GTK_ICON_SIZE_MENU); gtk_widget_set_size_request(icon, width, height); + gtk_misc_set_alignment(GTK_MISC(icon), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, padding); + gtk_widget_show(icon); /* Application name in a label */ GtkWidget * label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, APPLICATION_MENUITEM_PROP_NAME)); @@ -432,23 +384,24 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, padding); gtk_widget_show(label); + /* Insert the hbox */ + gtk_container_add(GTK_CONTAINER(gmi), hbox); + gtk_widget_show(hbox); + /* Build up the running icon */ - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), icon); + GtkWidget * running_icon = gtk_image_new_from_icon_name("application-running", GTK_ICON_SIZE_MENU); + gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), running_icon); + gtk_widget_show(running_icon); /* Make sure it always appears */ gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(gmi), TRUE); - /* Insert the hbox */ - gtk_container_add(GTK_CONTAINER(gmi), hbox); - gtk_widget_show(hbox); - /* Attach some of the standard GTK stuff */ dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); /* Make sure we can handle the label changing */ g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_prop_change_cb), label); g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_icon_change_cb), icon); - g_signal_connect_after (G_OBJECT (gmi), "expose_event", G_CALLBACK (application_triangle_draw_cb), NULL); return TRUE; } @@ -519,24 +472,12 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm indicator_item_t * mi_data = g_new0(indicator_item_t, 1); - GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_image_menu_item_new()); + GtkMenuItem * gmi = GTK_MENU_ITEM(gtk_menu_item_new()); - gchar buf[1024]; gint padding = 4; gint font_size = RIGHT_LABEL_FONT_SIZE; - gtk_widget_style_get(GTK_WIDGET(gmi), "horizontal-padding", &padding, NULL); - g_snprintf (buf, sizeof (buf), "idomessage-%p", gmi); - gtk_widget_set_name (GTK_WIDGET (gmi), buf); - - g_snprintf (buf, sizeof (buf), - "style \"ido-message\" {\n" - " GtkMenuItem::horizontal-padding = %d\n" - "} widget \"*.idomessage-%p\" style \"ido-message\"\n", - TRIANGLE_PADDING, gmi); - gtk_rc_parse_string (buf); - GtkWidget * hbox = gtk_hbox_new(FALSE, 0); /* Icon, probably someone's face or avatar on an IM */ @@ -570,18 +511,10 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm if (resized_pixbuf != pixbuf) { g_object_unref(resized_pixbuf); } - - /* Add the icon only if present. */ - gtk_misc_set_alignment(GTK_MISC(mi_data->icon), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(hbox), mi_data->icon, FALSE, FALSE, padding); - gtk_widget_show(mi_data->icon); } - - /* Label, probably a username, chat room or mailbox name */ - mi_data->label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_LABEL)); - gtk_misc_set_alignment(GTK_MISC(mi_data->label), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(hbox), mi_data->label, TRUE, TRUE, padding); - gtk_widget_show(mi_data->label); + gtk_misc_set_alignment(GTK_MISC(mi_data->icon), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), mi_data->icon, FALSE, FALSE, padding); + gtk_widget_show(mi_data->icon); /* Usually either the time or the count on the individual item. */ @@ -590,7 +523,7 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm /* Doesn't work, look numbers_draw_cb. */ /* PangoLayout * right_layout = gtk_label_get_layout (GTK_LABEL(mi_data->right)); - gint font_size = pango_font_description_get_size (pango_layout_get_font_description (right_layout)); */ + font_size = pango_font_description_get_size (pango_layout_get_font_description (right_layout)); */ g_signal_connect (G_OBJECT (mi_data->right), "expose_event", G_CALLBACK (numbers_draw_cb), NULL); -- cgit v1.2.3 From c4baebd40e86b2277f87a17df0a9d25d79cac251 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Thu, 29 Jul 2010 13:30:48 +0200 Subject: Ops, readded the label :P --- src/indicator-messages.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index a4299dc..550f1fd 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -516,6 +516,12 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm gtk_box_pack_start(GTK_BOX(hbox), mi_data->icon, FALSE, FALSE, padding); gtk_widget_show(mi_data->icon); + /* Label, probably a username, chat room or mailbox name */ + mi_data->label = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_LABEL)); + gtk_misc_set_alignment(GTK_MISC(mi_data->label), 0.0, 0.5); + gtk_box_pack_start(GTK_BOX(hbox), mi_data->label, TRUE, TRUE, padding); + gtk_widget_show(mi_data->label); + /* Usually either the time or the count on the individual item. */ mi_data->right = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_RIGHT)); -- cgit v1.2.3 From 4aa39a73041f2952ffd1918c9b68a7cda1028c6e Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Thu, 29 Jul 2010 13:40:02 +0200 Subject: check if widget is really a widget before getting its style (from dbarth) --- src/indicator-messages.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 550f1fd..d1133ea 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -314,6 +314,8 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) PangoLayout * layout; gint font_size = RIGHT_LABEL_FONT_SIZE; + if (!GTK_IS_WIDGET (widget)) return; + /* get style */ style = gtk_widget_get_style (widget); -- cgit v1.2.3 From 4749650191f707ae86574ca292bb21afe93e10e7 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Thu, 29 Jul 2010 15:32:08 +0200 Subject: Draw a triangle on the left --- src/indicator-messages.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index d1133ea..beea9f2 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -290,6 +290,47 @@ application_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, return; } +/* Draws a triangle on the left, using fg[STATE_TYPE] color. */ +static gboolean +application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) +{ + GtkStyle *style; + cairo_t *cr; + int x, y, arrow_width, arrow_height; + + if (!GTK_IS_WIDGET (widget)) return; + + /* get style */ + style = gtk_widget_get_style (widget); + + /* set arrow position / dimensions */ + arrow_width = widget->allocation.height/5.0; + arrow_height = widget->allocation.height/3.0; + x = widget->allocation.x; + y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0; + + /* initialize cairo drawing area */ + cr = (cairo_t*) gdk_cairo_create (widget->window); + + /* set line width */ + cairo_set_line_width (cr, 1.0); + + /* cairo drawing code */ + cairo_move_to (cr, x, y); + cairo_line_to (cr, x, y + arrow_height); + cairo_line_to (cr, x + arrow_width, y + (double)arrow_height/2.0); + cairo_close_path (cr); + cairo_set_source_rgb (cr, style->fg[gtk_widget_get_state(widget)].red/65535.0, + style->fg[gtk_widget_get_state(widget)].green/65535.0, + style->fg[gtk_widget_get_state(widget)].blue/65535.0); + cairo_fill (cr); + + /* remember to destroy cairo context to avoid leaks */ + cairo_destroy (cr); + + return FALSE; +} + /* Custom function to draw rounded rectangle with max radius */ static void custom_cairo_rounded_rectangle (cairo_t *cr, @@ -403,7 +444,8 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu /* Make sure we can handle the label changing */ g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_prop_change_cb), label); - g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_icon_change_cb), icon); + g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_icon_change_cb), icon); + g_signal_connect_after(G_OBJECT (gmi), "expose_event", G_CALLBACK (application_triangle_draw_cb), NULL); return TRUE; } -- cgit v1.2.3 From 0fc555a7ff95caca49ec4a48d6405c9255ad3c94 Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Thu, 29 Jul 2010 15:38:22 +0200 Subject: trailing whitespace --- src/indicator-messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index beea9f2..06a09c8 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -444,7 +444,7 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu /* Make sure we can handle the label changing */ g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_prop_change_cb), label); - g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_icon_change_cb), icon); + g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(application_icon_change_cb), icon); g_signal_connect_after(G_OBJECT (gmi), "expose_event", G_CALLBACK (application_triangle_draw_cb), NULL); return TRUE; -- cgit v1.2.3 From 07039865d9bb58f7d80c547bff0bc04327a383bc Mon Sep 17 00:00:00 2001 From: Andrea Cimitan Date: Thu, 29 Jul 2010 16:01:44 +0200 Subject: remove the previous icon --- src/indicator-messages.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 06a09c8..a7f79fd 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -431,14 +431,6 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu gtk_container_add(GTK_CONTAINER(gmi), hbox); gtk_widget_show(hbox); - /* Build up the running icon */ - GtkWidget * running_icon = gtk_image_new_from_icon_name("application-running", GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), running_icon); - gtk_widget_show(running_icon); - - /* Make sure it always appears */ - gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(gmi), TRUE); - /* Attach some of the standard GTK stuff */ dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); -- cgit v1.2.3 From 32e8f9ff37ace0f23895b762d5c5a4a5696a093e Mon Sep 17 00:00:00 2001 From: David Barth Date: Thu, 29 Jul 2010 16:03:42 +0200 Subject: fix typos to build and clean up comments --- src/indicator-messages.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 06a09c8..d45dfc8 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -298,7 +298,7 @@ application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer cairo_t *cr; int x, y, arrow_width, arrow_height; - if (!GTK_IS_WIDGET (widget)) return; + if (!GTK_IS_WIDGET (widget)) return FALSE; /* get style */ style = gtk_widget_get_style (widget); @@ -355,7 +355,7 @@ numbers_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer data) PangoLayout * layout; gint font_size = RIGHT_LABEL_FONT_SIZE; - if (!GTK_IS_WIDGET (widget)) return; + if (!GTK_IS_WIDGET (widget)) return FALSE; /* get style */ style = gtk_widget_get_style (widget); @@ -570,11 +570,7 @@ new_indicator_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm item. */ mi_data->right = gtk_label_new(dbusmenu_menuitem_property_get(newitem, INDICATOR_MENUITEM_PROP_RIGHT)); gtk_size_group_add_widget(indicator_right_group, mi_data->right); - - /* Doesn't work, look numbers_draw_cb. */ - /* PangoLayout * right_layout = gtk_label_get_layout (GTK_LABEL(mi_data->right)); - font_size = pango_font_description_get_size (pango_layout_get_font_description (right_layout)); */ - + /* install extra decoration overlay */ g_signal_connect (G_OBJECT (mi_data->right), "expose_event", G_CALLBACK (numbers_draw_cb), NULL); -- cgit v1.2.3 From 997a69df81d34c92263cad72eed1b772209b6e95 Mon Sep 17 00:00:00 2001 From: David Barth Date: Thu, 29 Jul 2010 16:04:07 +0200 Subject: remove the old running app. icon --- src/indicator-messages.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index d45dfc8..aa4cf26 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -431,11 +431,6 @@ new_application_item (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbu gtk_container_add(GTK_CONTAINER(gmi), hbox); gtk_widget_show(hbox); - /* Build up the running icon */ - GtkWidget * running_icon = gtk_image_new_from_icon_name("application-running", GTK_ICON_SIZE_MENU); - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gmi), running_icon); - gtk_widget_show(running_icon); - /* Make sure it always appears */ gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(gmi), TRUE); -- cgit v1.2.3 From 59b9d6fe4abecc1d986c73d077c0994fccae37e7 Mon Sep 17 00:00:00 2001 From: David Barth Date: Thu, 29 Jul 2010 16:08:34 +0200 Subject: adjust the triangle size --- src/indicator-messages.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index aa4cf26..8aa64de 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -304,8 +304,8 @@ application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer style = gtk_widget_get_style (widget); /* set arrow position / dimensions */ - arrow_width = widget->allocation.height/5.0; - arrow_height = widget->allocation.height/3.0; + arrow_width = (int) ((double)widget->allocation.height * 0.25f); + arrow_height = (int) ((double)widget->allocation.height * 0.60f); x = widget->allocation.x; y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0; -- cgit v1.2.3 From 29d8a891747905a2ec7c5f05f0a9df11fb45e764 Mon Sep 17 00:00:00 2001 From: David Barth Date: Thu, 29 Jul 2010 17:43:43 +0200 Subject: better aspect ratio for the triangle --- src/indicator-messages.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/indicator-messages.c b/src/indicator-messages.c index 8aa64de..dc10516 100644 --- a/src/indicator-messages.c +++ b/src/indicator-messages.c @@ -305,7 +305,7 @@ application_triangle_draw_cb (GtkWidget *widget, GdkEventExpose *event, gpointer /* set arrow position / dimensions */ arrow_width = (int) ((double)widget->allocation.height * 0.25f); - arrow_height = (int) ((double)widget->allocation.height * 0.60f); + arrow_height = (int) ((double)widget->allocation.height * 0.50f); x = widget->allocation.x; y = widget->allocation.y + widget->allocation.height/2.0 - (double)arrow_height/2.0; -- cgit v1.2.3 From 657571f91da4aa7ce96309a0fd234a2a30878140 Mon Sep 17 00:00:00 2001 From: David Barth Date: Thu, 29 Jul 2010 18:50:05 +0200 Subject: 0.3.8 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 2f95071..88b80b7 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_INIT(src/indicator-messages.c) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(indicator-messages, 0.3.7) +AM_INIT_AUTOMAKE(indicator-messages, 0.3.8) AM_MAINTAINER_MODE -- cgit v1.2.3