aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/messages-service.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/messages-service.c b/src/messages-service.c
index 585589a..6b4f7c6 100644
--- a/src/messages-service.c
+++ b/src/messages-service.c
@@ -31,6 +31,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
#include <libdbusmenu-glib/client.h>
#include <libdbusmenu-glib/server.h>
+#include <libdbusmenu-glib/menuitem-proxy.h>
#include "im-menu-item.h"
#include "app-menu-item.h"
@@ -51,6 +52,7 @@ 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_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,11 +584,20 @@ 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);
/* Put our new menu item in, with the separator behind it.
resort_menu will take care of whether it should be hidden
or not. */
dbusmenu_menuitem_child_append(menushell, DBUSMENU_MENUITEM(menuitem));
+
+ GList * shortcuts = app_menu_item_get_items(sl_item->menuitem);
+ while (shortcuts != NULL) {
+ DbusmenuMenuitem * mi = DBUSMENU_MENUITEM(shortcuts->data);
+ dbusmenu_menuitem_child_append(menushell, mi);
+ shortcuts = g_list_next(shortcuts);
+ }
+
dbusmenu_menuitem_child_append(menushell, DBUSMENU_MENUITEM(sl_item->separator));
resort_menu(menushell);
@@ -595,6 +606,46 @@ server_added (IndicateListener * listener, IndicateListenerServer * server, gcha
return;
}
+/* The shortcuts have changed, let's just remove them and put
+ the back. */
+static void
+server_shortcuts_changed (AppMenuItem * appitem, gpointer data)
+{
+ DbusmenuMenuitem * shell = DBUSMENU_MENUITEM(data);
+ gboolean appitemfound = FALSE;
+ GList * children = dbusmenu_menuitem_get_children(shell);
+ GList * removelist = NULL;
+
+ while (children != NULL) {
+ if (!appitemfound && children->data != appitem) {
+ children = g_list_next(children);
+ continue;
+ }
+ appitemfound = TRUE;
+
+ if (!DBUSMENU_IS_MENUITEM_PROXY(children->data)) {
+ break;
+ }
+
+ removelist = g_list_prepend(removelist, children->data);
+ }
+
+ GList * removeitem;
+ for (removeitem = removelist; removeitem != NULL; removeitem = g_list_next(removeitem)) {
+ 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);
+ dbusmenu_menuitem_child_append(shell, mi);
+ shortcuts = g_list_next(shortcuts);
+ }
+
+ return;
+}
+
/* The name of a server has changed, we probably
need to reorder the menu to keep it in alphabetical
order. This happens often after we read the destkop