From e84ef2f86d5005d6b7c298be37fd25c527d1a6fe Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 19 May 2009 05:04:04 +0200 Subject: Switching over to some autogenerated menu files instead of our test ones. --- libdbusmenu-gtk/Makefile.am | 4 ++-- libdbusmenu-gtk/menu.c | 49 +++++++++++++++++++++++++++++++++++++++++++++ libdbusmenu-gtk/menu.h | 33 ++++++++++++++++++++++++++++++ libdbusmenu-gtk/test.c | 4 ---- libdbusmenu-gtk/test.h | 2 -- 5 files changed, 84 insertions(+), 8 deletions(-) create mode 100644 libdbusmenu-gtk/menu.c create mode 100644 libdbusmenu-gtk/menu.h delete mode 100644 libdbusmenu-gtk/test.c delete mode 100644 libdbusmenu-gtk/test.h diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index 1e36228..364da62 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -8,10 +8,10 @@ lib_LTLIBRARIES = \ libdbusmenu_gtkincludedir=$(includedir)/libdbusmenu-0.1/libdbusmenu-gtk/ libdbusmenu_gtkinclude_HEADERS = \ - test.h + menu.h libdbusmenu_gtk_la_SOURCES = \ - test.c + menu.c libdbusmenu_gtk_la_LDFLAGS = \ -version-info $(LIBDBUSMENU_CURRENT):$(LIBDBUSMENU_REVISION):$(LIBDBUSMENU_AGE) \ diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c new file mode 100644 index 0000000..3e0a006 --- /dev/null +++ b/libdbusmenu-gtk/menu.c @@ -0,0 +1,49 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include + +typedef struct _MenuPrivate MenuPrivate; + +struct _MenuPrivate +{ +}; + +#define MENU_GET_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE ((o), MENU_TYPE, MenuPrivate)) + +static void menu_class_init (MenuClass *klass); +static void menu_init (Menu *self); +static void menu_dispose (GObject *object); +static void menu_finalize (GObject *object); + +G_DEFINE_TYPE (Menu, menu, GTK_TYPE_MENU); + +static void +menu_class_init (MenuClass *klass) +{ +GObjectClass *object_class = G_OBJECT_CLASS (klass); + +g_type_class_add_private (klass, sizeof (MenuPrivate)); + +object_class->dispose = menu_dispose; +object_class->finalize = menu_finalize; +} + +static void +menu_init (Menu *self) +{ +} + +static void +menu_dispose (GObject *object) +{ +G_OBJECT_CLASS (menu_parent_class)->dispose (object); +} + +static void +menu_finalize (GObject *object) +{ +G_OBJECT_CLASS (menu_parent_class)->finalize (object); +} diff --git a/libdbusmenu-gtk/menu.h b/libdbusmenu-gtk/menu.h new file mode 100644 index 0000000..783737a --- /dev/null +++ b/libdbusmenu-gtk/menu.h @@ -0,0 +1,33 @@ +#ifndef __MENU_H__ +#define __MENU_H__ + +#include +#include + +G_BEGIN_DECLS + +#define MENU_TYPE (menu_get_type ()) +#define MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MENU_TYPE, Menu)) +#define MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MENU_TYPE, MenuClass)) +#define IS_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MENU_TYPE)) +#define IS_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MENU_TYPE)) +#define MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MENU_TYPE, MenuClass)) + +typedef struct _Menu Menu; +typedef struct _MenuClass MenuClass; + +struct _MenuClass +{ +GtkMenuClass parent_class; +}; + +struct _Menu +{ +GtkMenu parent; +}; + +GType menu_get_type (void); + +G_END_DECLS + +#endif diff --git a/libdbusmenu-gtk/test.c b/libdbusmenu-gtk/test.c deleted file mode 100644 index 8ebb3f7..0000000 --- a/libdbusmenu-gtk/test.c +++ /dev/null @@ -1,4 +0,0 @@ - -void mysymbol (void) { - return; -} diff --git a/libdbusmenu-gtk/test.h b/libdbusmenu-gtk/test.h deleted file mode 100644 index ad000af..0000000 --- a/libdbusmenu-gtk/test.h +++ /dev/null @@ -1,2 +0,0 @@ - -void mysymbol (void); -- cgit v1.2.3 From f9ea57e39f9025dc93642fe306fd36c9ee61b28e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 19 May 2009 05:11:04 +0200 Subject: Getting the libs into the gtk library --- configure.ac | 14 ++++++++++++++ libdbusmenu-gtk/Makefile.am | 5 +++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 96b23fc..9770814 100644 --- a/configure.ac +++ b/configure.ac @@ -34,6 +34,20 @@ PKG_CHECK_MODULES(DBUSMENUGLIB, glib-2.0 >= $GLIB_REQUIRED_VERSION AC_SUBST(DBUSMENUGLIB_CFLAGS) AC_SUBST(DBUSMENUGLIB_LIBS) +########################### +# Dependencies - GTK +########################### + +GTK_REQUIRED_VERSION=2.16 + +PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-2.0 >= $GTK_REQUIRED_VERSION + glib-2.0 >= $GLIB_REQUIRED_VERSION + dbus-glib-1 >= $DBUS_REQUIRED_VERSION + libxml-2.0 >= $XML_REQUIRED_VERSION) + +AC_SUBST(DBUSMENUGTK_CFLAGS) +AC_SUBST(DBUSMENUGTK_LIBS) + ########################### # Lib versioning ########################### diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index 364da62..e73c8c1 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -19,10 +19,11 @@ libdbusmenu_gtk_la_LDFLAGS = \ -export-symbols-regex "^[^_].*" libdbusmenu_gtk_la_CFLAGS = \ - $(LIBDBUSMENU_GTK_CFLAGS) + $(DBUSMENUGTK_CFLAGS) libdbusmenu_gtk_la_LIBADD = \ - $(LIBDBUSMENU_GTK_LIBS) + ../libdbusmenu-glib/libdbusmenu-glib.la \ + $(DBUSMENUGTK_LIBS) pkgconfig_DATA = dbusmenu-gtk.pc pkgconfigdir = $(libdir)/pkgconfig -- cgit v1.2.3 From e0a30604a2d4b4ecbdd968f91971030a41066323 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 19 May 2009 05:11:37 +0200 Subject: Include the header too --- libdbusmenu-gtk/menu.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 3e0a006..420414a 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -4,6 +4,8 @@ #include +#include "menu.h" + typedef struct _MenuPrivate MenuPrivate; struct _MenuPrivate -- cgit v1.2.3 From c645d1c4e08f8c92d0c8fde7c609aa25892cf6f8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 19 May 2009 05:14:08 +0200 Subject: Ignore our new lo --- .bzrignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.bzrignore b/.bzrignore index 8c4e180..4cd2a88 100644 --- a/.bzrignore +++ b/.bzrignore @@ -33,3 +33,4 @@ menuitem-marshal.h libdbusmenu_glib_la-menuitem-marshal.lo test-glib-properties-client test-glib-properties-server +libdbusmenu_gtk_la-menu.lo -- cgit v1.2.3 From 3cd0f472e1e79d185681b87dced59559de9df4ff Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 20 May 2009 11:31:54 +0200 Subject: Cleaning up the name space and making it clear where we are. Now we have an object --- libdbusmenu-gtk/menu.c | 46 +++++++++++++++++++++++++++------------------- libdbusmenu-gtk/menu.h | 33 +++++++++++++++------------------ 2 files changed, 42 insertions(+), 37 deletions(-) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 420414a..8e4f53b 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -6,46 +6,54 @@ #include "menu.h" -typedef struct _MenuPrivate MenuPrivate; +typedef struct _DbusmenuGtkMenuPrivate DbusmenuGtkMenuPrivate; -struct _MenuPrivate +struct _DbusmenuGtkMenuPrivate { }; -#define MENU_GET_PRIVATE(o) \ -(G_TYPE_INSTANCE_GET_PRIVATE ((o), MENU_TYPE, MenuPrivate)) +#define DBUSMENU_GTKMENU_GET_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_GTKMENU_TYPE, DbusmenuGtkMenuPrivate)) -static void menu_class_init (MenuClass *klass); -static void menu_init (Menu *self); -static void menu_dispose (GObject *object); -static void menu_finalize (GObject *object); +static void dbusmenu_gtkmenu_class_init (DbusmenuGtkMenuClass *klass); +static void dbusmenu_gtkmenu_init (DbusmenuGtkMenu *self); +static void dbusmenu_gtkmenu_dispose (GObject *object); +static void dbusmenu_gtkmenu_finalize (GObject *object); -G_DEFINE_TYPE (Menu, menu, GTK_TYPE_MENU); +G_DEFINE_TYPE (DbusmenuGtkMenu, dbusmenu_gtkmenu, GTK_TYPE_MENU); static void -menu_class_init (MenuClass *klass) +dbusmenu_gtkmenu_class_init (DbusmenuGtkMenuClass *klass) { -GObjectClass *object_class = G_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); -g_type_class_add_private (klass, sizeof (MenuPrivate)); + g_type_class_add_private (klass, sizeof (DbusmenuGtkMenuPrivate)); -object_class->dispose = menu_dispose; -object_class->finalize = menu_finalize; + object_class->dispose = dbusmenu_gtkmenu_dispose; + object_class->finalize = dbusmenu_gtkmenu_finalize; + + return; } static void -menu_init (Menu *self) +dbusmenu_gtkmenu_init (DbusmenuGtkMenu *self) { + + return; } static void -menu_dispose (GObject *object) +dbusmenu_gtkmenu_dispose (GObject *object) { -G_OBJECT_CLASS (menu_parent_class)->dispose (object); + + G_OBJECT_CLASS (dbusmenu_gtkmenu_parent_class)->dispose (object); + return; } static void -menu_finalize (GObject *object) +dbusmenu_gtkmenu_finalize (GObject *object) { -G_OBJECT_CLASS (menu_parent_class)->finalize (object); + + G_OBJECT_CLASS (dbusmenu_gtkmenu_parent_class)->finalize (object); + return; } diff --git a/libdbusmenu-gtk/menu.h b/libdbusmenu-gtk/menu.h index 783737a..6d9c6ff 100644 --- a/libdbusmenu-gtk/menu.h +++ b/libdbusmenu-gtk/menu.h @@ -1,32 +1,29 @@ -#ifndef __MENU_H__ -#define __MENU_H__ +#ifndef __DBUSMENU_GTKMENU_H__ +#define __DBUSMENU_GTKMENU_H__ #include #include G_BEGIN_DECLS -#define MENU_TYPE (menu_get_type ()) -#define MENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MENU_TYPE, Menu)) -#define MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MENU_TYPE, MenuClass)) -#define IS_MENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MENU_TYPE)) -#define IS_MENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MENU_TYPE)) -#define MENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MENU_TYPE, MenuClass)) +#define DBUSMENU_GTKMENU_TYPE (dbusmenu_gtkmenu_get_type ()) +#define DBUSMENU_GTKMENU(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DBUSMENU_GTKMENU_TYPE, DbusmenuGtkMenu)) +#define DBUSMENU_GTKMENU_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DBUSMENU_GTKMENU_TYPE, DbusmenuGtkMenuClass)) +#define DBUSMENU_IS_GTKMENU(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DBUSMENU_GTKMENU_TYPE)) +#define DBUSMENU_IS_GTKMENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_GTKMENU_TYPE)) +#define DBUSMENU_GTKMENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_GTKMENU_TYPE, DbusmenuGtkMenuClass)) -typedef struct _Menu Menu; -typedef struct _MenuClass MenuClass; - -struct _MenuClass -{ -GtkMenuClass parent_class; +typedef struct _DbusmenuGtkMenuClass DbusmenuGtkMenuClass; +struct _DbusmenuGtkMenuClass { + GtkMenuClass parent_class; }; -struct _Menu -{ -GtkMenu parent; +typedef struct _DbusmenuGtkMenu DbusmenuGtkMenu; +struct _DbusmenuGtkMenu { + GtkMenu parent; }; -GType menu_get_type (void); +GType dbusmenu_gtkmenu_get_type (void); G_END_DECLS -- cgit v1.2.3 From 63544bc682361f1cd022d53032c2d1d92476cc31 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 20 May 2009 11:58:28 +0200 Subject: Building up a client, but that required a couple of properties. Bigger commit than I'd like. --- libdbusmenu-gtk/menu.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 112 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 8e4f53b..a049b62 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -5,21 +5,38 @@ #include #include "menu.h" +#include "libdbusmenu-glib/client.h" +/* Properties */ +enum { + PROP_0, + PROP_DBUSOBJECT, + PROP_DBUSNAME +}; + +/* Private */ typedef struct _DbusmenuGtkMenuPrivate DbusmenuGtkMenuPrivate; +struct _DbusmenuGtkMenuPrivate { + DbusmenuClient * client; -struct _DbusmenuGtkMenuPrivate -{ + gchar * dbus_object; + gchar * dbus_name; }; #define DBUSMENU_GTKMENU_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), DBUSMENU_GTKMENU_TYPE, DbusmenuGtkMenuPrivate)) +/* Prototypes */ static void dbusmenu_gtkmenu_class_init (DbusmenuGtkMenuClass *klass); static void dbusmenu_gtkmenu_init (DbusmenuGtkMenu *self); static void dbusmenu_gtkmenu_dispose (GObject *object); static void dbusmenu_gtkmenu_finalize (GObject *object); +static void set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec); +static void get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec); +/* Internal */ +static void build_client (DbusmenuGtkMenu * self); +/* GObject Stuff */ G_DEFINE_TYPE (DbusmenuGtkMenu, dbusmenu_gtkmenu, GTK_TYPE_MENU); static void @@ -31,6 +48,19 @@ dbusmenu_gtkmenu_class_init (DbusmenuGtkMenuClass *klass) object_class->dispose = dbusmenu_gtkmenu_dispose; object_class->finalize = dbusmenu_gtkmenu_finalize; + object_class->set_property = set_property; + object_class->get_property = get_property; + + g_object_class_install_property (object_class, PROP_DBUSOBJECT, + g_param_spec_string(DBUSMENU_CLIENT_PROP_DBUS_OBJECT, "DBus Object we represent", + "The Object on the client that we're getting our data from.", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (object_class, PROP_DBUSNAME, + g_param_spec_string(DBUSMENU_CLIENT_PROP_DBUS_NAME, "DBus Client we connect to", + "Name of the DBus client we're connecting to.", + NULL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); return; } @@ -38,6 +68,12 @@ dbusmenu_gtkmenu_class_init (DbusmenuGtkMenuClass *klass) static void dbusmenu_gtkmenu_init (DbusmenuGtkMenu *self) { + DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(self); + + priv->client = NULL; + + priv->dbus_object = NULL; + priv->dbus_name = NULL; return; } @@ -45,6 +81,12 @@ dbusmenu_gtkmenu_init (DbusmenuGtkMenu *self) static void dbusmenu_gtkmenu_dispose (GObject *object) { + DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(object); + + if (priv->client != NULL) { + g_object_unref(G_OBJECT(priv->client)); + priv->client = NULL; + } G_OBJECT_CLASS (dbusmenu_gtkmenu_parent_class)->dispose (object); return; @@ -53,7 +95,75 @@ dbusmenu_gtkmenu_dispose (GObject *object) static void dbusmenu_gtkmenu_finalize (GObject *object) { + DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(object); + + g_free(priv->dbus_object); + priv->dbus_object = NULL; + + g_free(priv->dbus_name); + priv->dbus_name = NULL; G_OBJECT_CLASS (dbusmenu_gtkmenu_parent_class)->finalize (object); return; } + +static void +set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) +{ + DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(obj); + + switch (id) { + case PROP_DBUSNAME: + priv->dbus_name = g_value_dup_string(value); + if (priv->dbus_name != NULL && priv->dbus_object != NULL) { + build_client(DBUSMENU_GTKMENU(obj)); + } + break; + case PROP_DBUSOBJECT: + priv->dbus_object = g_value_dup_string(value); + if (priv->dbus_name != NULL && priv->dbus_object != NULL) { + build_client(DBUSMENU_GTKMENU(obj)); + } + break; + default: + g_warning("Unknown property %d.", id); + return; + } + + return; +} + +static void +get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) +{ + DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(obj); + + switch (id) { + case PROP_DBUSNAME: + g_value_set_string(value, priv->dbus_name); + break; + case PROP_DBUSOBJECT: + g_value_set_string(value, priv->dbus_object); + break; + default: + g_warning("Unknown property %d.", id); + return; + } + + return; +} + +/* Internal Functions */ + +static void +build_client (DbusmenuGtkMenu * self) +{ + DbusmenuGtkMenuPrivate * priv = DBUSMENU_GTKMENU_GET_PRIVATE(self); + + if (priv->client == NULL) { + priv->client = dbusmenu_client_new(priv->dbus_name, priv->dbus_object); + } + + return; +} + -- cgit v1.2.3 From 1df52c61f44b049b9e023a139a558b9e835ad5f7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 20 May 2009 12:11:32 +0200 Subject: A new function. Literally. --- libdbusmenu-gtk/menu.c | 21 +++++++++++++++++++++ libdbusmenu-gtk/menu.h | 1 + 2 files changed, 22 insertions(+) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index a049b62..773d57a 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -167,3 +167,24 @@ build_client (DbusmenuGtkMenu * self) return; } +/* Public API */ + +/** + dbusmenu_gtkmenu_new: + @dbus_name: Name of the #DbusmenuServer on DBus + @dbus_name: Name of the object on the #DbusmenuServer + + Creates a new #DbusmenuGtkMenu object and creates a #DbusmenuClient + that connects across DBus to a #DbusmenuServer. + + Return value: A new #DbusmenuGtkMenu sync'd with a server +*/ +DbusmenuGtkMenu * +dbusmenu_gtkmenu_new (gchar * dbus_name, gchar * dbus_object) +{ + return g_object_new(DBUSMENU_GTKMENU_TYPE, + DBUSMENU_CLIENT_PROP_DBUS_OBJECT, dbus_object, + DBUSMENU_CLIENT_PROP_DBUS_NAME, dbus_name, + NULL); +} + diff --git a/libdbusmenu-gtk/menu.h b/libdbusmenu-gtk/menu.h index 6d9c6ff..96dcca2 100644 --- a/libdbusmenu-gtk/menu.h +++ b/libdbusmenu-gtk/menu.h @@ -24,6 +24,7 @@ struct _DbusmenuGtkMenu { }; GType dbusmenu_gtkmenu_get_type (void); +DbusmenuGtkMenu * dbusmenu_gtkmenu_new (gchar * dbus_name, gchar * dbus_object); G_END_DECLS -- cgit v1.2.3 From 039c05e5e8961e1eac265a7a073526a2257d6665 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 20 May 2009 12:17:25 +0200 Subject: Comments on the structures along with some reserved entries. --- libdbusmenu-gtk/menu.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libdbusmenu-gtk/menu.h b/libdbusmenu-gtk/menu.h index 96dcca2..34def17 100644 --- a/libdbusmenu-gtk/menu.h +++ b/libdbusmenu-gtk/menu.h @@ -13,11 +13,29 @@ G_BEGIN_DECLS #define DBUSMENU_IS_GTKMENU_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_GTKMENU_TYPE)) #define DBUSMENU_GTKMENU_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_GTKMENU_TYPE, DbusmenuGtkMenuClass)) +/** + DbusmenuGtkMenuClass: + @parent_class: #GtkMenuClass + @reserved1: Reserved for future use. + @reserved2: Reserved for future use. + @reserved3: Reserved for future use. + @reserved4: Reserved for future use. +*/ typedef struct _DbusmenuGtkMenuClass DbusmenuGtkMenuClass; struct _DbusmenuGtkMenuClass { GtkMenuClass parent_class; + + /* Reserved */ + void (*reserved1) (void); + void (*reserved2) (void); + void (*reserved3) (void); + void (*reserved4) (void); }; +/** + DbusmenuGtkMenu: + @parent: #GtkMenu +*/ typedef struct _DbusmenuGtkMenu DbusmenuGtkMenu; struct _DbusmenuGtkMenu { GtkMenu parent; -- cgit v1.2.3 From c5a17e6a710ffadb20cdd65a9f42a2a1299424a4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 20 May 2009 12:41:18 +0200 Subject: Adding in some section documentation describing the menu item --- libdbusmenu-gtk/menu.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/libdbusmenu-gtk/menu.h b/libdbusmenu-gtk/menu.h index 34def17..dd5bdd1 100644 --- a/libdbusmenu-gtk/menu.h +++ b/libdbusmenu-gtk/menu.h @@ -44,6 +44,31 @@ struct _DbusmenuGtkMenu { GType dbusmenu_gtkmenu_get_type (void); DbusmenuGtkMenu * dbusmenu_gtkmenu_new (gchar * dbus_name, gchar * dbus_object); +/** + SECTION:gtkmenu + @short_description: A GTK Menu Object that syncronizes over DBus + @stability: Unstable + @include: libdbusmenu-gtk/menu.h + + In general, this is just a #GtkMenu, why else would you care? Oh, + because this menu is created by someone else on a server that exists + on the other side of DBus. You need a #DbusmenuServer to be able + push the data into this menu. + + The first thing you need to know is how to find that #DbusmenuServer + on DBus. This involves both the DBus name and the DBus object that + the menu interface can be found on. Those two value should be set + when creating the object using dbusmenu_gtkmenu_new(). They are then + stored on two properties #DbusmenuGtkMenu:dbus-name and #DbusmenuGtkMenu:dbus-object. + + After creation the #DbusmenuGtkMenu it will continue to keep in + synchronization with the #DbusmenuServer object across Dbus. If the + number of entries change, the menus change, if they change thier + properties change, they update in the items. All of this should + be handled transparently to the user of this object. + + TODO: Document properties. +*/ G_END_DECLS #endif -- cgit v1.2.3 From 43b314cee39228e8d4c46fe3705f8cb927474977 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 22 May 2009 11:07:59 +0200 Subject: Adding a connection in for processing layout changes --- libdbusmenu-gtk/menu.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 773d57a..52ebd1a 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -155,6 +155,19 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) /* Internal Functions */ +/* Processing the layout being updated and handling + that and making it into a menu */ +void +process_layout_change (DbusmenuClient * client, DbusmenuGtkMenu * gtkmenu) +{ + + + return; +} + + +/* Builds the client and connects all of the signals + up for it so that it's happy-happy */ static void build_client (DbusmenuGtkMenu * self) { @@ -162,6 +175,10 @@ build_client (DbusmenuGtkMenu * self) if (priv->client == NULL) { priv->client = dbusmenu_client_new(priv->dbus_name, priv->dbus_object); + + /* Register for layout changes, this should come after the + creation of the client pulls it from DBus */ + g_signal_connect(G_OBJECT(priv->client), DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED, G_CALLBACK(process_layout_change), self); } return; -- cgit v1.2.3 From 96513ce9369857b857dd74072b9316b49e6f2f9e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 24 May 2009 19:05:32 +0200 Subject: Starting the processing of changing the layout from the server --- libdbusmenu-gtk/menu.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 52ebd1a..814aaca 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -155,12 +155,87 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) /* Internal Functions */ +static const gchar * data_menuitem = "dbusmenugtk-data-gtkmenuitem"; +static const gchar * data_menu = "dbusmenugtk-data-gtkmenu"; + +static void +menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, gchar * value, GtkMenuItem * gmi) +{ + + + +} + +static void +connect_menuitem (DbusmenuMenuitem * mi, GtkMenuItem * gmi) +{ + g_object_ref(gmi); + g_object_set_data_full(G_OBJECT(mi), data_menuitem, gmi, g_object_unref); + + g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menu_prop_change_cb), gmi); + + return; +} + +static void +process_dbusmenu_menuitem (DbusmenuMenuitem * mi, GtkMenu * parentmenu) +{ + gpointer unknown_menuitem = g_object_get_data(G_OBJECT(mi), data_menuitem); + if (unknown_menuitem == NULL) { + /* Oh, a virgin DbusmenuMenuitem, let's fix that. */ + GtkWidget * menuitem = gtk_menu_item_new(); + connect_menuitem(mi, GTK_MENU_ITEM(menuitem)); + unknown_menuitem = menuitem; + gtk_menu_shell_append(GTK_MENU_SHELL(parentmenu), menuitem); + } + + GList * children = dbusmenu_menuitem_get_children(mi); + if (children == NULL) { + /* If there are no children to process we are + done and we can move along */ + return; + } + + /* Phase 0: Make a submenu if we don't have one */ + gpointer unknown_menu = g_object_get_data(G_OBJECT(mi), data_menu); + if (unknown_menu == NULL) { + GtkWidget * gtkmenu = gtk_menu_new(); + g_object_ref(gtkmenu); + g_object_set_data_full(G_OBJECT(mi), data_menu, gtkmenu, g_object_unref); + unknown_menu = gtkmenu; + gtk_menuitem_set_submenu(GTK_MENU_ITEM(unknown_menuitem), gtkmenu); + gtk_widget_show(gtkmenu); + } + + /* Phase 1: Add missing children */ + GList * child = NULL; + for (child = children; child != NULL; child = g_list_next(child)) { + + } + + /* Phase 2: Delete removed children */ + + + /* Phase 3: Profit! */ + return; +} + /* Processing the layout being updated and handling that and making it into a menu */ -void +static void process_layout_change (DbusmenuClient * client, DbusmenuGtkMenu * gtkmenu) { + DbusmenuMenuitem * root = dbusmenu_client_get_root(client); + GList * children = dbusmenu_menuitem_get_children(root); + if (children == NULL) { + return; + } + + GList * child = NULL; + for (child = children; child != NULL; child = g_list_next(child)) { + process_dbusmenu_menuitem(DBUSMENU_MENUITEM(child->data), GTK_MENU(gtkmenu)); + } return; } -- cgit v1.2.3 From bd52d2d670eb6881fda44ca1ae4e0c85c44d59fc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 24 May 2009 19:19:35 +0200 Subject: Passing back the menuitem getting clicked on. --- libdbusmenu-gtk/menu.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 814aaca..90cf2e2 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -158,6 +158,13 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) static const gchar * data_menuitem = "dbusmenugtk-data-gtkmenuitem"; static const gchar * data_menu = "dbusmenugtk-data-gtkmenu"; +static gboolean +menu_pressed_cb (GtkMenuItem * gmi, DbusmenuMenuitem * mi) +{ + dbusmenu_menuitem_activate(mi); + return TRUE; +} + static void menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, gchar * value, GtkMenuItem * gmi) { @@ -173,6 +180,7 @@ connect_menuitem (DbusmenuMenuitem * mi, GtkMenuItem * gmi) g_object_set_data_full(G_OBJECT(mi), data_menuitem, gmi, g_object_unref); g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menu_prop_change_cb), gmi); + g_signal_connect(G_OBJECT(gmi), "activate", G_CALLBACK(menu_pressed_cb), mi); return; } -- cgit v1.2.3 From 6c7818f652ef2f56b48e87da059593e340063047 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 24 May 2009 20:24:34 +0200 Subject: Using a weak ref to handle the deletion stuff. --- libdbusmenu-gtk/menu.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 90cf2e2..9bb23a8 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -156,7 +156,7 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) /* Internal Functions */ static const gchar * data_menuitem = "dbusmenugtk-data-gtkmenuitem"; -static const gchar * data_menu = "dbusmenugtk-data-gtkmenu"; +static const gchar * data_menu = "dbusmenugtk-data-gtkmenu"; static gboolean menu_pressed_cb (GtkMenuItem * gmi, DbusmenuMenuitem * mi) @@ -168,9 +168,19 @@ menu_pressed_cb (GtkMenuItem * gmi, DbusmenuMenuitem * mi) static void menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, gchar * value, GtkMenuItem * gmi) { + if (g_strcmp0(prop, "label")) { + gtk_menu_item_set_label(gmi, value); + gtk_widget_show(GTK_WIDGET(gmi)); + } + return; +} - +static void +destoryed_dbusmenuitem_cb (gpointer udata, GObject * dbusmenuitem) +{ + g_object_destory(G_OBJECT(udata)); + return; } static void @@ -179,9 +189,11 @@ connect_menuitem (DbusmenuMenuitem * mi, GtkMenuItem * gmi) g_object_ref(gmi); g_object_set_data_full(G_OBJECT(mi), data_menuitem, gmi, g_object_unref); - g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menu_prop_change_cb), gmi); + g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menu_prop_change_cb), gmi); g_signal_connect(G_OBJECT(gmi), "activate", G_CALLBACK(menu_pressed_cb), mi); + g_object_weak_ref(G_OBJECT(mi), destoryed_dbusmenuitem_cb, gmi); + return; } @@ -218,11 +230,13 @@ process_dbusmenu_menuitem (DbusmenuMenuitem * mi, GtkMenu * parentmenu) /* Phase 1: Add missing children */ GList * child = NULL; for (child = children; child != NULL; child = g_list_next(child)) { - + process_dbusmenu_menuitem(DBUSMENU_MENUITEM(child->data), GTK_MENU(unknown_menu)); } /* Phase 2: Delete removed children */ - + /* Actually, we don't need to do this because of the weak + reference that we've added above. When the DbusmenuMenuitem + gets destroyed it takes its GtkMenuItem with it. Bye bye. */ /* Phase 3: Profit! */ return; -- cgit v1.2.3 From a3e5b5d4e8b5f0919039a94d9e05b484dc8b0c67 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 24 May 2009 21:28:21 +0200 Subject: Switching to a unref and no ref for the tracking of GTK Menu Item. Also add better warnings. --- libdbusmenu-gtk/Makefile.am | 2 +- libdbusmenu-gtk/menu.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index e73c8c1..80e6058 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -19,7 +19,7 @@ libdbusmenu_gtk_la_LDFLAGS = \ -export-symbols-regex "^[^_].*" libdbusmenu_gtk_la_CFLAGS = \ - $(DBUSMENUGTK_CFLAGS) + $(DBUSMENUGTK_CFLAGS) -Wall -Werror libdbusmenu_gtk_la_LIBADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 9bb23a8..26543be 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -179,14 +179,13 @@ menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, gchar * value, GtkMenu static void destoryed_dbusmenuitem_cb (gpointer udata, GObject * dbusmenuitem) { - g_object_destory(G_OBJECT(udata)); + g_object_unref(G_OBJECT(udata)); return; } static void connect_menuitem (DbusmenuMenuitem * mi, GtkMenuItem * gmi) { - g_object_ref(gmi); g_object_set_data_full(G_OBJECT(mi), data_menuitem, gmi, g_object_unref); g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menu_prop_change_cb), gmi); @@ -223,7 +222,7 @@ process_dbusmenu_menuitem (DbusmenuMenuitem * mi, GtkMenu * parentmenu) g_object_ref(gtkmenu); g_object_set_data_full(G_OBJECT(mi), data_menu, gtkmenu, g_object_unref); unknown_menu = gtkmenu; - gtk_menuitem_set_submenu(GTK_MENU_ITEM(unknown_menuitem), gtkmenu); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(unknown_menuitem), gtkmenu); gtk_widget_show(gtkmenu); } -- cgit v1.2.3 From c77c0f5b854bb2b924b98a09f598db66de0ab5e4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 00:06:22 +0200 Subject: Building up the gtk tests. Oops, should have committed these a while ago. --- tests/Makefile.am | 39 ++++++++- tests/test-gtk-label-client.c | 180 ++++++++++++++++++++++++++++++++++++++++++ tests/test-gtk-label-server.c | 85 ++++++++++++++++++++ tests/test-gtk-label.h | 95 ++++++++++++++++++++++ 4 files changed, 397 insertions(+), 2 deletions(-) create mode 100644 tests/test-gtk-label-client.c create mode 100644 tests/test-gtk-label-server.c create mode 100644 tests/test-gtk-label.h diff --git a/tests/Makefile.am b/tests/Makefile.am index 1f21141..70750ac 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -2,14 +2,16 @@ check: tests DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf -tests: test-glib-layout test-glib-properties +tests: test-glib-layout test-glib-properties test-gtk-label libexec_PROGRAMS = \ glib-server-nomenu \ test-glib-layout-client \ test-glib-layout-server \ test-glib-properties-client \ - test-glib-properties-server + test-glib-properties-server \ + test-gtk-label-client \ + test-gtk-label-server glib_server_nomenu_SOURCES = \ glib-server-nomenu.c @@ -82,6 +84,39 @@ test_glib_properties_client_LDADD = \ +test-gtk-label: test-gtk-label-client test-gtk-label-server + $(DBUS_RUNNER) --task ./test-gtk-label-client --task-name Client --task ./test-gtk-label-server --task-name Server --ignore-return + +test_gtk_label_server_SOURCES = \ + test-gtk-label.h \ + test-gtk-label-server.c + +test_gtk_label_server_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGTK_CFLAGS) \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_gtk_label_server_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + ../libdbusmenu-gtk/libdbusmenu-gtk.la \ + $(DBUSMENUGTK_LIBS) + +test_gtk_label_client_SOURCES = \ + test-gtk-label.h \ + test-gtk-label-client.c + +test_gtk_label_client_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGTK_CFLAGS) \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_gtk_label_client_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + ../libdbusmenu-gtk/libdbusmenu-gtk.la \ + $(DBUSMENUGTK_LIBS) + + + examplesdir = $(docdir)/examples/ examples_DATA = \ diff --git a/tests/test-gtk-label-client.c b/tests/test-gtk-label-client.c new file mode 100644 index 0000000..028a526 --- /dev/null +++ b/tests/test-gtk-label-client.c @@ -0,0 +1,180 @@ +/* +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 guint layouton = 0; +static GMainLoop * mainloop = NULL; +static gboolean passed = TRUE; +static guint death_timer = 0; + +#if 0 +static gboolean +verify_props (DbusmenuMenuitem * mi, gchar ** properties) +{ + if (properties == NULL) { + return TRUE; + } + + /* Verify they're all there and correct */ + guint i; + for (i = 0; properties[i] != NULL; i += 2) { + const gchar * value = dbusmenu_menuitem_property_get(mi, properties[i]); + if (g_strcmp0(value, properties[i + 1])) { + g_debug("\tFailed as property '%s' should be '%s' and is '%s'", properties[i], properties[i+1], value); + return FALSE; + } + } + + /* Verify that we don't have any extras */ + // GList * props = dbusmenu_menuitem_properties_list(mi); + + return TRUE; +} + +static gboolean +verify_root_to_layout(DbusmenuMenuitem * mi, proplayout_t * layout) +{ + g_debug("Verifying ID: %d", layout->id); + + if (layout->id != dbusmenu_menuitem_get_id(mi)) { + g_debug("\tFailed as ID %d is not equal to %d", layout->id, dbusmenu_menuitem_get_id(mi)); + return FALSE; + } + + if (!verify_props(mi, layout->properties)) { + g_debug("\tFailed as unable to verify properties."); + return FALSE; + } + + GList * children = dbusmenu_menuitem_get_children(mi); + + if (children == NULL && layout->submenu == NULL) { + g_debug("\tPassed: %d", layout->id); + return TRUE; + } + if (children == NULL || layout->submenu == NULL) { + if (children == NULL) { + g_debug("\tFailed as there are no children but we have submenus"); + } else { + g_debug("\tFailed as we have children but no submenu"); + } + return FALSE; + } + + guint i = 0; + for (i = 0; children != NULL && layout->submenu[i].id != 0; children = g_list_next(children), i++) { + if (!verify_root_to_layout(DBUSMENU_MENUITEM(children->data), &layout->submenu[i])) { + return FALSE; + } + } + + if (children == NULL && layout->submenu[i].id == 0) { + g_debug("\tPassed: %d", layout->id); + return TRUE; + } + + if (children != NULL) { + g_debug("\tFailed as there are still children but no submenus. (ID: %d)", layout->id); + } else { + g_debug("\tFailed as there are still submenus but no children. (ID: %d)", layout->id); + } + return FALSE; +} +#endif + +static gboolean +timer_func (gpointer data) +{ + g_debug("Death timer. Oops. Got to: %d", layouton); + passed = FALSE; + g_main_loop_quit(mainloop); + return FALSE; +} + +#if 0 +static gboolean layout_verify_timer (gpointer data); + +static void +layout_updated (DbusmenuClient * client, gpointer data) +{ + g_debug("Layout Updated"); + g_timeout_add (250, layout_verify_timer, client); + return; +} + +static gboolean +layout_verify_timer (gpointer data) +{ + DbusmenuMenuitem * menuroot = dbusmenu_client_get_root(DBUSMENU_CLIENT(data)); + proplayout_t * layout = &layouts[layouton]; + + if (!verify_root_to_layout(menuroot, layout)) { + g_debug("FAILED LAYOUT: %d", layouton); + passed = FALSE; + } else { + /* Extend our death */ + g_source_remove(death_timer); + death_timer = g_timeout_add_seconds(10, timer_func, data); + } + + layouton++; + + if (layouts[layouton].id == 0) { + g_main_loop_quit(mainloop); + } + + return FALSE; +} +#endif + +int +main (int argc, char ** argv) +{ + gtk_init(&argc, &argv); + + /* Make sure the server starts up and all that */ + g_usleep(500000); + + 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 (":1.0", "/org/test"))); + gtk_widget_show(menuitem); + gtk_menu_bar_append(menubar, menuitem); + gtk_widget_show(menubar); + gtk_container_add(GTK_CONTAINER(window), menubar); + gtk_widget_show(window); + + death_timer = g_timeout_add_seconds(10, timer_func, window); + + 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 0; + } +} diff --git a/tests/test-gtk-label-server.c b/tests/test-gtk-label-server.c new file mode 100644 index 0000000..477f951 --- /dev/null +++ b/tests/test-gtk-label-server.c @@ -0,0 +1,85 @@ +#include + +#include +#include +#include + +#include +#include + +#include "test-glib-properties.h" + +static void +set_props (DbusmenuMenuitem * mi, gchar ** props) +{ + if (props == NULL) return; + + guint i; + for (i = 0; props[i] != NULL; i += 2) { + dbusmenu_menuitem_property_set(mi, props[i], props[i+1]); + } + + return; +} + +static DbusmenuMenuitem * +layout2menuitem (proplayout_t * layout) +{ + if (layout == NULL || layout->id == 0) return NULL; + + DbusmenuMenuitem * local = dbusmenu_menuitem_new_with_id(layout->id); + set_props(local, layout->properties); + + if (layout->submenu != NULL) { + guint count; + for (count = 0; layout->submenu[count].id != 0; count++) { + DbusmenuMenuitem * child = layout2menuitem(&layout->submenu[count]); + if (child != NULL) { + dbusmenu_menuitem_child_append(local, child); + } + } + } + + g_debug("Layout to menu return: 0x%X", (unsigned int)local); + return local; +} + +static guint layouton = 0; +static DbusmenuServer * server = NULL; +static GMainLoop * mainloop = NULL; + +static gboolean +timer_func (gpointer data) +{ + if (layouts[layouton].id == 0) { + g_main_loop_quit(mainloop); + return FALSE; + } + g_debug("Updating to Layout %d", layouton); + + dbusmenu_server_set_root(server, layout2menuitem(&layouts[layouton])); + layouton++; + + return TRUE; +} + +int +main (int argc, char ** argv) +{ + g_type_init(); + + g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); + + server = dbusmenu_server_new("/org/test"); + + timer_func(NULL); + g_timeout_add(2500, timer_func, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + g_debug("Quiting"); + + return 0; +} + diff --git a/tests/test-gtk-label.h b/tests/test-gtk-label.h new file mode 100644 index 0000000..3ab7ee7 --- /dev/null +++ b/tests/test-gtk-label.h @@ -0,0 +1,95 @@ + +#include + +typedef struct _proplayout_t proplayout_t; +struct _proplayout_t { + guint id; + gchar ** properties; + proplayout_t * submenu; +}; + +gchar * props1[] = {"property1", "value1", "property2", "value2", NULL}; +gchar * props2[] = {"property00", "value00", "property01", "value01", "property02", "value02", "property03", "value03", "property04", "value04", + "property05", "value05", "property06", "value06", "property07", "value07", "property08", "value08", "property09", "value09", + "property10", "value10", "property11", "value11", "property12", "value12", "property13", "value13", "property14", "value14", + "property15", "value15", "property16", "value16", "property17", "value17", "property18", "value18", "property19", "value19", + "property20", "value20", "property21", "value21", "property22", "value22", "property23", "value23", "property24", "value24", + "property25", "value25", "property26", "value26", "property27", "value27", "property28", "value28", "property29", "value29", + "property30", "value30", "property31", "value31", "property32", "value32", "property33", "value33", "property34", "value34", + "property35", "value35", "property36", "value36", "property37", "value37", "property38", "value38", "property39", "value39", + "property40", "value40", "property41", "value41", "property42", "value42", "property43", "value43", "property44", "value44", + "property45", "value45", "property46", "value46", "property47", "value47", "property48", "value48", "property49", "value49", + "property50", "value50", "property51", "value51", "property52", "value52", "property53", "value53", "property54", "value54", + "property55", "value55", "property56", "value56", "property57", "value57", "property58", "value58", "property59", "value59", + "property60", "value60", "property61", "value61", "property62", "value62", "property63", "value63", "property64", "value64", + "property65", "value65", "property66", "value66", "property67", "value67", "property68", "value68", "property69", "value69", + "property70", "value70", "property71", "value71", "property72", "value72", "property73", "value73", "property74", "value74", + "property75", "value75", "property76", "value76", "property77", "value77", "property78", "value78", "property79", "value79", + "property80", "value80", "property81", "value81", "property82", "value82", "property83", "value83", "property84", "value84", + "property85", "value85", "property86", "value86", "property87", "value87", "property88", "value88", "property89", "value89", + "property90", "value90", "property91", "value91", "property92", "value92", "property93", "value93", "property94", "value94", + "property95", "value95", "property96", "value96", "property97", "value97", "property98", "value98", "property99", "value99", + NULL}; +gchar * props3[] = {"property name that is really long and will ensure that we can really have long property names, which could be important at some point.", + "And a property name that is really long should have a value that is really long, because well, that's an important part of the yin and yang of software testing.", + NULL}; +gchar * props4[] = {"icon-name", "network-status", "label", "Look at network", "right-column", "10:32", NULL}; + + +proplayout_t submenu_4_1[] = { + {id: 10, properties: props2, submenu: NULL}, + {id: 11, properties: props2, submenu: NULL}, + {id: 12, properties: props2, submenu: NULL}, + {id: 13, properties: props2, submenu: NULL}, + {id: 14, properties: props2, submenu: NULL}, + {id: 15, properties: props2, submenu: NULL}, + {id: 16, properties: props2, submenu: NULL}, + {id: 17, properties: props2, submenu: NULL}, + {id: 18, properties: props2, submenu: NULL}, + {id: 19, properties: props2, submenu: NULL}, + {id: 0, properties: NULL, submenu: NULL} +}; + +proplayout_t submenu_4_2[] = { + {id: 20, properties: props2, submenu: NULL}, + {id: 21, properties: props2, submenu: NULL}, + {id: 22, properties: props2, submenu: NULL}, + {id: 23, properties: props2, submenu: NULL}, + {id: 24, properties: props2, submenu: NULL}, + {id: 25, properties: props2, submenu: NULL}, + {id: 26, properties: props2, submenu: NULL}, + {id: 27, properties: props2, submenu: NULL}, + {id: 28, properties: props2, submenu: NULL}, + {id: 29, properties: props2, submenu: NULL}, + {id: 0, properties: NULL, submenu: NULL} +}; + +proplayout_t submenu_4_3[] = { + {id: 30, properties: props2, submenu: NULL}, + {id: 31, properties: props2, submenu: NULL}, + {id: 32, properties: props2, submenu: NULL}, + {id: 33, properties: props2, submenu: NULL}, + {id: 34, properties: props2, submenu: NULL}, + {id: 35, properties: props2, submenu: NULL}, + {id: 36, properties: props2, submenu: NULL}, + {id: 37, properties: props2, submenu: NULL}, + {id: 38, properties: props2, submenu: NULL}, + {id: 39, properties: props2, submenu: NULL}, + {id: 0, properties: NULL, submenu: NULL} +}; + +proplayout_t submenu_4_0[] = { + {id: 1, properties: props2, submenu: submenu_4_1}, + {id: 2, properties: props2, submenu: submenu_4_2}, + {id: 3, properties: props2, submenu: submenu_4_3}, + {id: 0, properties: NULL, submenu: NULL} +}; + +proplayout_t layouts[] = { + {id: 1, properties: props1, submenu: NULL}, + {id: 10, properties: props2, submenu: NULL}, + {id: 20, properties: props3, submenu: NULL}, + {id: 100, properties: props2, submenu: submenu_4_0}, + {id: 0, properties: NULL, submenu: NULL} +}; + -- cgit v1.2.3 From b5b9c25d8422e71e2f9d4c3c07fbc9f9a0d098fa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 00:06:51 +0200 Subject: Ignoring the binaries --- .bzrignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.bzrignore b/.bzrignore index 4cd2a88..da9e9ce 100644 --- a/.bzrignore +++ b/.bzrignore @@ -34,3 +34,5 @@ libdbusmenu_glib_la-menuitem-marshal.lo test-glib-properties-client test-glib-properties-server libdbusmenu_gtk_la-menu.lo +test-gtk-label-client +test-gtk-label-server -- cgit v1.2.3 From 8d10e66c11d3708a72e9c5f6ba79632e6fcc1b8f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 00:09:10 +0200 Subject: Properties that make a little more sense. --- tests/test-gtk-label.h | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/tests/test-gtk-label.h b/tests/test-gtk-label.h index 3ab7ee7..ca98700 100644 --- a/tests/test-gtk-label.h +++ b/tests/test-gtk-label.h @@ -8,29 +8,8 @@ struct _proplayout_t { proplayout_t * submenu; }; -gchar * props1[] = {"property1", "value1", "property2", "value2", NULL}; -gchar * props2[] = {"property00", "value00", "property01", "value01", "property02", "value02", "property03", "value03", "property04", "value04", - "property05", "value05", "property06", "value06", "property07", "value07", "property08", "value08", "property09", "value09", - "property10", "value10", "property11", "value11", "property12", "value12", "property13", "value13", "property14", "value14", - "property15", "value15", "property16", "value16", "property17", "value17", "property18", "value18", "property19", "value19", - "property20", "value20", "property21", "value21", "property22", "value22", "property23", "value23", "property24", "value24", - "property25", "value25", "property26", "value26", "property27", "value27", "property28", "value28", "property29", "value29", - "property30", "value30", "property31", "value31", "property32", "value32", "property33", "value33", "property34", "value34", - "property35", "value35", "property36", "value36", "property37", "value37", "property38", "value38", "property39", "value39", - "property40", "value40", "property41", "value41", "property42", "value42", "property43", "value43", "property44", "value44", - "property45", "value45", "property46", "value46", "property47", "value47", "property48", "value48", "property49", "value49", - "property50", "value50", "property51", "value51", "property52", "value52", "property53", "value53", "property54", "value54", - "property55", "value55", "property56", "value56", "property57", "value57", "property58", "value58", "property59", "value59", - "property60", "value60", "property61", "value61", "property62", "value62", "property63", "value63", "property64", "value64", - "property65", "value65", "property66", "value66", "property67", "value67", "property68", "value68", "property69", "value69", - "property70", "value70", "property71", "value71", "property72", "value72", "property73", "value73", "property74", "value74", - "property75", "value75", "property76", "value76", "property77", "value77", "property78", "value78", "property79", "value79", - "property80", "value80", "property81", "value81", "property82", "value82", "property83", "value83", "property84", "value84", - "property85", "value85", "property86", "value86", "property87", "value87", "property88", "value88", "property89", "value89", - "property90", "value90", "property91", "value91", "property92", "value92", "property93", "value93", "property94", "value94", - "property95", "value95", "property96", "value96", "property97", "value97", "property98", "value98", "property99", "value99", - NULL}; -gchar * props3[] = {"property name that is really long and will ensure that we can really have long property names, which could be important at some point.", +gchar * props1[] = {"label", "value1", NULL}; +gchar * props3[] = {"label", "And a property name that is really long should have a value that is really long, because well, that's an important part of the yin and yang of software testing.", NULL}; gchar * props4[] = {"icon-name", "network-status", "label", "Look at network", "right-column", "10:32", NULL}; -- cgit v1.2.3 From 342660113458cdcd2c19421733701aba335774eb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 00:35:41 +0200 Subject: Requesting a name on the bus --- tests/test-gtk-label-server.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/test-gtk-label-server.c b/tests/test-gtk-label-server.c index 477f951..0e395d4 100644 --- a/tests/test-gtk-label-server.c +++ b/tests/test-gtk-label-server.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -68,8 +69,23 @@ main (int argc, char ** argv) { 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); + GError * error = NULL; + 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); -- cgit v1.2.3 From b26bb869e0bc037533c62ae77907b5368fdee9a3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 00:39:09 +0200 Subject: Using the new name --- tests/test-gtk-label-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-gtk-label-client.c b/tests/test-gtk-label-client.c index 028a526..44a847f 100644 --- a/tests/test-gtk-label-client.c +++ b/tests/test-gtk-label-client.c @@ -158,7 +158,7 @@ main (int argc, char ** argv) 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 (":1.0", "/org/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); -- cgit v1.2.3 From c6e13ca433f0e8538a60a80cee3ce1a359b88bd6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 14:17:44 +0200 Subject: Switching to the right header and updating the properties more. --- tests/test-gtk-label-server.c | 2 +- tests/test-gtk-label.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/test-gtk-label-server.c b/tests/test-gtk-label-server.c index 0e395d4..426daa2 100644 --- a/tests/test-gtk-label-server.c +++ b/tests/test-gtk-label-server.c @@ -8,7 +8,7 @@ #include #include -#include "test-glib-properties.h" +#include "test-gtk-label.h" static void set_props (DbusmenuMenuitem * mi, gchar ** props) diff --git a/tests/test-gtk-label.h b/tests/test-gtk-label.h index ca98700..e63ac44 100644 --- a/tests/test-gtk-label.h +++ b/tests/test-gtk-label.h @@ -9,6 +9,7 @@ struct _proplayout_t { }; gchar * props1[] = {"label", "value1", NULL}; +gchar * props2[] = {"label", "value1", NULL}; gchar * props3[] = {"label", "And a property name that is really long should have a value that is really long, because well, that's an important part of the yin and yang of software testing.", NULL}; @@ -65,9 +66,9 @@ proplayout_t submenu_4_0[] = { }; proplayout_t layouts[] = { - {id: 1, properties: props1, submenu: NULL}, - {id: 10, properties: props2, submenu: NULL}, - {id: 20, properties: props3, submenu: NULL}, + {id: 1, properties: props1, submenu: submenu_4_3}, + {id: 10, properties: props2, submenu: submenu_4_2}, + {id: 20, properties: props3, submenu: submenu_4_1}, {id: 100, properties: props2, submenu: submenu_4_0}, {id: 0, properties: NULL, submenu: NULL} }; -- cgit v1.2.3 From 1f574297a0c846edb0cf84107de4b13247f28036 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 14:26:05 +0200 Subject: Bother, truth is so fickle in that it is so binary in wanting correctness. --- libdbusmenu-gtk/menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 26543be..3919314 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -168,7 +168,7 @@ menu_pressed_cb (GtkMenuItem * gmi, DbusmenuMenuitem * mi) static void menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, gchar * value, GtkMenuItem * gmi) { - if (g_strcmp0(prop, "label")) { + if (!g_strcmp0(prop, "label")) { gtk_menu_item_set_label(gmi, value); gtk_widget_show(GTK_WIDGET(gmi)); } -- cgit v1.2.3 From 3b4051390bfb7e150f552da448e00dece4fbdf2f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 17:17:34 +0200 Subject: Tracking destruction --- libdbusmenu-gtk/menu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 3919314..9ad1bcf 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -179,6 +179,7 @@ menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, gchar * value, GtkMenu static void destoryed_dbusmenuitem_cb (gpointer udata, GObject * dbusmenuitem) { + g_debug("DbusmenuMenuitem was destroyed"); g_object_unref(G_OBJECT(udata)); return; } -- cgit v1.2.3 From 7967d870eee94c0ce26cf820a6f6e556ee9cea48 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 22:56:31 +0200 Subject: Unref'ing the menuitem after being created. --- tests/test-glib-properties-server.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test-glib-properties-server.c b/tests/test-glib-properties-server.c index 477f951..c9d2880 100644 --- a/tests/test-glib-properties-server.c +++ b/tests/test-glib-properties-server.c @@ -40,7 +40,7 @@ layout2menuitem (proplayout_t * layout) } } - g_debug("Layout to menu return: 0x%X", (unsigned int)local); + /* g_debug("Layout to menu return: 0x%X", (unsigned int)local); */ return local; } @@ -57,7 +57,9 @@ timer_func (gpointer data) } g_debug("Updating to Layout %d", layouton); - dbusmenu_server_set_root(server, layout2menuitem(&layouts[layouton])); + DbusmenuMenuitem * mi = layout2menuitem(&layouts[layouton]); + dbusmenu_server_set_root(server, mi); + g_object_unref(G_OBJECT(mi)); layouton++; return TRUE; -- cgit v1.2.3 From 4614822dddd73d5ab16f7f97555f99e8b5460d4c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 23:08:14 +0200 Subject: Unref'ing the object put into the GValue as it gets reffed there. --- libdbusmenu-glib/server.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 562b2d7..cf8ea85 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -490,6 +490,7 @@ dbusmenu_server_set_root (DbusmenuServer * self, DbusmenuMenuitem * root) g_value_init(&rootvalue, G_TYPE_OBJECT); g_value_set_object(&rootvalue, root); g_object_set_property(G_OBJECT(self), DBUSMENU_SERVER_PROP_ROOT_NODE, &rootvalue); + g_object_unref(G_OBJECT(root)); return; } -- cgit v1.2.3 From 0b46d2d1e1acbe32b5468565731a6e5a08c9282b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 23:08:56 +0200 Subject: Unref'ing the children if we're being killed ourselves --- libdbusmenu-glib/menuitem.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 9506cad..91429d6 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -185,6 +185,14 @@ dbusmenu_menuitem_init (DbusmenuMenuitem *self) static void dbusmenu_menuitem_dispose (GObject *object) { + DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(object); + + GList * child = NULL; + for (child = priv->children; child != NULL; child = g_list_next(child)) { + g_object_unref(G_OBJECT(child->data)); + } + g_list_free(priv->children); + priv->children = NULL; G_OBJECT_CLASS (dbusmenu_menuitem_parent_class)->dispose (object); return; @@ -193,6 +201,7 @@ dbusmenu_menuitem_dispose (GObject *object) static void dbusmenu_menuitem_finalize (GObject *object) { + g_debug("Menuitem dying"); DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(object); if (priv->properties != NULL) { -- cgit v1.2.3 From 9ce6eb561b1a9e188330fe73952bbc1a3d2e256f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 23:09:19 +0200 Subject: Playing with debug stuff --- libdbusmenu-glib/client.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index c6833cc..f21f721 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -387,6 +387,7 @@ parse_layout_xml(xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * pa dbusmenu_menuitem_child_delete(parent, item); } g_object_unref(G_OBJECT(item)); + item = NULL; } if (id == 0) { @@ -403,6 +404,7 @@ parse_layout_xml(xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * pa xmlNodePtr children; guint position; GList * oldchildren = dbusmenu_menuitem_take_children(item); + /* g_debug("Starting old children: %d", g_list_length(oldchildren)); */ for (children = node->children, position = 0; children != NULL; children = children->next, position++) { /* g_debug("Looking at child: %d", position); */ @@ -423,9 +425,11 @@ parse_layout_xml(xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * pa dbusmenu_menuitem_child_add_position(item, childmi, position); } + /* g_debug("Stopping old children: %d", g_list_length(oldchildren)); */ GList * oldchildleft = NULL; for (oldchildleft = oldchildren; oldchildleft != NULL; oldchildleft = g_list_next(oldchildleft)) { DbusmenuMenuitem * oldmi = DBUSMENU_MENUITEM(oldchildleft->data); + g_debug("Unref'ing menu item with layout update. ID: %d", dbusmenu_menuitem_get_id(oldmi)); g_object_unref(G_OBJECT(oldmi)); } g_list_free(oldchildren); -- cgit v1.2.3 From 2d5dc7c1f0be1da109fd6a19a2f6f4db70bc2f1a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 23:11:00 +0200 Subject: Removing the server as we go away --- tests/test-glib-properties-server.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test-glib-properties-server.c b/tests/test-glib-properties-server.c index c9d2880..a51ac0c 100644 --- a/tests/test-glib-properties-server.c +++ b/tests/test-glib-properties-server.c @@ -80,6 +80,7 @@ main (int argc, char ** argv) mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); + g_object_unref(G_OBJECT(server)); g_debug("Quiting"); return 0; -- cgit v1.2.3 From 59e8bba4ca5c9164fcbc886af94e6e2c627d523e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 23:15:16 +0200 Subject: Unref'ing root when we dispose --- libdbusmenu-glib/client.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index f21f721..61f8c34 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -169,6 +169,11 @@ dbusmenu_client_dispose (GObject *object) } priv->session_bus = NULL; + if (priv->root != NULL) { + g_object_unref(G_OBJECT(priv->root)); + priv->root = NULL; + } + G_OBJECT_CLASS (dbusmenu_client_parent_class)->dispose (object); return; } -- cgit v1.2.3 From 1891e81fa2c10654d2e0707f48d510ab8543675b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 23:21:28 +0200 Subject: Switching so that we're destroying the widget instead of object unref'ing the widget. --- libdbusmenu-gtk/menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index 9ad1bcf..aa8dc10 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -180,14 +180,14 @@ static void destoryed_dbusmenuitem_cb (gpointer udata, GObject * dbusmenuitem) { g_debug("DbusmenuMenuitem was destroyed"); - g_object_unref(G_OBJECT(udata)); + gtk_widget_destroy(GTK_WIDGET(udata)); return; } static void connect_menuitem (DbusmenuMenuitem * mi, GtkMenuItem * gmi) { - g_object_set_data_full(G_OBJECT(mi), data_menuitem, gmi, g_object_unref); + g_object_set_data(G_OBJECT(mi), data_menuitem, gmi); g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(menu_prop_change_cb), gmi); g_signal_connect(G_OBJECT(gmi), "activate", G_CALLBACK(menu_pressed_cb), mi); -- cgit v1.2.3 From 30a97d87f44f64c5a533b244b7e77bb01787ea53 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 23:21:54 +0200 Subject: Debug fix --- libdbusmenu-gtk/menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/menu.c b/libdbusmenu-gtk/menu.c index aa8dc10..dd2df37 100644 --- a/libdbusmenu-gtk/menu.c +++ b/libdbusmenu-gtk/menu.c @@ -179,7 +179,7 @@ menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, gchar * value, GtkMenu static void destoryed_dbusmenuitem_cb (gpointer udata, GObject * dbusmenuitem) { - g_debug("DbusmenuMenuitem was destroyed"); + /* g_debug("DbusmenuMenuitem was destroyed"); */ gtk_widget_destroy(GTK_WIDGET(udata)); return; } -- cgit v1.2.3 From a679639007c82a37fcf144df7ed0e8ce23180a3b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 26 May 2009 23:30:42 +0200 Subject: Too many values on signal --- libdbusmenu-glib/menuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 91429d6..c4cc297 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -139,7 +139,7 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) G_STRUCT_OFFSET(DbusmenuMenuitemClass, child_added), NULL, NULL, _dbusmenu_menuitem_marshal_VOID__OBJECT, - G_TYPE_NONE, 2, G_TYPE_OBJECT); + G_TYPE_NONE, 1, G_TYPE_OBJECT); /** DbusmenuMenuitem::child-removed: @arg0: The #DbusmenuMenuitem which was the parent. -- cgit v1.2.3 From 1684aa666fa4c345030c17e439e5287ae1a2498e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 26 May 2009 23:46:17 +0200 Subject: Adding a reorder and prepend convience functions so that they emit the right signals. --- libdbusmenu-glib/menuitem.c | 47 +++++++++++++++++++++++++++++++++++++++++++++ libdbusmenu-glib/menuitem.h | 2 ++ 2 files changed, 49 insertions(+) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index c4cc297..bc499e0 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -402,6 +402,28 @@ dbusmenu_menuitem_child_append (DbusmenuMenuitem * mi, DbusmenuMenuitem * child) return TRUE; } +/** + dbusmenu_menuitem_child_prepend: + @mi: The #DbusmenuMenuitem which will become a new parent + @child: The #DbusmenMenuitem that will be a child + + This function adds @child to the list of children on @mi at + the beginning of that list. + + Return value: Whether the child has been added successfully. +*/ +gboolean +dbusmenu_menuitem_child_prepend (DbusmenuMenuitem * mi, DbusmenuMenuitem * child) +{ + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), FALSE); + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(child), FALSE); + + DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); + priv->children = g_list_prepend(priv->children, child); + g_signal_emit(G_OBJECT(mi), signals[CHILD_ADDED], 0, child, TRUE); + return TRUE; +} + /** dbusmenu_menuitem_child_delete: @mi: The #DbusmenuMenuitem which has @child as a child @@ -449,6 +471,31 @@ dbusmenu_menuitem_child_add_position (DbusmenuMenuitem * mi, DbusmenuMenuitem * return TRUE; } +/** + dbusmenu_menuitem_child_reorder: + @base: The #DbusmenuMenuitem that has children needing realignment + @child: The #DbusmenuMenuitem that is a child needing to be moved + @position: The position in the list to place it in + + This function moves a child on the list of children. It is + for a child that is already in the list, but simply needs a + new location. + + Return value: Whether the move was successful. +*/ +gboolean +dbusmenu_menuitem_child_reorder(DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position) +{ + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), FALSE); + g_return_val_if_fail(DBUSMENU_IS_MENUITEM(child), FALSE); + + DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); + priv->children = g_list_remove(priv->children, child); + priv->children = g_list_insert(priv->children, child, position); + + return TRUE; +} + /** dbusmenu_menuitem_child_find: @mi: The #DbusmenuMenuitem who's children to look on diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 3f3e97c..c4fcf73 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -107,8 +107,10 @@ GList * dbusmenu_menuitem_take_children (DbusmenuMenuitem * mi) G_GNUC_WARN_UNUS guint dbusmenu_menuitem_get_position (DbusmenuMenuitem * mi, DbusmenuMenuitem * parent); gboolean dbusmenu_menuitem_child_append (DbusmenuMenuitem * mi, DbusmenuMenuitem * child); +gboolean dbusmenu_menuitem_child_prepend (DbusmenuMenuitem * mi, DbusmenuMenuitem * child); gboolean dbusmenu_menuitem_child_delete (DbusmenuMenuitem * mi, DbusmenuMenuitem * child); gboolean dbusmenu_menuitem_child_add_position (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position); +gboolean dbusmenu_menuitem_child_reorder (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint position); DbusmenuMenuitem * dbusmenu_menuitem_child_find (DbusmenuMenuitem * mi, guint id); DbusmenuMenuitem * dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, guint id); -- cgit v1.2.3 From cf742bc4e9effbb68dd369c8ff9002d59701458c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 26 May 2009 23:55:32 +0200 Subject: Same cut and paste bug, you'd think I'd be smart enough to check this when I fixed the last one. Dumbass. --- libdbusmenu-glib/menuitem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index bc499e0..95391a4 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -156,7 +156,7 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) G_STRUCT_OFFSET(DbusmenuMenuitemClass, child_removed), NULL, NULL, _dbusmenu_menuitem_marshal_VOID__OBJECT, - G_TYPE_NONE, 2, G_TYPE_OBJECT); + G_TYPE_NONE, 1, G_TYPE_OBJECT); g_object_class_install_property (object_class, PROP_ID, g_param_spec_uint("id", "ID for the menu item", -- cgit v1.2.3 From cd053ef1cae0ffb2ccd38afcc5ea7c719daf3334 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 27 May 2009 10:11:12 +0200 Subject: Pointer casts make the 64-bit builds unhappy. --- tests/test-glib-layout-server.c | 2 +- tests/test-gtk-label-server.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test-glib-layout-server.c b/tests/test-glib-layout-server.c index e69c6b2..cc9b8e7 100644 --- a/tests/test-glib-layout-server.c +++ b/tests/test-glib-layout-server.c @@ -48,7 +48,7 @@ layout2menuitem (layout_t * layout) } } - g_debug("Layout to menu return: 0x%X", (unsigned int)local); + /* g_debug("Layout to menu return: 0x%X", (unsigned int)local); */ return local; } diff --git a/tests/test-gtk-label-server.c b/tests/test-gtk-label-server.c index 426daa2..4e2fe0a 100644 --- a/tests/test-gtk-label-server.c +++ b/tests/test-gtk-label-server.c @@ -41,7 +41,7 @@ layout2menuitem (proplayout_t * layout) } } - g_debug("Layout to menu return: 0x%X", (unsigned int)local); + /* g_debug("Layout to menu return: 0x%X", (unsigned int)local); */ return local; } -- cgit v1.2.3 From 757ec5c8852ca964f25326e96c66c0e44c8614b8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 5 Jun 2009 15:59:00 -0500 Subject: Getting distcheck to pass by getting the header files from the -glib branch of things. --- libdbusmenu-gtk/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index 80e6058..831719c 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -19,7 +19,7 @@ libdbusmenu_gtk_la_LDFLAGS = \ -export-symbols-regex "^[^_].*" libdbusmenu_gtk_la_CFLAGS = \ - $(DBUSMENUGTK_CFLAGS) -Wall -Werror + $(DBUSMENUGTK_CFLAGS) -I$(srcdir)/.. -Wall -Werror libdbusmenu_gtk_la_LIBADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ -- cgit v1.2.3 From 23b418faf95a4e8fef6c98726309292325b5919c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Jun 2009 13:48:50 -0500 Subject: Adding in json-glib to make the tests more configurable. --- configure.ac | 11 +++++++++++ tests/Makefile.am | 8 ++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 9770814..d35e27b 100644 --- a/configure.ac +++ b/configure.ac @@ -48,6 +48,17 @@ PKG_CHECK_MODULES(DBUSMENUGTK, gtk+-2.0 >= $GTK_REQUIRED_VERSION AC_SUBST(DBUSMENUGTK_CFLAGS) AC_SUBST(DBUSMENUGTK_LIBS) +########################### +# Dependencies - Testing +########################### + +JSON_GLIB_REQUIRED_VERSION=0.6.0 + +PKG_CHECK_MODULES(DBUSMENUTESTS, json-glib-1.0 >= $JSON_GLIB_REQUIRED_VERSION) + +AC_SUBST(DBUSMENUTESTS_CFLAGS) +AC_SUBST(DBUSMENUTESTS_LIBS) + ########################### # Lib versioning ########################### diff --git a/tests/Makefile.am b/tests/Makefile.am index 70750ac..3e818a2 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -94,12 +94,14 @@ test_gtk_label_server_SOURCES = \ test_gtk_label_server_CFLAGS = \ -I $(srcdir)/.. \ $(DBUSMENUGTK_CFLAGS) \ + $(DBUSMENUTESTS_CFLAGS) \ $(DBUSMENUGLIB_CFLAGS) -Wall -Werror test_gtk_label_server_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ ../libdbusmenu-gtk/libdbusmenu-gtk.la \ - $(DBUSMENUGTK_LIBS) + $(DBUSMENUGTK_LIBS) \ + $(DBUSMENUTESTS_LIBS) test_gtk_label_client_SOURCES = \ test-gtk-label.h \ @@ -108,12 +110,14 @@ test_gtk_label_client_SOURCES = \ test_gtk_label_client_CFLAGS = \ -I $(srcdir)/.. \ $(DBUSMENUGTK_CFLAGS) \ + $(DBUSMENUTESTS_CFLAGS) \ $(DBUSMENUGLIB_CFLAGS) -Wall -Werror test_gtk_label_client_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ ../libdbusmenu-gtk/libdbusmenu-gtk.la \ - $(DBUSMENUGTK_LIBS) + $(DBUSMENUGTK_LIBS) \ + $(DBUSMENUTESTS_LIBS) -- cgit v1.2.3 From 649793765154a37d717d833d305e4a9671c996f9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Jun 2009 14:26:13 -0500 Subject: Switching from a header file to building the layout using a json definition. --- tests/test-gtk-label-server.c | 70 +++++++++++++++++++++++++++++++++---------- 1 file changed, 54 insertions(+), 16 deletions(-) diff --git a/tests/test-gtk-label-server.c b/tests/test-gtk-label-server.c index 4e2fe0a..349d7d1 100644 --- a/tests/test-gtk-label-server.c +++ b/tests/test-gtk-label-server.c @@ -8,33 +8,55 @@ #include #include -#include "test-gtk-label.h" +#include static void -set_props (DbusmenuMenuitem * mi, gchar ** props) +set_props (DbusmenuMenuitem * mi, JsonObject * node) { - if (props == NULL) return; + if (node == NULL) return; - guint i; - for (i = 0; props[i] != NULL; i += 2) { - dbusmenu_menuitem_property_set(mi, props[i], props[i+1]); + GList * members = NULL; + for (members = json_object_get_members(node); members != NULL; members = g_list_next(members)) { + const gchar * member = members->data; + + if (!g_strcmp0(member, "id")) { continue; } + if (!g_strcmp0(member, "submenu")) { continue; } + + JsonNode * lnode = json_object_get_member(node, member); + if (JSON_NODE_TYPE(lnode) != JSON_NODE_VALUE) { continue; } + + dbusmenu_menuitem_property_set(mi, member, json_node_get_string(lnode)); } return; } static DbusmenuMenuitem * -layout2menuitem (proplayout_t * layout) +layout2menuitem (JsonNode * inlayout) { - if (layout == NULL || layout->id == 0) return NULL; + if (inlayout == NULL) return NULL; + if (JSON_NODE_TYPE(inlayout) != JSON_NODE_OBJECT) return NULL; + + JsonObject * layout = json_node_get_object(inlayout); + + DbusmenuMenuitem * local = NULL; + if (json_object_has_member(layout, "id")) { + JsonNode * node = json_object_get_member(layout, "id"); + g_return_val_if_fail(JSON_NODE_TYPE(node) == JSON_NODE_VALUE, NULL); + local = dbusmenu_menuitem_new_with_id(json_node_get_int(node)); + } else { + local = dbusmenu_menuitem_new(); + } - DbusmenuMenuitem * local = dbusmenu_menuitem_new_with_id(layout->id); - set_props(local, layout->properties); + set_props(local, layout); - if (layout->submenu != NULL) { + if (json_object_has_member(layout, "submenu")) { + JsonNode * node = json_object_get_member(layout, "submenu"); + g_return_val_if_fail(JSON_NODE_TYPE(node) == JSON_NODE_ARRAY, local); + JsonArray * array = json_node_get_array(node); guint count; - for (count = 0; layout->submenu[count].id != 0; count++) { - DbusmenuMenuitem * child = layout2menuitem(&layout->submenu[count]); + for (count = 0; count < json_array_get_length(array); count++) { + DbusmenuMenuitem * child = layout2menuitem(json_array_get_element(array, count)); if (child != NULL) { dbusmenu_menuitem_child_append(local, child); } @@ -45,6 +67,7 @@ layout2menuitem (proplayout_t * layout) return local; } +static JsonArray * root_array = NULL; static guint layouton = 0; static DbusmenuServer * server = NULL; static GMainLoop * mainloop = NULL; @@ -52,13 +75,14 @@ static GMainLoop * mainloop = NULL; static gboolean timer_func (gpointer data) { - if (layouts[layouton].id == 0) { + if (layouton == json_array_get_length(root_array)) { + g_debug("Completed %d layouts", layouton); g_main_loop_quit(mainloop); return FALSE; } g_debug("Updating to Layout %d", layouton); - dbusmenu_server_set_root(server, layout2menuitem(&layouts[layouton])); + dbusmenu_server_set_root(server, layout2menuitem(json_array_get_element(root_array, layouton))); layouton++; return TRUE; @@ -69,11 +93,25 @@ main (int argc, char ** argv) { g_type_init(); + JsonParser * parser = json_parser_new(); + GError * error = NULL; + if (!json_parser_load_from_file(parser, argv[1], &error)) { + g_debug("Failed parsing file %s because: %s", argv[1], error->message); + return 1; + } + JsonNode * root_node = json_parser_get_root(parser); + if (JSON_NODE_TYPE(root_node) != JSON_NODE_ARRAY) { + g_debug("Root node is not an array, fail. It's an: %s", json_node_type_name(root_node)); + return 1; + } + + 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); - GError * error = NULL; guint nameret = 0; if (!org_freedesktop_DBus_request_name(bus_proxy, "glib.label.test", 0, &nameret, &error)) { -- cgit v1.2.3 From 383f487b5ad3a22a78d9ee061fa5936b3a36725e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Jun 2009 14:59:57 -0500 Subject: Getting the label tests into a json file. --- tests/test-gtk-label.json | 158 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 tests/test-gtk-label.json diff --git a/tests/test-gtk-label.json b/tests/test-gtk-label.json new file mode 100644 index 0000000..64c1386 --- /dev/null +++ b/tests/test-gtk-label.json @@ -0,0 +1,158 @@ +[ + {"id": 1, + "label": "value1", + "submenu": [ + {"id": 30, + "label": "value30"}, + {"id": 31, + "label": "value31"}, + {"id": 32, + "label": "value32"}, + {"id": 33, + "label": "value33"}, + {"id": 34, + "label": "value34"}, + {"id": 35, + "label": "value35"}, + {"id": 36, + "label": "value36"}, + {"id": 37, + "label": "value37"}, + {"id": 38, + "label": "value38"}, + {"id": 39, + "label": "value39"} + ] + }, + {"id": 2, + "label": "value2", + "submenu": [ + {"id": 20, + "label": "value20"}, + {"id": 21, + "label": "value21"}, + {"id": 22, + "label": "value22"}, + {"id": 23, + "label": "value23"}, + {"id": 24, + "label": "value24"}, + {"id": 25, + "label": "value25"}, + {"id": 26, + "label": "value26"}, + {"id": 27, + "label": "value27"}, + {"id": 28, + "label": "value28"}, + {"id": 29, + "label": "value29"} + ] + }, + {"id": 3, + "label": "a super long label that is really of unreasonable length but we should make sure it makes it across the bus", + "not.a.value": "A useless value", + "submenu": [ + {"id": 10, + "label": "value10"}, + {"id": 11, + "label": "value11"}, + {"id": 12, + "label": "value12"}, + {"id": 13, + "label": "value13"}, + {"id": 14, + "label": "value14"}, + {"id": 15, + "label": "value15"}, + {"id": 16, + "label": "value16"}, + {"id": 17, + "label": "value17"}, + {"id": 18, + "label": "value18"}, + {"id": 19, + "label": "value19"} + ] + }, + {"id": 4, + "label": "value2", + "submenu": [ + {"id": 5, + "label": "value5", + "submenu": [ + {"id": 10, + "label": "value10"}, + {"id": 11, + "label": "value11"}, + {"id": 12, + "label": "value12"}, + {"id": 13, + "label": "value13"}, + {"id": 14, + "label": "value14"}, + {"id": 15, + "label": "value15"}, + {"id": 16, + "label": "value16"}, + {"id": 17, + "label": "value17"}, + {"id": 18, + "label": "value18"}, + {"id": 19, + "label": "value19"} + ] + }, + {"id": 6, + "label": "value6", + "submenu": [ + {"id": 20, + "label": "value20"}, + {"id": 21, + "label": "value21"}, + {"id": 22, + "label": "value22"}, + {"id": 23, + "label": "value23"}, + {"id": 24, + "label": "value24"}, + {"id": 25, + "label": "value25"}, + {"id": 26, + "label": "value26"}, + {"id": 27, + "label": "value27"}, + {"id": 28, + "label": "value28"}, + {"id": 29, + "label": "value29"} + ] + }, + {"id": 7, + "label": "value7", + "submenu": [ + {"id": 30, + "label": "value30"}, + {"id": 31, + "label": "value31"}, + {"id": 32, + "label": "value32"}, + {"id": 33, + "label": "value33"}, + {"id": 34, + "label": "value34"}, + {"id": 35, + "label": "value35"}, + {"id": 36, + "label": "value36"}, + {"id": 37, + "label": "value37"}, + {"id": 38, + "label": "value38"}, + {"id": 39, + "label": "value39"} + ] + }, + ] + } +] -- cgit v1.2.3 From 07b578064af5b24176c86e002cf410adebe99626 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Jun 2009 15:36:53 -0500 Subject: Removing test-gtk-label.h --- tests/Makefile.am | 2 -- tests/test-gtk-label-server.c | 4 +-- tests/test-gtk-label.h | 75 ------------------------------------------- 3 files changed, 2 insertions(+), 79 deletions(-) delete mode 100644 tests/test-gtk-label.h diff --git a/tests/Makefile.am b/tests/Makefile.am index 3e818a2..e566594 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -88,7 +88,6 @@ test-gtk-label: test-gtk-label-client test-gtk-label-server $(DBUS_RUNNER) --task ./test-gtk-label-client --task-name Client --task ./test-gtk-label-server --task-name Server --ignore-return test_gtk_label_server_SOURCES = \ - test-gtk-label.h \ test-gtk-label-server.c test_gtk_label_server_CFLAGS = \ @@ -104,7 +103,6 @@ test_gtk_label_server_LDADD = \ $(DBUSMENUTESTS_LIBS) test_gtk_label_client_SOURCES = \ - test-gtk-label.h \ test-gtk-label-client.c test_gtk_label_client_CFLAGS = \ diff --git a/tests/test-gtk-label-server.c b/tests/test-gtk-label-server.c index 349d7d1..a494ab0 100644 --- a/tests/test-gtk-label-server.c +++ b/tests/test-gtk-label-server.c @@ -95,8 +95,8 @@ main (int argc, char ** argv) JsonParser * parser = json_parser_new(); GError * error = NULL; - if (!json_parser_load_from_file(parser, argv[1], &error)) { - g_debug("Failed parsing file %s because: %s", argv[1], error->message); + if (!json_parser_load_from_file(parser, "test-gtk-label.json", &error)) { + g_debug("Failed parsing file %s because: %s", "test-gtk-label.json", error->message); return 1; } JsonNode * root_node = json_parser_get_root(parser); diff --git a/tests/test-gtk-label.h b/tests/test-gtk-label.h deleted file mode 100644 index e63ac44..0000000 --- a/tests/test-gtk-label.h +++ /dev/null @@ -1,75 +0,0 @@ - -#include - -typedef struct _proplayout_t proplayout_t; -struct _proplayout_t { - guint id; - gchar ** properties; - proplayout_t * submenu; -}; - -gchar * props1[] = {"label", "value1", NULL}; -gchar * props2[] = {"label", "value1", NULL}; -gchar * props3[] = {"label", - "And a property name that is really long should have a value that is really long, because well, that's an important part of the yin and yang of software testing.", - NULL}; -gchar * props4[] = {"icon-name", "network-status", "label", "Look at network", "right-column", "10:32", NULL}; - - -proplayout_t submenu_4_1[] = { - {id: 10, properties: props2, submenu: NULL}, - {id: 11, properties: props2, submenu: NULL}, - {id: 12, properties: props2, submenu: NULL}, - {id: 13, properties: props2, submenu: NULL}, - {id: 14, properties: props2, submenu: NULL}, - {id: 15, properties: props2, submenu: NULL}, - {id: 16, properties: props2, submenu: NULL}, - {id: 17, properties: props2, submenu: NULL}, - {id: 18, properties: props2, submenu: NULL}, - {id: 19, properties: props2, submenu: NULL}, - {id: 0, properties: NULL, submenu: NULL} -}; - -proplayout_t submenu_4_2[] = { - {id: 20, properties: props2, submenu: NULL}, - {id: 21, properties: props2, submenu: NULL}, - {id: 22, properties: props2, submenu: NULL}, - {id: 23, properties: props2, submenu: NULL}, - {id: 24, properties: props2, submenu: NULL}, - {id: 25, properties: props2, submenu: NULL}, - {id: 26, properties: props2, submenu: NULL}, - {id: 27, properties: props2, submenu: NULL}, - {id: 28, properties: props2, submenu: NULL}, - {id: 29, properties: props2, submenu: NULL}, - {id: 0, properties: NULL, submenu: NULL} -}; - -proplayout_t submenu_4_3[] = { - {id: 30, properties: props2, submenu: NULL}, - {id: 31, properties: props2, submenu: NULL}, - {id: 32, properties: props2, submenu: NULL}, - {id: 33, properties: props2, submenu: NULL}, - {id: 34, properties: props2, submenu: NULL}, - {id: 35, properties: props2, submenu: NULL}, - {id: 36, properties: props2, submenu: NULL}, - {id: 37, properties: props2, submenu: NULL}, - {id: 38, properties: props2, submenu: NULL}, - {id: 39, properties: props2, submenu: NULL}, - {id: 0, properties: NULL, submenu: NULL} -}; - -proplayout_t submenu_4_0[] = { - {id: 1, properties: props2, submenu: submenu_4_1}, - {id: 2, properties: props2, submenu: submenu_4_2}, - {id: 3, properties: props2, submenu: submenu_4_3}, - {id: 0, properties: NULL, submenu: NULL} -}; - -proplayout_t layouts[] = { - {id: 1, properties: props1, submenu: submenu_4_3}, - {id: 10, properties: props2, submenu: submenu_4_2}, - {id: 20, properties: props3, submenu: submenu_4_1}, - {id: 100, properties: props2, submenu: submenu_4_0}, - {id: 0, properties: NULL, submenu: NULL} -}; - -- cgit v1.2.3 From e685fa4eed5c4fcbc469e3ebe2a9c6562c91b057 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 17 Jun 2009 16:36:17 -0500 Subject: The new dbus-test-runner has parameters. So now we're changing the server to take the json parameter and the file. --- tests/Makefile.am | 8 +++++--- tests/test-gtk-label-server.c | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index e566594..2ec6ca7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -84,8 +84,8 @@ test_glib_properties_client_LDADD = \ -test-gtk-label: test-gtk-label-client test-gtk-label-server - $(DBUS_RUNNER) --task ./test-gtk-label-client --task-name Client --task ./test-gtk-label-server --task-name Server --ignore-return +test-gtk-label: test-gtk-label-client test-gtk-label-server test-gtk-label.json + $(DBUS_RUNNER) --task ./test-gtk-label-client --task-name Client --task ./test-gtk-label-server --parameter $(srcdir)/test-gtk-label.json --task-name Server --ignore-return test_gtk_label_server_SOURCES = \ test-gtk-label-server.c @@ -124,4 +124,6 @@ examplesdir = $(docdir)/examples/ examples_DATA = \ $(glib_server_nomenu_SOURCES) -EXTRA_DIST = $(examples_DATA) +EXTRA_DIST = \ + $(examples_DATA) \ + test-gtk-label.json diff --git a/tests/test-gtk-label-server.c b/tests/test-gtk-label-server.c index a494ab0..349d7d1 100644 --- a/tests/test-gtk-label-server.c +++ b/tests/test-gtk-label-server.c @@ -95,8 +95,8 @@ main (int argc, char ** argv) JsonParser * parser = json_parser_new(); GError * error = NULL; - if (!json_parser_load_from_file(parser, "test-gtk-label.json", &error)) { - g_debug("Failed parsing file %s because: %s", "test-gtk-label.json", error->message); + if (!json_parser_load_from_file(parser, argv[1], &error)) { + g_debug("Failed parsing file %s because: %s", argv[1], error->message); return 1; } JsonNode * root_node = json_parser_get_root(parser); -- cgit v1.2.3 From 9448adebb30c0fc3a96aa9a380c2280ae9fbb8be Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Jun 2009 09:28:56 -0500 Subject: Setting the window title --- tests/test-gtk-label-client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test-gtk-label-client.c b/tests/test-gtk-label-client.c index 44a847f..8a2d5d9 100644 --- a/tests/test-gtk-label-client.c +++ b/tests/test-gtk-label-client.c @@ -163,6 +163,7 @@ main (int argc, char ** argv) 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); death_timer = g_timeout_add_seconds(10, timer_func, window); -- cgit v1.2.3 From 218976c1a5087e745fdc2fb697deb154efd1ca3b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 18 Jun 2009 09:31:24 -0500 Subject: Lengthening timeouts so that each layout is shown for 15 seconds and the client runs for 60 --- tests/test-gtk-label-client.c | 2 +- tests/test-gtk-label-server.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/test-gtk-label-client.c b/tests/test-gtk-label-client.c index 8a2d5d9..b691f84 100644 --- a/tests/test-gtk-label-client.c +++ b/tests/test-gtk-label-client.c @@ -166,7 +166,7 @@ main (int argc, char ** argv) gtk_window_set_title(GTK_WINDOW(window), "libdbusmenu-gtk test"); gtk_widget_show(window); - death_timer = g_timeout_add_seconds(10, timer_func, window); + death_timer = g_timeout_add_seconds(60, timer_func, window); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); diff --git a/tests/test-gtk-label-server.c b/tests/test-gtk-label-server.c index 349d7d1..a7534f2 100644 --- a/tests/test-gtk-label-server.c +++ b/tests/test-gtk-label-server.c @@ -127,7 +127,7 @@ main (int argc, char ** argv) server = dbusmenu_server_new("/org/test"); timer_func(NULL); - g_timeout_add(2500, timer_func, NULL); + g_timeout_add_seconds(15, timer_func, NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3