From 9f4213d9d59c84c9c4811a69ee50d4baaab6dc58 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Mon, 19 Jul 2010 12:53:38 +0200 Subject: Started to implement click-to-dump --- tools/Makefile.am | 4 +- tools/dbusmenu-dumper.c | 129 ++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 122 insertions(+), 11 deletions(-) diff --git a/tools/Makefile.am b/tools/Makefile.am index 77d6eef..a36d224 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -10,11 +10,11 @@ dbusmenu_dumper_SOURCES = \ dbusmenu_dumper_CFLAGS = \ -I $(srcdir)/.. \ - $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + $(DBUSMENUGLIB_CFLAGS) -I/usr/include/dbus-1.0 -Wall -Werror dbusmenu_dumper_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ - $(DBUSMENUGLIB_LIBS) + $(DBUSMENUGLIB_LIBS) -lX11 -ldbus-glib-1 doc_DATA = README.dbusmenu-bench diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 55d631e..4a0dd03 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -21,10 +21,13 @@ with this program. If not, see . */ #include +#include #include #include +#include + static GMainLoop * mainloop = NULL; static void @@ -90,10 +93,104 @@ new_root_cb (DbusmenuClient * client, DbusmenuMenuitem * newroot) return; } +static Window +find_real_window(Display * display, Window w, int depth) +{ + if (depth > 5) { + return None; + } + /*static*/ Atom wm_state = XInternAtom(display, "WM_STATE", False); + Atom type; + int format; + unsigned long nitems, after; + unsigned char* prop; + if (XGetWindowProperty(display, w, wm_state, 0, 0, False, AnyPropertyType, + &type, &format, &nitems, &after, &prop) == Success) { + if (prop != NULL) { + XFree(prop); + } + if (type != None) { + return w; + } + } + Window root, parent; + Window* children; + unsigned int nchildren; + Window ret = None; + if (XQueryTree(display, w, &root, &parent, &children, &nchildren) != 0) { + unsigned int i; + for(i = 0; i < nchildren && ret == None; ++i) { + ret = find_real_window(display, children[ i ], depth + 1); + } + if (children != NULL) { + XFree(children); + } + } + return ret; +} + +static Window +get_window_under_cursor() +{ + Display * display = XOpenDisplay(NULL); + g_return_val_if_fail(display != NULL, None); + + Window root; + Window child; + uint mask; + int rootX, rootY, winX, winY; + XGrabServer(display); + Window root_window = DefaultRootWindow(display); + XQueryPointer(display, root_window, &root, &child, &rootX, &rootY, &winX, &winY, &mask); + if (child == None) { + return None; + } + return find_real_window(display, child, 0); +} static gchar * dbusname = NULL; static gchar * dbusobject = NULL; +static gboolean +init_dbus_vars_from_window(Window window) +{ + DBusGConnection *connection; + GError *error; + DBusGProxy *proxy; + + error = NULL; + connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); + if (connection == NULL) { + g_printerr("Failed to open connection to bus: %s\n", error->message); + g_error_free(error); + return FALSE; + } + + proxy = dbus_g_proxy_new_for_name (connection, + "org.ayatana.AppMenu.Registrar", + "/org/ayatana/AppMenu/Registrar", + "org.ayatana.AppMenu.Registrar"); + + error = NULL; + if (!dbus_g_proxy_call (proxy, "GetMenuForWindow", &error, + G_TYPE_UINT, window, G_TYPE_INVALID, + G_TYPE_STRING, &dbusname, DBUS_TYPE_G_OBJECT_PATH, &dbusobject, G_TYPE_INVALID)) + { + g_printerr("ERROR: %s\n", error->message); + g_error_free(error); + g_object_unref(proxy); + return FALSE; + } + + if (!g_strcmp0(dbusobject, "/")) { + return FALSE; + } + + g_object_unref (proxy); + + return TRUE; +} + static gboolean option_dbusname (const gchar * arg, const gchar * value, gpointer data, GError ** error) { @@ -147,16 +244,30 @@ main (int argc, char ** argv) return 1; } - if (dbusname == NULL) { - g_printerr("ERROR: dbus-name not specified\n"); - usage(); - return 1; - } + if (dbusname == NULL && dbusobject == NULL) { + Window window = get_window_under_cursor(); + if (window == None) { + g_printerr("ERROR: could not get the id for the pointed window\n"); + return 1; + } + g_debug("window: %u", (unsigned int)window); + if (!init_dbus_vars_from_window(window)) { + g_printerr("ERROR: could not find a menu for the pointed window\n"); + return 1; + } + g_debug("dbusname: %s, dbusobject: %s", dbusname, dbusobject); + } else { + if (dbusname == NULL) { + g_printerr("ERROR: dbus-name not specified\n"); + usage(); + return 1; + } - if (dbusobject == NULL) { - g_printerr("ERROR: dbus-object not specified\n"); - usage(); - return 1; + if (dbusobject == NULL) { + g_printerr("ERROR: dbus-object not specified\n"); + usage(); + return 1; + } } DbusmenuClient * client = dbusmenu_client_new (dbusname, dbusobject); -- cgit v1.2.3 From 6da7a3341f028d913fd3ad01d47a59f436b5e780 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Mon, 19 Jul 2010 17:21:38 +0200 Subject: Use pkgconfig to find libx11 --- configure.ac | 9 +++++++++ tools/Makefile.am | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index b88d96d..99911fa 100644 --- a/configure.ac +++ b/configure.ac @@ -50,6 +50,15 @@ PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-2.0 >= $GTK_REQUIRED_VERSION AC_SUBST(DBUSMENUGTK_CFLAGS) AC_SUBST(DBUSMENUGTK_LIBS) +########################### +# Dependencies - tools +########################### + +PKG_CHECK_MODULES(DBUSMENUTOOLS, x11) + +AC_SUBST(DBUSMENUTOOLS_CFLAGS) +AC_SUBST(DBUSMENUTOOLS_LIBS) + ########################### # Dependencies - Testing ########################### diff --git a/tools/Makefile.am b/tools/Makefile.am index a36d224..3cd5538 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -10,11 +10,11 @@ dbusmenu_dumper_SOURCES = \ dbusmenu_dumper_CFLAGS = \ -I $(srcdir)/.. \ - $(DBUSMENUGLIB_CFLAGS) -I/usr/include/dbus-1.0 -Wall -Werror + $(DBUSMENUGLIB_CFLAGS) $(DBUSMENUTOOLS_CFLAGS) -Wall -Werror dbusmenu_dumper_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ - $(DBUSMENUGLIB_LIBS) -lX11 -ldbus-glib-1 + $(DBUSMENUGLIB_LIBS) $(DBUSMENUTOOLS_LIBS) doc_DATA = README.dbusmenu-bench -- cgit v1.2.3 From 20ad762cf2fc9511b237007ec7412f6574e09223 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 05:37:35 -0500 Subject: Adding open menu signal --- libdbusmenu-glib/dbus-menu.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 53b67de..f2f1db6 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -344,6 +344,9 @@ License version 3 and version 2.1 along with this program. If not, see + + + -- cgit v1.2.3 From eab9731dcd26336aa44aee62073881919201df6f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 05:48:07 -0500 Subject: Changing to name to match --- libdbusmenu-glib/dbus-menu.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index f2f1db6..b09604b 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -344,7 +344,7 @@ License version 3 and version 2.1 along with this program. If not, see - + -- cgit v1.2.3 From 93c287ff9d2c7029eb275f10cf5f372b0edb54ef Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 05:55:55 -0500 Subject: Docs and a tense fix --- libdbusmenu-glib/dbus-menu.xml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index b09604b..b4f4439 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -344,8 +344,16 @@ License version 3 and version 2.1 along with this program. If not, see - - + + + The server is requesting that all clients displaying this + menu open it to the user. This would be for things like + hotkeys that when the user presses them the menu should + open and display itself to the user. + + + ID of the menu that should be activated + -- cgit v1.2.3 From 646c74694e86d6e5d479028a7dbd8cf9a1aca37a Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Tue, 20 Jul 2010 14:51:23 +0200 Subject: Ripped some code from wnckprop to do proper click-to-dump --- configure.ac | 11 ++++-- tools/Makefile.am | 4 +- tools/dbusmenu-dumper.c | 100 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 109 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 99911fa..2e95d55 100644 --- a/configure.ac +++ b/configure.ac @@ -51,13 +51,16 @@ AC_SUBST(DBUSMENUGTK_CFLAGS) AC_SUBST(DBUSMENUGTK_LIBS) ########################### -# Dependencies - tools +# Dependencies - dumper ########################### -PKG_CHECK_MODULES(DBUSMENUTOOLS, x11) +X11_REQUIRED_VERSION=1.3 -AC_SUBST(DBUSMENUTOOLS_CFLAGS) -AC_SUBST(DBUSMENUTOOLS_LIBS) +PKG_CHECK_MODULES(DBUSMENUDUMPER, gtk+-2.0 >= $GTK_REQUIRED_VERSION + x11 >= $X11_REQUIRED_VERSION) + +AC_SUBST(DBUSMENUDUMPER_CFLAGS) +AC_SUBST(DBUSMENUDUMPER_LIBS) ########################### # Dependencies - Testing diff --git a/tools/Makefile.am b/tools/Makefile.am index 3cd5538..ab7a598 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -10,11 +10,11 @@ dbusmenu_dumper_SOURCES = \ dbusmenu_dumper_CFLAGS = \ -I $(srcdir)/.. \ - $(DBUSMENUGLIB_CFLAGS) $(DBUSMENUTOOLS_CFLAGS) -Wall -Werror + $(DBUSMENUGLIB_CFLAGS) $(DBUSMENUDUMPER_CFLAGS) -Wall -Werror dbusmenu_dumper_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ - $(DBUSMENUGLIB_LIBS) $(DBUSMENUTOOLS_LIBS) + $(DBUSMENUGLIB_LIBS) $(DBUSMENUDUMPER_LIBS) doc_DATA = README.dbusmenu-bench diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 4a0dd03..3a47f21 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -23,6 +23,10 @@ with this program. If not, see . #include #include +#include +#include +#include + #include #include @@ -93,6 +97,12 @@ new_root_cb (DbusmenuClient * client, DbusmenuMenuitem * newroot) return; } +/* Window clicking ***************************************************/ +static GdkFilterReturn +click_filter (GdkXEvent *gdk_xevent, + GdkEvent *event, + gpointer data); + static Window find_real_window(Display * display, Window w, int depth) { @@ -148,6 +158,91 @@ get_window_under_cursor() return find_real_window(display, child, 0); } +static void +uninstall_click_filter (void) +{ + GdkWindow *root; + + root = gdk_get_default_root_window (); + gdk_window_remove_filter (root, (GdkFilterFunc) click_filter, NULL); + + gdk_pointer_ungrab (GDK_CURRENT_TIME); + gdk_keyboard_ungrab (GDK_CURRENT_TIME); + + gtk_main_quit (); +} + +static GdkFilterReturn +click_filter (GdkXEvent *gdk_xevent, + GdkEvent *event, + gpointer data) + +{ + XEvent *xevent = (XEvent *) gdk_xevent; + gboolean *success = (gboolean *)data; + + switch (xevent->type) { + case ButtonPress: + uninstall_click_filter(); + *success = TRUE; + return GDK_FILTER_REMOVE; + case KeyPress: + if (xevent->xkey.keycode == XKeysymToKeycode(gdk_display, XK_Escape)) { + uninstall_click_filter(); + *success = FALSE; + return GDK_FILTER_REMOVE; + } + break; + default: + break; + } + + return GDK_FILTER_CONTINUE; +} + +static gboolean +install_click_filter (gpointer data) +{ + GdkGrabStatus status; + GdkCursor *cross; + GdkWindow *root; + + root = gdk_get_default_root_window(); + + gdk_window_add_filter(root, (GdkFilterFunc) click_filter, data); + + cross = gdk_cursor_new(GDK_CROSS); + status = gdk_pointer_grab(root, FALSE, GDK_BUTTON_PRESS_MASK, + NULL, cross, GDK_CURRENT_TIME); + gdk_cursor_unref(cross); + + if (status != GDK_GRAB_SUCCESS) { + g_warning("Pointer grab failed.\n"); + uninstall_click_filter(); + return FALSE; + } + + status = gdk_keyboard_grab(root, FALSE, GDK_CURRENT_TIME); + if (status != GDK_GRAB_SUCCESS) { + g_warning("Keyboard grab failed.\n"); + uninstall_click_filter(); + return FALSE; + } + + gdk_flush(); + return FALSE; +} + +static gboolean +wait_for_click (int argc, char **argv) +{ + gtk_init(&argc, &argv); + gboolean success; + g_idle_add (install_click_filter, (gpointer)(&success)); + gtk_main (); + return success; +} + static gchar * dbusname = NULL; static gchar * dbusobject = NULL; @@ -191,6 +286,7 @@ init_dbus_vars_from_window(Window window) return TRUE; } +/* Option parser *****************************************************/ static gboolean option_dbusname (const gchar * arg, const gchar * value, gpointer data, GError ** error) { @@ -245,6 +341,9 @@ main (int argc, char ** argv) } if (dbusname == NULL && dbusobject == NULL) { + if (!wait_for_click(argc, argv)) { + return 1; + } Window window = get_window_under_cursor(); if (window == None) { g_printerr("ERROR: could not get the id for the pointed window\n"); @@ -256,6 +355,7 @@ main (int argc, char ** argv) return 1; } g_debug("dbusname: %s, dbusobject: %s", dbusname, dbusobject); + return 1; } else { if (dbusname == NULL) { g_printerr("ERROR: dbus-name not specified\n"); -- cgit v1.2.3 From 463b05a77a8e21e60ffe197f58461b0fb02ed930 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Tue, 20 Jul 2010 14:58:16 +0200 Subject: Clean up --- tools/dbusmenu-dumper.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 3a47f21..4ddb057 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -104,17 +104,17 @@ click_filter (GdkXEvent *gdk_xevent, gpointer data); static Window -find_real_window(Display * display, Window w, int depth) +find_real_window (Window w, int depth) { if (depth > 5) { return None; } - /*static*/ Atom wm_state = XInternAtom(display, "WM_STATE", False); + /*static*/ Atom wm_state = XInternAtom(gdk_display, "WM_STATE", False); Atom type; int format; unsigned long nitems, after; unsigned char* prop; - if (XGetWindowProperty(display, w, wm_state, 0, 0, False, AnyPropertyType, + if (XGetWindowProperty(gdk_display, w, wm_state, 0, 0, False, AnyPropertyType, &type, &format, &nitems, &after, &prop) == Success) { if (prop != NULL) { XFree(prop); @@ -127,10 +127,10 @@ find_real_window(Display * display, Window w, int depth) Window* children; unsigned int nchildren; Window ret = None; - if (XQueryTree(display, w, &root, &parent, &children, &nchildren) != 0) { + if (XQueryTree(gdk_display, w, &root, &parent, &children, &nchildren) != 0) { unsigned int i; for(i = 0; i < nchildren && ret == None; ++i) { - ret = find_real_window(display, children[ i ], depth + 1); + ret = find_real_window(children[ i ], depth + 1); } if (children != NULL) { XFree(children); @@ -140,22 +140,17 @@ find_real_window(Display * display, Window w, int depth) } static Window -get_window_under_cursor() +get_window_under_cursor (void) { - Display * display = XOpenDisplay(NULL); - g_return_val_if_fail(display != NULL, None); - Window root; Window child; uint mask; int rootX, rootY, winX, winY; - XGrabServer(display); - Window root_window = DefaultRootWindow(display); - XQueryPointer(display, root_window, &root, &child, &rootX, &rootY, &winX, &winY, &mask); + XQueryPointer(gdk_display, gdk_x11_get_default_root_xwindow(), &root, &child, &rootX, &rootY, &winX, &winY, &mask); if (child == None) { return None; } - return find_real_window(display, child, 0); + return find_real_window(child, 0); } static void @@ -234,9 +229,8 @@ install_click_filter (gpointer data) } static gboolean -wait_for_click (int argc, char **argv) +wait_for_click (void) { - gtk_init(&argc, &argv); gboolean success; g_idle_add (install_click_filter, (gpointer)(&success)); gtk_main (); @@ -341,7 +335,8 @@ main (int argc, char ** argv) } if (dbusname == NULL && dbusobject == NULL) { - if (!wait_for_click(argc, argv)) { + gtk_init(&argc, &argv); + if (!wait_for_click()) { return 1; } Window window = get_window_under_cursor(); -- cgit v1.2.3 From 70961ba202ced579d434e19f185f442684814722 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Tue, 20 Jul 2010 15:03:39 +0200 Subject: Unbreak command line parser --- tools/dbusmenu-dumper.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 4ddb057..82ca5c1 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -314,7 +314,8 @@ usage (void) static GOptionEntry general_options[] = { {"dbus-name", 'd', 0, G_OPTION_ARG_CALLBACK, option_dbusname, "The name of the program to connect to (i.e. org.test.bob", "dbusname"}, - {"dbus-object", 'o', 0, G_OPTION_ARG_CALLBACK, option_dbusobject, "The path to the Dbus object (i.e /org/test/bob/alvin)", "dbusobject"} + {"dbus-object", 'o', 0, G_OPTION_ARG_CALLBACK, option_dbusobject, "The path to the Dbus object (i.e /org/test/bob/alvin)", "dbusobject"}, + {NULL} }; int @@ -350,7 +351,6 @@ main (int argc, char ** argv) return 1; } g_debug("dbusname: %s, dbusobject: %s", dbusname, dbusobject); - return 1; } else { if (dbusname == NULL) { g_printerr("ERROR: dbus-name not specified\n"); -- cgit v1.2.3 From 63bb196ef8482430bbf742a7a6389a9897766f43 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 08:18:22 -0500 Subject: Adding a timestamp --- libdbusmenu-glib/dbus-menu.xml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index b4f4439..9e8013c 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -354,6 +354,9 @@ License version 3 and version 2.1 along with this program. If not, see ID of the menu that should be activated + + The time that the event occured + -- cgit v1.2.3 From 3d98145e318bb486451603c2a312e65c14ea809f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 16:09:35 -0500 Subject: Building the signal slot --- libdbusmenu-glib/server.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index f4e3527..4daf448 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -58,10 +58,10 @@ G_BEGIN_DECLS @id_prop_update: Slot for #DbusmenuServer::id-prop-update. @id_update: Slot for #DbusmenuServer::id-update. @layout_updated: Slot for #DbusmenuServer::layout-update. + @item_activation_requested: Slot for #DbusmenuServer::item-activation-requested. @dbusmenu_server_reserved1: Reserved for future use. @dbusmenu_server_reserved2: Reserved for future use. @dbusmenu_server_reserved3: Reserved for future use. - @dbusmenu_server_reserved4: Reserved for future use. The class implementing the virtual functions for #DbusmenuServer. */ @@ -73,12 +73,12 @@ struct _DbusmenuServerClass { void (*id_prop_update)(gint id, gchar * property, gchar * value); void (*id_update)(gint id); void (*layout_updated)(gint revision); + void (*item_activation_requested)(gint id, guint timestamp); /* Reserved */ void (*dbusmenu_server_reserved1)(void); void (*dbusmenu_server_reserved2)(void); void (*dbusmenu_server_reserved3)(void); - void (*dbusmenu_server_reserved4)(void); }; /** -- cgit v1.2.3 From 903aaf402c081506173b31c755fe58338b6cd930 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 16:15:25 -0500 Subject: Actually build the signal and put it on the object. --- libdbusmenu-glib/server-marshal.list | 1 + libdbusmenu-glib/server.c | 17 +++++++++++++++++ libdbusmenu-glib/server.h | 3 ++- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/server-marshal.list b/libdbusmenu-glib/server-marshal.list index 1689a05..0d68c4e 100644 --- a/libdbusmenu-glib/server-marshal.list +++ b/libdbusmenu-glib/server-marshal.list @@ -1,2 +1,3 @@ VOID: INT, STRING, POINTER VOID: UINT, INT +VOID: INT, UINT diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 13c2843..deee5da 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -65,6 +65,7 @@ enum { ID_PROP_UPDATE, ID_UPDATE, LAYOUT_UPDATED, + ITEM_ACTIVATION, LAST_SIGNAL }; @@ -165,6 +166,22 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) NULL, NULL, _dbusmenu_server_marshal_VOID__UINT_INT, G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_INT); + /** + DbusmenuServer::item-activation-requested: + @arg0: The #DbusmenuServer emitting the signal. + @arg1: The ID of the parent for this update. + @arg2: The timestamp of when the event happened + + This is signaled when a menuitem under this server + sends it's activate signal. + */ + signals[ITEM_ACTIVATION] = g_signal_new(DBUSMENU_SERVER_SIGNAL_ITEM_ACTIVATION, + G_TYPE_FROM_CLASS(class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(DbusmenuServerClass, item_activation), + NULL, NULL, + _dbusmenu_server_marshal_VOID__INT_UINT, + G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_UINT); g_object_class_install_property (object_class, PROP_DBUS_OBJECT, diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index 4daf448..a9bf213 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -46,6 +46,7 @@ G_BEGIN_DECLS #define DBUSMENU_SERVER_SIGNAL_ID_PROP_UPDATE "item-property-updated" #define DBUSMENU_SERVER_SIGNAL_ID_UPDATE "item-updated" #define DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATED "layout-updated" +#define DBUSMENU_SERVER_SIGNAL_ITEM_ACTIVATION "item-activation-requested" #define DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATE DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATED #define DBUSMENU_SERVER_PROP_DBUS_OBJECT "dbus-object" @@ -73,7 +74,7 @@ struct _DbusmenuServerClass { void (*id_prop_update)(gint id, gchar * property, gchar * value); void (*id_update)(gint id); void (*layout_updated)(gint revision); - void (*item_activation_requested)(gint id, guint timestamp); + void (*item_activation)(gint id, guint timestamp); /* Reserved */ void (*dbusmenu_server_reserved1)(void); -- cgit v1.2.3 From 4fbfb66b98d31283facfd425a91d084c61288ac8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 16:21:13 -0500 Subject: Setting up listening on the menuitems to send the activate signal over. --- libdbusmenu-glib/server.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index deee5da..aa8dfac 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -376,6 +376,15 @@ menuitem_child_moved (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint return; } +/* Called when a menu item emits its activated signal so it + gets passed across the bus. */ +static void +menuitem_activated (DbusmenuMenuitem * mi, guint timestamp, DbusmenuServer * server) +{ + g_signal_emit(G_OBJECT(server), signals[ITEM_ACTIVATION], 0, dbusmenu_menuitem_get_id(mi), timestamp, TRUE); + return; +} + /* Connects all the signals that we're interested in coming from a menuitem */ static void @@ -385,6 +394,7 @@ menuitem_signals_create (DbusmenuMenuitem * mi, gpointer data) g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_CHILD_REMOVED, G_CALLBACK(menuitem_child_removed), data); g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_CHILD_MOVED, G_CALLBACK(menuitem_child_moved), data); g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menuitem_property_changed), data); + g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(menuitem_activated), data); return; } -- cgit v1.2.3 From ec7452bf38e9e58c2a87ff460b861473b90f321d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 16:38:48 -0500 Subject: Autogen update --- configure | 145 ++++++++++++++++++++++++++++++++++++++++++++++++------ debian/changelog | 3 +- tools/Makefile.in | 12 +++-- 3 files changed, 142 insertions(+), 18 deletions(-) diff --git a/configure b/configure index 8d57d1f..479eed5 100755 --- a/configure +++ b/configure @@ -776,6 +776,8 @@ INTROSPECTION_COMPILER INTROSPECTION_SCANNER DBUSMENUTESTS_LIBS DBUSMENUTESTS_CFLAGS +DBUSMENUDUMPER_LIBS +DBUSMENUDUMPER_CFLAGS DBUSMENUGTK_LIBS DBUSMENUGTK_CFLAGS DBUSMENUGLIB_LIBS @@ -981,6 +983,8 @@ DBUSMENUGLIB_CFLAGS DBUSMENUGLIB_LIBS DBUSMENUGTK_CFLAGS DBUSMENUGTK_LIBS +DBUSMENUDUMPER_CFLAGS +DBUSMENUDUMPER_LIBS DBUSMENUTESTS_CFLAGS DBUSMENUTESTS_LIBS' @@ -1653,6 +1657,10 @@ Some influential environment variables: C compiler flags for DBUSMENUGTK, overriding pkg-config DBUSMENUGTK_LIBS linker flags for DBUSMENUGTK, overriding pkg-config + DBUSMENUDUMPER_CFLAGS + C compiler flags for DBUSMENUDUMPER, overriding pkg-config + DBUSMENUDUMPER_LIBS + linker flags for DBUSMENUDUMPER, overriding pkg-config DBUSMENUTESTS_CFLAGS C compiler flags for DBUSMENUTESTS, overriding pkg-config DBUSMENUTESTS_LIBS @@ -6285,13 +6293,13 @@ if test "${lt_cv_nm_interface+set}" = set; then : else lt_cv_nm_interface="BSD nm" echo "int some_variable = 0;" > conftest.$ac_ext - (eval echo "\"\$as_me:6288: $ac_compile\"" >&5) + (eval echo "\"\$as_me:6296: $ac_compile\"" >&5) (eval "$ac_compile" 2>conftest.err) cat conftest.err >&5 - (eval echo "\"\$as_me:6291: $NM \\\"conftest.$ac_objext\\\"\"" >&5) + (eval echo "\"\$as_me:6299: $NM \\\"conftest.$ac_objext\\\"\"" >&5) (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) cat conftest.err >&5 - (eval echo "\"\$as_me:6294: output\"" >&5) + (eval echo "\"\$as_me:6302: output\"" >&5) cat conftest.out >&5 if $GREP 'External.*some_variable' conftest.out > /dev/null; then lt_cv_nm_interface="MS dumpbin" @@ -7496,7 +7504,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 7499 "configure"' > conftest.$ac_ext + echo '#line 7507 "configure"' > conftest.$ac_ext if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -8772,11 +8780,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:8775: $lt_compile\"" >&5) + (eval echo "\"\$as_me:8783: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:8779: \$? = $ac_status" >&5 + echo "$as_me:8787: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -9111,11 +9119,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9114: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9122: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:9118: \$? = $ac_status" >&5 + echo "$as_me:9126: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings other than the usual output. @@ -9216,11 +9224,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9219: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9227: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9223: \$? = $ac_status" >&5 + echo "$as_me:9231: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -9271,11 +9279,11 @@ else -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:9274: $lt_compile\"" >&5) + (eval echo "\"\$as_me:9282: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:9278: \$? = $ac_status" >&5 + echo "$as_me:9286: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -11655,7 +11663,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11658 "configure" +#line 11666 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11751,7 +11759,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 11754 "configure" +#line 11762 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12679,6 +12687,115 @@ fi +########################### +# Dependencies - dumper +########################### + +X11_REQUIRED_VERSION=1.3 + + +pkg_failed=no +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for DBUSMENUDUMPER" >&5 +$as_echo_n "checking for DBUSMENUDUMPER... " >&6; } + +if test -n "$PKG_CONFIG"; then + if test -n "$DBUSMENUDUMPER_CFLAGS"; then + pkg_cv_DBUSMENUDUMPER_CFLAGS="$DBUSMENUDUMPER_CFLAGS" + else + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gtk+-2.0 >= \$GTK_REQUIRED_VERSION + x11 >= \$X11_REQUIRED_VERSION\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gtk+-2.0 >= $GTK_REQUIRED_VERSION + x11 >= $X11_REQUIRED_VERSION") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_DBUSMENUDUMPER_CFLAGS=`$PKG_CONFIG --cflags "gtk+-2.0 >= $GTK_REQUIRED_VERSION + x11 >= $X11_REQUIRED_VERSION" 2>/dev/null` +else + pkg_failed=yes +fi + fi +else + pkg_failed=untried +fi +if test -n "$PKG_CONFIG"; then + if test -n "$DBUSMENUDUMPER_LIBS"; then + pkg_cv_DBUSMENUDUMPER_LIBS="$DBUSMENUDUMPER_LIBS" + else + if test -n "$PKG_CONFIG" && \ + { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"gtk+-2.0 >= \$GTK_REQUIRED_VERSION + x11 >= \$X11_REQUIRED_VERSION\""; } >&5 + ($PKG_CONFIG --exists --print-errors "gtk+-2.0 >= $GTK_REQUIRED_VERSION + x11 >= $X11_REQUIRED_VERSION") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then + pkg_cv_DBUSMENUDUMPER_LIBS=`$PKG_CONFIG --libs "gtk+-2.0 >= $GTK_REQUIRED_VERSION + x11 >= $X11_REQUIRED_VERSION" 2>/dev/null` +else + pkg_failed=yes +fi + fi +else + pkg_failed=untried +fi + + + +if test $pkg_failed = yes; then + +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi + if test $_pkg_short_errors_supported = yes; then + DBUSMENUDUMPER_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "gtk+-2.0 >= $GTK_REQUIRED_VERSION + x11 >= $X11_REQUIRED_VERSION"` + else + DBUSMENUDUMPER_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "gtk+-2.0 >= $GTK_REQUIRED_VERSION + x11 >= $X11_REQUIRED_VERSION"` + fi + # Put the nasty error message in config.log where it belongs + echo "$DBUSMENUDUMPER_PKG_ERRORS" >&5 + + as_fn_error "Package requirements (gtk+-2.0 >= $GTK_REQUIRED_VERSION + x11 >= $X11_REQUIRED_VERSION) were not met: + +$DBUSMENUDUMPER_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +Alternatively, you may set the environment variables DBUSMENUDUMPER_CFLAGS +and DBUSMENUDUMPER_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. +" "$LINENO" 5 +elif test $pkg_failed = untried; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error "The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +Alternatively, you may set the environment variables DBUSMENUDUMPER_CFLAGS +and DBUSMENUDUMPER_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details. + +To get pkg-config, see . +See \`config.log' for more details." "$LINENO" 5; } +else + DBUSMENUDUMPER_CFLAGS=$pkg_cv_DBUSMENUDUMPER_CFLAGS + DBUSMENUDUMPER_LIBS=$pkg_cv_DBUSMENUDUMPER_LIBS + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + : +fi + + + + ########################### # Dependencies - Testing ########################### diff --git a/debian/changelog b/debian/changelog index 3e96017..a23c33d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,8 +2,9 @@ libdbusmenu (0.3.6-0ubuntu2~ppa1) UNRELEASED; urgency=low * Upstream Merge * Making dbusmenu-dumper have a click to dump feature. + * Autogen update - -- Ted Gould Tue, 20 Jul 2010 16:37:33 -0500 + -- Ted Gould Tue, 20 Jul 2010 16:38:38 -0500 libdbusmenu (0.3.6-0ubuntu1) maverick; urgency=low diff --git a/tools/Makefile.in b/tools/Makefile.in index 2d2e865..59288b3 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -55,7 +55,8 @@ am_dbusmenu_dumper_OBJECTS = \ dbusmenu_dumper_OBJECTS = $(am_dbusmenu_dumper_OBJECTS) am__DEPENDENCIES_1 = dbusmenu_dumper_DEPENDENCIES = \ - ../libdbusmenu-glib/libdbusmenu-glib.la $(am__DEPENDENCIES_1) + ../libdbusmenu-glib/libdbusmenu-glib.la $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent @@ -173,6 +174,8 @@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ +DBUSMENUDUMPER_CFLAGS = @DBUSMENUDUMPER_CFLAGS@ +DBUSMENUDUMPER_LIBS = @DBUSMENUDUMPER_LIBS@ DBUSMENUGLIB_CFLAGS = @DBUSMENUGLIB_CFLAGS@ DBUSMENUGLIB_LIBS = @DBUSMENUGLIB_LIBS@ DBUSMENUGTK_CFLAGS = @DBUSMENUGTK_CFLAGS@ @@ -325,11 +328,14 @@ dbusmenu_dumper_SOURCES = \ dbusmenu_dumper_CFLAGS = \ -I $(srcdir)/.. \ - $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + $(DBUSMENUGLIB_CFLAGS) \ + $(DBUSMENUDUMPER_CFLAGS) \ + -Wall -Werror dbusmenu_dumper_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ - $(DBUSMENUGLIB_LIBS) + $(DBUSMENUGLIB_LIBS) \ + $(DBUSMENUDUMPER_LIBS) doc_DATA = README.dbusmenu-bench EXTRA_DIST = \ -- cgit v1.2.3 From ba87ab7a9a65c5ed349dda5c472ae6c8adbef322 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 20 Jul 2010 16:40:32 -0500 Subject: releasing version 0.3.6-0ubuntu2~ppa1 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index a23c33d..8fcb649 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,10 +1,10 @@ -libdbusmenu (0.3.6-0ubuntu2~ppa1) UNRELEASED; urgency=low +libdbusmenu (0.3.6-0ubuntu2~ppa1) lucid; urgency=low * Upstream Merge * Making dbusmenu-dumper have a click to dump feature. * Autogen update - -- Ted Gould Tue, 20 Jul 2010 16:38:38 -0500 + -- Ted Gould Tue, 20 Jul 2010 16:40:29 -0500 libdbusmenu (0.3.6-0ubuntu1) maverick; urgency=low -- cgit v1.2.3 From fd7ffaa78b2c75db0b8138903d7272ed15641ce1 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Thu, 22 Jul 2010 10:44:33 +0200 Subject: Fix menu order in submenus --- libdbusmenu-gtk/client.c | 4 +- tests/Makefile.am | 47 ++++++++++++- tests/test-gtk-reorder-server.c | 19 ++++-- tests/test-gtk-submenu-client.c | 143 ++++++++++++++++++++++++++++++++++++++++ tests/test-gtk-submenu-server.c | 86 ++++++++++++++++++++++++ 5 files changed, 289 insertions(+), 10 deletions(-) create mode 100644 tests/test-gtk-submenu-client.c create mode 100644 tests/test-gtk-submenu-server.c diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index b406697..b5b509f 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -491,7 +491,7 @@ dbusmenu_gtkclient_newitem_base (DbusmenuGtkClient * client, DbusmenuMenuitem * /* Oh, we're a child, let's deal with that */ if (parent != NULL) { - new_child(parent, item, dbusmenu_menuitem_get_position_realized(item, parent), DBUSMENU_GTKCLIENT(client)); + new_child(parent, item, dbusmenu_menuitem_get_position(item, parent), DBUSMENU_GTKCLIENT(client)); } return; @@ -519,7 +519,7 @@ new_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position, Dbus } GtkMenuItem * childmi = dbusmenu_gtkclient_menuitem_get(gtkclient, child); - gtk_menu_shell_insert(GTK_MENU_SHELL(menu), GTK_WIDGET(childmi), dbusmenu_menuitem_get_position_realized(child, mi)); + gtk_menu_shell_insert(GTK_MENU_SHELL(menu), GTK_WIDGET(childmi), position); gtk_widget_show(GTK_WIDGET(menu)); return; diff --git a/tests/Makefile.am b/tests/Makefile.am index 63857a2..9f621cb 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -14,7 +14,8 @@ TESTS = \ test-gtk-objects-test \ test-gtk-label \ test-gtk-shortcut \ - test-gtk-reorder + test-gtk-reorder \ + test-gtk-submenu check_PROGRAMS = \ glib-server-nomenu \ @@ -36,7 +37,9 @@ check_PROGRAMS = \ test-glib-simple-items \ test-gtk-reorder-server \ test-json-client \ - test-json-server + test-json-server \ + test-gtk-submenu-server \ + test-gtk-submenu-client XVFB_RUN=". $(srcdir)/run-xvfb.sh" @@ -453,6 +456,46 @@ test_gtk_reorder_server_LDADD = \ $(DBUSMENUGTK_LIBS) \ $(DBUSMENUTESTS_LIBS) +######################### +# Test GTK Submenu +######################### + +test-gtk-submenu: test-gtk-submenu-client test-gtk-submenu-server Makefile.am + @echo "#!/bin/bash" > $@ + @echo $(XVFB_RUN) >> $@ + @echo $(DBUS_RUNNER) --task ./test-gtk-submenu-client --task-name Client --task ./test-gtk-submenu-server --task-name Server --ignore-return >> $@ + @chmod +x $@ + +test_gtk_submenu_server_SOURCES = \ + test-gtk-submenu-server.c + +test_gtk_submenu_server_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGTK_CFLAGS) \ + $(DBUSMENUTESTS_CFLAGS) \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_gtk_submenu_server_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + ../libdbusmenu-gtk/libdbusmenu-gtk.la \ + $(DBUSMENUGTK_LIBS) \ + $(DBUSMENUTESTS_LIBS) + +test_gtk_submenu_client_SOURCES = \ + test-gtk-submenu-client.c + +test_gtk_submenu_client_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGTK_CFLAGS) \ + $(DBUSMENUTESTS_CFLAGS) \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_gtk_submenu_client_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + ../libdbusmenu-gtk/libdbusmenu-gtk.la \ + $(DBUSMENUGTK_LIBS) \ + $(DBUSMENUTESTS_LIBS) + ######################### # Test Mago ######################### diff --git a/tests/test-gtk-reorder-server.c b/tests/test-gtk-reorder-server.c index eee9bb8..a3fadb1 100644 --- a/tests/test-gtk-reorder-server.c +++ b/tests/test-gtk-reorder-server.c @@ -41,17 +41,18 @@ guint ordering [NUMBER_TESTS][NUMBER_ENTRIES] = { }; gchar * names [NUMBER_ENTRIES] = { - "One", "Two", "Three", "Four", "Five" + "0", "1", "2", "3", "4" }; DbusmenuMenuitem * entries[NUMBER_ENTRIES] = {0}; DbusmenuMenuitem * root = NULL; - +DbusmenuMenuitem * parent = NULL; gint test = 0; static DbusmenuServer * server = NULL; static GMainLoop * mainloop = NULL; +#if 0 static gboolean timer_func (gpointer data) { @@ -65,13 +66,14 @@ timer_func (gpointer data) int i; for (i = 0; i < NUMBER_ENTRIES; i++) { g_debug("Putting entry '%d' at position '%d'", i, ordering[test][i]); - dbusmenu_menuitem_child_reorder(root, entries[i], ordering[test][i]); + dbusmenu_menuitem_child_reorder(parent, entries[i], ordering[test][i]); dbusmenu_menuitem_property_set(entries[i], "label", names[ordering[test][i]]); } test++; return TRUE; } +#endif int main (int argc, char ** argv) @@ -101,13 +103,18 @@ main (int argc, char ** argv) dbusmenu_server_set_root(server, root); int i; + parent = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(parent, "label", "Parent"); + dbusmenu_menuitem_child_append(root, parent); + for (i = 0; i < NUMBER_ENTRIES; i++) { entries[i] = dbusmenu_menuitem_new(); - dbusmenu_menuitem_child_append(root, entries[i]); + dbusmenu_menuitem_property_set(entries[i], "label", names[ordering[test][i]]); + dbusmenu_menuitem_child_append(parent, entries[i]); } - timer_func(NULL); - g_timeout_add_seconds(5, timer_func, NULL); + //timer_func(NULL); + //g_timeout_add_seconds(5, timer_func, NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); diff --git a/tests/test-gtk-submenu-client.c b/tests/test-gtk-submenu-client.c new file mode 100644 index 0000000..2e1ef7a --- /dev/null +++ b/tests/test-gtk-submenu-client.c @@ -0,0 +1,143 @@ +/* +A test for libdbusmenu to ensure its quality. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include +#include + +static GMainLoop * mainloop = NULL; +static gboolean passed = TRUE; + +static gboolean check_menu_content(GtkMenu * menu, char ** content) +{ + GList * child = gtk_container_get_children(GTK_CONTAINER(menu)); + char ** expected = content; + for (; child != NULL; child = g_list_next(child), ++expected) { + if (*expected == NULL) { + g_warning("Too many gtk items"); + return FALSE; + } + const char * label = gtk_menu_item_get_label(GTK_MENU_ITEM(child->data)); + if (g_strcmp0(label, *expected) != 0) { + g_warning("Expected '%s', got '%s'", *expected, label); + return FALSE; + } + } + if (*expected != NULL) { + g_warning("Not enough gtk items"); + return FALSE; + } + return TRUE; +} + +static void +abort_test(const char * message) +{ + if (message) { + g_warning("%s", message); + } + passed = FALSE; + g_main_loop_quit(mainloop); +} + +static gboolean +timer_func (gpointer data) +{ + static char * root_content[] = { "Folder 1", "Folder 2", NULL }; + static char * folder1_content[] = { "1.1", "1.2", "1.3", NULL }; + static char * folder2_content[] = { "2.1", "2.2", "2.3", NULL }; + + GtkMenuItem * root_item = GTK_MENU_ITEM(data); + GtkMenu * menu = GTK_MENU(gtk_menu_item_get_submenu(root_item)); + + /* Root */ + if (!check_menu_content(menu, root_content)) { + abort_test("Checking root content failed"); + return FALSE; + } + + /* Folder 1 */ + GList * child = gtk_container_get_children(GTK_CONTAINER(menu)); + GtkMenuItem * item = GTK_MENU_ITEM(child->data); + GtkMenu * folder_menu = GTK_MENU(gtk_menu_item_get_submenu(item)); + if (!folder_menu) { + abort_test("Folder 1 has no menu"); + return FALSE; + } + + if (!check_menu_content(folder_menu, folder1_content)) { + abort_test("Checking folder1 content failed"); + return FALSE; + } + + /* Folder 2 */ + child = g_list_next(child); + item = GTK_MENU_ITEM(child->data); + folder_menu = GTK_MENU(gtk_menu_item_get_submenu(item)); + if (!folder_menu) { + abort_test("Folder 2 has no menu"); + return FALSE; + } + + if (!check_menu_content(folder_menu, folder2_content)) { + abort_test("Checking folder2 content failed"); + return FALSE; + } + + passed = TRUE; + g_main_loop_quit(mainloop); + return FALSE; +} + +int +main (int argc, char ** argv) +{ + gtk_init(&argc, &argv); + + g_debug("Client Initialized. Waiting."); + /* Make sure the server starts up and all that */ + g_usleep(500000); + + g_debug("Building Window"); + GtkWidget * window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + GtkWidget * menubar = gtk_menu_bar_new(); + GtkWidget * menuitem = gtk_menu_item_new_with_label("Test"); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(dbusmenu_gtkmenu_new ("glib.label.test", "/org/test"))); + gtk_widget_show(menuitem); + gtk_menu_bar_append(menubar, menuitem); + gtk_widget_show(menubar); + gtk_container_add(GTK_CONTAINER(window), menubar); + gtk_window_set_title(GTK_WINDOW(window), "libdbusmenu-gtk test"); + gtk_widget_show(window); + + g_timeout_add_seconds(1, timer_func, menuitem); + + g_debug("Entering Mainloop"); + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + if (passed) { + g_debug("Quiting"); + return 0; + } else { + g_debug("Quiting as we're a failure"); + return 1; + } +} diff --git a/tests/test-gtk-submenu-server.c b/tests/test-gtk-submenu-server.c new file mode 100644 index 0000000..ed9cf79 --- /dev/null +++ b/tests/test-gtk-submenu-server.c @@ -0,0 +1,86 @@ +/* +A test for libdbusmenu to ensure its quality. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include + +#include +#include +#include +#include + +#include +#include + +DbusmenuMenuitem * +add_item(DbusmenuMenuitem * parent, const char * label) +{ + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(item, "label", label); + dbusmenu_menuitem_child_append(parent, item); + return item; +} + +int +main (int argc, char ** argv) +{ + GError * error = NULL; + + g_type_init(); + + 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; + } + + DbusmenuServer * server = dbusmenu_server_new("/org/test"); + DbusmenuMenuitem * root = dbusmenu_menuitem_new(); + dbusmenu_server_set_root(server, root); + + DbusmenuMenuitem * item; + item = add_item(root, "Folder 1"); + add_item(item, "1.1"); + add_item(item, "1.2"); + add_item(item, "1.3"); + + item = add_item(root, "Folder 2"); + add_item(item, "2.1"); + add_item(item, "2.2"); + add_item(item, "2.3"); + + GMainLoop * mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + g_debug("Quiting"); + + return 0; +} + -- cgit v1.2.3 From d96d7282b58e60141cde234e106ab3281f50d7b6 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Thu, 22 Jul 2010 11:31:48 +0200 Subject: Reverted changes to test-gtk-reorder-server --- tests/test-gtk-reorder-server.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/tests/test-gtk-reorder-server.c b/tests/test-gtk-reorder-server.c index a3fadb1..eee9bb8 100644 --- a/tests/test-gtk-reorder-server.c +++ b/tests/test-gtk-reorder-server.c @@ -41,18 +41,17 @@ guint ordering [NUMBER_TESTS][NUMBER_ENTRIES] = { }; gchar * names [NUMBER_ENTRIES] = { - "0", "1", "2", "3", "4" + "One", "Two", "Three", "Four", "Five" }; DbusmenuMenuitem * entries[NUMBER_ENTRIES] = {0}; DbusmenuMenuitem * root = NULL; -DbusmenuMenuitem * parent = NULL; + gint test = 0; static DbusmenuServer * server = NULL; static GMainLoop * mainloop = NULL; -#if 0 static gboolean timer_func (gpointer data) { @@ -66,14 +65,13 @@ timer_func (gpointer data) int i; for (i = 0; i < NUMBER_ENTRIES; i++) { g_debug("Putting entry '%d' at position '%d'", i, ordering[test][i]); - dbusmenu_menuitem_child_reorder(parent, entries[i], ordering[test][i]); + dbusmenu_menuitem_child_reorder(root, entries[i], ordering[test][i]); dbusmenu_menuitem_property_set(entries[i], "label", names[ordering[test][i]]); } test++; return TRUE; } -#endif int main (int argc, char ** argv) @@ -103,18 +101,13 @@ main (int argc, char ** argv) dbusmenu_server_set_root(server, root); int i; - parent = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(parent, "label", "Parent"); - dbusmenu_menuitem_child_append(root, parent); - for (i = 0; i < NUMBER_ENTRIES; i++) { entries[i] = dbusmenu_menuitem_new(); - dbusmenu_menuitem_property_set(entries[i], "label", names[ordering[test][i]]); - dbusmenu_menuitem_child_append(parent, entries[i]); + dbusmenu_menuitem_child_append(root, entries[i]); } - //timer_func(NULL); - //g_timeout_add_seconds(5, timer_func, NULL); + timer_func(NULL); + g_timeout_add_seconds(5, timer_func, NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From d52e108200e0214e770e9cf151f5b96af5ee41f5 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Thu, 22 Jul 2010 21:05:53 +0200 Subject: Test fixes. --- tests/Makefile.am | 1 - tests/test-gtk-submenu-server.c | 14 +++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 9f621cb..839305f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -10,7 +10,6 @@ TESTS = \ test-glib-proxy \ test-glib-simple-items \ test-glib-submenu \ - test-json \ test-gtk-objects-test \ test-gtk-label \ test-gtk-shortcut \ diff --git a/tests/test-gtk-submenu-server.c b/tests/test-gtk-submenu-server.c index ed9cf79..ba3993e 100644 --- a/tests/test-gtk-submenu-server.c +++ b/tests/test-gtk-submenu-server.c @@ -29,6 +29,16 @@ with this program. If not, see . #include #include +static GMainLoop *mainloop = NULL; + +static gboolean +timer_func (gpointer data) +{ + g_main_loop_quit (mainloop); + + return FALSE; +} + DbusmenuMenuitem * add_item(DbusmenuMenuitem * parent, const char * label) { @@ -76,7 +86,9 @@ main (int argc, char ** argv) add_item(item, "2.2"); add_item(item, "2.3"); - GMainLoop * mainloop = g_main_loop_new(NULL, FALSE); + g_timeout_add_seconds(3, timer_func, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); g_debug("Quiting"); -- cgit v1.2.3 From 8c75a152b79446cf8a63a79097b05b6fd620e778 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Thu, 22 Jul 2010 21:09:39 +0200 Subject: Bump version. --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 93aa557..d54dc41 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.6, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.7, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.6, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.7, [-Wno-portability]) AM_MAINTAINER_MODE -- cgit v1.2.3 From 9b82146e224aa02bc77d1a5a57cf931cadd86438 Mon Sep 17 00:00:00 2001 From: Cody Russell Date: Fri, 30 Jul 2010 12:29:54 -0500 Subject: Bump version to 0.3.8. --- configure.ac | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index d54dc41..d8211b1 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.3.7, ted@canonical.com) +AC_INIT(libdbusmenu, 0.3.8, ted@canonical.com) AC_COPYRIGHT([Copyright 2009,2010 Canonical]) AC_PREREQ(2.62) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.3.7, [-Wno-portability]) +AM_INIT_AUTOMAKE(libdbusmenu, 0.3.8, [-Wno-portability]) AM_MAINTAINER_MODE -- cgit v1.2.3