diff options
-rw-r--r-- | libdbusmenu-glib/client.c | 3 | ||||
-rw-r--r-- | libdbusmenu-glib/menuitem.c | 41 | ||||
-rw-r--r-- | libdbusmenu-glib/menuitem.h | 3 |
3 files changed, 47 insertions, 0 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index b9a5b90..7319a7f 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -538,6 +538,9 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it /* Build a new item */ item = dbusmenu_menuitem_new_with_id(id); + if (parent == NULL) { + dbusmenu_menuitem_set_root(item, TRUE); + } g_signal_emit(G_OBJECT(client), signals[NEW_MENUITEM], 0, item, TRUE); /* Get the properties queued up for this item */ org_freedesktop_dbusmenu_get_properties_async(proxy, id, menuitem_get_properties_cb, item); diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 57f1832..8a3d12b 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -39,6 +39,7 @@ License version 3 and version 2.1 along with this program. If not, see @children: A list of #DbusmenuMenuitem objects that are children to this one. @properties: All of the properties on this menu item. + @root: Whether this node is the root node These are the little secrets that we don't want getting out of data that we have. They can still be gotten using @@ -50,6 +51,7 @@ struct _DbusmenuMenuitemPrivate guint id; GList * children; GHashTable * properties; + gboolean root; }; /* Signals */ @@ -197,6 +199,8 @@ dbusmenu_menuitem_init (DbusmenuMenuitem *self) priv->children = NULL; priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); + + priv->root = FALSE; return; } @@ -745,6 +749,43 @@ dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi) } /** + dbusmenu_menuitem_set_root: + @mi: #DbusmenuMenuitem to set whether it's root + @root: Whether @mi is a root node or not + + This function sets the internal value of whether this is a + root node or not. + + Return value: None +*/ +void +dbusmenu_menuitem_set_root (DbusmenuMenuitem * mi, gboolean root) +{ + g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); + DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); + priv->root = root; + return; +} + +/** + dbusmenu_menuitem_get_root: + @mi: #DbusmenuMenuitem to see whether it's root + + This function returns the internal value of whether this is a + root node or not. + + Return value: #TRUE if this is a root node +*/ +gboolean +dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi) +{ + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), FALSE); + DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); + return priv->root; +} + + +/** dbusmenu_menuitem_buildxml: @mi: #DbusmenuMenuitem to represent in XML @array: A list of string that will be turned into an XML file diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index bad687b..29865c7 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -123,6 +123,9 @@ gboolean dbusmenu_menuitem_property_exist (DbusmenuMenuitem * mi, const gchar * GList * dbusmenu_menuitem_properties_list (DbusmenuMenuitem * mi) G_GNUC_WARN_UNUSED_RESULT; GHashTable * dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi); +void dbusmenu_menuitem_set_root (DbusmenuMenuitem * mi, gboolean root); +gboolean dbusmenu_menuitem_get_root (DbusmenuMenuitem * mi); + void dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array); void dbusmenu_menuitem_foreach (DbusmenuMenuitem * mi, void (*func) (DbusmenuMenuitem * mi, gpointer data), gpointer data); void dbusmenu_menuitem_activate (DbusmenuMenuitem * mi); |