From 3c93168a4518426fb28f06c3635b7f32fad2f6a1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 13:48:53 -0600 Subject: Adding API for getting items --- src/app-menu-item.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/app-menu-item.c') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 5fc2a9c..b1b2a02 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -309,3 +309,11 @@ app_menu_item_get_desktop (AppMenuItem * appitem) AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(appitem); return priv->desktop; } + +/* Get the dynamic items added onto the end of + and app entry. */ +GList * +app_menu_item_get_items (AppMenuItem * appitem) +{ + return NULL; +} -- cgit v1.2.3 From d307fee44ed8e2588c23a9461a44b0d86362e53c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 14:17:18 -0600 Subject: Fleshing out menu_cb, lots of avenues for expantion in other directions now. --- src/app-menu-item.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/app-menu-item.c') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index b1b2a02..ece5a83 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -26,6 +26,7 @@ with this program. If not, see . #include #include +#include #include "app-menu-item.h" #include "dbus-data.h" @@ -48,6 +49,9 @@ struct _AppMenuItemPrivate GAppInfo * appinfo; gchar * desktop; guint unreadcount; + + DbusmenuClient * client; + DbusmenuMenuitem * root; }; #define APP_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), APP_MENU_ITEM_TYPE, AppMenuItemPrivate)) @@ -60,6 +64,7 @@ static void app_menu_item_finalize (GObject *object); static void activate_cb (AppMenuItem * self, guint timestamp, gpointer data); static void count_changed (IndicateListener * listener, IndicateListenerServer * server, guint count, gpointer data); static void count_cb (IndicateListener * listener, IndicateListenerServer * server, guint value, gpointer data); +static void menu_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * menupath, gpointer data); static void desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data); static void update_label (AppMenuItem * self); @@ -168,6 +173,7 @@ app_menu_item_new (IndicateListener * listener, IndicateListenerServer * server) /* Get the values we care about from the server */ indicate_listener_server_get_desktop(listener, server, desktop_cb, self); indicate_listener_server_get_count(listener, server, count_cb, self); + indicate_listener_server_get_menu(listener, server, menu_cb, self); g_signal_connect(G_OBJECT(self), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_cb), NULL); @@ -262,6 +268,27 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar return; } +static void +root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer user_data) +{ + + +} + +/* Gets the path to menuitems if there are some. Now we need to + make them special. */ +static void +menu_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * menupath, gpointer data) +{ + AppMenuItem * self = APP_MENU_ITEM(data); + AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); + + priv->client = dbusmenu_client_new(indicate_listener_server_get_dbusname(server), menupath); + g_signal_connect(G_OBJECT(priv->client), DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(root_changed), self); + + return; +} + static void activate_cb (AppMenuItem * self, guint timestamp, gpointer data) { -- cgit v1.2.3 From 1728c0be0db166c30a2e2b2a5373d135b404d3ed Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 14:22:15 -0600 Subject: Init and cleanup the client and root private properties. --- src/app-menu-item.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'src/app-menu-item.c') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index ece5a83..67f616a 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -112,6 +112,9 @@ app_menu_item_init (AppMenuItem *self) priv->desktop = NULL; priv->unreadcount = 0; + priv->client = NULL; + priv->root = NULL; + return; } @@ -122,8 +125,20 @@ app_menu_item_dispose (GObject *object) AppMenuItem * self = APP_MENU_ITEM(object); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); - g_signal_handlers_disconnect_by_func(G_OBJECT(priv->listener), count_changed, self); - g_object_unref(priv->listener); + if (priv->listener != NULL) { + g_signal_handlers_disconnect_by_func(G_OBJECT(priv->listener), count_changed, self); + g_object_unref(priv->listener); + } + + if (priv->root != NULL) { + g_object_unref(priv->root); + priv->root = NULL; + } + + if (priv->client != NULL) { + g_object_unref(priv->client); + priv->client = NULL; + } G_OBJECT_CLASS (app_menu_item_parent_class)->dispose (object); } -- cgit v1.2.3 From de7363b6804d843f9c8c9a692297570bf1a19cfe Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 14:56:52 -0600 Subject: Handling root item changes. Mostly. --- src/app-menu-item.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) (limited to 'src/app-menu-item.c') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 67f616a..5d53053 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -27,6 +27,7 @@ with this program. If not, see . #include #include #include +#include #include "app-menu-item.h" #include "dbus-data.h" @@ -51,7 +52,7 @@ struct _AppMenuItemPrivate guint unreadcount; DbusmenuClient * client; - DbusmenuMenuitem * root; + DbusmenuMenuitemProxy * root; }; #define APP_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), APP_MENU_ITEM_TYPE, AppMenuItemPrivate)) @@ -284,10 +285,63 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar } static void -root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer user_data) +child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, gpointer user_data) { + return; +} + +static void +child_removed_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer user_data) +{ + + return; +} +static void +child_moved_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newpos, guint oldpos, gpointer user_data) +{ + + return; +} + +/* We've got a new root. We need to proxy it and handle it's children + if that's a relevant thing to do. */ +static void +root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data) +{ + 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_object_unref(priv->root); + priv->root = NULL; + } + + /* We need to proxy the new root across to the old + world of indicator land. */ + priv->root = dbusmenu_menuitem_proxy_new(newroot); + 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; + } + + if (change_time) { + /* Signal that something has changed */ + change_time = FALSE; + } + + return; } /* Gets the path to menuitems if there are some. Now we need to -- cgit v1.2.3 From 958bb92e0346294d34d7628061faf134f1043621 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 15:01:13 -0600 Subject: Adding in a shortcuts changed signal --- src/app-menu-item.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/app-menu-item.c') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 5d53053..e9ba0f1 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -34,6 +34,7 @@ with this program. If not, see . enum { COUNT_CHANGED, NAME_CHANGED, + SHORTCUTS_CHANGED, LAST_SIGNAL }; @@ -96,6 +97,13 @@ 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, + G_TYPE_FROM_CLASS(klass), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (AppMenuItemClass, shortcuts_changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0, G_TYPE_NONE); return; } -- cgit v1.2.3 From ed9e77cb4d6bf3359138c28153a316ad5418be83 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 15:03:21 -0600 Subject: Emitting the new signal all over the place. --- src/app-menu-item.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/app-menu-item.c') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index e9ba0f1..59b435a 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -292,24 +292,30 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar return; } +/* Relay this signal into causing a rebuild of the shortcuts + from those above us. */ static void child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, gpointer user_data) { - + g_signal_emit(G_OBJECT(user_data), APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, 0, TRUE); return; } +/* Relay this signal into causing a rebuild of the shortcuts + from those above us. */ static void child_removed_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer user_data) { - + g_signal_emit(G_OBJECT(user_data), APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, 0, TRUE); return; } +/* Relay this signal into causing a rebuild of the shortcuts + from those above us. */ static void child_moved_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newpos, guint oldpos, gpointer user_data) { - + g_signal_emit(G_OBJECT(user_data), APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, 0, TRUE); return; } @@ -345,8 +351,7 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data } if (change_time) { - /* Signal that something has changed */ - change_time = FALSE; + g_signal_emit(G_OBJECT(self), APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, 0, TRUE); } return; -- cgit v1.2.3 From 7c08cb9a551c4c9c58bf7ebc1b591471479e9d73 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 15:20:24 -0600 Subject: Oops, wrong signal name for this function. --- src/app-menu-item.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/app-menu-item.c') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 59b435a..2f96c49 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -297,7 +297,7 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar static void child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, gpointer user_data) { - g_signal_emit(G_OBJECT(user_data), APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, 0, TRUE); + g_signal_emit(G_OBJECT(user_data), signals[SHORTCUTS_CHANGED], 0, TRUE); return; } @@ -306,7 +306,7 @@ child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint positio static void child_removed_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer user_data) { - g_signal_emit(G_OBJECT(user_data), APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, 0, TRUE); + g_signal_emit(G_OBJECT(user_data), signals[SHORTCUTS_CHANGED], 0, TRUE); return; } @@ -315,7 +315,7 @@ child_removed_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer us static void child_moved_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newpos, guint oldpos, gpointer user_data) { - g_signal_emit(G_OBJECT(user_data), APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, 0, TRUE); + g_signal_emit(G_OBJECT(user_data), signals[SHORTCUTS_CHANGED], 0, TRUE); return; } @@ -351,7 +351,7 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data } if (change_time) { - g_signal_emit(G_OBJECT(self), APP_MENU_ITEM_SIGNAL_SHORTCUTS_CHANGED, 0, TRUE); + g_signal_emit(G_OBJECT(self), signals[SHORTCUTS_CHANGED], 0, TRUE); } return; -- cgit v1.2.3 From 3bd80ee8e9bfa1c2b50225b67349eaff8bbeafa2 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 15:41:38 -0600 Subject: Adding a list to put the shortcuts in --- src/app-menu-item.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/app-menu-item.c') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 2f96c49..58c8a02 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -54,6 +54,7 @@ struct _AppMenuItemPrivate DbusmenuClient * client; DbusmenuMenuitemProxy * root; + GList * shortcuts; }; #define APP_MENU_ITEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), APP_MENU_ITEM_TYPE, AppMenuItemPrivate)) @@ -123,10 +124,19 @@ app_menu_item_init (AppMenuItem *self) priv->client = NULL; priv->root = NULL; + priv->shortcuts = NULL; return; } +/* A wrapper to make the prototypes work for GFunc */ +static void +func_unref (gpointer data, gpointer user_data) +{ + g_object_unref(G_OBJECT(data)); + return; +} + /* Disconnect the count_changed signal and unref the listener */ static void app_menu_item_dispose (GObject *object) @@ -139,6 +149,13 @@ app_menu_item_dispose (GObject *object) g_object_unref(priv->listener); } + if (priv->shortcuts != NULL) { + g_list_foreach(priv->shortcuts, func_unref, NULL); + g_list_free(priv->shortcuts); + priv->shortcuts = NULL; + g_signal_emit(object, signals[SHORTCUTS_CHANGED], 0, TRUE); + } + if (priv->root != NULL) { g_object_unref(priv->root); priv->root = NULL; -- cgit v1.2.3 From 072da6cccd26225f1528bf09917dd38006f9bd7d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 16:10:18 -0600 Subject: Realized that we can't proxy the root as the items can't then have two parents, and they need to exist with a parent in the menu that we're building. So we have to leave the proxy items unparented until they get picked up in the service themselves. --- src/app-menu-item.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 59 insertions(+), 8 deletions(-) (limited to 'src/app-menu-item.c') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 58c8a02..53d4afa 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -53,7 +53,7 @@ struct _AppMenuItemPrivate guint unreadcount; DbusmenuClient * client; - DbusmenuMenuitemProxy * root; + DbusmenuMenuitem * root; GList * shortcuts; }; @@ -312,27 +312,70 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar /* Relay this signal into causing a rebuild of the shortcuts from those above us. */ static void -child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, gpointer user_data) +child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, gpointer data) { - g_signal_emit(G_OBJECT(user_data), signals[SHORTCUTS_CHANGED], 0, TRUE); + AppMenuItem * self = APP_MENU_ITEM(data); + AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); + DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(child); + + priv->shortcuts = g_list_insert(priv->shortcuts, mip, position); + + g_signal_emit(G_OBJECT(data), signals[SHORTCUTS_CHANGED], 0, TRUE); return; } /* Relay this signal into causing a rebuild of the shortcuts from those above us. */ static void -child_removed_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer user_data) +child_removed_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer data) { - g_signal_emit(G_OBJECT(user_data), signals[SHORTCUTS_CHANGED], 0, TRUE); + AppMenuItem * self = APP_MENU_ITEM(data); + AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); + + GList * pitems = priv->shortcuts; + while (pitems != NULL) { + DbusmenuMenuitemProxy * mip = DBUSMENU_MENUITEM_PROXY(pitems->data); + + if (dbusmenu_menuitem_proxy_get_wrapped(mip) == child) { + break; + } + + pitems = g_list_next(pitems); + } + + 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); + } + return; } /* Relay this signal into causing a rebuild of the shortcuts from those above us. */ static void -child_moved_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newpos, guint oldpos, gpointer user_data) +child_moved_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newpos, guint oldpos, gpointer data) { - g_signal_emit(G_OBJECT(user_data), signals[SHORTCUTS_CHANGED], 0, TRUE); + AppMenuItem * self = APP_MENU_ITEM(data); + AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); + + DbusmenuMenuitemProxy * mip = DBUSMENU_MENUITEM_PROXY(g_list_nth_data(priv->shortcuts, oldpos)); + + if (mip != NULL) { + if (dbusmenu_menuitem_proxy_get_wrapped(mip) != child) { + mip = NULL; + } + } + + 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); + } + return; } @@ -348,6 +391,9 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data 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; } g_object_unref(priv->root); priv->root = NULL; @@ -355,7 +401,8 @@ 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 = dbusmenu_menuitem_proxy_new(newroot); + 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); @@ -365,6 +412,10 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data GList * children = dbusmenu_menuitem_get_children(DBUSMENU_MENUITEM(priv->root)); if (children != NULL) { change_time = TRUE; + while (children != NULL) { + DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(DBUSMENU_MENUITEM(children->data)); + priv->shortcuts = g_list_append(priv->shortcuts, mip); + } } if (change_time) { -- cgit v1.2.3 From bcc596a2912f66658058d14f8e30b04cb67915e5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 20:31:16 -0600 Subject: Adding some debug messages --- src/app-menu-item.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/app-menu-item.c') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 53d4afa..57a4e6a 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -384,6 +384,7 @@ child_moved_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newpos, static void 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; @@ -412,6 +413,7 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data 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)); priv->shortcuts = g_list_append(priv->shortcuts, mip); -- cgit v1.2.3 From 0d8b02c5c23e4e66d99481888e8e82baa937ce8f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 20:31:48 -0600 Subject: If we already have children, make sure to process them right away. --- src/app-menu-item.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/app-menu-item.c') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 57a4e6a..19179c8 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -432,12 +432,18 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data static void menu_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * menupath, gpointer data) { + g_debug("Got Menu: %s", menupath); AppMenuItem * self = APP_MENU_ITEM(data); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); priv->client = dbusmenu_client_new(indicate_listener_server_get_dbusname(server), menupath); g_signal_connect(G_OBJECT(priv->client), DBUSMENU_CLIENT_SIGNAL_ROOT_CHANGED, G_CALLBACK(root_changed), self); + DbusmenuMenuitem * root = dbusmenu_client_get_root(priv->client); + if (root != NULL) { + root_changed(priv->client, root, self); + } + return; } -- cgit v1.2.3 From 1df34439fe9a32a2f9f3288d500fdb8a53046185 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 20:41:56 -0600 Subject: Eh, forgot to flesh out the lists --- src/app-menu-item.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/app-menu-item.c') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 19179c8..e24d43b 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -500,5 +500,7 @@ app_menu_item_get_desktop (AppMenuItem * appitem) GList * app_menu_item_get_items (AppMenuItem * appitem) { - return NULL; + g_return_val_if_fail(IS_APP_MENU_ITEM(appitem), NULL); + AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(appitem); + return priv->shortcuts; } -- cgit v1.2.3 From 88f7d844a5bfbbd3797fef798086d0cd3ea1a59c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Feb 2010 20:47:52 -0600 Subject: Did I ever talk to you about why I hate while loops? I have to stop using them. They just lead to bugs. --- src/app-menu-item.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/app-menu-item.c') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index e24d43b..b55de2f 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -417,6 +417,7 @@ root_changed (DbusmenuClient * client, DbusmenuMenuitem * newroot, gpointer data while (children != NULL) { DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(DBUSMENU_MENUITEM(children->data)); priv->shortcuts = g_list_append(priv->shortcuts, mip); + children = g_list_next(children); } } -- cgit v1.2.3 From 536034bb020f39dcf45d9a0d636f3f5dbd55deb7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Feb 2010 08:38:39 -0600 Subject: Setting the listener to NULL after unrefing it. --- src/app-menu-item.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src/app-menu-item.c') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index b55de2f..8e1c50f 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -147,6 +147,7 @@ app_menu_item_dispose (GObject *object) if (priv->listener != NULL) { g_signal_handlers_disconnect_by_func(G_OBJECT(priv->listener), count_changed, self); g_object_unref(priv->listener); + priv->listener = NULL; } if (priv->shortcuts != NULL) { -- cgit v1.2.3 From 06a4fba68ccbdc5b490cd8a9709e4426ec80a0ff Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Feb 2010 08:41:56 -0600 Subject: Adding protection from data fields by checking to ensure they're AppMenuItems --- src/app-menu-item.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/app-menu-item.c') diff --git a/src/app-menu-item.c b/src/app-menu-item.c index 8e1c50f..2fb24f6 100644 --- a/src/app-menu-item.c +++ b/src/app-menu-item.c @@ -254,6 +254,7 @@ update_label (AppMenuItem * self) static void count_changed (IndicateListener * listener, IndicateListenerServer * server, guint count, gpointer data) { + g_return_if_fail(IS_APP_MENU_ITEM(data)); AppMenuItem * self = APP_MENU_ITEM(data); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); @@ -282,6 +283,7 @@ count_cb (IndicateListener * listener, IndicateListenerServer * server, guint va static void desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * value, gpointer data) { + g_return_if_fail(IS_APP_MENU_ITEM(data)); AppMenuItem * self = APP_MENU_ITEM(data); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); @@ -315,6 +317,7 @@ desktop_cb (IndicateListener * listener, IndicateListenerServer * server, gchar static void child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint position, gpointer data) { + g_return_if_fail(IS_APP_MENU_ITEM(data)); AppMenuItem * self = APP_MENU_ITEM(data); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); DbusmenuMenuitemProxy * mip = dbusmenu_menuitem_proxy_new(child); @@ -330,6 +333,7 @@ child_added_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint positio static void child_removed_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer data) { + g_return_if_fail(IS_APP_MENU_ITEM(data)); AppMenuItem * self = APP_MENU_ITEM(data); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); @@ -360,6 +364,7 @@ child_removed_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, gpointer da static void child_moved_cb (DbusmenuMenuitem * root, DbusmenuMenuitem * child, guint newpos, guint oldpos, gpointer data) { + g_return_if_fail(IS_APP_MENU_ITEM(data)); AppMenuItem * self = APP_MENU_ITEM(data); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); @@ -435,6 +440,7 @@ static void menu_cb (IndicateListener * listener, IndicateListenerServer * server, gchar * menupath, gpointer data) { g_debug("Got Menu: %s", menupath); + g_return_if_fail(IS_APP_MENU_ITEM(data)); AppMenuItem * self = APP_MENU_ITEM(data); AppMenuItemPrivate * priv = APP_MENU_ITEM_GET_PRIVATE(self); -- cgit v1.2.3