2
A test for libdbusmenu to ensure its quality.
4
Copyright 2009 Canonical Ltd.
7
Ted Gould <ted@canonical.com>
9
This program is free software: you can redistribute it and/or modify it
10
under the terms of the GNU General Public License version 3, as published
11
by the Free Software Foundation.
13
This program is distributed in the hope that it will be useful, but
14
WITHOUT ANY WARRANTY; without even the implied warranties of
15
MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
16
PURPOSE. See the GNU General Public License for more details.
18
You should have received a copy of the GNU General Public License along
19
with this program. If not, see <http://www.gnu.org/licenses/>.
24
#include <dbus/dbus.h>
25
#include <dbus/dbus-glib.h>
26
#include <dbus/dbus-glib-lowlevel.h>
28
#include <libdbusmenu-glib/server.h>
29
#include <libdbusmenu-glib/menuitem.h>
31
#include "test-glib-layout.h"
34
static DbusmenuMenuitem *
35
layout2menuitem (layout_t * layout)
37
if (layout == NULL || layout->id == 0) return NULL;
39
DbusmenuMenuitem * local = dbusmenu_menuitem_new_with_id(layout->id);
41
if (layout->submenu != NULL) {
43
for (count = 0; layout->submenu[count].id != 0; count++) {
44
DbusmenuMenuitem * child = layout2menuitem(&layout->submenu[count]);
46
dbusmenu_menuitem_child_append(local, child);
51
g_debug("Layout to menu return: 0x%X", (unsigned int)local);
55
static guint layouton = 0;
56
static DbusmenuServer * server = NULL;
57
static GMainLoop * mainloop = NULL;
60
timer_func (gpointer data)
62
if (layouts[layouton].id == 0) {
63
g_main_loop_quit(mainloop);
66
g_debug("Updating to Layout %d", layouton);
68
dbusmenu_server_set_root(server, layout2menuitem(&layouts[layouton]));
75
main (int argc, char ** argv)
79
g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL))));
81
server = dbusmenu_server_new("/org/test");
84
g_timeout_add(2500, timer_func, NULL);
86
mainloop = g_main_loop_new(NULL, FALSE);
87
g_main_loop_run(mainloop);