diff options
author | Ted Gould <ted@gould.cx> | 2010-02-19 13:07:15 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-02-19 13:07:15 -0600 |
commit | 0df9435e0859a16e5b36d6964bcd38ca470bed5e (patch) | |
tree | 7ae3978fd79446f7a3f50c8b9ecdb2c592bad05a | |
parent | 2912cd25c85d03bd8250b75080a0463f7c3ffd3e (diff) | |
download | libdbusmenu-0df9435e0859a16e5b36d6964bcd38ca470bed5e.tar.gz libdbusmenu-0df9435e0859a16e5b36d6964bcd38ca470bed5e.tar.bz2 libdbusmenu-0df9435e0859a16e5b36d6964bcd38ca470bed5e.zip |
Adding a timeout to the server
-rw-r--r-- | tests/test-glib-proxy-server.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test-glib-proxy-server.c b/tests/test-glib-proxy-server.c index 7dcae52..14bc0b7 100644 --- a/tests/test-glib-proxy-server.c +++ b/tests/test-glib-proxy-server.c @@ -69,6 +69,15 @@ layout2menuitem (proplayout_t * layout) static guint layouton = 0; static DbusmenuServer * server = NULL; static GMainLoop * mainloop = NULL; +static guint death_timer = 0; + +static gboolean +timer_func (gpointer data) +{ + g_debug("Death timer. Oops. Got to: %d", layouton); + g_main_loop_quit(mainloop); + return FALSE; +} static gboolean layout_change (DbusmenuMenuitem * oldroot, guint timestamp, gpointer data) @@ -85,6 +94,10 @@ layout_change (DbusmenuMenuitem * oldroot, guint timestamp, gpointer data) g_object_unref(G_OBJECT(mi)); layouton++; + /* Extend our death */ + g_source_remove(death_timer); + death_timer = g_timeout_add_seconds(2, timer_func, data); + return TRUE; } @@ -117,6 +130,8 @@ main (int argc, char ** argv) g_signal_connect(G_OBJECT(root), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(layout_change), NULL); dbusmenu_server_set_root(server, root); + death_timer = g_timeout_add_seconds(2, timer_func, NULL); + mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); |