diff options
author | Cody Russell <crussell@canonical.com> | 2010-06-21 14:47:08 -0500 |
---|---|---|
committer | Cody Russell <crussell@canonical.com> | 2010-06-21 14:47:08 -0500 |
commit | c4eb1c83cb2bc10c1cfb2346a83182f09e159e53 (patch) | |
tree | 5e640a3f32b597dd406cbd425d1ced9b5e5ab3ff /libdbusmenu-glib | |
parent | cfdd33a19758224cb835efa705a410d3d4d0db91 (diff) | |
parent | 3d800bf9b0133a613d28c31957c081d157a89af8 (diff) | |
download | libdbusmenu-c4eb1c83cb2bc10c1cfb2346a83182f09e159e53.tar.gz libdbusmenu-c4eb1c83cb2bc10c1cfb2346a83182f09e159e53.tar.bz2 libdbusmenu-c4eb1c83cb2bc10c1cfb2346a83182f09e159e53.zip |
Mainline merge, resolve conflicts.
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r-- | libdbusmenu-glib/client.c | 28 | ||||
-rw-r--r-- | libdbusmenu-glib/menuitem.c | 20 | ||||
-rw-r--r-- | libdbusmenu-glib/menuitem.h | 2 |
3 files changed, 50 insertions, 0 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index c0d3b7a..fa233a4 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -30,6 +30,8 @@ License version 3 and version 2.1 along with this program. If not, see #include "config.h" #endif +#include <dbus/dbus-glib-bindings.h> + #include <libxml/parser.h> #include <libxml/tree.h> @@ -397,6 +399,25 @@ dbus_owner_change (DBusGProxy * proxy, const gchar * name, const gchar * prev, c return build_proxies(client); } +/* This is the response to see if the name has an owner. If + it does, then we should build the proxies here. Race condition + check. */ +static void +name_owner_check (DBusGProxy *proxy, gboolean has_owner, GError *error, gpointer userdata) +{ + if (error != NULL) { + return; + } + + if (!has_owner) { + return; + } + + DbusmenuClient * client = DBUSMENU_CLIENT(userdata); + build_proxies(client); + return; +} + /* This function builds the DBus proxy which will look out for the service coming up. */ static void @@ -426,6 +447,13 @@ build_dbus_proxy (DbusmenuClient * client) dbus_g_proxy_connect_signal(priv->dbusproxy, "NameOwnerChanged", G_CALLBACK(dbus_owner_change), client, NULL); + /* Now let's check to make sure we're not in some race + condition case. */ + org_freedesktop_DBus_name_has_owner_async(priv->dbusproxy, + priv->dbus_name, + name_owner_check, + client); + return; } diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 93c7d38..623539c 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -517,6 +517,9 @@ dbusmenu_menuitem_take_children (DbusmenuMenuitem * mi) GList * children = priv->children; priv->children = NULL; g_list_foreach(children, take_children_signal, mi); + + dbusmenu_menuitem_property_remove(mi, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY); + return children; } @@ -622,6 +625,10 @@ dbusmenu_menuitem_child_append (DbusmenuMenuitem * mi, DbusmenuMenuitem * child) DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); g_return_val_if_fail(g_list_find(priv->children, child) == NULL, FALSE); + if (priv->children == NULL && !dbusmenu_menuitem_property_exist(mi, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY)) { + dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY, DBUSMENU_MENUITEM_CHILD_DISPLAY_SUBMENU); + } + priv->children = g_list_append(priv->children, child); #ifdef MASSIVEDEBUGGING g_debug("Menuitem %d (%s) signalling child added %d (%s) at %d", ID(mi), LABEL(mi), ID(child), LABEL(child), g_list_length(priv->children) - 1); @@ -650,6 +657,10 @@ dbusmenu_menuitem_child_prepend (DbusmenuMenuitem * mi, DbusmenuMenuitem * child DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); g_return_val_if_fail(g_list_find(priv->children, child) == NULL, FALSE); + if (priv->children == NULL && !dbusmenu_menuitem_property_exist(mi, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY)) { + dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY, DBUSMENU_MENUITEM_CHILD_DISPLAY_SUBMENU); + } + priv->children = g_list_prepend(priv->children, child); #ifdef MASSIVEDEBUGGING g_debug("Menuitem %d (%s) signalling child added %d (%s) at %d", ID(mi), LABEL(mi), ID(child), LABEL(child), 0); @@ -683,6 +694,11 @@ dbusmenu_menuitem_child_delete (DbusmenuMenuitem * mi, DbusmenuMenuitem * child) #endif g_signal_emit(G_OBJECT(mi), signals[CHILD_REMOVED], 0, child, TRUE); g_object_unref(G_OBJECT(child)); + + if (priv->children == NULL) { + dbusmenu_menuitem_property_remove(mi, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY); + } + return TRUE; } @@ -707,6 +723,10 @@ dbusmenu_menuitem_child_add_position (DbusmenuMenuitem * mi, DbusmenuMenuitem * DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); g_return_val_if_fail(g_list_find(priv->children, child) == NULL, FALSE); + if (priv->children == NULL && !dbusmenu_menuitem_property_exist(mi, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY)) { + dbusmenu_menuitem_property_set(mi, DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY, DBUSMENU_MENUITEM_CHILD_DISPLAY_SUBMENU); + } + priv->children = g_list_insert(priv->children, child, position); #ifdef MASSIVEDEBUGGING g_debug("Menuitem %d (%s) signalling child added %d (%s) at %d", ID(mi), LABEL(mi), ID(child), LABEL(child), position); diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 77997ba..e17d851 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -59,6 +59,7 @@ G_BEGIN_DECLS #define DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE "toggle-type" #define DBUSMENU_MENUITEM_PROP_TOGGLE_STATE "toggle-state" #define DBUSMENU_MENUITEM_PROP_SHORTCUT "shortcut" +#define DBUSMENU_MENUITEM_PROP_CHILD_DISPLAY "children-display" #define DBUSMENU_MENUITEM_TOGGLE_CHECK "checkmark" #define DBUSMENU_MENUITEM_TOGGLE_RADIO "radio" @@ -74,6 +75,7 @@ G_BEGIN_DECLS #define DBUSMENU_MENUITEM_SHORTCUT_SHIFT "Shift" #define DBUSMENU_MENUITEM_SHORTCUT_SUPER "Super" +#define DBUSMENU_MENUITEM_CHILD_DISPLAY_SUBMENU "submenu" /** * DbusmenuMenuitem: |