aboutsummaryrefslogtreecommitdiff
path: root/tests/test-gtk-label-server.c
diff options
context:
space:
mode:
authorSebastien Bacher <seb128@ubuntu.com>2011-01-13 15:09:17 -0600
committerSebastien Bacher <seb128@ubuntu.com>2011-01-13 15:09:17 -0600
commit2dbf76884c921e35ea77c8faa9a7bb3cf9ecc3f0 (patch)
tree78ae1af1d48db003f296db1e1fbc584f5faf1e82 /tests/test-gtk-label-server.c
parent6cc24ff51aab2888b854fb61d2c5b12d89b77f29 (diff)
parentbdea6b479fe42197519c98900f726c53b9e8e66f (diff)
downloadlibdbusmenu-2dbf76884c921e35ea77c8faa9a7bb3cf9ecc3f0.tar.gz
libdbusmenu-2dbf76884c921e35ea77c8faa9a7bb3cf9ecc3f0.tar.bz2
libdbusmenu-2dbf76884c921e35ea77c8faa9a7bb3cf9ecc3f0.zip
releasing version 0.3.91-0ubuntu1
Diffstat (limited to 'tests/test-gtk-label-server.c')
-rw-r--r--tests/test-gtk-label-server.c52
1 files changed, 28 insertions, 24 deletions
diff --git a/tests/test-gtk-label-server.c b/tests/test-gtk-label-server.c
index 32572fc..ddf8fcf 100644
--- a/tests/test-gtk-label-server.c
+++ b/tests/test-gtk-label-server.c
@@ -20,11 +20,7 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <glib.h>
-
-#include <dbus/dbus.h>
-#include <dbus/dbus-glib.h>
-#include <dbus/dbus-glib-lowlevel.h>
-#include <dbus/dbus-glib-bindings.h>
+#include <gio/gio.h>
#include <libdbusmenu-glib/menuitem.h>
#include <libdbusmenu-glib/server.h>
@@ -53,6 +49,25 @@ timer_func (gpointer data)
return TRUE;
}
+static void
+on_bus (GDBusConnection * connection, const gchar * name, gpointer user_data)
+{
+ server = dbusmenu_server_new("/org/test");
+
+ timer_func(NULL);
+ g_timeout_add_seconds(5, timer_func, NULL);
+
+ return;
+}
+
+static void
+name_lost (GDBusConnection * connection, const gchar * name, gpointer user_data)
+{
+ g_error("Unable to get name '%s' on DBus", name);
+ g_main_loop_quit(mainloop);
+ return;
+}
+
int
main (int argc, char ** argv)
{
@@ -73,26 +88,15 @@ main (int argc, char ** argv)
root_array = json_node_get_array(root_node);
g_debug("%d layouts in test description '%s'", json_array_get_length(root_array), argv[1]);
- DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL);
- g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL))));
- DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS);
- guint nameret = 0;
-
- if (!org_freedesktop_DBus_request_name(bus_proxy, "glib.label.test", 0, &nameret, &error)) {
- g_error("Unable to call to request name");
- return 1;
- }
-
- if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) {
- g_error("Unable to get name");
- return 1;
- }
-
- server = dbusmenu_server_new("/org/test");
-
- timer_func(NULL);
- g_timeout_add_seconds(5, timer_func, NULL);
+ g_bus_own_name(G_BUS_TYPE_SESSION,
+ "glib.label.test",
+ G_BUS_NAME_OWNER_FLAGS_NONE,
+ on_bus,
+ NULL,
+ name_lost,
+ NULL,
+ NULL);
mainloop = g_main_loop_new(NULL, FALSE);
g_main_loop_run(mainloop);