diff options
author | Evgeni Golov <evgeni@debian.org> | 2010-07-14 10:14:20 +0200 |
---|---|---|
committer | Evgeni Golov <evgeni@debian.org> | 2010-07-14 10:14:20 +0200 |
commit | 674342c670052bcfcc92b7638de9af482ae2a856 (patch) | |
tree | 0432b0802a7b35beaac76d51d797219a4b586d80 /tests/test-gtk-label-server.c | |
parent | 6830905830ac78271515c586442a090cf7a0e3ff (diff) | |
parent | 271f62baede153472711c3dcf2388df3acffa006 (diff) | |
download | libdbusmenu-674342c670052bcfcc92b7638de9af482ae2a856.tar.gz libdbusmenu-674342c670052bcfcc92b7638de9af482ae2a856.tar.bz2 libdbusmenu-674342c670052bcfcc92b7638de9af482ae2a856.zip |
Merged lp:~ubuntu-desktop/dbusmenu/ubuntu
* New upstream release.
∘ Protect against NULL nodes (LP: #602444)
∘ Remove extra warnings and messages
∘ Handle not having a session bus better (LP: #598715)
* New upstream release.
* Block building submenus on separators (LP: #598620)
* Adding more through JSON support for testing
* Fixing up value handling in dbusmenu-dumper
* debian/control, debian/libdbusmenu-jsonloader*install: Adding
two binary packages for the jsonloader test library.
* Merge Ubuntu.
Preserve Maintainer and Vcs-* fields.
* Standards-Version: 3.9.0
* Source-Format: 1.0 for now
- -doc packages are Arch:all
Diffstat (limited to 'tests/test-gtk-label-server.c')
-rw-r--r-- | tests/test-gtk-label-server.c | 71 |
1 files changed, 2 insertions, 69 deletions
diff --git a/tests/test-gtk-label-server.c b/tests/test-gtk-label-server.c index 32d7a43..32572fc 100644 --- a/tests/test-gtk-label-server.c +++ b/tests/test-gtk-label-server.c @@ -30,74 +30,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <libdbusmenu-glib/server.h> #include <json-glib/json-glib.h> - -static void -menuitem_click(DbusmenuMenuitem * mi, guint32 time, gpointer user_data) -{ - g_debug("Clicked on: %d @ %d", dbusmenu_menuitem_get_id(mi), time); - return; -} - -static void -set_props (DbusmenuMenuitem * mi, JsonObject * node) -{ - if (node == NULL) return; - - GList * members = NULL; - for (members = json_object_get_members(node); members != NULL; members = g_list_next(members)) { - const gchar * member = members->data; - - if (!g_strcmp0(member, "id")) { continue; } - if (!g_strcmp0(member, "submenu")) { continue; } - - JsonNode * lnode = json_object_get_member(node, member); - if (JSON_NODE_TYPE(lnode) != JSON_NODE_VALUE) { continue; } - - GValue value = {0}; - json_node_get_value(lnode, &value); - dbusmenu_menuitem_property_set_value(mi, member, &value); - g_value_unset(&value); - } - - return; -} - -static DbusmenuMenuitem * -layout2menuitem (JsonNode * inlayout) -{ - if (inlayout == NULL) return NULL; - if (JSON_NODE_TYPE(inlayout) != JSON_NODE_OBJECT) return NULL; - - JsonObject * layout = json_node_get_object(inlayout); - - DbusmenuMenuitem * local = NULL; - if (json_object_has_member(layout, "id")) { - JsonNode * node = json_object_get_member(layout, "id"); - g_return_val_if_fail(JSON_NODE_TYPE(node) == JSON_NODE_VALUE, NULL); - local = dbusmenu_menuitem_new_with_id(json_node_get_int(node)); - } else { - local = dbusmenu_menuitem_new(); - } - g_signal_connect(G_OBJECT(local), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(menuitem_click), NULL); - - set_props(local, layout); - - if (json_object_has_member(layout, "submenu")) { - JsonNode * node = json_object_get_member(layout, "submenu"); - g_return_val_if_fail(JSON_NODE_TYPE(node) == JSON_NODE_ARRAY, local); - JsonArray * array = json_node_get_array(node); - guint count; - for (count = 0; count < json_array_get_length(array); count++) { - DbusmenuMenuitem * child = layout2menuitem(json_array_get_element(array, count)); - if (child != NULL) { - dbusmenu_menuitem_child_append(local, child); - } - } - } - - /* g_debug("Layout to menu return: 0x%X", (unsigned int)local); */ - return local; -} +#include "json-loader.h" static JsonArray * root_array = NULL; static guint layouton = 0; @@ -114,7 +47,7 @@ timer_func (gpointer data) } g_debug("Updating to Layout %d", layouton); - dbusmenu_server_set_root(server, layout2menuitem(json_array_get_element(root_array, layouton))); + dbusmenu_server_set_root(server, dbusmenu_json_build_from_node(json_array_get_element(root_array, layouton))); layouton++; return TRUE; |