diff options
author | Ted Gould <ted@canonical.com> | 2009-04-16 13:07:25 -0500 |
---|---|---|
committer | Ted Gould <ted@canonical.com> | 2009-04-16 13:07:25 -0500 |
commit | 00eafa4bed235caacd87bc119433577c0e1fa7a9 (patch) | |
tree | 0c5cdba53549d9c7c1e80f2e2cdd0834735e6ca6 | |
parent | c3d826854d0dd3b27b5591d03e70d2c1d903bb37 (diff) | |
download | libdbusmenu-00eafa4bed235caacd87bc119433577c0e1fa7a9.tar.gz libdbusmenu-00eafa4bed235caacd87bc119433577c0e1fa7a9.tar.bz2 libdbusmenu-00eafa4bed235caacd87bc119433577c0e1fa7a9.zip |
Okay, let's build some XML
-rw-r--r-- | libdbusmenu-glib/menuitem.c | 14 | ||||
-rw-r--r-- | libdbusmenu-glib/menuitem.h | 4 | ||||
-rw-r--r-- | libdbusmenu-glib/server.c | 2 |
3 files changed, 16 insertions, 4 deletions
diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index f6cd99e..3aa39c6 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -135,8 +135,20 @@ dbusmenu_menuitem_property_exist (DbusmenuMenuitem * mi, const gchar * property) } void -dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray ** array) +dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array) { + g_return_if_fail(DBUSMENU_IS_MENUITEM(mi)); + + GList * children = dbusmenu_menuitem_get_children(mi); + if (children == NULL) { + g_ptr_array_add(array, g_strdup_printf("<menu id=\"%d\" />", dbusmenu_menuitem_get_id(mi))); + } else { + g_ptr_array_add(array, g_strdup_printf("<menu id=\"%d\">", dbusmenu_menuitem_get_id(mi))); + for ( ; children != NULL; children = children->next) { + dbus_menuitem_buildxml(DBUSMENU_MENUITEM(children->data), array); + } + g_ptr_array_add(array, g_strdup("</menu>")); + } return; } diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index a820d4b..15a07a5 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -28,7 +28,7 @@ struct _DbusmenuMenuitemClass void (*item_activated) (void); /* Virtual functions */ - void (*buildxml) (GPtrArray ** stringarray); + void (*buildxml) (GPtrArray * stringarray); void (*reserved1) (void); void (*reserved2) (void); @@ -54,7 +54,7 @@ gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * pr const gchar * dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property); gboolean dbusmenu_menuitem_property_exist (DbusmenuMenuitem * mi, const gchar * property); -void dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray ** array); +void dbusmenu_menuitem_buildxml (DbusmenuMenuitem * mi, GPtrArray * array); G_END_DECLS diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 70a1482..d8c87bf 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -195,7 +195,7 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) GPtrArray * xmlarray = g_ptr_array_new(); g_ptr_array_add(xmlarray, g_strdup("<menu>")); if (priv->root != NULL) { - dbusmenu_menuitem_buildxml(priv->root, &xmlarray); + dbusmenu_menuitem_buildxml(priv->root, xmlarray); } g_ptr_array_add(xmlarray, g_strdup("</menu>")); g_ptr_array_add(xmlarray, NULL); |