From 981daa0d406ddf15038fc89da6f130cfa7093352 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Feb 2010 12:46:47 -0600 Subject: Changing from a timeout to a signal of change. --- tests/test-glib-proxy-server.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/test-glib-proxy-server.c b/tests/test-glib-proxy-server.c index cba8ec7..7dcae52 100644 --- a/tests/test-glib-proxy-server.c +++ b/tests/test-glib-proxy-server.c @@ -71,7 +71,7 @@ static DbusmenuServer * server = NULL; static GMainLoop * mainloop = NULL; static gboolean -timer_func (gpointer data) +layout_change (DbusmenuMenuitem * oldroot, guint timestamp, gpointer data) { if (layouts[layouton].id == -1) { g_main_loop_quit(mainloop); @@ -80,6 +80,7 @@ timer_func (gpointer data) g_debug("Updating to Layout %d", layouton); DbusmenuMenuitem * mi = layout2menuitem(&layouts[layouton]); + g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(layout_change), NULL); dbusmenu_server_set_root(server, mi); g_object_unref(G_OBJECT(mi)); layouton++; @@ -112,8 +113,9 @@ main (int argc, char ** argv) server = dbusmenu_server_new("/org/test"); - timer_func(NULL); - g_timeout_add(2500, timer_func, NULL); + DbusmenuMenuitem * root = dbusmenu_menuitem_new(); + g_signal_connect(G_OBJECT(root), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(layout_change), NULL); + dbusmenu_server_set_root(server, root); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From 7243d998da4d037d4afc94d89cae05966a7ed364 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Feb 2010 12:56:24 -0600 Subject: Setting signals back down the pipe --- tests/test-glib-proxy-client.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tests/test-glib-proxy-client.c b/tests/test-glib-proxy-client.c index 50ad5d3..36b553a 100644 --- a/tests/test-glib-proxy-client.c +++ b/tests/test-glib-proxy-client.c @@ -119,7 +119,15 @@ layout_updated (DbusmenuClient * client, gpointer data) return; } layouton++; - g_timeout_add (1500, layout_verify_timer, client); + if (layouton != 0) { + 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); + } return; } @@ -143,6 +151,11 @@ layout_verify_timer (gpointer data) g_main_loop_quit(mainloop); } + GValue value = {0}; + g_value_init(&value, G_TYPE_INT); + g_value_set_int(&value, 0); + dbusmenu_menuitem_handle_event(menuroot, "clicked", &value, layouton); + return FALSE; } -- cgit v1.2.3 From 2912cd25c85d03bd8250b75080a0463f7c3ffd3e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Feb 2010 12:56:56 -0600 Subject: Shorter timeout. --- tests/test-glib-proxy-client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test-glib-proxy-client.c b/tests/test-glib-proxy-client.c index 36b553a..4a24172 100644 --- a/tests/test-glib-proxy-client.c +++ b/tests/test-glib-proxy-client.c @@ -144,7 +144,7 @@ layout_verify_timer (gpointer data) } else { /* Extend our death */ g_source_remove(death_timer); - death_timer = g_timeout_add_seconds(10, timer_func, data); + death_timer = g_timeout_add_seconds(2, timer_func, data); } if (layouts[layouton+1].id == -1) { @@ -167,7 +167,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(10, timer_func, client); + death_timer = g_timeout_add_seconds(2, timer_func, client); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From 0df9435e0859a16e5b36d6964bcd38ca470bed5e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Feb 2010 13:07:15 -0600 Subject: Adding a timeout to the server --- tests/test-glib-proxy-server.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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); -- cgit v1.2.3 From 8630ce1c8e41a45ba83d8f49b517095ed25617d5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Feb 2010 13:49:53 -0600 Subject: Starting in the right place --- tests/test-glib-proxy-client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test-glib-proxy-client.c b/tests/test-glib-proxy-client.c index 4a24172..fc3eac6 100644 --- a/tests/test-glib-proxy-client.c +++ b/tests/test-glib-proxy-client.c @@ -26,7 +26,7 @@ with this program. If not, see . #include "test-glib-proxy.h" -static guint layouton = -1; +static guint layouton = -2; static GMainLoop * mainloop = NULL; static gboolean passed = TRUE; static guint death_timer = 0; @@ -119,7 +119,7 @@ layout_updated (DbusmenuClient * client, gpointer data) return; } layouton++; - if (layouton != 0) { + if (layouton != -1) { g_timeout_add (1500, layout_verify_timer, client); } else { DbusmenuMenuitem * mi = dbusmenu_client_get_root(client); -- cgit v1.2.3 From 2ad7f9ec616163f8de67700a99b1dbdd5d6b003d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Feb 2010 13:50:01 -0600 Subject: Adding a submenu to get layout changed. --- tests/test-glib-proxy.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-glib-proxy.h b/tests/test-glib-proxy.h index bc12df6..7402ecd 100644 --- a/tests/test-glib-proxy.h +++ b/tests/test-glib-proxy.h @@ -132,7 +132,7 @@ proplayout_t submenu_5_1[] = { }; proplayout_t layouts[] = { - {id: 1, properties: props1, submenu: NULL}, + {id: 1, properties: props1, submenu: submenu_5_5}, {id: 10, properties: props2, submenu: submenu_4_1}, {id: 20, properties: props3, submenu: submenu_4_2}, {id: 100, properties: props2, submenu: submenu_4_0}, -- cgit v1.2.3 From feada06b32e4bcf70a05de8a3669ff07449dc750 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Feb 2010 15:12:21 -0600 Subject: Putting the layout number on the root element --- tests/test-glib-proxy-client.c | 28 ++++++++++++++++------------ tests/test-glib-proxy-server.c | 1 + 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 . #include +#define LAYOUT_ON "proxy-layout-on" + typedef struct _proplayout_t proplayout_t; struct _proplayout_t { gint id; -- cgit v1.2.3 From 5e7f04b944d0fd52b38697a6bfdf7df0e61aa83a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Feb 2010 15:16:29 -0600 Subject: No dummy update --- tests/test-glib-proxy-server.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/test-glib-proxy-server.c b/tests/test-glib-proxy-server.c index 4fa0844..f32b426 100644 --- a/tests/test-glib-proxy-server.c +++ b/tests/test-glib-proxy-server.c @@ -79,12 +79,12 @@ timer_func (gpointer data) return FALSE; } -static gboolean +static void layout_change (DbusmenuMenuitem * oldroot, guint timestamp, gpointer data) { if (layouts[layouton].id == -1) { g_main_loop_quit(mainloop); - return FALSE; + return; } g_debug("Updating to Layout %d", layouton); @@ -96,10 +96,12 @@ layout_change (DbusmenuMenuitem * oldroot, guint timestamp, gpointer data) layouton++; /* Extend our death */ - g_source_remove(death_timer); - death_timer = g_timeout_add_seconds(2, timer_func, data); + if (death_timer != 0) { + g_source_remove(death_timer); + } + death_timer = g_timeout_add_seconds(4, timer_func, data); - return TRUE; + return; } int @@ -126,12 +128,7 @@ main (int argc, char ** argv) } server = dbusmenu_server_new("/org/test"); - - DbusmenuMenuitem * root = dbusmenu_menuitem_new(); - 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); + layout_change(NULL, 0, NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From aceec4edeaaca20cebfe894a51e4ce681fa5fa95 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Feb 2010 15:17:38 -0600 Subject: Don't need to send a signal at start --- tests/test-glib-proxy-client.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/tests/test-glib-proxy-client.c b/tests/test-glib-proxy-client.c index 5cdd7a1..cb26163 100644 --- a/tests/test-glib-proxy-client.c +++ b/tests/test-glib-proxy-client.c @@ -122,13 +122,8 @@ layout_updated (DbusmenuClient * client, gpointer data) 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); + verify_timer = g_timeout_add (2500, layout_verify_timer, client); return; } -- cgit v1.2.3 From cba26859bdea6cfeb19d3e9b2ceb7a40ab7cb470 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 19 Feb 2010 15:41:56 -0600 Subject: Longer timeout :-/ --- tests/test-glib-proxy-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-glib-proxy-client.c b/tests/test-glib-proxy-client.c index cb26163..0ae2e20 100644 --- a/tests/test-glib-proxy-client.c +++ b/tests/test-glib-proxy-client.c @@ -123,7 +123,7 @@ layout_updated (DbusmenuClient * client, gpointer data) g_source_remove(verify_timer); } - verify_timer = g_timeout_add (2500, layout_verify_timer, client); + verify_timer = g_timeout_add (3000, layout_verify_timer, client); return; } -- cgit v1.2.3