diff options
author | Ted Gould <ted@gould.cx> | 2010-02-19 15:12:21 -0600 |
---|---|---|
committer | Ted Gould <ted@gould.cx> | 2010-02-19 15:12:21 -0600 |
commit | feada06b32e4bcf70a05de8a3669ff07449dc750 (patch) | |
tree | 567b95dc6c53f51699334fe0674694024bd8c29b | |
parent | 2ad7f9ec616163f8de67700a99b1dbdd5d6b003d (diff) | |
download | libdbusmenu-feada06b32e4bcf70a05de8a3669ff07449dc750.tar.gz libdbusmenu-feada06b32e4bcf70a05de8a3669ff07449dc750.tar.bz2 libdbusmenu-feada06b32e4bcf70a05de8a3669ff07449dc750.zip |
Putting the layout number on the root element
-rw-r--r-- | tests/test-glib-proxy-client.c | 28 | ||||
-rw-r--r-- | tests/test-glib-proxy-server.c | 1 | ||||
-rw-r--r-- | tests/test-glib-proxy.h | 2 |
3 files changed, 19 insertions, 12 deletions
diff --git a/tests/test-glib-proxy-client.c b/tests/test-glib-proxy-client.c index fc3eac6..5cdd7a1 100644 --- a/tests/test-glib-proxy-client.c +++ b/tests/test-glib-proxy-client.c @@ -30,6 +30,7 @@ static guint layouton = -2; static GMainLoop * mainloop = NULL; static gboolean passed = TRUE; static guint death_timer = 0; +static guint verify_timer = 0; static gboolean verify_props (DbusmenuMenuitem * mi, gchar ** properties) @@ -118,24 +119,27 @@ layout_updated (DbusmenuClient * client, gpointer data) g_debug("\tIgnored, no root"); return; } - layouton++; - if (layouton != -1) { - g_timeout_add (1500, layout_verify_timer, client); - } else { - DbusmenuMenuitem * mi = dbusmenu_client_get_root(client); - GValue value = {0}; - g_value_init(&value, G_TYPE_INT); - g_value_set_int(&value, 0); - dbusmenu_menuitem_handle_event(mi, "clicked", &value, layouton); + if (verify_timer != 0) { + g_source_remove(verify_timer); } + verify_timer = g_timeout_add (2500, layout_verify_timer, client); + + DbusmenuMenuitem * mi = dbusmenu_client_get_root(client); + GValue value = {0}; + g_value_init(&value, G_TYPE_INT); + g_value_set_int(&value, 0); + dbusmenu_menuitem_handle_event(mi, "clicked", &value, layouton); return; } static gboolean layout_verify_timer (gpointer data) { - g_debug("Verifing Layout: %d", layouton); DbusmenuMenuitem * menuroot = dbusmenu_client_get_root(DBUSMENU_CLIENT(data)); + layouton = dbusmenu_menuitem_property_get_int(menuroot, LAYOUT_ON); + + g_debug("Verifing Layout: %d", layouton); + verify_timer = 0; proplayout_t * layout = &layouts[layouton]; if (!verify_root_to_layout(menuroot, layout)) { @@ -144,7 +148,7 @@ layout_verify_timer (gpointer data) } else { /* Extend our death */ g_source_remove(death_timer); - death_timer = g_timeout_add_seconds(2, timer_func, data); + death_timer = g_timeout_add_seconds(4, timer_func, data); } if (layouts[layouton+1].id == -1) { @@ -167,7 +171,7 @@ main (int argc, char ** argv) DbusmenuClient * client = dbusmenu_client_new("test.proxy.first_proxy", "/org/test"); g_signal_connect(G_OBJECT(client), DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED, G_CALLBACK(layout_updated), NULL); - death_timer = g_timeout_add_seconds(2, timer_func, client); + death_timer = g_timeout_add_seconds(4, timer_func, client); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); diff --git a/tests/test-glib-proxy-server.c b/tests/test-glib-proxy-server.c index 14bc0b7..4fa0844 100644 --- a/tests/test-glib-proxy-server.c +++ b/tests/test-glib-proxy-server.c @@ -90,6 +90,7 @@ layout_change (DbusmenuMenuitem * oldroot, guint timestamp, gpointer data) DbusmenuMenuitem * mi = layout2menuitem(&layouts[layouton]); g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(layout_change), NULL); + dbusmenu_menuitem_property_set_int(mi, LAYOUT_ON, layouton); dbusmenu_server_set_root(server, mi); g_object_unref(G_OBJECT(mi)); layouton++; diff --git a/tests/test-glib-proxy.h b/tests/test-glib-proxy.h index 7402ecd..7bb58b6 100644 --- a/tests/test-glib-proxy.h +++ b/tests/test-glib-proxy.h @@ -22,6 +22,8 @@ with this program. If not, see <http://www.gnu.org/licenses/>. #include <glib.h> +#define LAYOUT_ON "proxy-layout-on" + typedef struct _proplayout_t proplayout_t; struct _proplayout_t { gint id; |