From a8f8217d034836341482127be57f12f71a1d4a38 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 12 Nov 2009 15:57:21 -0600 Subject: Adding in a version number --- 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 c22d477..21b4679 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -48,8 +48,11 @@ XML syntax: ... --> + + + - + - - - + + + + + + + - - + + + - + + - + + + - + + + + + + + + + + + - + + + - - + + -- cgit v1.2.3 From 43e54b6b9331c4b626cac1a4929a93f4fcf5af87 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Fri, 13 Nov 2009 15:20:08 -0600 Subject: Removed ItemAdded/ItemRemoved for now --- libdbusmenu-glib/dbus-menu.xml | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index 6f5bdb2..7433ba2 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -138,29 +138,6 @@ for item @a id. - - - - - - - - - - - - -- cgit v1.2.3 From 8145a3f756f116b4be480e2a75a782e5c237dd15 Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Fri, 13 Nov 2009 15:24:01 -0600 Subject: Fixed type of value param in ItemPropertyUpdated() signal --- 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 7433ba2..bd2d7e5 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -119,7 +119,7 @@ from item @a id has changed to @a value. - + + + + + + + + + + + - - + + - + @@ -131,11 +169,16 @@ Triggered by the application to notify the applet that all properties of item - - + + + -- cgit v1.2.3 From b83632a648ef96d295d494c07cf07be5457fd719 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 8 Dec 2009 14:15:23 -0600 Subject: debian/control, debian/libdbusmenu-tools.install: Setting up a package for the new dbusmenu-dumper tool. --- debian/changelog | 2 ++ debian/control | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/debian/changelog b/debian/changelog index cd3f68a..23c6972 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ libdbusmenu (0.2.0~dev-0ubuntu1~ppa1) UNRELEASED; urgency=low * Test suite fixes and automation support * dbus-dumper tool * Switch to org.ayatana + * debian/control, debian/libdbusmenu-tools.install: Setting + up a package for the new dbusmenu-dumper tool. -- Ted Gould Tue, 08 Dec 2009 14:07:44 -0600 diff --git a/debian/control b/debian/control index 69d6adf..7854be9 100644 --- a/debian/control +++ b/debian/control @@ -58,3 +58,11 @@ Description: Menus over DBus shared library for GTK This package contains files that are needed to build applications. . This package provides the development files. + +Package: libdbusmenu-tools +Section: devel +Architecture: any +Depends: ${shlibs:Depends}, + ${misc:Depends}, + libdbusmenu-glib0 (= ${binary:Version}) +Description: Need a better description. -- cgit v1.2.3 From b6323180bf553bfc55b715aec40559937ea89568 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 8 Dec 2009 14:16:38 -0600 Subject: releasing version 0.2.0~dev-0ubuntu1~ppa1 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 23c6972..95800f6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -libdbusmenu (0.2.0~dev-0ubuntu1~ppa1) UNRELEASED; urgency=low +libdbusmenu (0.2.0~dev-0ubuntu1~ppa1) karmic; urgency=low * Updating to trunk * Test suite fixes and automation support @@ -7,7 +7,7 @@ libdbusmenu (0.2.0~dev-0ubuntu1~ppa1) UNRELEASED; urgency=low * debian/control, debian/libdbusmenu-tools.install: Setting up a package for the new dbusmenu-dumper tool. - -- Ted Gould Tue, 08 Dec 2009 14:07:44 -0600 + -- Ted Gould Tue, 08 Dec 2009 14:16:37 -0600 libdbusmenu (0.1.7-0ubuntu1~ppa1) karmic; urgency=low -- cgit v1.2.3 From 90735eb115caa784d53464e91e5125623d406f21 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 8 Dec 2009 23:47:29 -0600 Subject: Getting the server building again, not great shape though. Needs more work. --- libdbusmenu-glib/server.c | 73 +++++++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 7ad9c46..2131ea0 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -35,9 +35,11 @@ License version 3 and version 2.1 along with this program. If not, see #include "server-marshal.h" /* DBus Prototypes */ +static gboolean _dbusmenu_server_get_layout (DbusmenuServer * server, guint parent, guint * revision, gchar ** layout, GError ** error); static gboolean _dbusmenu_server_get_property (DbusmenuServer * server, guint id, gchar * property, gchar ** value, GError ** error); static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, guint id, GHashTable ** dict, GError ** error); -static gboolean _dbusmenu_server_call (DbusmenuServer * server, guint id, GError ** error); +static gboolean _dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, GArray * properties, GHashTable ** values, GError ** error); +static gboolean _dbusmenu_server_event (DbusmenuServer * server, guint id, gchar * eventid, GValue * data, GError ** error); #include "dbusmenu-server.h" @@ -68,8 +70,7 @@ static guint signals[LAST_SIGNAL] = { 0 }; enum { PROP_0, PROP_DBUS_OBJECT, - PROP_ROOT_NODE, - PROP_LAYOUT + PROP_ROOT_NODE }; /* Errors */ @@ -169,11 +170,6 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) "The base object of the menus that are served", DBUSMENU_TYPE_MENUITEM, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property (object_class, PROP_LAYOUT, - g_param_spec_string(DBUSMENU_SERVER_PROP_LAYOUT, "XML Layout of the menus", - "A simple XML string that describes the layout of the menus", - "", - G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); dbus_g_object_type_install_info(DBUSMENU_TYPE_SERVER, &dbus_glib__dbusmenu_server_object_info); @@ -243,9 +239,6 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) priv->layout_revision++; g_signal_emit(obj, signals[LAYOUT_UPDATE], 0, priv->layout_revision, TRUE); break; - case PROP_LAYOUT: - /* Can't set this, fall through to error */ - g_warning("Can not set property: layout"); default: g_return_if_reached(); break; @@ -277,25 +270,6 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) case PROP_ROOT_NODE: g_value_set_object(value, priv->root); break; - case PROP_LAYOUT: { - GPtrArray * xmlarray = g_ptr_array_new(); - if (priv->root == NULL) { - /* g_debug("Getting layout without root node!"); */ - g_ptr_array_add(xmlarray, g_strdup_printf("", priv->layout_revision)); - } else { - dbusmenu_menuitem_buildxml(priv->root, xmlarray, priv->layout_revision); - } - g_ptr_array_add(xmlarray, NULL); - - /* build string */ - gchar * finalstring = g_strjoinv("", (gchar **)xmlarray->pdata); - g_value_take_string(value, finalstring); - /* g_debug("Final string: %s", finalstring); */ - - g_ptr_array_foreach(xmlarray, xmlarray_foreach_free, NULL); - g_ptr_array_free(xmlarray, TRUE); - break; - } default: g_return_if_reached(); break; @@ -377,6 +351,36 @@ error_quark (void) } /* DBus interface */ +static gboolean +_dbusmenu_server_get_layout (DbusmenuServer * server, guint parent, guint * revision, gchar ** layout, GError ** error) +{ + DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); + + *revision = priv->layout_revision; + GPtrArray * xmlarray = g_ptr_array_new(); + + if (parent == 0) { + if (priv->root == NULL) { + /* g_debug("Getting layout without root node!"); */ + g_ptr_array_add(xmlarray, g_strdup_printf("", priv->layout_revision)); + } else { + dbusmenu_menuitem_buildxml(priv->root, xmlarray, priv->layout_revision); + } + } else { + DbusmenuMenuitem * item = dbusmenu_menuitem_find_id(priv->root, parent); + dbusmenu_menuitem_buildxml(item, xmlarray, priv->layout_revision); + } + g_ptr_array_add(xmlarray, NULL); + + /* build string */ + *layout = g_strjoinv("", (gchar **)xmlarray->pdata); + + g_ptr_array_foreach(xmlarray, xmlarray_foreach_free, NULL); + g_ptr_array_free(xmlarray, TRUE); + + return TRUE; +} + static gboolean _dbusmenu_server_get_property (DbusmenuServer * server, guint id, gchar * property, gchar ** value, GError ** error) { @@ -445,7 +449,14 @@ _dbusmenu_server_get_properties (DbusmenuServer * server, guint id, GHashTable * } static gboolean -_dbusmenu_server_call (DbusmenuServer * server, guint id, GError ** error) +_dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, GArray * properties, GHashTable ** values, GError ** error) +{ + + return FALSE; +} + +static gboolean +_dbusmenu_server_event (DbusmenuServer * server, guint id, gchar * eventid, GValue * data, GError ** error) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); -- cgit v1.2.3 From 020181eea586b8f8b1876c4a30543cdae17bf9d8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 09:47:15 -0600 Subject: Updating to new API so that we build. Nice touch. --- libdbusmenu-glib/client.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index eb3b42b..623ef2d 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -352,7 +352,8 @@ id_update (DBusGProxy * proxy, guint id, DbusmenuClient * client) DbusmenuMenuitem * menuitem = dbusmenu_menuitem_find_id(priv->root, id); g_return_if_fail(menuitem != NULL); - org_ayatana_dbusmenu_get_properties_async(proxy, id, menuitem_get_properties_cb, menuitem); + gchar * properties[1] = {NULL}; /* This gets them all */ + org_ayatana_dbusmenu_get_properties_async(proxy, id, (const gchar **)properties, menuitem_get_properties_cb, menuitem); return; } @@ -648,7 +649,7 @@ static void menuitem_activate (DbusmenuMenuitem * mi, DbusmenuClient * client) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); - org_ayatana_dbusmenu_call_async (priv->menuproxy, dbusmenu_menuitem_get_id(mi), menuitem_call_cb, mi); + org_ayatana_dbusmenu_event_async (priv->menuproxy, dbusmenu_menuitem_get_id(mi), "clicked", NULL, menuitem_call_cb, mi); return; } @@ -690,7 +691,8 @@ parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * it propdata->item = item; propdata->parent = parent; - org_ayatana_dbusmenu_get_properties_async(proxy, id, menuitem_get_properties_new_cb, propdata); + gchar * properties[1] = {NULL}; /* This gets them all */ + org_ayatana_dbusmenu_get_properties_async(proxy, id, (const gchar **)properties, menuitem_get_properties_new_cb, propdata); } else { g_warning("Unable to allocate memory to get properties for menuitem. This menuitem will never be realized."); } -- cgit v1.2.3 From d2a430d295bcfb1a43183920e5a21d6140c26aba Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 10:17:35 -0600 Subject: Switching get properties to include the properties list. --- libdbusmenu-glib/server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 2131ea0..f1177cf 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -37,7 +37,7 @@ License version 3 and version 2.1 along with this program. If not, see /* DBus Prototypes */ static gboolean _dbusmenu_server_get_layout (DbusmenuServer * server, guint parent, guint * revision, gchar ** layout, GError ** error); static gboolean _dbusmenu_server_get_property (DbusmenuServer * server, guint id, gchar * property, gchar ** value, GError ** error); -static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, guint id, GHashTable ** dict, GError ** error); +static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, guint id, GPtrArray * properties, GHashTable ** dict, GError ** error); static gboolean _dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, GArray * properties, GHashTable ** values, GError ** error); static gboolean _dbusmenu_server_event (DbusmenuServer * server, guint id, gchar * eventid, GValue * data, GError ** error); @@ -427,7 +427,7 @@ _dbusmenu_server_get_property (DbusmenuServer * server, guint id, gchar * proper } static gboolean -_dbusmenu_server_get_properties (DbusmenuServer * server, guint id, GHashTable ** dict, GError ** error) +_dbusmenu_server_get_properties (DbusmenuServer * server, guint id, GPtrArray * properties, GHashTable ** dict, GError ** error) { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id); -- cgit v1.2.3 From c04823067179ec819fee4a9fb7ff382b108115e6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 10:19:41 -0600 Subject: Making a proper error on GroupProperties not being implemented. --- libdbusmenu-glib/server.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index f1177cf..ba79f55 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -78,6 +78,7 @@ enum { INVALID_MENUITEM_ID, INVALID_PROPERTY_NAME, UNKNOWN_DBUS_ERROR, + NOT_IMPLEMENTED, LAST_ERROR }; @@ -451,7 +452,12 @@ _dbusmenu_server_get_properties (DbusmenuServer * server, guint id, GPtrArray * static gboolean _dbusmenu_server_get_group_properties (DbusmenuServer * server, GArray * ids, GArray * properties, GHashTable ** values, GError ** error) { - + if (error != NULL) { + g_set_error(error, + error_quark(), + NOT_IMPLEMENTED, + "The GetGroupProperties function is not implemented, sorry."); + } return FALSE; } -- cgit v1.2.3 From 9a8ed6d971bd957b5ca1aaa469ab710a4a96a367 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 10:25:32 -0600 Subject: Changing signal names to match the new (more logical) naming pattern. --- 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 a966943..43d5b2f 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -43,8 +43,8 @@ G_BEGIN_DECLS #define DBUSMENU_IS_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DBUSMENU_TYPE_SERVER)) #define DBUSMENU_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DBUSMENU_TYPE_SERVER, DbusmenuServerClass)) -#define DBUSMENU_SERVER_SIGNAL_ID_PROP_UPDATE "id-prop-update" -#define DBUSMENU_SERVER_SIGNAL_ID_UPDATE "id-update" +#define DBUSMENU_SERVER_SIGNAL_ID_PROP_UPDATE "item-property-updated" +#define DBUSMENU_SERVER_SIGNAL_ID_UPDATE "item-updated" #define DBUSMENU_SERVER_SIGNAL_LAYOUT_UPDATE "layout-update" #define DBUSMENU_SERVER_PROP_DBUS_OBJECT "dbus-object" -- cgit v1.2.3 From 9645c12aff4beb39bebe01147918f827bcc763c9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 10:37:26 -0600 Subject: Switching from using the 'Layout' property to using the 'GetLayout' function with more fun parameters. --- libdbusmenu-glib/client.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 623ef2d..93f281b 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -102,7 +102,7 @@ static void build_proxies (DbusmenuClient * client); static guint parse_node_get_id (xmlNodePtr node); static DbusmenuMenuitem * parse_layout_xml(DbusmenuClient * client, xmlNodePtr node, DbusmenuMenuitem * item, DbusmenuMenuitem * parent, DBusGProxy * proxy); static gint parse_layout (DbusmenuClient * client, const gchar * layout); -static void update_layout_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data); +static void update_layout_cb (DBusGProxy * proxy, guint rev, gchar * xml, GError * in_error, void * data); static void update_layout (DbusmenuClient * client); static void menuitem_get_properties_cb (DBusGProxy * proxy, GHashTable * properties, GError * error, gpointer data); @@ -774,26 +774,17 @@ parse_layout (DbusmenuClient * client, const gchar * layout) /* When the layout property returns, here's where we take care of that. */ static void -update_layout_cb (DBusGProxy * proxy, DBusGProxyCall * call, void * data) +update_layout_cb (DBusGProxy * proxy, guint rev, gchar * xml, GError * error, void * data) { DbusmenuClient * client = DBUSMENU_CLIENT(data); DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); - GError * error = NULL; - GValue value = {0}; - - priv->layoutcall = NULL; - if (!dbus_g_proxy_end_call(proxy, call, &error, G_TYPE_VALUE, &value, G_TYPE_INVALID)) { + if (error != NULL) { g_warning("Getting layout failed on client %s object %s: %s", priv->dbus_name, priv->dbus_object, error->message); - g_error_free(error); return; } - const gchar * xml = g_value_get_string(&value); - /* g_debug("Got layout string: %s", xml); */ - gint rev = parse_layout(client, xml); - - if (rev == 0) { + if (!parse_layout(client, xml)) { g_warning("Unable to parse layout!"); return; } @@ -827,14 +818,10 @@ update_layout (DbusmenuClient * client) return; } - priv->layoutcall = dbus_g_proxy_begin_call (priv->propproxy, - "Get", - update_layout_cb, - client, - NULL, - G_TYPE_STRING, "org.ayatana.dbusmenu", - G_TYPE_STRING, "layout", - G_TYPE_INVALID, G_TYPE_VALUE, G_TYPE_INVALID); + priv->layoutcall = org_ayatana_dbusmenu_get_layout_async(priv->menuproxy, + 0, /* Parent is the root */ + update_layout_cb, + client); return; } -- cgit v1.2.3 From d5bdb615a218fe64bc102e7c4b733b380f72dce3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 10:48:57 -0600 Subject: Adding in layout debug message. --- libdbusmenu-glib/client.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 93f281b..36c8f60 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -789,6 +789,8 @@ update_layout_cb (DBusGProxy * proxy, guint rev, gchar * xml, GError * error, vo return; } + g_debug("Got layout: %s", xml); + priv->my_revision = rev; /* g_debug("Root is now: 0x%X", (unsigned int)priv->root); */ #ifdef MASSIVEDEBUGGING -- cgit v1.2.3 From 221c276afc0e33bb0da3381020229309f65e806f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 11:02:53 -0600 Subject: Changing signal prototypes in the signal handlers. --- libdbusmenu-glib/client.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 36c8f60..8723057 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -95,8 +95,8 @@ static void dbusmenu_client_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); /* Private Funcs */ -static void layout_update (DBusGProxy * proxy, gint revision, DbusmenuClient * client); -static void id_prop_update (DBusGProxy * proxy, guint id, gchar * property, gchar * value, DbusmenuClient * client); +static void layout_update (DBusGProxy * proxy, gint revision, guint parent, DbusmenuClient * client); +static void id_prop_update (DBusGProxy * proxy, guint id, gchar * property, GValue * value, DbusmenuClient * client); static void id_update (DBusGProxy * proxy, guint id, DbusmenuClient * client); static void build_proxies (DbusmenuClient * client); static guint parse_node_get_id (xmlNodePtr node); @@ -308,7 +308,7 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) /* Annoying little wrapper to make the right function update */ static void -layout_update (DBusGProxy * proxy, gint revision, DbusmenuClient * client) +layout_update (DBusGProxy * proxy, gint revision, guint parent, DbusmenuClient * client) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); priv->current_revision = revision; @@ -321,7 +321,7 @@ layout_update (DBusGProxy * proxy, gint revision, DbusmenuClient * client) /* Signal from the server that a property has changed on one of our menuitems */ static void -id_prop_update (DBusGProxy * proxy, guint id, gchar * property, gchar * value, DbusmenuClient * client) +id_prop_update (DBusGProxy * proxy, guint id, gchar * property, GValue * value, DbusmenuClient * client) { #ifdef MASSIVEDEBUGGING g_debug("Property change sent to client for item %d property %s value %s", id, property, g_utf8_strlen(value, 50) < 25 ? value : ""); @@ -333,7 +333,7 @@ id_prop_update (DBusGProxy * proxy, guint id, gchar * property, gchar * value, D DbusmenuMenuitem * menuitem = dbusmenu_menuitem_find_id(priv->root, id); g_return_if_fail(menuitem != NULL); - dbusmenu_menuitem_property_set(menuitem, property, value); + dbusmenu_menuitem_property_set(menuitem, property, g_value_get_string(value)); return; } @@ -490,15 +490,15 @@ build_proxies (DbusmenuClient * client) priv->dbusproxy = NULL; } - dbus_g_proxy_add_signal(priv->menuproxy, "LayoutUpdate", G_TYPE_INT, G_TYPE_INVALID); + dbus_g_proxy_add_signal(priv->menuproxy, "LayoutUpdate", G_TYPE_INT, G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_connect_signal(priv->menuproxy, "LayoutUpdate", G_CALLBACK(layout_update), client, NULL); dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__UINT_STRING_STRING, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_add_signal(priv->menuproxy, "IdPropUpdate", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(priv->menuproxy, "IdPropUpdate", G_CALLBACK(id_prop_update), client, NULL); + dbus_g_proxy_add_signal(priv->menuproxy, "ItemPropertyUpdated", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); + dbus_g_proxy_connect_signal(priv->menuproxy, "ItemPropertyUpdated", G_CALLBACK(id_prop_update), client, NULL); - dbus_g_proxy_add_signal(priv->menuproxy, "IdUpdate", G_TYPE_UINT, G_TYPE_INVALID); - dbus_g_proxy_connect_signal(priv->menuproxy, "IdUpdate", G_CALLBACK(id_update), client, NULL); + dbus_g_proxy_add_signal(priv->menuproxy, "ItemUpdated", G_TYPE_UINT, G_TYPE_INVALID); + dbus_g_proxy_connect_signal(priv->menuproxy, "ItemUpdated", G_CALLBACK(id_update), client, NULL); update_layout(client); -- cgit v1.2.3 From bb4ccc2bbb60b34fdbb1141d3b6565d7d041bc5d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 11:17:32 -0600 Subject: Switching the marshallers around to match the new signal interfaces. --- libdbusmenu-glib/server-marshal.list | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/server-marshal.list b/libdbusmenu-glib/server-marshal.list index 950fc9d..044c64d 100644 --- a/libdbusmenu-glib/server-marshal.list +++ b/libdbusmenu-glib/server-marshal.list @@ -1 +1,2 @@ -VOID: UINT, STRING, STRING +VOID: UINT, STRING, POINTER +VOID: INT, UINT -- cgit v1.2.3 From 469b32828a8877f7c21c3b4a9fd43c41513eb213 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 11:24:10 -0600 Subject: Changing ID_PROP_UPDATE signal to use GValues instead of strings. --- libdbusmenu-glib/server.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index ba79f55..aff582b 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -125,8 +125,8 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(DbusmenuServerClass, id_prop_update), NULL, NULL, - _dbusmenu_server_marshal_VOID__UINT_STRING_STRING, - G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING); + _dbusmenu_server_marshal_VOID__UINT_STRING_POINTER, + G_TYPE_NONE, 3, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_VALUE); /** DbusmenuServer::id-update: @arg0: The #DbusmenuServer emitting the signal. @@ -280,9 +280,12 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) } static void -menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, gchar * value, DbusmenuServer * server) +menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, gchar * strvalue, DbusmenuServer * server) { - g_signal_emit(G_OBJECT(server), signals[ID_PROP_UPDATE], 0, dbusmenu_menuitem_get_id(mi), property, value, TRUE); + GValue value = {0}; + g_value_init(&value, G_TYPE_STRING); + g_value_set_static_string(&value, strvalue); + g_signal_emit(G_OBJECT(server), signals[ID_PROP_UPDATE], 0, dbusmenu_menuitem_get_id(mi), property, &value, TRUE); return; } -- cgit v1.2.3 From 43f88882b5075e1fec4c02f052fe70d45f9bcb3f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 11:25:52 -0600 Subject: Switching the marshaller to give us the GValue --- libdbusmenu-glib/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 8723057..9cf3736 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -493,7 +493,7 @@ build_proxies (DbusmenuClient * client) dbus_g_proxy_add_signal(priv->menuproxy, "LayoutUpdate", G_TYPE_INT, G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_connect_signal(priv->menuproxy, "LayoutUpdate", G_CALLBACK(layout_update), client, NULL); - dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__UINT_STRING_STRING, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INVALID); + dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__UINT_STRING_POINTER, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); dbus_g_proxy_add_signal(priv->menuproxy, "ItemPropertyUpdated", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); dbus_g_proxy_connect_signal(priv->menuproxy, "ItemPropertyUpdated", G_CALLBACK(id_prop_update), client, NULL); -- cgit v1.2.3 From c72d9b087155590c51a962c351375ce05f4b6a87 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 11:36:48 -0600 Subject: Adding marshaller for the 'LayoutUpdate' signal. --- libdbusmenu-glib/client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 9cf3736..81c9a2c 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -490,6 +490,7 @@ build_proxies (DbusmenuClient * client) priv->dbusproxy = NULL; } + dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__INT_UINT, G_TYPE_NONE, G_TYPE_INT, G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_add_signal(priv->menuproxy, "LayoutUpdate", G_TYPE_INT, G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_connect_signal(priv->menuproxy, "LayoutUpdate", G_CALLBACK(layout_update), client, NULL); -- cgit v1.2.3 From fc53aa8c28fa83b004329b79532a6847bb63619d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 13:47:52 -0600 Subject: Fixing the layout update signature to have two parameters. --- libdbusmenu-glib/server.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index aff582b..7eef534 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -148,6 +148,7 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) @arg0: The #DbusmenuServer emitting the signal. @arg1: A revision number representing which revision the update represents itself as. + @arg2: The ID of the parent for this update. This signal is emitted any time the layout of the menuitems under this server is changed. @@ -157,8 +158,8 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(DbusmenuServerClass, layout_update), NULL, NULL, - g_cclosure_marshal_VOID__INT, - G_TYPE_NONE, 1, G_TYPE_INT); + _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, @@ -238,7 +239,7 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec) g_debug("Setting root node to NULL"); } priv->layout_revision++; - g_signal_emit(obj, signals[LAYOUT_UPDATE], 0, priv->layout_revision, TRUE); + g_signal_emit(obj, signals[LAYOUT_UPDATE], 0, priv->layout_revision, 0, TRUE); break; default: g_return_if_reached(); @@ -296,7 +297,7 @@ menuitem_child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint /* TODO: We probably need to group the layout update signals to make the number more reasonble. */ DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); priv->layout_revision++; - g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATE], 0, priv->layout_revision, TRUE); + g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATE], 0, priv->layout_revision, 0, TRUE); return; } @@ -307,7 +308,7 @@ menuitem_child_removed (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, Dbu /* TODO: We probably need to group the layout update signals to make the number more reasonble. */ DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); priv->layout_revision++; - g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATE], 0, priv->layout_revision, TRUE); + g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATE], 0, priv->layout_revision, 0, TRUE); return; } @@ -316,7 +317,7 @@ menuitem_child_moved (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint { DbusmenuServerPrivate * priv = DBUSMENU_SERVER_GET_PRIVATE(server); priv->layout_revision++; - g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATE], 0, priv->layout_revision, TRUE); + g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATE], 0, priv->layout_revision, 0, TRUE); return; } -- cgit v1.2.3 From f8b95bdab9579b19b59a5ece923f0aac79f99390 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 13:58:32 -0600 Subject: Adding in the 'version' property --- libdbusmenu-glib/server.c | 13 ++++++++++++- libdbusmenu-glib/server.h | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 7eef534..4ab60cf 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -43,6 +43,8 @@ static gboolean _dbusmenu_server_event (DbusmenuServer * server, guint id, gchar #include "dbusmenu-server.h" +#define DBUSMENU_VERSION_NUMBER 1 + /* Privates, I'll show you mine... */ typedef struct _DbusmenuServerPrivate DbusmenuServerPrivate; @@ -70,7 +72,8 @@ static guint signals[LAST_SIGNAL] = { 0 }; enum { PROP_0, PROP_DBUS_OBJECT, - PROP_ROOT_NODE + PROP_ROOT_NODE, + PROP_VERSION }; /* Errors */ @@ -172,6 +175,11 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) "The base object of the menus that are served", DBUSMENU_TYPE_MENUITEM, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (object_class, PROP_VERSION, + g_param_spec_uint(DBUSMENU_SERVER_PROP_VERSION, "Dbusmenu API version", + "The version of the DBusmenu API that we're implementing.", + DBUSMENU_VERSION_NUMBER, DBUSMENU_VERSION_NUMBER, DBUSMENU_VERSION_NUMBER, + G_PARAM_READABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); dbus_g_object_type_install_info(DBUSMENU_TYPE_SERVER, &dbus_glib__dbusmenu_server_object_info); @@ -272,6 +280,9 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) case PROP_ROOT_NODE: g_value_set_object(value, priv->root); break; + case PROP_VERSION: + g_value_set_uint(value, DBUSMENU_VERSION_NUMBER); + break; default: g_return_if_reached(); break; diff --git a/libdbusmenu-glib/server.h b/libdbusmenu-glib/server.h index 43d5b2f..566b3cf 100644 --- a/libdbusmenu-glib/server.h +++ b/libdbusmenu-glib/server.h @@ -49,7 +49,7 @@ G_BEGIN_DECLS #define DBUSMENU_SERVER_PROP_DBUS_OBJECT "dbus-object" #define DBUSMENU_SERVER_PROP_ROOT_NODE "root-node" -#define DBUSMENU_SERVER_PROP_LAYOUT "layout" +#define DBUSMENU_SERVER_PROP_VERSION "version" /** DbusmenuServerClass: -- cgit v1.2.3 From bc29c3e31adbed4dd2b93c1a461da9936b54456c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 14:00:40 -0600 Subject: Adding in support for bustling the 'test-glib-layout' test results. --- tests/Makefile.am | 5 +++-- tests/test-glib-layout-client.c | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index fa85d7f..36b870d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -42,7 +42,7 @@ glib_server_nomenu_LDADD = \ test-glib-layout: test-glib-layout-client test-glib-layout-server Makefile.am @echo "#!/bin/bash" > $@ - @echo $(DBUS_RUNNER) --task ./test-glib-layout-client --task-name Client --task ./test-glib-layout-server --task-name Server --ignore-return >> $@ + @echo $(DBUS_RUNNER) -b test-glib-layout.bustle --task ./test-glib-layout-client --task-name Client --task ./test-glib-layout-server --task-name Server --ignore-return >> $@ @chmod +x $@ test_glib_layout_server_SOURCES = \ @@ -238,4 +238,5 @@ distclean-local: -rm -rf $(builddir)/mago.results DISTCLEANFILES = \ - $(TESTS) + $(TESTS) \ + test-glib-layout.bustle diff --git a/tests/test-glib-layout-client.c b/tests/test-glib-layout-client.c index a7dd683..6a79321 100644 --- a/tests/test-glib-layout-client.c +++ b/tests/test-glib-layout-client.c @@ -111,7 +111,7 @@ main (int argc, char ** argv) g_usleep(500000); - DbusmenuClient * client = dbusmenu_client_new(":1.0", "/org/test"); + DbusmenuClient * client = dbusmenu_client_new(":1.1", "/org/test"); g_signal_connect(G_OBJECT(client), DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED, G_CALLBACK(layout_updated), NULL); g_timeout_add_seconds(10, timer_func, client); -- cgit v1.2.3 From 969add38b333138095850f3dc9cbd701954b49b6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 14:51:00 -0600 Subject: Fixing the proxies correctly and making sure to reset the call pointer. --- libdbusmenu-glib/client.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 81c9a2c..264eb77 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -216,7 +216,7 @@ dbusmenu_client_dispose (GObject *object) DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(object); if (priv->layoutcall != NULL) { - dbus_g_proxy_cancel_call(priv->propproxy, priv->layoutcall); + dbus_g_proxy_cancel_call(priv->menuproxy, priv->layoutcall); priv->layoutcall = NULL; } if (priv->menuproxy != NULL) { @@ -794,6 +794,7 @@ update_layout_cb (DBusGProxy * proxy, guint rev, gchar * xml, GError * error, vo priv->my_revision = rev; /* g_debug("Root is now: 0x%X", (unsigned int)priv->root); */ + priv->layoutcall = NULL; #ifdef MASSIVEDEBUGGING g_debug("Client signaling layout has changed."); #endif @@ -813,7 +814,7 @@ update_layout (DbusmenuClient * client) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); - if (priv->propproxy == NULL) { + if (priv->menuproxy == NULL) { return; } -- cgit v1.2.3 From 887632f6fa0a1f0b5050ec79fd3be441b6e9f515 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 14:51:58 -0600 Subject: Removing debug message --- libdbusmenu-glib/client.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 264eb77..a3349af 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -790,8 +790,6 @@ update_layout_cb (DBusGProxy * proxy, guint rev, gchar * xml, GError * error, vo return; } - g_debug("Got layout: %s", xml); - priv->my_revision = rev; /* g_debug("Root is now: 0x%X", (unsigned int)priv->root); */ priv->layoutcall = NULL; -- cgit v1.2.3 From cf65a3c712a12a85ac1a624e493acfb61b967479 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 14:58:32 -0600 Subject: Remove the ability to construct the property as it's not writable. --- libdbusmenu-glib/server.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 4ab60cf..f61b0fb 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -179,7 +179,7 @@ dbusmenu_server_class_init (DbusmenuServerClass *class) g_param_spec_uint(DBUSMENU_SERVER_PROP_VERSION, "Dbusmenu API version", "The version of the DBusmenu API that we're implementing.", DBUSMENU_VERSION_NUMBER, DBUSMENU_VERSION_NUMBER, DBUSMENU_VERSION_NUMBER, - G_PARAM_READABLE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); dbus_g_object_type_install_info(DBUSMENU_TYPE_SERVER, &dbus_glib__dbusmenu_server_object_info); -- cgit v1.2.3 From a3492a08d1d914f0d62f8cc717288d4c10cda3ef Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 15:32:43 -0600 Subject: Adding in a bunch of bustle data gathering and cleanup. --- tests/Makefile.am | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 36b870d..1d58700 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,5 @@ -DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf +DBUS_RUNNER=dbus-test-runner TESTS = \ test-glib-layout \ @@ -42,7 +42,7 @@ glib_server_nomenu_LDADD = \ test-glib-layout: test-glib-layout-client test-glib-layout-server Makefile.am @echo "#!/bin/bash" > $@ - @echo $(DBUS_RUNNER) -b test-glib-layout.bustle --task ./test-glib-layout-client --task-name Client --task ./test-glib-layout-server --task-name Server --ignore-return >> $@ + @echo $(DBUS_RUNNER) -b $@.bustle --task ./test-glib-layout-client --task-name Client --task ./test-glib-layout-server --task-name Server --ignore-return >> $@ @chmod +x $@ test_glib_layout_server_SOURCES = \ @@ -76,7 +76,7 @@ test_glib_layout_client_LDADD = \ test-glib-properties: test-glib-properties-client test-glib-properties-server Makefile.am @echo "#!/bin/bash" > $@ - @echo $(DBUS_RUNNER) --task ./test-glib-properties-client --task-name Client --task ./test-glib-properties-server --task-name Server --ignore-return >> $@ + @echo $(DBUS_RUNNER) -b $@.bustle --task ./test-glib-properties-client --task-name Client --task ./test-glib-properties-server --task-name Server --ignore-return >> $@ @chmod +x $@ test_glib_properties_server_SOURCES = \ @@ -125,7 +125,7 @@ test_glib_simple_items_LDADD = \ test-gtk-label: test-gtk-label-client test-gtk-label-server test-gtk-label.json Makefile.am @echo "#!/bin/bash" > $@ @echo $(XVFB_RUN) >> $@ - @echo $(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 >> $@ + @echo $(DBUS_RUNNER) -b $@.bustle --task ./test-gtk-label-client --task-name Client --task ./test-gtk-label-server --parameter $(srcdir)/test-gtk-label.json --task-name Server --ignore-return >> $@ @chmod +x $@ test_gtk_label_server_SOURCES = \ @@ -165,7 +165,7 @@ test_gtk_label_client_LDADD = \ test-gtk-reorder: test-gtk-label-client test-gtk-reorder-server Makefile.am @echo "#!/bin/bash" > $@ @echo $(XVFB_RUN) >> $@ - @echo $(DBUS_RUNNER) --task ./test-gtk-label-client --task-name Client --task ./test-gtk-reorder-server --parameter $(srcdir)/test-gtk-label.json --task-name Server --ignore-return >> $@ + @echo $(DBUS_RUNNER) -b $@.bustle --task ./test-gtk-label-client --task-name Client --task ./test-gtk-reorder-server --parameter $(srcdir)/test-gtk-label.json --task-name Server --ignore-return >> $@ @chmod +x $@ test_gtk_reorder_server_SOURCES = \ @@ -239,4 +239,8 @@ distclean-local: DISTCLEANFILES = \ $(TESTS) \ - test-glib-layout.bustle + test-glib-layout.bustle \ + test-glib-properties.bustle \ + test-glib-simple-items.bustle \ + test-gtk-label.bustle \ + test-gtk-reorder.bustle -- cgit v1.2.3 From 91636df6e71cb70c627e60d7a2399cbbc1da3c24 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 15:36:55 -0600 Subject: Switching to a new object number as now the bustler is there. --- tests/test-glib-properties-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-glib-properties-client.c b/tests/test-glib-properties-client.c index 39815aa..9e257ea 100644 --- a/tests/test-glib-properties-client.c +++ b/tests/test-glib-properties-client.c @@ -155,7 +155,7 @@ main (int argc, char ** argv) /* Make sure the server starts up and all that */ g_usleep(500000); - DbusmenuClient * client = dbusmenu_client_new(":1.0", "/org/test"); + DbusmenuClient * client = dbusmenu_client_new(":1.1", "/org/test"); g_signal_connect(G_OBJECT(client), DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED, G_CALLBACK(layout_updated), NULL); death_timer = g_timeout_add_seconds(10, timer_func, client); -- cgit v1.2.3 From bb0bab7e81c1ca6e5e4a6ddb33a124ae4e6e59ab Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 19:56:05 -0600 Subject: Switching the return from get properties should have values now. --- libdbusmenu-glib/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index a3349af..0823951 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -567,7 +567,7 @@ parse_node_get_id (xmlNodePtr node) static void get_properties_helper (gpointer key, gpointer value, gpointer data) { - dbusmenu_menuitem_property_set((DbusmenuMenuitem *)data, (gchar *)key, (gchar *)value); + dbusmenu_menuitem_property_set((DbusmenuMenuitem *)data, (gchar *)key, g_value_get_string((GValue *)value)); return; } -- cgit v1.2.3 From 79f1234edad909f457e9571a05d90c7343c8acd6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 19:57:24 -0600 Subject: Translating the table of string properties over to a hash of values. --- libdbusmenu-glib/server.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index f61b0fb..73c21e2 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -442,6 +442,16 @@ _dbusmenu_server_get_property (DbusmenuServer * server, guint id, gchar * proper return TRUE; } +static void +value_table (gpointer pkey, gpointer pvalue, gpointer phash) +{ + GValue * value = g_new0(GValue, 1); + g_value_init(value, G_TYPE_STRING); + g_value_set_string(value, (gchar *)pvalue); + g_hash_table_insert((GHashTable *)phash, g_strdup((gchar *)pkey), value); + return; +} + static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, guint id, GPtrArray * properties, GHashTable ** dict, GError ** error) { @@ -461,6 +471,12 @@ _dbusmenu_server_get_properties (DbusmenuServer * server, guint id, GPtrArray * *dict = dbusmenu_menuitem_properties_copy(mi); + GHashTable * newtable = g_hash_table_new(g_str_hash, g_str_equal); + g_hash_table_foreach(*dict, value_table, newtable); + g_hash_table_destroy(*dict); + + *dict = newtable; + return TRUE; } -- cgit v1.2.3 From 700e01d8b92d2d11e4d7ce13ec4861a4b744d10b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 20:11:36 -0600 Subject: Ignoring the bustle files. --- .bzrignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.bzrignore b/.bzrignore index 398d2da..591b750 100644 --- a/.bzrignore +++ b/.bzrignore @@ -52,3 +52,4 @@ tools/dbusmenu-dumper libdbusmenu-[0-9].[0-9].[0-9].tar.gz libdbusmenu-[0-9].[0-9].[0-9].tar.gz.asc tests/test-mago +tests/*.bustle -- cgit v1.2.3 From 07ddbba1253463e159d13f65eabcfade699df2e8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 20:54:25 -0600 Subject: Removing debug message --- libdbusmenu-glib/client.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 0823951..a038cda 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -353,6 +353,7 @@ id_update (DBusGProxy * proxy, guint id, DbusmenuClient * client) g_return_if_fail(menuitem != NULL); gchar * properties[1] = {NULL}; /* This gets them all */ + g_debug("Getting properties"); org_ayatana_dbusmenu_get_properties_async(proxy, id, (const gchar **)properties, menuitem_get_properties_cb, menuitem); return; } -- cgit v1.2.3 From 2997a508fd49ebbbfa53d1c5fc5d0d56250de760 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 21:50:25 -0600 Subject: Switching the menuitem internal storage to be a hashtable of values. --- libdbusmenu-glib/menuitem.c | 78 +++++++++++++++++++++++++++++++++++++++++---- libdbusmenu-glib/menuitem.h | 4 ++- libdbusmenu-glib/server.c | 16 ---------- 3 files changed, 75 insertions(+), 23 deletions(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index d486b53..77f8e90 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -213,6 +213,20 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) static guint menuitem_next_id = 1; +/* A small little function to both clear the insides of a + value as well as the memory it itself uses. */ +static void +g_value_free (gpointer data) +{ + if (data == NULL) return; + GValue * value = (GValue*)data; + g_value_unset(value); + g_free(data); + return; +} + +/* Initialize the values of the in the object, and build the + properties hash table. */ static void dbusmenu_menuitem_init (DbusmenuMenuitem *self) { @@ -221,7 +235,7 @@ dbusmenu_menuitem_init (DbusmenuMenuitem *self) priv->id = 0; priv->children = NULL; - priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); + priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_value_free); priv->root = FALSE; @@ -673,28 +687,59 @@ dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, guint id) */ gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value) +{ + GValue val = {0}; + g_value_init(&val, G_TYPE_STRING); + g_value_set_static_string(&val, value); + return dbusmenu_menuitem_property_set_value(mi, property, &val); +} + +/** + dbusmenu_menuitem_property_set: + @mi: The #DbusmenuMenuitem to set the property on. + @property: Name of the property to set. + @value: The value of the property. + + Takes the pair of @property and @value and places them as a + property on @mi. If a property already exists by that name, + then the value is set to the new value. If not, the property + is added. If the value is changed or the property was previously + unset then the signal #DbusmenuMenuitem::prop-changed will be + emitted by this function. + + Return value: A boolean representing if the property value was set. +*/ +gboolean +dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * property, const GValue * value) { g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), FALSE); g_return_val_if_fail(property != NULL, FALSE); + g_return_val_if_fail(G_IS_VALUE(value), FALSE); DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); /* g_debug("Setting a property. ID: %d Prop: %s Value: %s", priv->id, property, value); */ + #if 0 gpointer lookup = g_hash_table_lookup(priv->properties, property); if (g_strcmp0((gchar *)lookup, value) == 0) { /* The value is the same as the value currently in the table so we don't really care. Just say everything's okay */ return TRUE; } + #endif gchar * lprop = g_strdup(property); - gchar * lval = g_strdup(value); + GValue * lval = g_new0(GValue, 1); + g_value_init(lval, G_VALUE_TYPE(value)); + g_value_copy(value, lval); g_hash_table_insert(priv->properties, lprop, lval); #ifdef MASSIVEDEBUGGING - g_debug("Menuitem %d (%s) signalling property '%s' changed to '%s'", ID(mi), LABEL(mi), property, g_utf8_strlen(value, 50) < 25 ? value : ""); + gchar * valstr = g_strdup_value_contents(lval); + g_debug("Menuitem %d (%s) signalling property '%s' changed to '%s'", ID(mi), LABEL(mi), property, g_utf8_strlen(valstr, 50) < 25 ? valstr : ""); + g_free(valstr); #endif - g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, property, value, TRUE); + g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, lprop, lval, TRUE); return TRUE; } @@ -710,19 +755,40 @@ dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, c Return value: A string with the value of the property that shouldn't be free'd. Or #NULL if the property - is not set. + is not set or is not a string. */ const gchar * dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property) +{ + const GValue * value = dbusmenu_menuitem_property_get_value(mi, property); + if (value == NULL) return NULL; + if (G_VALUE_TYPE(value) != G_TYPE_STRING) return NULL; + return g_value_get_string(value); +} + +/** + dbusmenu_menuitem_property_get_value: + @mi: The #DbusmenuMenuitem to look for the property on. + @property: The property to grab. + + Look up a property on @mi and return the value of it if + it exits. #NULL will be returned if the property doesn't + exist. + + Return value: A GValue for the property. +*/ +const GValue * +dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * property) { g_return_val_if_fail(DBUSMENU_IS_MENUITEM(mi), NULL); g_return_val_if_fail(property != NULL, NULL); DbusmenuMenuitemPrivate * priv = DBUSMENU_MENUITEM_GET_PRIVATE(mi); - return (const gchar *)g_hash_table_lookup(priv->properties, property); + return (const GValue *)g_hash_table_lookup(priv->properties, property); } + /** dbusmenu_menuitem_property_exit: @mi: The #DbusmenuMenuitem to look for the property on. diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index 27a86a2..f0615d7 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -94,7 +94,7 @@ struct _DbusmenuMenuitemClass GObjectClass parent_class; /* Signals */ - void (*property_changed) (gchar * property, gchar * value); + void (*property_changed) (gchar * property, GValue * value); void (*item_activated) (void); void (*child_added) (DbusmenuMenuitem * child, guint position); void (*child_removed) (DbusmenuMenuitem * child); @@ -129,7 +129,9 @@ DbusmenuMenuitem * dbusmenu_menuitem_child_find (DbusmenuMenuitem * mi, guint id DbusmenuMenuitem * dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, guint id); gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value); +gboolean dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * property, const GValue * value); const gchar * dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property); +const GValue * dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * property); gboolean dbusmenu_menuitem_property_exist (DbusmenuMenuitem * mi, const gchar * property); GList * dbusmenu_menuitem_properties_list (DbusmenuMenuitem * mi) G_GNUC_WARN_UNUSED_RESULT; GHashTable * dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi); diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index 73c21e2..f61b0fb 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -442,16 +442,6 @@ _dbusmenu_server_get_property (DbusmenuServer * server, guint id, gchar * proper return TRUE; } -static void -value_table (gpointer pkey, gpointer pvalue, gpointer phash) -{ - GValue * value = g_new0(GValue, 1); - g_value_init(value, G_TYPE_STRING); - g_value_set_string(value, (gchar *)pvalue); - g_hash_table_insert((GHashTable *)phash, g_strdup((gchar *)pkey), value); - return; -} - static gboolean _dbusmenu_server_get_properties (DbusmenuServer * server, guint id, GPtrArray * properties, GHashTable ** dict, GError ** error) { @@ -471,12 +461,6 @@ _dbusmenu_server_get_properties (DbusmenuServer * server, guint id, GPtrArray * *dict = dbusmenu_menuitem_properties_copy(mi); - GHashTable * newtable = g_hash_table_new(g_str_hash, g_str_equal); - g_hash_table_foreach(*dict, value_table, newtable); - g_hash_table_destroy(*dict); - - *dict = newtable; - return TRUE; } -- cgit v1.2.3 From 24c71d792f77c57d1ede30b23100d020b6624511 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 22:57:31 -0600 Subject: Cleaning up our types. No more image type (but leaving to not confuse) and adding in the properties needed for toggle stuff. --- libdbusmenu-glib/client.h | 2 +- libdbusmenu-glib/menuitem.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.h b/libdbusmenu-glib/client.h index fff9a6b..b42bc83 100644 --- a/libdbusmenu-glib/client.h +++ b/libdbusmenu-glib/client.h @@ -52,7 +52,7 @@ G_BEGIN_DECLS #define DBUSMENU_CLIENT_TYPES_DEFAULT "menuitem" #define DBUSMENU_CLIENT_TYPES_SEPARATOR "separator" -#define DBUSMENU_CLIENT_TYPES_IMAGE "imageitem" +#define DBUSMENU_CLIENT_TYPES_IMAGE "menuitem" /** DbusmenuClientClass: diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index f0615d7..be56fc8 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -56,6 +56,11 @@ G_BEGIN_DECLS #define DBUSMENU_MENUITEM_PROP_LABEL "label" #define DBUSMENU_MENUITEM_PROP_ICON "icon" #define DBUSMENU_MENUITEM_PROP_ICON_DATA "icon-data" +#define DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE "toggle-type" +#define DBUSMENU_MENUITEM_PROP_TOGGLE_CHECKED "toggle-checked" + +#define DBUSMENU_MENUITEM_TOGGLE_CHECK "checkmark" +#define DBUSMENU_MENUITEM_TOGGLE_RADIO "radio" /** DbusmenuMenuitem: -- cgit v1.2.3 From b0969bfe4707c56eb17b7d7df56102b92359339a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 23:33:30 -0600 Subject: Flow through GValue changes. --- libdbusmenu-gtk/client.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 68c0549..66b876f 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -49,8 +49,8 @@ static gboolean new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuite static gboolean new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static gboolean new_item_image (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); -static void process_visible (GtkMenuItem * gmi, const gchar * value); -static void process_sensitive (GtkMenuItem * gmi, const gchar * value); +static void process_visible (GtkMenuItem * gmi, const GValue * value); +static void process_sensitive (GtkMenuItem * gmi, const GValue * value); /* GObject Stuff */ G_DEFINE_TYPE (DbusmenuGtkClient, dbusmenu_gtkclient, DBUSMENU_TYPE_CLIENT); @@ -115,9 +115,9 @@ menu_pressed_cb (GtkMenuItem * gmi, DbusmenuMenuitem * mi) /* Process the visible property */ static void -process_visible (GtkMenuItem * gmi, const gchar * value) +process_visible (GtkMenuItem * gmi, const GValue * value) { - if (value == NULL || !g_strcmp0(value, "true")) { + if (value == NULL || !g_strcmp0(g_value_get_string(value), "true")) { gtk_widget_show(GTK_WIDGET(gmi)); } else { gtk_widget_hide(GTK_WIDGET(gmi)); @@ -127,9 +127,9 @@ process_visible (GtkMenuItem * gmi, const gchar * value) /* Process the sensitive property */ static void -process_sensitive (GtkMenuItem * gmi, const gchar * value) +process_sensitive (GtkMenuItem * gmi, const GValue * value) { - if (value == NULL || !g_strcmp0(value, "true")) { + if (value == NULL || !g_strcmp0(g_value_get_string(value), "true")) { gtk_widget_set_sensitive(GTK_WIDGET(gmi), TRUE); } else { gtk_widget_set_sensitive(GTK_WIDGET(gmi), FALSE); @@ -140,10 +140,10 @@ process_sensitive (GtkMenuItem * gmi, const gchar * value) /* Whenever we have a property change on a DbusmenuMenuitem we need to be responsive to that. */ static void -menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, gchar * value, GtkMenuItem * gmi) +menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkMenuItem * gmi) { if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_LABEL)) { - gtk_menu_item_set_label(gmi, value); + gtk_menu_item_set_label(gmi, g_value_get_string(value)); } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_VISIBLE)) { process_visible(gmi, value); } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_SENSITIVE)) { @@ -228,8 +228,8 @@ dbusmenu_gtkclient_newitem_base (DbusmenuGtkClient * client, DbusmenuMenuitem * /* Life insurance */ g_object_weak_ref(G_OBJECT(item), destoryed_dbusmenuitem_cb, gmi); - process_visible(gmi, dbusmenu_menuitem_property_get(item, DBUSMENU_MENUITEM_PROP_VISIBLE)); - process_sensitive(gmi, dbusmenu_menuitem_property_get(item, DBUSMENU_MENUITEM_PROP_SENSITIVE)); + process_visible(gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_VISIBLE)); + process_sensitive(gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_SENSITIVE)); if (parent != NULL) { new_child(parent, item, dbusmenu_menuitem_get_position(item, parent), DBUSMENU_GTKCLIENT(client)); @@ -395,10 +395,11 @@ new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm /* This handler looks at property changes for items that are image menu items. */ static void -image_property_handle (DbusmenuMenuitem * item, const gchar * property, const gchar * value, gpointer userdata) +image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GValue * invalue, gpointer userdata) { /* We're only looking at these two properties here */ g_return_if_fail(!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON) || !g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON_DATA)); + const gchar * value = g_value_get_string(invalue); if (value == NULL || value[0] == '\0') { /* This means that we're unsetting a value. */ @@ -501,11 +502,11 @@ new_item_image (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuC image_property_handle(newitem, DBUSMENU_MENUITEM_PROP_ICON, - dbusmenu_menuitem_property_get(newitem, DBUSMENU_MENUITEM_PROP_ICON), + dbusmenu_menuitem_property_get_value(newitem, DBUSMENU_MENUITEM_PROP_ICON), client); image_property_handle(newitem, DBUSMENU_MENUITEM_PROP_ICON_DATA, - dbusmenu_menuitem_property_get(newitem, DBUSMENU_MENUITEM_PROP_ICON_DATA), + dbusmenu_menuitem_property_get_value(newitem, DBUSMENU_MENUITEM_PROP_ICON_DATA), client); g_signal_connect(G_OBJECT(newitem), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, -- cgit v1.2.3 From 676987c27da3fb20881d9c56c25a005bdd088010 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 9 Dec 2009 23:38:20 -0600 Subject: Killing the image item as it's own beast. --- libdbusmenu-gtk/client.c | 50 ++++++++++++++---------------------------------- 1 file changed, 14 insertions(+), 36 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 66b876f..d201cc4 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -47,10 +47,10 @@ static void move_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint n static gboolean new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static gboolean new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); -static gboolean new_item_image (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static void process_visible (GtkMenuItem * gmi, const GValue * value); static void process_sensitive (GtkMenuItem * gmi, const GValue * value); +static void image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GValue * invalue, gpointer userdata); /* GObject Stuff */ G_DEFINE_TYPE (DbusmenuGtkClient, dbusmenu_gtkclient, DBUSMENU_TYPE_CLIENT); @@ -74,7 +74,6 @@ dbusmenu_gtkclient_init (DbusmenuGtkClient *self) { dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(self), DBUSMENU_CLIENT_TYPES_DEFAULT, new_item_normal); dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(self), DBUSMENU_CLIENT_TYPES_SEPARATOR, new_item_seperator); - dbusmenu_client_add_type_handler(DBUSMENU_CLIENT(self), DBUSMENU_CLIENT_TYPES_IMAGE, new_item_image); g_signal_connect(G_OBJECT(self), DBUSMENU_CLIENT_SIGNAL_NEW_MENUITEM, G_CALLBACK(new_menuitem), NULL); @@ -367,6 +366,19 @@ new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusmenu return FALSE; } + image_property_handle(newitem, + DBUSMENU_MENUITEM_PROP_ICON, + dbusmenu_menuitem_property_get_value(newitem, DBUSMENU_MENUITEM_PROP_ICON), + client); + image_property_handle(newitem, + DBUSMENU_MENUITEM_PROP_ICON_DATA, + dbusmenu_menuitem_property_get_value(newitem, DBUSMENU_MENUITEM_PROP_ICON_DATA), + client); + g_signal_connect(G_OBJECT(newitem), + DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, + G_CALLBACK(image_property_handle), + client); + return TRUE; } @@ -481,37 +493,3 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GV return; } -/* This is a type call back for the image type where - it uses the GtkImageMenuitem to create the menu item. */ -static gboolean -new_item_image (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client) -{ - g_return_val_if_fail(DBUSMENU_IS_MENUITEM(newitem), FALSE); - g_return_val_if_fail(DBUSMENU_IS_GTKCLIENT(client), FALSE); - /* Note: not checking parent, it's reasonable for it to be NULL */ - - GtkMenuItem * gmi; - gmi = GTK_MENU_ITEM(gtk_image_menu_item_new_with_label(dbusmenu_menuitem_property_get(newitem, DBUSMENU_MENUITEM_PROP_LABEL))); - gtk_menu_item_set_use_underline (gmi, TRUE); - - if (gmi != NULL) { - dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); - } else { - return FALSE; - } - - image_property_handle(newitem, - DBUSMENU_MENUITEM_PROP_ICON, - dbusmenu_menuitem_property_get_value(newitem, DBUSMENU_MENUITEM_PROP_ICON), - client); - image_property_handle(newitem, - DBUSMENU_MENUITEM_PROP_ICON_DATA, - dbusmenu_menuitem_property_get_value(newitem, DBUSMENU_MENUITEM_PROP_ICON_DATA), - client); - g_signal_connect(G_OBJECT(newitem), - DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, - G_CALLBACK(image_property_handle), - client); - - return TRUE; -} -- cgit v1.2.3 From a7edc933259ba5f3352496bd7f1a09d856ec39b4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 10 Dec 2009 13:03:44 -0600 Subject: releasing version 0.2.0~dev-0ubuntu1~ppa2 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 04d99af..4f02263 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,9 @@ -libdbusmenu (0.2.0~dev-0ubuntu1~ppa2) UNRELEASED; urgency=low +libdbusmenu (0.2.0~dev-0ubuntu1~ppa2) karmic; urgency=low * Updating to trunk * Adding underline support - -- Ted Gould Thu, 10 Dec 2009 13:01:58 -0600 + -- Ted Gould Thu, 10 Dec 2009 13:03:41 -0600 libdbusmenu (0.2.0~dev-0ubuntu1~ppa1) karmic; urgency=low -- cgit v1.2.3 From 030d27a1ca21c10ddad7f04848f60b0b2adc4c40 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Dec 2009 11:50:59 -0600 Subject: Basic implementation of some helper getter/setters for GValues with int and bools --- libdbusmenu-glib/menuitem.c | 36 ++++++++++++++++++++++++++++++++++++ libdbusmenu-glib/menuitem.h | 4 ++++ 2 files changed, 40 insertions(+) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 77f8e90..76ce79c 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -694,6 +694,24 @@ dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, c return dbusmenu_menuitem_property_set_value(mi, property, &val); } +gboolean +dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * property, const gboolean value) +{ + GValue val = {0}; + g_value_init(&val, G_TYPE_BOOLEAN); + g_value_set_boolean(&val, value); + return dbusmenu_menuitem_property_set_value(mi, property, &val); +} + +gboolean +dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * property, const gint value) +{ + GValue val = {0}; + g_value_init(&val, G_TYPE_INT); + g_value_set_int(&val, value); + return dbusmenu_menuitem_property_set_value(mi, property, &val); +} + /** dbusmenu_menuitem_property_set: @mi: The #DbusmenuMenuitem to set the property on. @@ -788,6 +806,24 @@ dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * prope return (const GValue *)g_hash_table_lookup(priv->properties, property); } +gboolean +dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * property) +{ + const GValue * value = dbusmenu_menuitem_property_get_value(mi, property); + if (value == NULL) return FALSE; + if (G_VALUE_TYPE(value) != G_TYPE_BOOLEAN) return FALSE; + return g_value_get_boolean(value); +} + +gint +dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * property) +{ + const GValue * value = dbusmenu_menuitem_property_get_value(mi, property); + if (value == NULL) return 0; + if (G_VALUE_TYPE(value) != G_TYPE_INT) return 0; + return g_value_get_int(value); +} + /** dbusmenu_menuitem_property_exit: diff --git a/libdbusmenu-glib/menuitem.h b/libdbusmenu-glib/menuitem.h index be56fc8..fc9e410 100644 --- a/libdbusmenu-glib/menuitem.h +++ b/libdbusmenu-glib/menuitem.h @@ -135,8 +135,12 @@ DbusmenuMenuitem * dbusmenu_menuitem_find_id (DbusmenuMenuitem * mi, guint id); gboolean dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, const gchar * value); gboolean dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * property, const GValue * value); +gboolean dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * property, const gboolean value); +gboolean dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * property, const gint value); const gchar * dbusmenu_menuitem_property_get (DbusmenuMenuitem * mi, const gchar * property); const GValue * dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * property); +gboolean dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * property); +gint dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * property); gboolean dbusmenu_menuitem_property_exist (DbusmenuMenuitem * mi, const gchar * property); GList * dbusmenu_menuitem_properties_list (DbusmenuMenuitem * mi) G_GNUC_WARN_UNUSED_RESULT; GHashTable * dbusmenu_menuitem_properties_copy (DbusmenuMenuitem * mi); -- cgit v1.2.3 From 655498939579199807de427c65597e503c84f3da Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Dec 2009 13:17:20 -0600 Subject: Docs for the new functions. --- libdbusmenu-glib/menuitem.c | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 76ce79c..cec9486 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -694,6 +694,21 @@ dbusmenu_menuitem_property_set (DbusmenuMenuitem * mi, const gchar * property, c return dbusmenu_menuitem_property_set_value(mi, property, &val); } +/** + dbusmenu_menuitem_property_set_bool: + @mi: The #DbusmenuMenuitem to set the property on. + @property: Name of the property to set. + @value: The value of the property. + + Takes a boolean @value and sets it on @property as a + property on @mi. If a property already exists by that name, + then the value is set to the new value. If not, the property + is added. If the value is changed or the property was previously + unset then the signal #DbusmenuMenuitem::prop-changed will be + emitted by this function. + + Return value: A boolean representing if the property value was set. +*/ gboolean dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * property, const gboolean value) { @@ -703,6 +718,21 @@ dbusmenu_menuitem_property_set_bool (DbusmenuMenuitem * mi, const gchar * proper return dbusmenu_menuitem_property_set_value(mi, property, &val); } +/** + dbusmenu_menuitem_property_set_int: + @mi: The #DbusmenuMenuitem to set the property on. + @property: Name of the property to set. + @value: The value of the property. + + Takes a boolean @value and sets it on @property as a + property on @mi. If a property already exists by that name, + then the value is set to the new value. If not, the property + is added. If the value is changed or the property was previously + unset then the signal #DbusmenuMenuitem::prop-changed will be + emitted by this function. + + Return value: A boolean representing if the property value was set. +*/ gboolean dbusmenu_menuitem_property_set_int (DbusmenuMenuitem * mi, const gchar * property, const gint value) { @@ -806,6 +836,16 @@ dbusmenu_menuitem_property_get_value (DbusmenuMenuitem * mi, const gchar * prope return (const GValue *)g_hash_table_lookup(priv->properties, property); } +/** + dbusmenu_menuitem_property_get_bool: + @mi: The #DbusmenuMenuitem to look for the property on. + @property: The property to grab. + + Look up a property on @mi and return the value of it if + it exits. Returns #FALSE if the property doesn't exist. + + Return value: The value of the property or #FALSE. +*/ gboolean dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * property) { @@ -815,6 +855,16 @@ dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * proper return g_value_get_boolean(value); } +/** + dbusmenu_menuitem_property_get_int: + @mi: The #DbusmenuMenuitem to look for the property on. + @property: The property to grab. + + Look up a property on @mi and return the value of it if + it exits. Returns zero if the property doesn't exist. + + Return value: The value of the property or zero. +*/ gint dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * property) { -- cgit v1.2.3 From 167d610ec25a9074c09dfc44e82995582b24b90a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Dec 2009 13:56:14 -0600 Subject: Adding in a couple of transfer functions so that we can be backwards compatible with our string way of doing things. --- libdbusmenu-glib/menuitem.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index cec9486..d8da357 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -26,6 +26,7 @@ License version 3 and version 2.1 along with this program. If not, see */ +#include #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -89,6 +90,8 @@ static void dbusmenu_menuitem_dispose (GObject *object); static void dbusmenu_menuitem_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); +static void g_value_transform_STRING_BOOLEAN (const GValue * in, GValue * out); +static void g_value_transform_STRING_INT (const GValue * in, GValue * out); /* GObject stuff */ G_DEFINE_TYPE (DbusmenuMenuitem, dbusmenu_menuitem, G_TYPE_OBJECT); @@ -208,6 +211,37 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) 0, 30000, 0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + /* Check transfer functions for GValue */ + if (!g_value_type_transformable(G_TYPE_STRING, G_TYPE_BOOLEAN)) { + g_value_register_transform_func(G_TYPE_STRING, G_TYPE_BOOLEAN, g_value_transform_STRING_BOOLEAN); + } + if (!g_value_type_transformable(G_TYPE_STRING, G_TYPE_INT)) { + g_value_register_transform_func(G_TYPE_STRING, G_TYPE_INT, g_value_transform_STRING_INT); + } + + return; +} + +/* A little helper function to translate a string into + a boolean value */ +static void +g_value_transform_STRING_BOOLEAN (const GValue * in, GValue * out) +{ + const gchar * string = g_value_get_string(in); + if (!g_strcmp0(string, "TRUE") || !g_strcmp0(string, "true") || !g_strcmp0(string, "True")) { + g_value_set_boolean(out, TRUE); + } else { + g_value_set_boolean(out, FALSE); + } + return; +} + +/* A little helper function to translate a string into + a integer value */ +static void +g_value_transform_STRING_INT (const GValue * in, GValue * out) +{ + g_value_set_int(out, atoi(g_value_get_string(in))); return; } -- cgit v1.2.3 From 3bee257cedf6af6f94b2e77ee77f6eb76e784a90 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Dec 2009 14:03:08 -0600 Subject: Adding in transforms for our getters. --- libdbusmenu-glib/menuitem.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index d8da357..dc01157 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -885,7 +885,16 @@ dbusmenu_menuitem_property_get_bool (DbusmenuMenuitem * mi, const gchar * proper { const GValue * value = dbusmenu_menuitem_property_get_value(mi, property); if (value == NULL) return FALSE; - if (G_VALUE_TYPE(value) != G_TYPE_BOOLEAN) return FALSE; + if (G_VALUE_TYPE(value) != G_TYPE_BOOLEAN) { + if (g_value_type_transformable(G_VALUE_TYPE(value), G_TYPE_BOOLEAN)) { + GValue boolval = {0}; + g_value_init(&boolval, G_TYPE_BOOLEAN); + g_value_transform(value, &boolval); + return g_value_get_boolean(&boolval); + } else { + return FALSE; + } + } return g_value_get_boolean(value); } @@ -904,7 +913,16 @@ dbusmenu_menuitem_property_get_int (DbusmenuMenuitem * mi, const gchar * propert { const GValue * value = dbusmenu_menuitem_property_get_value(mi, property); if (value == NULL) return 0; - if (G_VALUE_TYPE(value) != G_TYPE_INT) return 0; + if (G_VALUE_TYPE(value) != G_TYPE_INT) { + if (g_value_type_transformable(G_VALUE_TYPE(value), G_TYPE_INT)) { + GValue intval = {0}; + g_value_init(&intval, G_TYPE_INT); + g_value_transform(value, &intval); + return g_value_get_int(&intval); + } else { + return 0; + } + } return g_value_get_int(value); } -- cgit v1.2.3 From d3ce0f4a3b2f5b087586429a5f188a494dedc6fe Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Dec 2009 14:27:15 -0600 Subject: Switching around the visible and sensitive handling to use our new fancy getters so that we have consistent handling there. --- libdbusmenu-gtk/client.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index d201cc4..66862d3 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -48,8 +48,8 @@ static void move_child (DbusmenuMenuitem * mi, DbusmenuMenuitem * child, guint n static gboolean new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); static gboolean new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, DbusmenuClient * client); -static void process_visible (GtkMenuItem * gmi, const GValue * value); -static void process_sensitive (GtkMenuItem * gmi, const GValue * value); +static void process_visible (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value); +static void process_sensitive (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value); static void image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GValue * invalue, gpointer userdata); /* GObject Stuff */ @@ -114,9 +114,14 @@ menu_pressed_cb (GtkMenuItem * gmi, DbusmenuMenuitem * mi) /* Process the visible property */ static void -process_visible (GtkMenuItem * gmi, const GValue * value) +process_visible (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value) { - if (value == NULL || !g_strcmp0(g_value_get_string(value), "true")) { + gboolean val = TRUE; + if (value != NULL) { + val = dbusmenu_menuitem_property_get_bool(mi, DBUSMENU_MENUITEM_PROP_VISIBLE); + } + + if (val) { gtk_widget_show(GTK_WIDGET(gmi)); } else { gtk_widget_hide(GTK_WIDGET(gmi)); @@ -126,13 +131,13 @@ process_visible (GtkMenuItem * gmi, const GValue * value) /* Process the sensitive property */ static void -process_sensitive (GtkMenuItem * gmi, const GValue * value) +process_sensitive (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value) { - if (value == NULL || !g_strcmp0(g_value_get_string(value), "true")) { - gtk_widget_set_sensitive(GTK_WIDGET(gmi), TRUE); - } else { - gtk_widget_set_sensitive(GTK_WIDGET(gmi), FALSE); + gboolean val = TRUE; + if (value != NULL) { + val = dbusmenu_menuitem_property_get_bool(mi, DBUSMENU_MENUITEM_PROP_SENSITIVE); } + gtk_widget_set_sensitive(GTK_WIDGET(gmi), val); return; } @@ -144,9 +149,9 @@ menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkMen if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_LABEL)) { gtk_menu_item_set_label(gmi, g_value_get_string(value)); } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_VISIBLE)) { - process_visible(gmi, value); + process_visible(mi, gmi, value); } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_SENSITIVE)) { - process_sensitive(gmi, value); + process_sensitive(mi, gmi, value); } return; @@ -227,8 +232,8 @@ dbusmenu_gtkclient_newitem_base (DbusmenuGtkClient * client, DbusmenuMenuitem * /* Life insurance */ g_object_weak_ref(G_OBJECT(item), destoryed_dbusmenuitem_cb, gmi); - process_visible(gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_VISIBLE)); - process_sensitive(gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_SENSITIVE)); + process_visible(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_VISIBLE)); + process_sensitive(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_SENSITIVE)); if (parent != NULL) { new_child(parent, item, dbusmenu_menuitem_get_position(item, parent), DBUSMENU_GTKCLIENT(client)); -- cgit v1.2.3 From b0478abc4d87214dcc19bfd1c3d101c19b2990e5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Dec 2009 14:35:08 -0600 Subject: Transition the dumper to getting values and converting them to strings instead of only using strings. --- tools/dbusmenu-dumper.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tools/dbusmenu-dumper.c b/tools/dbusmenu-dumper.c index 5704311..55d631e 100644 --- a/tools/dbusmenu-dumper.c +++ b/tools/dbusmenu-dumper.c @@ -36,7 +36,11 @@ print_menuitem (DbusmenuMenuitem * item, int depth) GList * properties = dbusmenu_menuitem_properties_list(item); GList * property; for (property = properties; property != NULL; property = g_list_next(property)) { - g_print(",\n%s\"%s\": \"%s\"", space, (gchar *)property->data, dbusmenu_menuitem_property_get(item, (gchar *)property->data)); + GValue value = {0}; + g_value_init(&value, G_TYPE_STRING); + g_value_transform(dbusmenu_menuitem_property_get_value(item, (gchar *)property->data), &value); + g_print(",\n%s\"%s\": \"%s\"", space, (gchar *)property->data, g_value_get_string(&value)); + g_value_unset(&value); } g_list_free(properties); -- cgit v1.2.3 From f70759b6c1a61e34660a3bc2dddfb3f2cbf18fe7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Dec 2009 16:04:29 -0600 Subject: Building the basic generic menu item. --- .bzrignore | 1 + libdbusmenu-gtk/Makefile.am | 2 ++ libdbusmenu-gtk/genericmenuitem.c | 49 +++++++++++++++++++++++++++++++++++++++ libdbusmenu-gtk/genericmenuitem.h | 34 +++++++++++++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 libdbusmenu-gtk/genericmenuitem.c create mode 100644 libdbusmenu-gtk/genericmenuitem.h diff --git a/.bzrignore b/.bzrignore index 591b750..d7b28a6 100644 --- a/.bzrignore +++ b/.bzrignore @@ -53,3 +53,4 @@ libdbusmenu-[0-9].[0-9].[0-9].tar.gz libdbusmenu-[0-9].[0-9].[0-9].tar.gz.asc tests/test-mago tests/*.bustle +libdbusmenu-gtk/libdbusmenu_gtk_la-genericmenuitem.lo diff --git a/libdbusmenu-gtk/Makefile.am b/libdbusmenu-gtk/Makefile.am index 87a82a6..97d8563 100644 --- a/libdbusmenu-gtk/Makefile.am +++ b/libdbusmenu-gtk/Makefile.am @@ -15,6 +15,8 @@ libdbusmenu_gtkinclude_HEADERS = \ libdbusmenu_gtk_la_SOURCES = \ client.h \ client.c \ + genericmenuitem.h \ + genericmenuitem.c \ menu.h \ menu.c \ menuitem.h \ diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c new file mode 100644 index 0000000..3dd3969 --- /dev/null +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -0,0 +1,49 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "genericmenuitem.h" + +typedef struct _GenericmenuitemPrivate GenericmenuitemPrivate; + +struct _GenericmenuitemPrivate +{ +}; + +#define GENERICMENUITEM_GET_PRIVATE(o) \ +(G_TYPE_INSTANCE_GET_PRIVATE ((o), GENERICMENUITEM_TYPE, GenericmenuitemPrivate)) + +static void genericmenuitem_class_init (GenericmenuitemClass *klass); +static void genericmenuitem_init (Genericmenuitem *self); +static void genericmenuitem_dispose (GObject *object); +static void genericmenuitem_finalize (GObject *object); + +G_DEFINE_TYPE (Genericmenuitem, genericmenuitem, GTK_TYPE_CHECK_MENU_ITEM); + +static void +genericmenuitem_class_init (GenericmenuitemClass *klass) +{ +GObjectClass *object_class = G_OBJECT_CLASS (klass); + +g_type_class_add_private (klass, sizeof (GenericmenuitemPrivate)); + +object_class->dispose = genericmenuitem_dispose; +object_class->finalize = genericmenuitem_finalize; +} + +static void +genericmenuitem_init (Genericmenuitem *self) +{ +} + +static void +genericmenuitem_dispose (GObject *object) +{ +G_OBJECT_CLASS (genericmenuitem_parent_class)->dispose (object); +} + +static void +genericmenuitem_finalize (GObject *object) +{ +G_OBJECT_CLASS (genericmenuitem_parent_class)->finalize (object); +} diff --git a/libdbusmenu-gtk/genericmenuitem.h b/libdbusmenu-gtk/genericmenuitem.h new file mode 100644 index 0000000..fdfbee1 --- /dev/null +++ b/libdbusmenu-gtk/genericmenuitem.h @@ -0,0 +1,34 @@ +#ifndef __GENERICMENUITEM_H__ +#define __GENERICMENUITEM_H__ + +#include +#include +#include + +G_BEGIN_DECLS + +#define GENERICMENUITEM_TYPE (genericmenuitem_get_type ()) +#define GENERICMENUITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GENERICMENUITEM_TYPE, Genericmenuitem)) +#define GENERICMENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GENERICMENUITEM_TYPE, GenericmenuitemClass)) +#define IS_GENERICMENUITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GENERICMENUITEM_TYPE)) +#define IS_GENERICMENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GENERICMENUITEM_TYPE)) +#define GENERICMENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GENERICMENUITEM_TYPE, GenericmenuitemClass)) + +typedef struct _Genericmenuitem Genericmenuitem; +typedef struct _GenericmenuitemClass GenericmenuitemClass; + +struct _GenericmenuitemClass +{ +GtkCheckMenuItemClass parent_class; +}; + +struct _Genericmenuitem +{ +GtkCheckMenuItem parent; +}; + +GType genericmenuitem_get_type (void); + +G_END_DECLS + +#endif -- cgit v1.2.3 From eda482ed8bee77ed0904f1b1f3e835b49e174c5b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Dec 2009 16:26:08 -0600 Subject: Slight cleanups, getting this code going. --- libdbusmenu-gtk/genericmenuitem.c | 39 +++++++++++++++++++++++++++++---------- libdbusmenu-gtk/genericmenuitem.h | 26 +++++++++++++++++--------- 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 3dd3969..1d59d34 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -4,10 +4,9 @@ #include "genericmenuitem.h" -typedef struct _GenericmenuitemPrivate GenericmenuitemPrivate; - -struct _GenericmenuitemPrivate -{ +struct _GenericmenuitemPrivate { + int checkbox_type; + int state; }; #define GENERICMENUITEM_GET_PRIVATE(o) \ @@ -20,30 +19,50 @@ static void genericmenuitem_finalize (GObject *object); G_DEFINE_TYPE (Genericmenuitem, genericmenuitem, GTK_TYPE_CHECK_MENU_ITEM); +/* Initializing all of the classes. Most notably we're + disabling the drawing of the check early. */ static void genericmenuitem_class_init (GenericmenuitemClass *klass) { -GObjectClass *object_class = G_OBJECT_CLASS (klass); + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + g_type_class_add_private (klass, sizeof (GenericmenuitemPrivate)); + + object_class->dispose = genericmenuitem_dispose; + object_class->finalize = genericmenuitem_finalize; -g_type_class_add_private (klass, sizeof (GenericmenuitemPrivate)); + GtkCheckMenuItemClass * check_class = GTK_CHECK_MENU_ITEM_CLASS (klass); -object_class->dispose = genericmenuitem_dispose; -object_class->finalize = genericmenuitem_finalize; + /* We'll put this back if we get a type set */ + check_class->draw_indicator = NULL; + + return; } +/* Sets default values for all the class variables. Mostly, + this puts us in a default state. */ static void genericmenuitem_init (Genericmenuitem *self) { + self->priv = GENERICMENUITEM_GET_PRIVATE(self); + + return; } +/* Clean everything up. Whew, that can be work. */ static void genericmenuitem_dispose (GObject *object) { -G_OBJECT_CLASS (genericmenuitem_parent_class)->dispose (object); + + G_OBJECT_CLASS (genericmenuitem_parent_class)->dispose (object); + return; } +/* Now free memory, we no longer need it. */ static void genericmenuitem_finalize (GObject *object) { -G_OBJECT_CLASS (genericmenuitem_parent_class)->finalize (object); + + G_OBJECT_CLASS (genericmenuitem_parent_class)->finalize (object); + return; } diff --git a/libdbusmenu-gtk/genericmenuitem.h b/libdbusmenu-gtk/genericmenuitem.h index fdfbee1..8a19282 100644 --- a/libdbusmenu-gtk/genericmenuitem.h +++ b/libdbusmenu-gtk/genericmenuitem.h @@ -14,17 +14,25 @@ G_BEGIN_DECLS #define IS_GENERICMENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GENERICMENUITEM_TYPE)) #define GENERICMENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GENERICMENUITEM_TYPE, GenericmenuitemClass)) -typedef struct _Genericmenuitem Genericmenuitem; -typedef struct _GenericmenuitemClass GenericmenuitemClass; - -struct _GenericmenuitemClass -{ -GtkCheckMenuItemClass parent_class; +typedef struct _Genericmenuitem Genericmenuitem; +typedef struct _GenericmenuitemClass GenericmenuitemClass; +typedef struct _GenericmenuitemPrivate GenericmenuitemPrivate; + +/** + GenericmenuitemClass: + @parent_class: Our parent #GtkCheckMenuItemClass +*/ +struct _GenericmenuitemClass { + GtkCheckMenuItemClass parent_class; }; -struct _Genericmenuitem -{ -GtkCheckMenuItem parent; +/** + Genericmenuitem: + @parent: Our parent #GtkCheckMenuItem +*/ +struct _Genericmenuitem { + GtkCheckMenuItem parent; + GenericmenuitemPrivate * priv; }; GType genericmenuitem_get_type (void); -- cgit v1.2.3 From fcb8ac056eceee3ac25f28812cd9090177d91463 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Dec 2009 16:37:12 -0600 Subject: Setting up enums for the type of check and the state of it. --- libdbusmenu-gtk/genericmenuitem.c | 7 +++++-- libdbusmenu-gtk/genericmenuitem.h | 20 +++++++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 1d59d34..ee02a1c 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -5,8 +5,8 @@ #include "genericmenuitem.h" struct _GenericmenuitemPrivate { - int checkbox_type; - int state; + GenericmenuitemCheckType check_type; + GenericmenuitemState state; }; #define GENERICMENUITEM_GET_PRIVATE(o) \ @@ -46,6 +46,9 @@ genericmenuitem_init (Genericmenuitem *self) { self->priv = GENERICMENUITEM_GET_PRIVATE(self); + self->priv->check_type = GENERICMENUITEM_CHECK_TYPE_NONE; + self->priv->state = GENERICMENUITEM_STATE_UNCHECKED; + return; } diff --git a/libdbusmenu-gtk/genericmenuitem.h b/libdbusmenu-gtk/genericmenuitem.h index 8a19282..b735fe4 100644 --- a/libdbusmenu-gtk/genericmenuitem.h +++ b/libdbusmenu-gtk/genericmenuitem.h @@ -14,9 +14,11 @@ G_BEGIN_DECLS #define IS_GENERICMENUITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GENERICMENUITEM_TYPE)) #define GENERICMENUITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GENERICMENUITEM_TYPE, GenericmenuitemClass)) -typedef struct _Genericmenuitem Genericmenuitem; -typedef struct _GenericmenuitemClass GenericmenuitemClass; -typedef struct _GenericmenuitemPrivate GenericmenuitemPrivate; +typedef struct _Genericmenuitem Genericmenuitem; +typedef struct _GenericmenuitemClass GenericmenuitemClass; +typedef struct _GenericmenuitemPrivate GenericmenuitemPrivate; +typedef enum _GenericmenuitemCheckType GenericmenuitemCheckType; +typedef enum _GenericmenuitemState GenericmenuitemState; /** GenericmenuitemClass: @@ -35,6 +37,18 @@ struct _Genericmenuitem { GenericmenuitemPrivate * priv; }; +enum _GenericmenuitemCheckType { + GENERICMENUITEM_CHECK_TYPE_NONE, + GENERICMENUITEM_CHECK_TYPE_CHECKBOX, + GENErICMENUITEM_CHECK_TYPE_RADIO +}; + +enum _GenericmenuitemState { + GENERICMENUITEM_STATE_UNCHECKED, + GENERICMENUITEM_STATE_CHECKED, + GENERICMENUITEM_STATE_INDETERMINATE +}; + GType genericmenuitem_get_type (void); G_END_DECLS -- cgit v1.2.3 From 5e7b2cec7f0ffd4147d81470ca162fd14ed92836 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Dec 2009 16:49:07 -0600 Subject: Better handling of the draw_indicator function, as in, this one will actually work. --- libdbusmenu-gtk/genericmenuitem.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index ee02a1c..b40a3f5 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -4,21 +4,33 @@ #include "genericmenuitem.h" +/** + GenericmenuitemPrivate: + @check_type: What type of check we have, or none at all. + @state: What the state of our check is. +*/ struct _GenericmenuitemPrivate { GenericmenuitemCheckType check_type; GenericmenuitemState state; }; +/* Private macro */ #define GENERICMENUITEM_GET_PRIVATE(o) \ (G_TYPE_INSTANCE_GET_PRIVATE ((o), GENERICMENUITEM_TYPE, GenericmenuitemPrivate)) +/* Prototypes */ static void genericmenuitem_class_init (GenericmenuitemClass *klass); static void genericmenuitem_init (Genericmenuitem *self); static void genericmenuitem_dispose (GObject *object); static void genericmenuitem_finalize (GObject *object); +static void draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area); +/* GObject stuff */ G_DEFINE_TYPE (Genericmenuitem, genericmenuitem, GTK_TYPE_CHECK_MENU_ITEM); +/* Globals */ +static void (*parent_draw_indicator) (GtkCheckMenuItem *check_menu_item, GdkRectangle *area) = NULL; + /* Initializing all of the classes. Most notably we're disabling the drawing of the check early. */ static void @@ -33,8 +45,8 @@ genericmenuitem_class_init (GenericmenuitemClass *klass) GtkCheckMenuItemClass * check_class = GTK_CHECK_MENU_ITEM_CLASS (klass); - /* We'll put this back if we get a type set */ - check_class->draw_indicator = NULL; + parent_draw_indicator = check_class->draw_indicator; + check_class->draw_indicator = draw_indicator; return; } @@ -69,3 +81,16 @@ genericmenuitem_finalize (GObject *object) G_OBJECT_CLASS (genericmenuitem_parent_class)->finalize (object); return; } + +/* Checks to see if we should be drawing a little box at + all. If we should be, let's do that, otherwise we're + going suppress the box drawing. */ +static void +draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area) +{ + Genericmenuitem * self = GENERICMENUITEM(check_menu_item); + if (self->priv->check_type != GENERICMENUITEM_CHECK_TYPE_NONE) { + parent_draw_indicator(check_menu_item, area); + } + return; +} -- cgit v1.2.3 From f54a417fde8f6937ecafd269db51a135af2e7a3e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Dec 2009 17:09:16 -0600 Subject: Functions for setting the check type and state of the check. --- libdbusmenu-gtk/genericmenuitem.c | 45 +++++++++++++++++++++++++++++++++++++++ libdbusmenu-gtk/genericmenuitem.h | 6 +++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index b40a3f5..6eee2f7 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -94,3 +94,48 @@ draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area) } return; } + +/** + genericmenuitem_set_check_type: + @item: #Genericmenuitem to set the type on + @check_type: Which type of check should be displayed + + This function changes the type of the checkmark that + appears in the left hand gutter for the menuitem. +*/ +void +genericmenuitem_set_check_type (Genericmenuitem * item, GenericmenuitemCheckType check_type) +{ + if (item->priv->check_type == check_type) { + return; + } + + item->priv->check_type = check_type; + + gtk_widget_queue_draw(GTK_WIDGET(item)); + + return; +} + +/** + genericmenuitem_set_state: + @item: #Genericmenuitem to set the type on + @check_type: What is the state of the check + + Sets the state of the check in the menu item. It does + not require, but isn't really useful if the type of + check that the menuitem is set to #GENERICMENUITEM_CHECK_TYPE_NONE. +*/ +void +genericmenuitem_set_state (Genericmenuitem * item, GenericmenuitemState state) +{ + if (item->priv->state == state) { + return; + } + + item->priv->state = state; + + gtk_widget_queue_draw(GTK_WIDGET(item)); + + return; +} diff --git a/libdbusmenu-gtk/genericmenuitem.h b/libdbusmenu-gtk/genericmenuitem.h index b735fe4..8586590 100644 --- a/libdbusmenu-gtk/genericmenuitem.h +++ b/libdbusmenu-gtk/genericmenuitem.h @@ -49,7 +49,11 @@ enum _GenericmenuitemState { GENERICMENUITEM_STATE_INDETERMINATE }; -GType genericmenuitem_get_type (void); +GType genericmenuitem_get_type (void); +void genericmenuitem_set_check_type (Genericmenuitem * item, + GenericmenuitemCheckType check_type); +void genericmenuitem_set_state (Genericmenuitem * item, + GenericmenuitemState state); G_END_DECLS -- cgit v1.2.3 From 16812b7ca72e41dfaf76b14d5517739f44e815b7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 15 Dec 2009 17:12:32 -0600 Subject: Building up the case statements. --- libdbusmenu-gtk/genericmenuitem.c | 24 ++++++++++++++++++++++++ libdbusmenu-gtk/genericmenuitem.h | 2 +- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 6eee2f7..3f36bbf 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -112,6 +112,18 @@ genericmenuitem_set_check_type (Genericmenuitem * item, GenericmenuitemCheckType item->priv->check_type = check_type; + switch (item->priv->check_type) { + case GENERICMENUITEM_CHECK_TYPE_NONE: + break; + case GENERICMENUITEM_CHECK_TYPE_CHECKBOX: + break; + case GENERICMENUITEM_CHECK_TYPE_RADIO: + break; + default: + g_warning("Generic Menuitem invalid check type: %d", check_type); + return; + } + gtk_widget_queue_draw(GTK_WIDGET(item)); return; @@ -135,6 +147,18 @@ genericmenuitem_set_state (Genericmenuitem * item, GenericmenuitemState state) item->priv->state = state; + switch (item->priv->state) { + case GENERICMENUITEM_STATE_UNCHECKED: + break; + case GENERICMENUITEM_STATE_CHECKED: + break; + case GENERICMENUITEM_STATE_INDETERMINATE: + break; + default: + g_warning("Generic Menuitem invalid check state: %d", state); + return; + } + gtk_widget_queue_draw(GTK_WIDGET(item)); return; diff --git a/libdbusmenu-gtk/genericmenuitem.h b/libdbusmenu-gtk/genericmenuitem.h index 8586590..4f54924 100644 --- a/libdbusmenu-gtk/genericmenuitem.h +++ b/libdbusmenu-gtk/genericmenuitem.h @@ -40,7 +40,7 @@ struct _Genericmenuitem { enum _GenericmenuitemCheckType { GENERICMENUITEM_CHECK_TYPE_NONE, GENERICMENUITEM_CHECK_TYPE_CHECKBOX, - GENErICMENUITEM_CHECK_TYPE_RADIO + GENERICMENUITEM_CHECK_TYPE_RADIO }; enum _GenericmenuitemState { -- cgit v1.2.3 From 0669b0c473075115337aede5eb1ae6b86a521668 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Dec 2009 08:31:02 -0600 Subject: Setting the properties based on the enum value changes. --- libdbusmenu-gtk/genericmenuitem.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 3f36bbf..d8e9b39 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -111,13 +111,23 @@ genericmenuitem_set_check_type (Genericmenuitem * item, GenericmenuitemCheckType } item->priv->check_type = check_type; + GValue value = {0}; switch (item->priv->check_type) { case GENERICMENUITEM_CHECK_TYPE_NONE: + /* We don't need to do anything here as we're queuing the + draw and then when it draws it'll avoid drawing the + check on the item. */ break; case GENERICMENUITEM_CHECK_TYPE_CHECKBOX: + g_value_init(&value, G_TYPE_BOOLEAN); + g_value_set_boolean(&value, FALSE); + g_object_set_property(G_OBJECT(item), "draw-as-radio", &value); break; case GENERICMENUITEM_CHECK_TYPE_RADIO: + g_value_init(&value, G_TYPE_BOOLEAN); + g_value_set_boolean(&value, TRUE); + g_object_set_property(G_OBJECT(item), "draw-as-radio", &value); break; default: g_warning("Generic Menuitem invalid check type: %d", check_type); @@ -146,13 +156,27 @@ genericmenuitem_set_state (Genericmenuitem * item, GenericmenuitemState state) } item->priv->state = state; + GValue value = {0}; + g_value_init(&value, G_TYPE_BOOLEAN); switch (item->priv->state) { case GENERICMENUITEM_STATE_UNCHECKED: + g_value_set_boolean(&value, FALSE); + g_object_set_property(G_OBJECT(item), "active", &value); + g_value_set_boolean(&value, FALSE); + g_object_set_property(G_OBJECT(item), "inconsistent", &value); break; case GENERICMENUITEM_STATE_CHECKED: + g_value_set_boolean(&value, TRUE); + g_object_set_property(G_OBJECT(item), "active", &value); + g_value_set_boolean(&value, FALSE); + g_object_set_property(G_OBJECT(item), "inconsistent", &value); break; case GENERICMENUITEM_STATE_INDETERMINATE: + g_value_set_boolean(&value, TRUE); + g_object_set_property(G_OBJECT(item), "active", &value); + g_value_set_boolean(&value, TRUE); + g_object_set_property(G_OBJECT(item), "inconsistent", &value); break; default: g_warning("Generic Menuitem invalid check state: %d", state); -- cgit v1.2.3 From 58c6ed7efa57ff15c27cee2fc07b4b31a48b734b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Dec 2009 13:09:32 -0600 Subject: Stubs for setting and getting the image and label. --- libdbusmenu-gtk/genericmenuitem.c | 39 +++++++++++++++++++++++++++++++++++++++ libdbusmenu-gtk/genericmenuitem.h | 3 +++ 2 files changed, 42 insertions(+) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index d8e9b39..20fb8e2 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -24,6 +24,8 @@ static void genericmenuitem_init (Genericmenuitem *self); static void genericmenuitem_dispose (GObject *object); static void genericmenuitem_finalize (GObject *object); static void draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area); +static void set_label (GtkMenuItem * menu_item, const gchar * label); +static const gchar * get_label (GtkMenuItem * menu_item); /* GObject stuff */ G_DEFINE_TYPE (Genericmenuitem, genericmenuitem, GTK_TYPE_CHECK_MENU_ITEM); @@ -48,6 +50,10 @@ genericmenuitem_class_init (GenericmenuitemClass *klass) parent_draw_indicator = check_class->draw_indicator; check_class->draw_indicator = draw_indicator; + GtkMenuItemClass * menuitem_class = GTK_MENU_ITEM_CLASS (klass); + menuitem_class->set_label = set_label; + menuitem_class->get_label = get_label; + return; } @@ -95,6 +101,23 @@ draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area) return; } +/* Set the label on the item */ +static void +set_label (GtkMenuItem * menu_item, const gchar * label) +{ + + return; +} + +/* Get the text of the label for the item */ +static const gchar * +get_label (GtkMenuItem * menu_item) +{ + + + return NULL; +} + /** genericmenuitem_set_check_type: @item: #Genericmenuitem to set the type on @@ -187,3 +210,19 @@ genericmenuitem_set_state (Genericmenuitem * item, GenericmenuitemState state) return; } + +void +genericmenuitem_set_image (Genericmenuitem * item, GtkWidget * image) +{ + + + return; +} + +GtkWidget * +genericmenuitem_get_image (Genericmenuitem * item) +{ + + + return NULL; +} diff --git a/libdbusmenu-gtk/genericmenuitem.h b/libdbusmenu-gtk/genericmenuitem.h index 4f54924..eaccee8 100644 --- a/libdbusmenu-gtk/genericmenuitem.h +++ b/libdbusmenu-gtk/genericmenuitem.h @@ -54,6 +54,9 @@ void genericmenuitem_set_check_type (Genericmenuitem * item, GenericmenuitemCheckType check_type); void genericmenuitem_set_state (Genericmenuitem * item, GenericmenuitemState state); +void genericmenuitem_set_image (Genericmenuitem * item, + GtkWidget * image); +GtkWidget * genericmenuitem_get_image (Genericmenuitem * item); G_END_DECLS -- cgit v1.2.3 From ab52deb8a0b8fe4dd2fb602cb32beafac4d5dae0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Dec 2009 13:11:08 -0600 Subject: Stupid formating changes. --- libdbusmenu-gtk/genericmenuitem.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libdbusmenu-gtk/genericmenuitem.h b/libdbusmenu-gtk/genericmenuitem.h index eaccee8..6c494e8 100644 --- a/libdbusmenu-gtk/genericmenuitem.h +++ b/libdbusmenu-gtk/genericmenuitem.h @@ -49,14 +49,14 @@ enum _GenericmenuitemState { GENERICMENUITEM_STATE_INDETERMINATE }; -GType genericmenuitem_get_type (void); -void genericmenuitem_set_check_type (Genericmenuitem * item, - GenericmenuitemCheckType check_type); -void genericmenuitem_set_state (Genericmenuitem * item, - GenericmenuitemState state); -void genericmenuitem_set_image (Genericmenuitem * item, - GtkWidget * image); -GtkWidget * genericmenuitem_get_image (Genericmenuitem * item); +GType genericmenuitem_get_type (void); +void genericmenuitem_set_check_type (Genericmenuitem * item, + GenericmenuitemCheckType check_type); +void genericmenuitem_set_state (Genericmenuitem * item, + GenericmenuitemState state); +void genericmenuitem_set_image (Genericmenuitem * item, + GtkWidget * image); +GtkWidget * genericmenuitem_get_image (Genericmenuitem * item); G_END_DECLS -- cgit v1.2.3 From 7ee8c7fd98fa88c2821b955064240364d1c0c903 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Dec 2009 13:13:23 -0600 Subject: Comments --- libdbusmenu-gtk/genericmenuitem.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 20fb8e2..63cc936 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -211,6 +211,13 @@ genericmenuitem_set_state (Genericmenuitem * item, GenericmenuitemState state) return; } +/** + genericmenuitem_set_image: + @item: A #Genericmenuitem + @image: The image to set as the image of @item + + Sets the image of the menu item. +*/ void genericmenuitem_set_image (Genericmenuitem * item, GtkWidget * image) { @@ -219,6 +226,15 @@ genericmenuitem_set_image (Genericmenuitem * item, GtkWidget * image) return; } +/** + genericmenuitem_get_image: + @item: A #Genericmenuitem + + Returns the image if there is one. + + Return value: A pointer to the image of the item or #NULL + if there isn't one. +*/ GtkWidget * genericmenuitem_get_image (Genericmenuitem * item) { -- cgit v1.2.3 From 0f9080a861c521e41fe4fa4c8c8ab138671d6659 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Dec 2009 13:41:29 -0600 Subject: Woot, a set label function. --- libdbusmenu-gtk/genericmenuitem.c | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 63cc936..d2a20ef 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -101,10 +101,50 @@ draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area) return; } +/* A small helper to look through the widgets in the + box and find the one that is the label. */ +static void +set_label_helper (GtkWidget * widget, gpointer data) +{ + GtkWidget ** labelval = (GtkWidget **)data; + if (GTK_IS_LABEL(widget)) { + *labelval = widget; + } + return; +} + /* Set the label on the item */ static void set_label (GtkMenuItem * menu_item, const gchar * label) { + GtkWidget * child = gtk_bin_get_child(GTK_BIN(menu_item)); + + if (child == NULL) { + GtkWidget * labelw = gtk_label_new(label); + gtk_label_set_use_underline(GTK_LABEL(labelw), TRUE); + gtk_container_add(GTK_CONTAINER(menu_item), labelw); + } else if (GTK_IS_LABEL(child)) { + gtk_label_set_label(GTK_LABEL(child), label); + } else if (GTK_IS_BOX(child)) { + GtkWidget * labelw = NULL; + /* Look for the label */ + gtk_container_foreach(GTK_CONTAINER(child), set_label_helper, &labelw); + + if (labelw == NULL) { + /* We don't have a label, so we need to build */ + labelw = gtk_label_new(label); + gtk_label_set_use_underline(GTK_LABEL(labelw), TRUE); + gtk_box_pack_end(GTK_BOX(child), labelw, TRUE, TRUE, 0); + } else { + /* We can reset the label that we have. */ + gtk_label_set_label(GTK_LABEL(labelw), label); + } + } else { + g_error("Generic item in an indeterminate state."); + return; + } + + g_object_notify(G_OBJECT(menu_item), "label"); return; } -- cgit v1.2.3 From cd561a9dad4d1d82e5c03fc89780130cc75ece01 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Dec 2009 15:41:14 -0600 Subject: Using the GValues instead of setting the strings. --- libdbusmenu-glib/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index a038cda..eecfb22 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -333,7 +333,7 @@ id_prop_update (DBusGProxy * proxy, guint id, gchar * property, GValue * value, DbusmenuMenuitem * menuitem = dbusmenu_menuitem_find_id(priv->root, id); g_return_if_fail(menuitem != NULL); - dbusmenu_menuitem_property_set(menuitem, property, g_value_get_string(value)); + dbusmenu_menuitem_property_set_value(menuitem, property, value); return; } @@ -568,7 +568,7 @@ parse_node_get_id (xmlNodePtr node) static void get_properties_helper (gpointer key, gpointer value, gpointer data) { - dbusmenu_menuitem_property_set((DbusmenuMenuitem *)data, (gchar *)key, g_value_get_string((GValue *)value)); + dbusmenu_menuitem_property_set_value((DbusmenuMenuitem *)data, (gchar *)key, (GValue *)value); return; } -- cgit v1.2.3 From 4cc0915b394bb63dad3018d342d4baf57fd215f0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Dec 2009 16:26:49 -0600 Subject: Switching the client over to creating generic items. --- libdbusmenu-gtk/client.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 66862d3..325399d 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -34,6 +34,7 @@ License version 3 and version 2.1 along with this program. If not, see #include "client.h" #include "menuitem.h" +#include "genericmenuitem.h" /* Prototypes */ static void dbusmenu_gtkclient_class_init (DbusmenuGtkClientClass *klass); @@ -362,8 +363,8 @@ new_item_normal (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusmenu /* Note: not checking parent, it's reasonable for it to be NULL */ GtkMenuItem * gmi; - gmi = GTK_MENU_ITEM(gtk_menu_item_new_with_label(dbusmenu_menuitem_property_get(newitem, DBUSMENU_MENUITEM_PROP_LABEL))); - gtk_menu_item_set_use_underline (gmi, TRUE); + gmi = GTK_MENU_ITEM(g_object_new(GENERICMENUITEM_TYPE, NULL)); + gtk_menu_item_set_label(gmi, dbusmenu_menuitem_property_get(newitem, DBUSMENU_MENUITEM_PROP_LABEL)); if (gmi != NULL) { dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); @@ -416,7 +417,12 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GV { /* We're only looking at these two properties here */ g_return_if_fail(!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON) || !g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON_DATA)); - const gchar * value = g_value_get_string(invalue); + + const gchar * value = NULL; + + if (invalue != NULL && G_VALUE_TYPE(invalue) == G_TYPE_STRING) { + value = g_value_get_string(invalue); + } if (value == NULL || value[0] == '\0') { /* This means that we're unsetting a value. */ @@ -435,12 +441,12 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GV g_warning("Oddly we're handling image properties on a menuitem that doesn't have any GTK structures associated with it."); return; } - GtkWidget * gtkimage = gtk_image_menu_item_get_image(GTK_IMAGE_MENU_ITEM(gimi)); + GtkWidget * gtkimage = genericmenuitem_get_image(GENERICMENUITEM(gimi)); if (!g_strcmp0(property, DBUSMENU_MENUITEM_PROP_ICON_DATA)) { /* If we have an image already built from a name that is way better than a pixbuf. Keep it. */ - if (gtk_image_get_storage_type(GTK_IMAGE(gtkimage)) == GTK_IMAGE_ICON_NAME) { + if (gtkimage != NULL && gtk_image_get_storage_type(GTK_IMAGE(gtkimage)) == GTK_IMAGE_ICON_NAME) { return; } } @@ -493,7 +499,7 @@ image_property_handle (DbusmenuMenuitem * item, const gchar * property, const GV } - gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(gimi), gtkimage); + genericmenuitem_set_image(GENERICMENUITEM(gimi), gtkimage); return; } -- cgit v1.2.3 From 9ab79b5a7cf9a6d0224acd7902324a76ad2f8cf5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Dec 2009 16:29:24 -0600 Subject: Yeah, gotta show those labels. --- libdbusmenu-gtk/genericmenuitem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index d2a20ef..5eba55a 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -123,6 +123,7 @@ set_label (GtkMenuItem * menu_item, const gchar * label) GtkWidget * labelw = gtk_label_new(label); gtk_label_set_use_underline(GTK_LABEL(labelw), TRUE); gtk_container_add(GTK_CONTAINER(menu_item), labelw); + gtk_widget_show(labelw); } else if (GTK_IS_LABEL(child)) { gtk_label_set_label(GTK_LABEL(child), label); } else if (GTK_IS_BOX(child)) { @@ -135,6 +136,7 @@ set_label (GtkMenuItem * menu_item, const gchar * label) labelw = gtk_label_new(label); gtk_label_set_use_underline(GTK_LABEL(labelw), TRUE); gtk_box_pack_end(GTK_BOX(child), labelw, TRUE, TRUE, 0); + gtk_widget_show(labelw); } else { /* We can reset the label that we have. */ gtk_label_set_label(GTK_LABEL(labelw), label); -- cgit v1.2.3 From 6731f63179ec24929a8209aee8eed363f3350c47 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Dec 2009 16:32:50 -0600 Subject: Set alignment on the labels. --- libdbusmenu-gtk/genericmenuitem.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 5eba55a..3f7f22d 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -122,6 +122,7 @@ set_label (GtkMenuItem * menu_item, const gchar * label) if (child == NULL) { GtkWidget * labelw = gtk_label_new(label); gtk_label_set_use_underline(GTK_LABEL(labelw), TRUE); + gtk_misc_set_alignment(GTK_MISC(labelw), 0.0, 0.5); gtk_container_add(GTK_CONTAINER(menu_item), labelw); gtk_widget_show(labelw); } else if (GTK_IS_LABEL(child)) { @@ -135,6 +136,7 @@ set_label (GtkMenuItem * menu_item, const gchar * label) /* We don't have a label, so we need to build */ labelw = gtk_label_new(label); gtk_label_set_use_underline(GTK_LABEL(labelw), TRUE); + gtk_misc_set_alignment(GTK_MISC(labelw), 0.0, 0.5); gtk_box_pack_end(GTK_BOX(child), labelw, TRUE, TRUE, 0); gtk_widget_show(labelw); } else { -- cgit v1.2.3 From 763a7a3e7915858a80ceb0140a13631c7c042a13 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Dec 2009 21:31:32 -0600 Subject: Handline the toggle based properties --- libdbusmenu-gtk/client.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 325399d..80d067f 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -142,6 +142,47 @@ process_sensitive (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * valu return; } +/* Process the sensitive property */ +static void +process_toggle_type (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value) +{ + if (!IS_GENERICMENUITEM(gmi)) return; + if (G_VALUE_TYPE(value) != G_TYPE_STRING) return; + + const gchar * strval = g_value_get_string(value); + GenericmenuitemCheckType type = GENERICMENUITEM_CHECK_TYPE_NONE; + + if (!g_strcmp0(strval, "checkbox")) { + type = GENERICMENUITEM_CHECK_TYPE_CHECKBOX; + } else if (!g_strcmp0(strval, "radio")) { + type = GENERICMENUITEM_CHECK_TYPE_RADIO; + } + + genericmenuitem_set_check_type(GENERICMENUITEM(gmi), type); + + return; +} + +/* Process the sensitive property */ +static void +process_toggle_checked (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value) +{ + if (!IS_GENERICMENUITEM(gmi)) return; + if (G_VALUE_TYPE(value) != G_TYPE_STRING) return; + + const gchar * strval = g_value_get_string(value); + GenericmenuitemState state = GENERICMENUITEM_STATE_UNCHECKED; + + if (!g_strcmp0(strval, "checked")) { + state = GENERICMENUITEM_STATE_CHECKED; + } else if (!g_strcmp0(strval, "indeterminate")) { + state = GENERICMENUITEM_STATE_INDETERMINATE; + } + + genericmenuitem_set_state(GENERICMENUITEM(gmi), state); + return; +} + /* Whenever we have a property change on a DbusmenuMenuitem we need to be responsive to that. */ static void @@ -153,6 +194,10 @@ menu_prop_change_cb (DbusmenuMenuitem * mi, gchar * prop, GValue * value, GtkMen process_visible(mi, gmi, value); } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_SENSITIVE)) { process_sensitive(mi, gmi, value); + } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE)) { + process_toggle_type(mi, gmi, value); + } else if (!g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TOGGLE_CHECKED)) { + process_toggle_checked(mi, gmi, value); } return; @@ -233,9 +278,13 @@ dbusmenu_gtkclient_newitem_base (DbusmenuGtkClient * client, DbusmenuMenuitem * /* Life insurance */ g_object_weak_ref(G_OBJECT(item), destoryed_dbusmenuitem_cb, gmi); + /* Check our set of props to see if any are set already */ process_visible(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_VISIBLE)); process_sensitive(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_SENSITIVE)); + process_toggle_type(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_TOGGLE_TYPE)); + process_toggle_checked(item, gmi, dbusmenu_menuitem_property_get_value(item, DBUSMENU_MENUITEM_PROP_TOGGLE_CHECKED)); + /* Oh, we're a child, let's deal with that */ if (parent != NULL) { new_child(parent, item, dbusmenu_menuitem_get_position(item, parent), DBUSMENU_GTKCLIENT(client)); } -- cgit v1.2.3 From 1630c946d0a760ebf4796db40d4e70ce454e2e74 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Dec 2009 21:35:02 -0600 Subject: Adding some debug messages to the printout. --- tests/test-gtk-label-client.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/test-gtk-label-client.c b/tests/test-gtk-label-client.c index 09325be..070c278 100644 --- a/tests/test-gtk-label-client.c +++ b/tests/test-gtk-label-client.c @@ -152,9 +152,11 @@ 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"); @@ -168,6 +170,7 @@ main (int argc, char ** argv) death_timer = g_timeout_add_seconds(60, timer_func, window); + g_debug("Entering Mainloop"); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From 8ae44198e16818478035a666e2f998d8e584ab7c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Dec 2009 21:43:40 -0600 Subject: Protect against NULL values and treat them as default values. --- libdbusmenu-gtk/client.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 80d067f..80d2b4f 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -147,15 +147,17 @@ static void process_toggle_type (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value) { if (!IS_GENERICMENUITEM(gmi)) return; - if (G_VALUE_TYPE(value) != G_TYPE_STRING) return; - const gchar * strval = g_value_get_string(value); GenericmenuitemCheckType type = GENERICMENUITEM_CHECK_TYPE_NONE; - if (!g_strcmp0(strval, "checkbox")) { - type = GENERICMENUITEM_CHECK_TYPE_CHECKBOX; - } else if (!g_strcmp0(strval, "radio")) { - type = GENERICMENUITEM_CHECK_TYPE_RADIO; + if (value != NULL && G_VALUE_TYPE(value) == G_TYPE_STRING) { + const gchar * strval = g_value_get_string(value); + + if (!g_strcmp0(strval, "checkbox")) { + type = GENERICMENUITEM_CHECK_TYPE_CHECKBOX; + } else if (!g_strcmp0(strval, "radio")) { + type = GENERICMENUITEM_CHECK_TYPE_RADIO; + } } genericmenuitem_set_check_type(GENERICMENUITEM(gmi), type); @@ -168,15 +170,17 @@ static void process_toggle_checked (DbusmenuMenuitem * mi, GtkMenuItem * gmi, const GValue * value) { if (!IS_GENERICMENUITEM(gmi)) return; - if (G_VALUE_TYPE(value) != G_TYPE_STRING) return; - const gchar * strval = g_value_get_string(value); GenericmenuitemState state = GENERICMENUITEM_STATE_UNCHECKED; - if (!g_strcmp0(strval, "checked")) { - state = GENERICMENUITEM_STATE_CHECKED; - } else if (!g_strcmp0(strval, "indeterminate")) { - state = GENERICMENUITEM_STATE_INDETERMINATE; + if (value != NULL && G_VALUE_TYPE(value) == G_TYPE_STRING) { + const gchar * strval = g_value_get_string(value); + + if (!g_strcmp0(strval, "checked")) { + state = GENERICMENUITEM_STATE_CHECKED; + } else if (!g_strcmp0(strval, "indeterminate")) { + state = GENERICMENUITEM_STATE_INDETERMINATE; + } } genericmenuitem_set_state(GENERICMENUITEM(gmi), state); -- cgit v1.2.3 From f55f6bc97d2f5b3b8d6a68d6a2e6fda15a1d5320 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Dec 2009 21:48:28 -0600 Subject: Making sure a value is passed even if we're not using it for clicked. --- libdbusmenu-glib/client.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index eecfb22..366d60d 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -651,7 +651,10 @@ static void menuitem_activate (DbusmenuMenuitem * mi, DbusmenuClient * client) { DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); - org_ayatana_dbusmenu_event_async (priv->menuproxy, dbusmenu_menuitem_get_id(mi), "clicked", NULL, menuitem_call_cb, mi); + GValue value = {0}; + g_value_init(&value, G_TYPE_INT); + g_value_set_int(&value, 0); + org_ayatana_dbusmenu_event_async (priv->menuproxy, dbusmenu_menuitem_get_id(mi), "clicked", &value, menuitem_call_cb, mi); return; } -- cgit v1.2.3 From 186e1058f5142308a02ecf20ed4653a7862cd973 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 16 Dec 2009 23:17:59 -0600 Subject: Adding in an activate function so that we don't toggle our value on click. We're letting the application handle that. But, in turn, it turns out that is the only way to set the active property. So without an activate function, we can't set it. So, we're taking a lot more responsibility for setting it properly when we want to. --- libdbusmenu-gtk/genericmenuitem.c | 43 ++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 3f7f22d..09d5004 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -26,6 +26,7 @@ static void genericmenuitem_finalize (GObject *object); static void draw_indicator (GtkCheckMenuItem *check_menu_item, GdkRectangle *area); static void set_label (GtkMenuItem * menu_item, const gchar * label); static const gchar * get_label (GtkMenuItem * menu_item); +static void activate (GtkMenuItem * menu_item); /* GObject stuff */ G_DEFINE_TYPE (Genericmenuitem, genericmenuitem, GTK_TYPE_CHECK_MENU_ITEM); @@ -53,6 +54,7 @@ genericmenuitem_class_init (GenericmenuitemClass *klass) GtkMenuItemClass * menuitem_class = GTK_MENU_ITEM_CLASS (klass); menuitem_class->set_label = set_label; menuitem_class->get_label = get_label; + menuitem_class->activate = activate; return; } @@ -162,6 +164,14 @@ get_label (GtkMenuItem * menu_item) return NULL; } +/* Make sure we don't toggle when there is an + activate like a normal check menu item. */ +static void +activate (GtkMenuItem * menu_item) +{ + return; +} + /** genericmenuitem_set_check_type: @item: #Genericmenuitem to set the type on @@ -223,33 +233,38 @@ genericmenuitem_set_state (Genericmenuitem * item, GenericmenuitemState state) } item->priv->state = state; - GValue value = {0}; - g_value_init(&value, G_TYPE_BOOLEAN); + + GtkCheckMenuItem * check = GTK_CHECK_MENU_ITEM(item); + + gboolean old_active = check->active; + gboolean old_inconsist = check->inconsistent; switch (item->priv->state) { case GENERICMENUITEM_STATE_UNCHECKED: - g_value_set_boolean(&value, FALSE); - g_object_set_property(G_OBJECT(item), "active", &value); - g_value_set_boolean(&value, FALSE); - g_object_set_property(G_OBJECT(item), "inconsistent", &value); + check->active = FALSE; + check->inconsistent = FALSE; break; case GENERICMENUITEM_STATE_CHECKED: - g_value_set_boolean(&value, TRUE); - g_object_set_property(G_OBJECT(item), "active", &value); - g_value_set_boolean(&value, FALSE); - g_object_set_property(G_OBJECT(item), "inconsistent", &value); + check->active = TRUE; + check->inconsistent = FALSE; break; case GENERICMENUITEM_STATE_INDETERMINATE: - g_value_set_boolean(&value, TRUE); - g_object_set_property(G_OBJECT(item), "active", &value); - g_value_set_boolean(&value, TRUE); - g_object_set_property(G_OBJECT(item), "inconsistent", &value); + check->active = TRUE; + check->inconsistent = TRUE; break; default: g_warning("Generic Menuitem invalid check state: %d", state); return; } + if (old_active != check->active) { + g_object_notify(G_OBJECT(item), "active"); + } + + if (old_inconsist != check->inconsistent) { + g_object_notify(G_OBJECT(item), "inconsistent"); + } + gtk_widget_queue_draw(GTK_WIDGET(item)); return; -- cgit v1.2.3 From 339b68e8b1a816a9ee5d44fea3a98e0492c65885 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Dec 2009 14:25:32 -0600 Subject: License headers. I hate these. --- libdbusmenu-gtk/genericmenuitem.c | 28 ++++++++++++++++++++++++++++ libdbusmenu-gtk/genericmenuitem.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 09d5004..aff14ef 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -1,3 +1,31 @@ +/* +A menuitem subclass that has the ability to do lots of different +things depending on it's settings. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of either or both of the following licenses: + +1) the GNU Lesser General Public License version 3, as published by the +Free Software Foundation; and/or +2) the GNU Lesser General Public License version 2.1, 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 applicable version of the GNU Lesser General Public +License for more details. + +You should have received a copy of both the GNU Lesser General Public +License version 3 and version 2.1 along with this program. If not, see + +*/ + #ifdef HAVE_CONFIG_H #include "config.h" #endif diff --git a/libdbusmenu-gtk/genericmenuitem.h b/libdbusmenu-gtk/genericmenuitem.h index 6c494e8..3c4af0c 100644 --- a/libdbusmenu-gtk/genericmenuitem.h +++ b/libdbusmenu-gtk/genericmenuitem.h @@ -1,3 +1,31 @@ +/* +A menuitem subclass that has the ability to do lots of different +things depending on it's settings. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of either or both of the following licenses: + +1) the GNU Lesser General Public License version 3, as published by the +Free Software Foundation; and/or +2) the GNU Lesser General Public License version 2.1, 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 applicable version of the GNU Lesser General Public +License for more details. + +You should have received a copy of both the GNU Lesser General Public +License version 3 and version 2.1 along with this program. If not, see + +*/ + #ifndef __GENERICMENUITEM_H__ #define __GENERICMENUITEM_H__ -- cgit v1.2.3 From 7f702b6234af4ec162997c16a3c4e8eb64afa8cb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Dec 2009 15:21:58 -0600 Subject: Trying to reduce the complexity of adding a label. Now we can detect the various cases and make sense of them. Which is kinda nice. More confident in this code. --- libdbusmenu-gtk/genericmenuitem.c | 91 +++++++++++++++++++++++++++++---------- 1 file changed, 68 insertions(+), 23 deletions(-) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index aff14ef..0eb78dc 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -148,37 +148,66 @@ static void set_label (GtkMenuItem * menu_item, const gchar * label) { GtkWidget * child = gtk_bin_get_child(GTK_BIN(menu_item)); + GtkLabel * labelw = NULL; + gboolean suppress_update = FALSE; + + /* Try to find if we have a label already */ + if (child != NULL) { + if (GTK_IS_LABEL(child)) { + /* We've got a label, let's update it. */ + labelw = GTK_LABEL(child); + } else if (GTK_IS_BOX(child)) { + /* Look for the label in the box */ + gtk_container_foreach(GTK_CONTAINER(child), set_label_helper, &labelw); + } else { + /* We need to put the child into a new box and + make the box the child of the menu item. Basically + we're inserting a box in the middle. */ + GtkWidget * hbox = gtk_hbox_new(FALSE, 0); + g_object_ref(child); + gtk_container_remove(GTK_CONTAINER(menu_item), child); + gtk_box_pack_start(GTK_BOX(hbox), child, FALSE, FALSE, 0); + gtk_container_add(GTK_CONTAINER(menu_item), hbox); + gtk_widget_show(hbox); + g_object_unref(child); + child = hbox; + /* It's important to notice that labelw is not set + by this condition. There was no label to find. */ + } + } - if (child == NULL) { - GtkWidget * labelw = gtk_label_new(label); + /* No we can see if we need to ethier build a label or just + update the one that we already have. */ + if (labelw == NULL) { + /* Build it */ + labelw = GTK_LABEL(gtk_label_new(label)); gtk_label_set_use_underline(GTK_LABEL(labelw), TRUE); gtk_misc_set_alignment(GTK_MISC(labelw), 0.0, 0.5); - gtk_container_add(GTK_CONTAINER(menu_item), labelw); - gtk_widget_show(labelw); - } else if (GTK_IS_LABEL(child)) { - gtk_label_set_label(GTK_LABEL(child), label); - } else if (GTK_IS_BOX(child)) { - GtkWidget * labelw = NULL; - /* Look for the label */ - gtk_container_foreach(GTK_CONTAINER(child), set_label_helper, &labelw); - - if (labelw == NULL) { - /* We don't have a label, so we need to build */ - labelw = gtk_label_new(label); - gtk_label_set_use_underline(GTK_LABEL(labelw), TRUE); - gtk_misc_set_alignment(GTK_MISC(labelw), 0.0, 0.5); - gtk_box_pack_end(GTK_BOX(child), labelw, TRUE, TRUE, 0); - gtk_widget_show(labelw); + gtk_widget_show(GTK_WIDGET(labelw)); + + /* Check to see if it needs to be in the bin for this + menu item or whether it gets packed in a box. */ + if (child == NULL) { + gtk_container_add(GTK_CONTAINER(menu_item), GTK_WIDGET(labelw)); } else { - /* We can reset the label that we have. */ - gtk_label_set_label(GTK_LABEL(labelw), label); + gtk_box_pack_end(GTK_BOX(child), GTK_WIDGET(labelw), TRUE, TRUE, 0); } } else { - g_error("Generic item in an indeterminate state."); - return; + /* Oh, just an update. No biggie. */ + if (!g_strcmp0(label, gtk_label_get_label(labelw))) { + /* The only reason to suppress the update is if we had + a label and the value was the same as the one we're + getting in. */ + suppress_update = TRUE; + } else { + gtk_label_set_label(labelw, label); + } } - g_object_notify(G_OBJECT(menu_item), "label"); + /* If we changed the value, tell folks. */ + if (!suppress_update) { + g_object_notify(G_OBJECT(menu_item), "label"); + } return; } @@ -187,7 +216,23 @@ set_label (GtkMenuItem * menu_item, const gchar * label) static const gchar * get_label (GtkMenuItem * menu_item) { + GtkWidget * child = gtk_bin_get_child(GTK_BIN(menu_item)); + GtkLabel * labelw = NULL; + + /* Try to find if we have a label already */ + if (child != NULL) { + if (GTK_IS_LABEL(child)) { + /* We've got a label, let's update it. */ + labelw = GTK_LABEL(child); + } else if (GTK_IS_BOX(child)) { + /* Look for the label in the box */ + gtk_container_foreach(GTK_CONTAINER(child), set_label_helper, &labelw); + } + } + if (labelw != NULL) { + return gtk_label_get_label(labelw); + } return NULL; } -- cgit v1.2.3 From ef5865fb14bb25ffbb05c6c22c7a74cb22a89f5e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Dec 2009 15:35:23 -0600 Subject: Fleshing out the image functions for our generic item. --- libdbusmenu-gtk/genericmenuitem.c | 70 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index 0eb78dc..dded1de 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -343,6 +343,18 @@ genericmenuitem_set_state (Genericmenuitem * item, GenericmenuitemState state) return; } +/* A small helper to look through the widgets in the + box and find the one that is the image. */ +static void +set_image_helper (GtkWidget * widget, gpointer data) +{ + GtkWidget ** labelval = (GtkWidget **)data; + if (GTK_IS_IMAGE(widget)) { + *labelval = widget; + } + return; +} + /** genericmenuitem_set_image: @item: A #Genericmenuitem @@ -351,9 +363,49 @@ genericmenuitem_set_state (Genericmenuitem * item, GenericmenuitemState state) Sets the image of the menu item. */ void -genericmenuitem_set_image (Genericmenuitem * item, GtkWidget * image) +genericmenuitem_set_image (Genericmenuitem * menu_item, GtkWidget * image) { + GtkWidget * child = gtk_bin_get_child(GTK_BIN(menu_item)); + GtkImage * imagew = NULL; + /* Try to find if we have a label already */ + if (child != NULL) { + if (GTK_IS_IMAGE(child)) { + /* We've got a label, let's update it. */ + imagew = GTK_IMAGE(child); + } else if (GTK_IS_BOX(child)) { + /* Look for the label in the box */ + gtk_container_foreach(GTK_CONTAINER(child), set_image_helper, &imagew); + } else { + /* We need to put the child into a new box and + make the box the child of the menu item. Basically + we're inserting a box in the middle. */ + GtkWidget * hbox = gtk_hbox_new(FALSE, 0); + g_object_ref(child); + gtk_container_remove(GTK_CONTAINER(menu_item), child); + gtk_box_pack_end(GTK_BOX(hbox), child, TRUE, TRUE, 0); + gtk_container_add(GTK_CONTAINER(menu_item), hbox); + gtk_widget_show(hbox); + g_object_unref(child); + child = hbox; + /* It's important to notice that imagew is not set + by this condition. There was no label to find. */ + } + } + + /* No we can see if we need to ethier replace and image or + just put ourselves into the structures */ + if (imagew != NULL) { + gtk_widget_destroy(GTK_WIDGET(imagew)); + } + + /* Check to see if it needs to be in the bin for this + menu item or whether it gets packed in a box. */ + if (child == NULL) { + gtk_container_add(GTK_CONTAINER(menu_item), GTK_WIDGET(image)); + } else { + gtk_box_pack_start(GTK_BOX(child), GTK_WIDGET(image), FALSE, FALSE, 0); + } return; } @@ -368,9 +420,21 @@ genericmenuitem_set_image (Genericmenuitem * item, GtkWidget * image) if there isn't one. */ GtkWidget * -genericmenuitem_get_image (Genericmenuitem * item) +genericmenuitem_get_image (Genericmenuitem * menu_item) { + GtkWidget * child = gtk_bin_get_child(GTK_BIN(menu_item)); + GtkWidget * imagew = NULL; + /* Try to find if we have a label already */ + if (child != NULL) { + if (GTK_IS_IMAGE(child)) { + /* We've got a label, let's update it. */ + imagew = child; + } else if (GTK_IS_BOX(child)) { + /* Look for the label in the box */ + gtk_container_foreach(GTK_CONTAINER(child), set_image_helper, &imagew); + } + } - return NULL; + return imagew; } -- cgit v1.2.3 From e22718dfc5c747182529e75b7d28f0b450b6ba5b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Dec 2009 15:40:49 -0600 Subject: We killed the image item, time to update the tests. --- tests/test-gtk-label.json | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/tests/test-gtk-label.json b/tests/test-gtk-label.json index 14584c3..17e2738 100644 --- a/tests/test-gtk-label.json +++ b/tests/test-gtk-label.json @@ -205,43 +205,43 @@ "label": "value1", "submenu": [ {"id": 80, - "type": "imageitem", + "type": "menuitem", "icon": "face-angel", "label": "angel"}, {"id": 81, - "type": "imageitem", + "type": "menuitem", "icon": "face-angry", "label": "angry"}, {"id": 82, - "type": "imageitem", + "type": "menuitem", "icon": "face-cool", "label": "cool"}, {"id": 83, - "type":"imageitem", + "type":"menuitem", "icon": "face-devilish", "label": "devilish"}, {"id": 84, - "type": "imageitem", + "type": "menuitem", "icon": "face-embarrassed", "label": "embarrassed"}, {"id": 85, - "type": "imageitem", + "type": "menuitem", "icon": "face-kiss", "label": "kiss"}, {"id": 86, - "type": "imageitem", + "type": "menuitem", "icon": "face-laugh", "label": "laugh"}, {"id": 87, - "type": "imageitem", + "type": "menuitem", "icon": "face-monkey", "label": "monkey"}, {"id": 88, - "type": "imageitem", + "type": "menuitem", "icon": "face-sad", "label": "sad"}, {"id": 89, - "type": "imageitem", + "type": "menuitem", "icon": "face-sick", "label": "sick"} ] @@ -250,7 +250,7 @@ "label": "value1", "submenu": [ {"id": 90, - "type": "imageitem", + "type": "menuitem", "icon-data": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACPUlEQVR4nGJgoBAAAAAA///Ch1gW BzK0LQ5iaGNgYGDBpQgAAAD//8KpeY4/Q9+DCV7/H/S4/p8byDABlyEAAAAA///CqnluAMOEx5O8 @@ -266,7 +266,7 @@ Bi8YEIEIBwAAAAD//8JmAAcDA4MAlEYGPxgYGD5AaTgAAAAA//8DAD6xjTP5Y+A7AAAAAElFTkSu QmCC", "label": "up"}, {"id": 91, - "type": "imageitem", + "type": "menuitem", "icon-data": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACl0lEQVR4nGJgoBAAAAAA//9ixCLG sSWS4bs0B1QWip/+YGDwWcLAycDA8ANZMQAAAP//YsFigIA0JwODdvIsBob/fxgY/vxk+P/7OwPD @@ -283,7 +283,7 @@ AwODR18kw4UJ0QyX8WkGAAAA///ClpkYoAolGBgYFKBqHjAwMDxnYGD4ha4QAAAA///CZQDMEG4o +ys2zQwMDAwAAAAA//8DAAF5nhyE7tENAAAAAElFTkSuQmCC", "label": "down"}, {"id": 92, - "type": "imageitem", + "type": "menuitem", "icon": "up", "icon-data": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACl0lEQVR4nGJgoBAAAAAA//9ixCLG @@ -301,7 +301,7 @@ AwODR18kw4UJ0QyX8WkGAAAA///ClpkYoAolGBgYFKBqHjAwMDxnYGD4ha4QAAAA///CZQDMEG4o +ys2zQwMDAwAAAAA//8DAAF5nhyE7tENAAAAAElFTkSuQmCC", "label": "up"}, {"id": 93, - "type": "imageitem", + "type": "menuitem", "icon": "down", "icon-data": "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACPUlEQVR4nGJgoBAAAAAA///Ch1gW -- cgit v1.2.3 From c300f8c5be570efbf14792dcee496db8d957154e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Dec 2009 15:43:00 -0600 Subject: Adding in a layout that has all kinds of different checks in it. --- tests/test-gtk-label.json | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/tests/test-gtk-label.json b/tests/test-gtk-label.json index 17e2738..464dc2d 100644 --- a/tests/test-gtk-label.json +++ b/tests/test-gtk-label.json @@ -319,4 +319,53 @@ QmCC", "label": "down"} ] }, + {"id": 1, "type": "menuitem", + "label": "value1", + "submenu": [ + {"id": 30, + "label": "No check (empty)", + "toggle-type": "none" + }, + {"id": 31, + "label": "No check (checked)", + "toggle-type": "none", + "toggle-checked": "checked" + }, + {"id": 32, + "label": "No check (????)", + "toggle-type": "none", + "toggle-checked": "indeterminate" + }, + {"id": 33, + "label": "Check (empty)", + "toggle-type": "checkbox", + "toggle-checked": "unchecked" + }, + {"id": 34, + "label": "Check (checked)", + "toggle-type": "checkbox", + "toggle-checked": "checked" + }, + {"id": 35, + "label": "Check (?????)", + "toggle-type": "checkbox", + "toggle-checked": "indeterminate" + }, + {"id": 36, + "label": "Radio (empty)", + "toggle-type": "radio", + "toggle-checked": "unchecked" + }, + {"id": 37, + "label": "Radio (checked)", + "toggle-type": "radio", + "toggle-checked": "checked" + }, + {"id": 38, + "label": "Radio (?????)", + "toggle-type": "radio", + "toggle-checked": "indeterminate" + } + ] + }, ] -- cgit v1.2.3 From 21b5c268ced2ded5ffe46be7f718e186eb2c834c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Dec 2009 15:49:27 -0600 Subject: Handling the case of getting an image with the purpose of clearing the label. Also showing the image. --- libdbusmenu-gtk/genericmenuitem.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/libdbusmenu-gtk/genericmenuitem.c b/libdbusmenu-gtk/genericmenuitem.c index dded1de..f927556 100644 --- a/libdbusmenu-gtk/genericmenuitem.c +++ b/libdbusmenu-gtk/genericmenuitem.c @@ -376,7 +376,7 @@ genericmenuitem_set_image (Genericmenuitem * menu_item, GtkWidget * image) } else if (GTK_IS_BOX(child)) { /* Look for the label in the box */ gtk_container_foreach(GTK_CONTAINER(child), set_image_helper, &imagew); - } else { + } else if (image != NULL) { /* We need to put the child into a new box and make the box the child of the menu item. Basically we're inserting a box in the middle. */ @@ -401,10 +401,14 @@ genericmenuitem_set_image (Genericmenuitem * menu_item, GtkWidget * image) /* Check to see if it needs to be in the bin for this menu item or whether it gets packed in a box. */ - if (child == NULL) { - gtk_container_add(GTK_CONTAINER(menu_item), GTK_WIDGET(image)); - } else { - gtk_box_pack_start(GTK_BOX(child), GTK_WIDGET(image), FALSE, FALSE, 0); + if (image != NULL) { + if (child == NULL) { + gtk_container_add(GTK_CONTAINER(menu_item), GTK_WIDGET(image)); + } else { + gtk_box_pack_start(GTK_BOX(child), GTK_WIDGET(image), FALSE, FALSE, 0); + } + + gtk_widget_show(image); } return; -- cgit v1.2.3 From 53ce3275daf3cd64f160a5f77a03b9949f196e1d Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 17 Dec 2009 16:43:32 -0600 Subject: Not setting the underline for seperators. --- libdbusmenu-gtk/client.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libdbusmenu-gtk/client.c b/libdbusmenu-gtk/client.c index 80d2b4f..27ac4dc 100644 --- a/libdbusmenu-gtk/client.c +++ b/libdbusmenu-gtk/client.c @@ -452,7 +452,6 @@ new_item_seperator (DbusmenuMenuitem * newitem, DbusmenuMenuitem * parent, Dbusm GtkMenuItem * gmi; gmi = GTK_MENU_ITEM(gtk_separator_menu_item_new()); - gtk_menu_item_set_use_underline (gmi, TRUE); if (gmi != NULL) { dbusmenu_gtkclient_newitem_base(DBUSMENU_GTKCLIENT(client), newitem, gmi, parent); -- cgit v1.2.3 From 7cbec8065b76e02f383d9161b68fa2062b9db0b5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 11:59:58 -0600 Subject: Fixing MASSIVEDEBUGGING as it was still looking for a string. --- libdbusmenu-glib/client.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 366d60d..59494a3 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -324,7 +324,11 @@ static void id_prop_update (DBusGProxy * proxy, guint id, gchar * property, GValue * value, DbusmenuClient * client) { #ifdef MASSIVEDEBUGGING - g_debug("Property change sent to client for item %d property %s value %s", id, property, g_utf8_strlen(value, 50) < 25 ? value : ""); + GValue valstr = {0}; + g_value_init(&valstr, G_TYPE_STRING); + g_value_transform(value, &valstr); + g_debug("Property change sent to client for item %d property %s value %s", id, property, g_utf8_strlen(g_value_get_string(&valstr), 50) < 25 ? g_value_get_string(&valstr) : ""); + g_value_unset(&valstr); #endif DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client); -- cgit v1.2.3 From 49ae07290d8fb13ec4adae36759b0e0a94d1ea82 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 12:13:12 -0600 Subject: Somehow I messed up the merge and lost the version change. Oops. --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 3b19cea..e2bc1a7 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.1.7, ted@canonical.com) +AC_INIT(libdbusmenu, 0.1.8, ted@canonical.com) AC_COPYRIGHT([Copyright 2009 Canonical]) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.1.7) +AM_INIT_AUTOMAKE(libdbusmenu, 0.1.8) AM_MAINTAINER_MODE @@ -66,7 +66,7 @@ AC_SUBST(DBUSMENUTESTS_LIBS) ########################### LIBDBUSMENU_CURRENT=0 -LIBDBUSMENU_REVISION=7 +LIBDBUSMENU_REVISION=8 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3 From 85842906707111c8e0869956f4fd29327de9a0a6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 14:30:21 -0600 Subject: debian/control: Mentioning nicely that this will cause indicator-messages << 0.3 and indicator-session << 0.2 to break. --- debian/changelog | 3 +++ debian/control | 2 ++ 2 files changed, 5 insertions(+) diff --git a/debian/changelog b/debian/changelog index 370acaa..1e6f70e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,9 @@ libdbusmenu (0.2.0~dev-0ubuntu1~ppa3) UNRELEASED; urgency=low * Updating trunk * Changing API to be V0.2 for reals + * debian/control: Mentioning nicely that this will cause + indicator-messages << 0.3 and indicator-session << 0.2 to + break. -- Ted Gould Fri, 18 Dec 2009 13:21:40 -0600 diff --git a/debian/control b/debian/control index 7854be9..c392b34 100644 --- a/debian/control +++ b/debian/control @@ -21,6 +21,8 @@ Section: libs Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} +Breaks: indicator-messages (<< 0.3.0), + indicator-session (<< 0.2.0) Description: Menus over DBus shared library for glib This package contains shared libraries to be used by applications. -- cgit v1.2.3 From 5f76cf3fe29f1392172b51cf64e572a984bc396f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 14:31:47 -0600 Subject: releasing version 0.2.0~dev-0ubuntu1~ppa3 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 1e6f70e..0aead8a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -libdbusmenu (0.2.0~dev-0ubuntu1~ppa3) UNRELEASED; urgency=low +libdbusmenu (0.2.0~dev-0ubuntu1~ppa3) karmic; urgency=low * Updating trunk * Changing API to be V0.2 for reals @@ -6,7 +6,7 @@ libdbusmenu (0.2.0~dev-0ubuntu1~ppa3) UNRELEASED; urgency=low indicator-messages << 0.3 and indicator-session << 0.2 to break. - -- Ted Gould Fri, 18 Dec 2009 13:21:40 -0600 + -- Ted Gould Fri, 18 Dec 2009 14:31:45 -0600 libdbusmenu (0.2.0~dev-0ubuntu1~ppa2) karmic; urgency=low -- cgit v1.2.3 From ba3999565f0bbc19df01111a1f6dd4108f323aae Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 15:22:07 -0600 Subject: Giving us some room in the 0.1.x series, but still getting version numbers in the right place so that people can start depending on this API. --- configure.ac | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 3b19cea..fc12668 100644 --- a/configure.ac +++ b/configure.ac @@ -1,11 +1,11 @@ -AC_INIT(libdbusmenu, 0.1.7, ted@canonical.com) +AC_INIT(libdbusmenu, 0.2.0, ted@canonical.com) AC_COPYRIGHT([Copyright 2009 Canonical]) AC_PREREQ(2.53) AM_CONFIG_HEADER(config.h) -AM_INIT_AUTOMAKE(libdbusmenu, 0.1.7) +AM_INIT_AUTOMAKE(libdbusmenu, 0.2.0) AM_MAINTAINER_MODE @@ -66,7 +66,7 @@ AC_SUBST(DBUSMENUTESTS_LIBS) ########################### LIBDBUSMENU_CURRENT=0 -LIBDBUSMENU_REVISION=7 +LIBDBUSMENU_REVISION=10 LIBDBUSMENU_AGE=0 AC_SUBST(LIBDBUSMENU_CURRENT) -- cgit v1.2.3 From 69be0c929a75c877ffa89703e8e3ab4f3b8919e1 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 15:31:12 -0600 Subject: releasing version 0.2.0~dev-0ubuntu1~ppa4 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 9435122..0bc0579 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,9 @@ -libdbusmenu (0.2.0~dev-0ubuntu1~ppa4) UNRELEASED; urgency=low +libdbusmenu (0.2.0~dev-0ubuntu1~ppa4) karmic; urgency=low * Updating trunk * Setting version numbers - -- Ted Gould Fri, 18 Dec 2009 15:22:57 -0600 + -- Ted Gould Fri, 18 Dec 2009 15:31:08 -0600 libdbusmenu (0.2.0~dev-0ubuntu1~ppa3) karmic; urgency=low -- cgit v1.2.3 From 995a27ae56fb63ec7835090e6264b3e489e38b64 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 21:18:19 -0600 Subject: debian/control: Switching the breaks to be ~dev as those versions are not yet released. --- debian/changelog | 7 +++++++ debian/control | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 0bc0579..e8026b0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +libdbusmenu (0.2.0~dev-0ubuntu1~ppa5) UNRELEASED; urgency=low + + * debian/control: Switching the breaks to be ~dev as those + versions are not yet released. + + -- Ted Gould Fri, 18 Dec 2009 21:17:31 -0600 + libdbusmenu (0.2.0~dev-0ubuntu1~ppa4) karmic; urgency=low * Updating trunk diff --git a/debian/control b/debian/control index c392b34..7e307d3 100644 --- a/debian/control +++ b/debian/control @@ -21,8 +21,8 @@ Section: libs Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} -Breaks: indicator-messages (<< 0.3.0), - indicator-session (<< 0.2.0) +Breaks: indicator-messages (<< 0.3.0~dev), + indicator-session (<< 0.2.0~dev) Description: Menus over DBus shared library for glib This package contains shared libraries to be used by applications. -- cgit v1.2.3 From e930f7d167fe1e5a889be0fd7e1ed0b625773fe4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 21:21:15 -0600 Subject: releasing version 0.2.0~dev-0ubuntu1~ppa5 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index e8026b0..b4593ec 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,9 @@ -libdbusmenu (0.2.0~dev-0ubuntu1~ppa5) UNRELEASED; urgency=low +libdbusmenu (0.2.0~dev-0ubuntu1~ppa5) karmic; urgency=low * debian/control: Switching the breaks to be ~dev as those versions are not yet released. - -- Ted Gould Fri, 18 Dec 2009 21:17:31 -0600 + -- Ted Gould Fri, 18 Dec 2009 21:21:12 -0600 libdbusmenu (0.2.0~dev-0ubuntu1~ppa4) karmic; urgency=low -- cgit v1.2.3 From ad4bfb14e3449857f52f50bca76ce52ee72be5f5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 21:58:26 -0600 Subject: Changing the prototype on the signal so that it isn't a string, but a value. --- libdbusmenu-glib/menuitem-marshal.list | 2 +- libdbusmenu-glib/menuitem.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libdbusmenu-glib/menuitem-marshal.list b/libdbusmenu-glib/menuitem-marshal.list index a32e7e3..dc4ba53 100644 --- a/libdbusmenu-glib/menuitem-marshal.list +++ b/libdbusmenu-glib/menuitem-marshal.list @@ -1,4 +1,4 @@ -VOID: STRING, STRING +VOID: STRING, POINTER VOID: OBJECT, UINT, UINT VOID: OBJECT, UINT VOID: OBJECT diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index dc01157..5d45e98 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -122,8 +122,8 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET(DbusmenuMenuitemClass, property_changed), NULL, NULL, - _dbusmenu_menuitem_marshal_VOID__STRING_STRING, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); + _dbusmenu_menuitem_marshal_VOID__STRING_POINTER, + G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VALUE); /** DbusmenuMenuitem::item-activated: @arg0: The #DbusmenuMenuitem object. -- cgit v1.2.3 From 1088cbfdb3cfd67ee3dfe048c7b0879d6f83a8d9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 22:04:00 -0600 Subject: releasing version 0.2.0~dev-0ubuntu1~ppa6~sigfix1 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 08f8b96..83f9a25 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,9 @@ -libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix1) UNRELEASED; urgency=low +libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix1) karmic; urgency=low * Upstream * Fixing the signal prototypes. - -- Ted Gould Fri, 18 Dec 2009 21:59:03 -0600 + -- Ted Gould Fri, 18 Dec 2009 22:03:56 -0600 libdbusmenu (0.2.0~dev-0ubuntu1~ppa5) karmic; urgency=low -- cgit v1.2.3 From 8f3554c1f22f58ab8e601a4efc5eabfbf04c2349 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 22:09:02 -0600 Subject: Switching to just being a string and a pointer. --- 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 5d45e98..ec37da5 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -123,7 +123,7 @@ dbusmenu_menuitem_class_init (DbusmenuMenuitemClass *klass) G_STRUCT_OFFSET(DbusmenuMenuitemClass, property_changed), NULL, NULL, _dbusmenu_menuitem_marshal_VOID__STRING_POINTER, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_VALUE); + G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_POINTER); /** DbusmenuMenuitem::item-activated: @arg0: The #DbusmenuMenuitem object. -- cgit v1.2.3 From 13a19ef39002664d91cabfea8bfe0cb3ad01d61e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 22:10:47 -0600 Subject: releasing version 0.2.0~dev-0ubuntu1~ppa6~sigfix1 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 93e5787..09f5c79 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,8 @@ -libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix1) UNRELEASED; urgency=low +libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix1) karmic; urgency=low * Trying again - -- Ted Gould Fri, 18 Dec 2009 22:09:20 -0600 + -- Ted Gould Fri, 18 Dec 2009 22:10:45 -0600 libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix1) karmic; urgency=low -- cgit v1.2.3 From 5217f7324cedb09aba9fab35c348c3191279a90e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 22:11:07 -0600 Subject: releasing version 0.2.0~dev-0ubuntu1~ppa6~sigfix2 --- debian/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 09f5c79..b1308ae 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix1) karmic; urgency=low +libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix2) karmic; urgency=low * Trying again -- cgit v1.2.3 From 9676ac55e84b21bf1318925bceb3b3135e07403c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 22:20:10 -0600 Subject: debian/rules: Massive debugging --- debian/changelog | 6 ++++++ debian/rules | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index b1308ae..41dc81e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix3) UNRELEASED; urgency=low + + * debian/rules: Massive debugging + + -- Ted Gould Fri, 18 Dec 2009 22:19:52 -0600 + libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix2) karmic; urgency=low * Trying again diff --git a/debian/rules b/debian/rules index 7f7f405..ebcbf31 100755 --- a/debian/rules +++ b/debian/rules @@ -3,7 +3,7 @@ include /usr/share/cdbs/1/rules/debhelper.mk include /usr/share/cdbs/1/class/gnome.mk -DEB_CONFIGURE_EXTRA_FLAGS += --disable-scrollkeeper +DEB_CONFIGURE_EXTRA_FLAGS += --disable-scrollkeeper --enable-massivedebugging LDFLAGS += -Wl,-z,defs -Wl,--as-needed DEB_DH_MAKESHLIBS_ARGS_libdbusmenu-gtk0 += -V 'libdbusmenu-gtk0 (>= 0.1.2)' -- cgit v1.2.3 From ac0fbaf02100ff196bef3d97db162a4f01d58d58 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 22:21:46 -0600 Subject: releasing version 0.2.0~dev-0ubuntu1~ppa6~sigfix3 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 41dc81e..4621c6f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,8 @@ -libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix3) UNRELEASED; urgency=low +libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix3) karmic; urgency=low * debian/rules: Massive debugging - -- Ted Gould Fri, 18 Dec 2009 22:19:52 -0600 + -- Ted Gould Fri, 18 Dec 2009 22:21:44 -0600 libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix2) karmic; urgency=low -- cgit v1.2.3 From 9276f061d4565b57a160ece79ec547550195188b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 18 Dec 2009 22:24:25 -0600 Subject: Making sure we get our function. --- libdbusmenu-glib/menuitem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index ec37da5..2cefce4 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -250,7 +250,7 @@ static guint menuitem_next_id = 1; /* A small little function to both clear the insides of a value as well as the memory it itself uses. */ static void -g_value_free (gpointer data) +_g_value_free (gpointer data) { if (data == NULL) return; GValue * value = (GValue*)data; @@ -269,7 +269,7 @@ dbusmenu_menuitem_init (DbusmenuMenuitem *self) priv->id = 0; priv->children = NULL; - priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_value_free); + priv->properties = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, _g_value_free); priv->root = FALSE; -- cgit v1.2.3 From d7f273f9fced68bea1d711503b9a0fd2defa72c6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 14:29:56 -0600 Subject: Starting a framework for object testing. --- tests/test-glib-objects.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/test-glib-objects.c diff --git a/tests/test-glib-objects.c b/tests/test-glib-objects.c new file mode 100644 index 0000000..cc95b81 --- /dev/null +++ b/tests/test-glib-objects.c @@ -0,0 +1,60 @@ +/* +Testing for the various objects just by themselves. + +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 + +void +test_object_menuitem (void) +{ + + +} + +void +test_object_menuitem_props (void) +{ + + +} + +void +test_glib_objects_suite (void) +{ + g_test_add_func ("/dbusmenu/glib/objects/menuitem", test_object_menuitem); + g_test_add_func ("/dbusmenu/glib/objects/menuitem-props", test_object_menuitem_props); + return; +} + +gint +main (gint argc, gchar * argv[]) +{ + g_type_init(); + g_test_init(&argc, &argv, NULL); + + /* Test suites */ + test_glib_objects_suite(); + + + return g_test_run (); +} -- cgit v1.2.3 From 7f05a7e84a3bf4bf936bc9e81465e7feac1f7487 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 14:41:50 -0600 Subject: Adding the object tests into the build. --- .bzrignore | 2 ++ tests/Makefile.am | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/.bzrignore b/.bzrignore index d7b28a6..66f815e 100644 --- a/.bzrignore +++ b/.bzrignore @@ -54,3 +54,5 @@ libdbusmenu-[0-9].[0-9].[0-9].tar.gz.asc tests/test-mago tests/*.bustle libdbusmenu-gtk/libdbusmenu_gtk_la-genericmenuitem.lo +tests/test-glib-objects +tests/test-glib-objects-test diff --git a/tests/Makefile.am b/tests/Makefile.am index 1d58700..0c2ab57 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -2,6 +2,7 @@ DBUS_RUNNER=dbus-test-runner TESTS = \ + test-glib-objects-test \ test-glib-layout \ test-glib-properties \ test-glib-simple-items \ @@ -10,6 +11,7 @@ TESTS = \ check_PROGRAMS = \ glib-server-nomenu \ + test-glib-objects \ test-glib-layout-client \ test-glib-layout-server \ test-glib-properties-client \ @@ -70,6 +72,26 @@ test_glib_layout_client_LDADD = \ $(DBUSMENUGLIB_LIBS) +###################### +# Test Glib Object +###################### + +test-glib-objects-test: test-glib-objects Makefile.am + @echo "#!/bin/bash" > $@ + @echo $(DBUS_RUNNER) -b $@.bustle --task gtester --parameter ./test-glib-objects >> $@ + @chmod +x $@ + +test_glib_objects_SOURCES = \ + test-glib-objects.c + +test_glib_objects_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_glib_objects_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + $(DBUSMENUGLIB_LIBS) + ###################### # Test Glib Properties ###################### @@ -239,6 +261,7 @@ distclean-local: DISTCLEANFILES = \ $(TESTS) \ + test-glib-objects-test.bustle \ test-glib-layout.bustle \ test-glib-properties.bustle \ test-glib-simple-items.bustle \ -- cgit v1.2.3 From b03128c902c0b9906a34e3cc9f4fc5985d7a06d3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 14:52:44 -0600 Subject: Adding a menuitem allocation test. --- tests/test-glib-objects.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test-glib-objects.c b/tests/test-glib-objects.c index cc95b81..cc59751 100644 --- a/tests/test-glib-objects.c +++ b/tests/test-glib-objects.c @@ -27,8 +27,22 @@ with this program. If not, see . void test_object_menuitem (void) { + /* Build a menu item */ + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); + /* Test to make sure it's a happy object */ + g_assert(item != NULL); + g_assert(G_IS_OBJECT(item)); + g_assert(DBUSMENU_IS_MENUITEM(item)); + /* Set up a check to make sure it gets destroyed on unref */ + g_object_add_weak_pointer(G_OBJECT(item), (gpointer *)&item); + g_object_unref(item); + + /* Did it go away? */ + g_assert(item == NULL); + + return; } void -- cgit v1.2.3 From 46532dd8beb62a6aa4a639ee646eb0bf1682b75c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 14:56:49 -0600 Subject: Adding in an XML report file. --- tests/Makefile.am | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 0c2ab57..fa18b9d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -76,9 +76,11 @@ test_glib_layout_client_LDADD = \ # Test Glib Object ###################### +OBJECT_XML_REPORT = test-glib-objects.xml + test-glib-objects-test: test-glib-objects Makefile.am @echo "#!/bin/bash" > $@ - @echo $(DBUS_RUNNER) -b $@.bustle --task gtester --parameter ./test-glib-objects >> $@ + @echo $(DBUS_RUNNER) -b $@.bustle --task gtester --parameter -k --parameter -o --parameter $(OBJECT_XML_REPORT) --parameter ./test-glib-objects >> $@ @chmod +x $@ test_glib_objects_SOURCES = \ @@ -261,6 +263,7 @@ distclean-local: DISTCLEANFILES = \ $(TESTS) \ + $(OBJECT_XML_FILE) \ test-glib-objects-test.bustle \ test-glib-layout.bustle \ test-glib-properties.bustle \ -- cgit v1.2.3 From 0d32243f7b12d6d1bc94658a61c4f06c4643051b Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 15:07:39 -0600 Subject: Setting all the different properties. --- tests/test-glib-objects.c | 70 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/tests/test-glib-objects.c b/tests/test-glib-objects.c index cc59751..d45baa0 100644 --- a/tests/test-glib-objects.c +++ b/tests/test-glib-objects.c @@ -46,17 +46,81 @@ test_object_menuitem (void) } void -test_object_menuitem_props (void) +test_object_menuitem_props_string (void) { + /* Build a menu item */ + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); + const GValue * out = NULL; + + /* Test to make sure it's a happy object */ + g_assert(item != NULL); + + /* Setting a string */ + dbusmenu_menuitem_property_set(item, "string", "value"); + out = dbusmenu_menuitem_property_get_value(item, "string"); + g_assert(out != NULL); + g_assert(G_VALUE_TYPE(out) == G_TYPE_STRING); + g_assert(!g_strcmp0(g_value_get_string(out), "value")); + g_assert(!g_strcmp0(dbusmenu_menuitem_property_get(item, "string"), "value")); + + g_object_unref(item); + + return; +} + +void +test_object_menuitem_props_int (void) +{ + /* Build a menu item */ + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); + const GValue * out = NULL; + + /* Test to make sure it's a happy object */ + g_assert(item != NULL); + + /* Setting a string */ + dbusmenu_menuitem_property_set_int(item, "int", 12345); + out = dbusmenu_menuitem_property_get_value(item, "int"); + g_assert(out != NULL); + g_assert(G_VALUE_TYPE(out) == G_TYPE_INT); + g_assert(g_value_get_int(out) == 12345); + g_assert(dbusmenu_menuitem_property_get_int(item, "int") == 12345); + + g_object_unref(item); + + return; +} + +void +test_object_menuitem_props_bool (void) +{ + /* Build a menu item */ + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); + const GValue * out = NULL; + /* Test to make sure it's a happy object */ + g_assert(item != NULL); + /* Setting a string */ + dbusmenu_menuitem_property_set_bool(item, "boolean", TRUE); + out = dbusmenu_menuitem_property_get_value(item, "boolean"); + g_assert(out != NULL); + g_assert(G_VALUE_TYPE(out) == G_TYPE_BOOLEAN); + g_assert(g_value_get_boolean(out)); + g_assert(dbusmenu_menuitem_property_get_int(item, "boolean")); + + g_object_unref(item); + + return; } void test_glib_objects_suite (void) { - g_test_add_func ("/dbusmenu/glib/objects/menuitem", test_object_menuitem); - g_test_add_func ("/dbusmenu/glib/objects/menuitem-props", test_object_menuitem_props); + g_test_add_func ("/dbusmenu/glib/objects/menuitem/base", test_object_menuitem); + g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_string", test_object_menuitem_props_string); + g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_int", test_object_menuitem_props_int); + g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_bool", test_object_menuitem_props_bool); return; } -- cgit v1.2.3 From d7480ea88bc34ac80c468e28ce8b6a0704cb3c8c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 15:08:03 -0600 Subject: Ignoring the generated test description. --- .bzrignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.bzrignore b/.bzrignore index 66f815e..06863df 100644 --- a/.bzrignore +++ b/.bzrignore @@ -56,3 +56,4 @@ tests/*.bustle libdbusmenu-gtk/libdbusmenu_gtk_la-genericmenuitem.lo tests/test-glib-objects tests/test-glib-objects-test +tests/test-glib-objects.xml -- cgit v1.2.3 From c96e551eccc631c726e0987ebe8ed859c2305e42 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 15:26:19 -0600 Subject: Testing setting the same prop multiple times of different types. --- tests/test-glib-objects.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tests/test-glib-objects.c b/tests/test-glib-objects.c index d45baa0..7f79746 100644 --- a/tests/test-glib-objects.c +++ b/tests/test-glib-objects.c @@ -114,6 +114,36 @@ test_object_menuitem_props_bool (void) return; } +void +test_object_menuitem_props_swap (void) +{ + /* Build a menu item */ + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); + + /* Test to make sure it's a happy object */ + g_assert(item != NULL); + + /* Setting a boolean */ + dbusmenu_menuitem_property_set_bool(item, "swapper", TRUE); + g_assert(dbusmenu_menuitem_property_get_bool(item, "swapper")); + + /* Setting a int */ + dbusmenu_menuitem_property_set_int(item, "swapper", 5432); + g_assert(dbusmenu_menuitem_property_get_int(item, "swapper") == 5432); + + /* Setting a string */ + dbusmenu_menuitem_property_set(item, "swapper", "mystring"); + g_assert(!g_strcmp0(dbusmenu_menuitem_property_get(item, "swapper"), "mystring")); + + /* Setting a boolean */ + dbusmenu_menuitem_property_set_bool(item, "swapper", FALSE); + g_assert(!dbusmenu_menuitem_property_get_bool(item, "swapper")); + + g_object_unref(item); + + return; +} + void test_glib_objects_suite (void) { @@ -121,6 +151,7 @@ test_glib_objects_suite (void) g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_string", test_object_menuitem_props_string); g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_int", test_object_menuitem_props_int); g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_bool", test_object_menuitem_props_bool); + g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_swap", test_object_menuitem_props_swap); return; } -- cgit v1.2.3 From d33832e3fd108c002216551123d419ec494bd668 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 15:28:08 -0600 Subject: Comments are good for the soul. --- tests/test-glib-objects.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test-glib-objects.c b/tests/test-glib-objects.c index 7f79746..d63c26d 100644 --- a/tests/test-glib-objects.c +++ b/tests/test-glib-objects.c @@ -24,6 +24,8 @@ with this program. If not, see . #include +/* Building the basic menu item, make sure we didn't break + any core GObject stuff */ void test_object_menuitem (void) { @@ -45,6 +47,7 @@ test_object_menuitem (void) return; } +/* Set a string prop, make sure it's stored as one */ void test_object_menuitem_props_string (void) { @@ -68,6 +71,7 @@ test_object_menuitem_props_string (void) return; } +/* Set an integer prop, make sure it's stored as one */ void test_object_menuitem_props_int (void) { @@ -91,6 +95,7 @@ test_object_menuitem_props_int (void) return; } +/* Set a boolean prop, make sure it's stored as one */ void test_object_menuitem_props_bool (void) { @@ -114,6 +119,8 @@ test_object_menuitem_props_bool (void) return; } +/* Set the same property several times with + different types. */ void test_object_menuitem_props_swap (void) { @@ -144,6 +151,7 @@ test_object_menuitem_props_swap (void) return; } +/* Build the test suite */ void test_glib_objects_suite (void) { -- cgit v1.2.3 From f5a12b2235fe0437d58ec2743382eef39f2b40fc Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 15:59:41 -0600 Subject: Adding test to signal property changes. --- tests/test-glib-objects.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tests/test-glib-objects.c b/tests/test-glib-objects.c index d63c26d..1807243 100644 --- a/tests/test-glib-objects.c +++ b/tests/test-glib-objects.c @@ -151,6 +151,60 @@ test_object_menuitem_props_swap (void) return; } +/* A helper to put a value into a pointer for eval. */ +void +test_object_menuitem_props_signals_helper (DbusmenuMenuitem * mi, gchar * property, GValue * value, GValue ** out) +{ + if (!g_strcmp0(property, "swapper")) { + *out = value; + } + return; +} + +/* Set the same property several times with + different types. */ +void +test_object_menuitem_props_signals (void) +{ + /* Build a menu item */ + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); + GValue * out; + + /* Test to make sure it's a happy object */ + g_assert(item != NULL); + + /* Setting up our callback */ + g_signal_connect(G_OBJECT(item), DBUSMENU_MENUITEM_SIGNAL_PROPERTY_CHANGED, G_CALLBACK(test_object_menuitem_props_signals_helper), &out); + + /* Setting a boolean */ + dbusmenu_menuitem_property_set_bool(item, "swapper", TRUE); + g_assert(out != NULL); + g_assert(g_value_get_boolean(out)); + out = NULL; + + /* Setting a int */ + dbusmenu_menuitem_property_set_int(item, "swapper", 5432); + g_assert(out != NULL); + g_assert(g_value_get_int(out) == 5432); + out = NULL; + + /* Setting a string */ + dbusmenu_menuitem_property_set(item, "swapper", "mystring"); + g_assert(out != NULL); + g_assert(!g_strcmp0(g_value_get_string(out), "mystring")); + out = NULL; + + /* Setting a boolean */ + dbusmenu_menuitem_property_set_bool(item, "swapper", FALSE); + g_assert(out != NULL); + g_assert(g_value_get_boolean(out)); + out = NULL; + + g_object_unref(item); + + return; +} + /* Build the test suite */ void test_glib_objects_suite (void) @@ -160,6 +214,7 @@ test_glib_objects_suite (void) g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_int", test_object_menuitem_props_int); g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_bool", test_object_menuitem_props_bool); g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_swap", test_object_menuitem_props_swap); + g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_signals", test_object_menuitem_props_signals); return; } -- cgit v1.2.3 From 2d6a51051442499e65f4dade13ba91d13a28fca9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 16:01:49 -0600 Subject: Making functions static so that we can get warnings if we don't use them. --- tests/test-glib-objects.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test-glib-objects.c b/tests/test-glib-objects.c index 1807243..9e46128 100644 --- a/tests/test-glib-objects.c +++ b/tests/test-glib-objects.c @@ -26,7 +26,7 @@ with this program. If not, see . /* Building the basic menu item, make sure we didn't break any core GObject stuff */ -void +static void test_object_menuitem (void) { /* Build a menu item */ @@ -48,7 +48,7 @@ test_object_menuitem (void) } /* Set a string prop, make sure it's stored as one */ -void +static void test_object_menuitem_props_string (void) { /* Build a menu item */ @@ -72,7 +72,7 @@ test_object_menuitem_props_string (void) } /* Set an integer prop, make sure it's stored as one */ -void +static void test_object_menuitem_props_int (void) { /* Build a menu item */ @@ -96,7 +96,7 @@ test_object_menuitem_props_int (void) } /* Set a boolean prop, make sure it's stored as one */ -void +static void test_object_menuitem_props_bool (void) { /* Build a menu item */ @@ -121,7 +121,7 @@ test_object_menuitem_props_bool (void) /* Set the same property several times with different types. */ -void +static void test_object_menuitem_props_swap (void) { /* Build a menu item */ @@ -152,7 +152,7 @@ test_object_menuitem_props_swap (void) } /* A helper to put a value into a pointer for eval. */ -void +static void test_object_menuitem_props_signals_helper (DbusmenuMenuitem * mi, gchar * property, GValue * value, GValue ** out) { if (!g_strcmp0(property, "swapper")) { @@ -163,12 +163,12 @@ test_object_menuitem_props_signals_helper (DbusmenuMenuitem * mi, gchar * proper /* Set the same property several times with different types. */ -void +static void test_object_menuitem_props_signals (void) { /* Build a menu item */ DbusmenuMenuitem * item = dbusmenu_menuitem_new(); - GValue * out; + GValue * out = NULL; /* Test to make sure it's a happy object */ g_assert(item != NULL); @@ -206,7 +206,7 @@ test_object_menuitem_props_signals (void) } /* Build the test suite */ -void +static void test_glib_objects_suite (void) { g_test_add_func ("/dbusmenu/glib/objects/menuitem/base", test_object_menuitem); -- cgit v1.2.3 From 14e7084968a1ce9fe8a1c1419351f435acd0eda5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 16:15:12 -0600 Subject: Fix an assertion that is the wrong direction --- tests/test-glib-objects.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test-glib-objects.c b/tests/test-glib-objects.c index 9e46128..afa669a 100644 --- a/tests/test-glib-objects.c +++ b/tests/test-glib-objects.c @@ -155,6 +155,7 @@ test_object_menuitem_props_swap (void) static void test_object_menuitem_props_signals_helper (DbusmenuMenuitem * mi, gchar * property, GValue * value, GValue ** out) { + /* g_debug("Signal handler got: %s", property); */ if (!g_strcmp0(property, "swapper")) { *out = value; } @@ -197,7 +198,7 @@ test_object_menuitem_props_signals (void) /* Setting a boolean */ dbusmenu_menuitem_property_set_bool(item, "swapper", FALSE); g_assert(out != NULL); - g_assert(g_value_get_boolean(out)); + g_assert(!g_value_get_boolean(out)); out = NULL; g_object_unref(item); -- cgit v1.2.3 From 7d0dbc3dd6be6ffaeca675b460767e20e505841e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 16:15:45 -0600 Subject: Switching to a replace so that new values are added. --- libdbusmenu-glib/menuitem.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c index 2cefce4..a03117c 100644 --- a/libdbusmenu-glib/menuitem.c +++ b/libdbusmenu-glib/menuitem.c @@ -815,12 +815,13 @@ dbusmenu_menuitem_property_set_value (DbusmenuMenuitem * mi, const gchar * prope g_value_init(lval, G_VALUE_TYPE(value)); g_value_copy(value, lval); - g_hash_table_insert(priv->properties, lprop, lval); + g_hash_table_replace(priv->properties, lprop, lval); #ifdef MASSIVEDEBUGGING gchar * valstr = g_strdup_value_contents(lval); g_debug("Menuitem %d (%s) signalling property '%s' changed to '%s'", ID(mi), LABEL(mi), property, g_utf8_strlen(valstr, 50) < 25 ? valstr : ""); g_free(valstr); #endif + g_signal_emit(G_OBJECT(mi), signals[PROPERTY_CHANGED], 0, lprop, lval, TRUE); return TRUE; -- cgit v1.2.3 From e32d593cf3457b68a1f05a5ece4aafd5a5918033 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 16:20:44 -0600 Subject: releasing version 0.2.0~dev-0ubuntu1~ppa6~sigfix4 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index ab376d2..174aae2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,8 @@ -libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix4) UNRELEASED; urgency=low +libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix4) karmic; urgency=low * Using a hash table replace - -- Ted Gould Mon, 21 Dec 2009 16:16:45 -0600 + -- Ted Gould Mon, 21 Dec 2009 16:20:42 -0600 libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix3) karmic; urgency=low -- cgit v1.2.3 From 2c02b8e394a55f099b03066774543396078932aa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 16:54:48 -0600 Subject: Adding a test for the string to boolean convertions --- tests/test-glib-objects.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tests/test-glib-objects.c b/tests/test-glib-objects.c index afa669a..7b22b7a 100644 --- a/tests/test-glib-objects.c +++ b/tests/test-glib-objects.c @@ -206,6 +206,49 @@ test_object_menuitem_props_signals (void) return; } +/* Set a boolean prop, as a string too! */ +static void +test_object_menuitem_props_boolstr (void) +{ + /* Build a menu item */ + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); + + /* Test to make sure it's a happy object */ + g_assert(item != NULL); + + /* Setting a bool */ + dbusmenu_menuitem_property_set_bool(item, "boolean", TRUE); + g_assert(dbusmenu_menuitem_property_get_bool(item, "boolean")); + + /* Setting "true" */ + dbusmenu_menuitem_property_set(item, "boolean", "true"); + g_assert(dbusmenu_menuitem_property_get_bool(item, "boolean")); + + /* Setting "True" */ + dbusmenu_menuitem_property_set(item, "boolean", "True"); + g_assert(dbusmenu_menuitem_property_get_bool(item, "boolean")); + + /* Setting "TRUE" */ + dbusmenu_menuitem_property_set(item, "boolean", "TRUE"); + g_assert(dbusmenu_menuitem_property_get_bool(item, "boolean")); + + /* Setting "false" */ + dbusmenu_menuitem_property_set(item, "boolean", "false"); + g_assert(!dbusmenu_menuitem_property_get_bool(item, "boolean")); + + /* Setting "False" */ + dbusmenu_menuitem_property_set(item, "boolean", "False"); + g_assert(!dbusmenu_menuitem_property_get_bool(item, "boolean")); + + /* Setting "FALSE" */ + dbusmenu_menuitem_property_set(item, "boolean", "FALSE"); + g_assert(!dbusmenu_menuitem_property_get_bool(item, "boolean")); + + g_object_unref(item); + + return; +} + /* Build the test suite */ static void test_glib_objects_suite (void) @@ -216,6 +259,7 @@ test_glib_objects_suite (void) g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_bool", test_object_menuitem_props_bool); g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_swap", test_object_menuitem_props_swap); g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_signals", test_object_menuitem_props_signals); + g_test_add_func ("/dbusmenu/glib/objects/menuitem/props_boolstr", test_object_menuitem_props_boolstr); return; } -- cgit v1.2.3 From 3634997456ea36b66d720fcb7b7f60d51a403e99 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 21:18:35 -0600 Subject: Switching the server function over to values. Oh, how I hate the untyped signals in GLib. --- libdbusmenu-glib/server.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c index f61b0fb..0825997 100644 --- a/libdbusmenu-glib/server.c +++ b/libdbusmenu-glib/server.c @@ -92,7 +92,7 @@ static void dbusmenu_server_dispose (GObject *object); static void dbusmenu_server_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); -static void menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, gchar * value, DbusmenuServer * server); +static void menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GValue * value, DbusmenuServer * server); static void menuitem_child_added (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, guint pos, DbusmenuServer * server); static void menuitem_child_removed (DbusmenuMenuitem * parent, DbusmenuMenuitem * child, DbusmenuServer * server); static void menuitem_signals_create (DbusmenuMenuitem * mi, gpointer data); @@ -292,12 +292,9 @@ get_property (GObject * obj, guint id, GValue * value, GParamSpec * pspec) } static void -menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, gchar * strvalue, DbusmenuServer * server) +menuitem_property_changed (DbusmenuMenuitem * mi, gchar * property, GValue * value, DbusmenuServer * server) { - GValue value = {0}; - g_value_init(&value, G_TYPE_STRING); - g_value_set_static_string(&value, strvalue); - g_signal_emit(G_OBJECT(server), signals[ID_PROP_UPDATE], 0, dbusmenu_menuitem_get_id(mi), property, &value, TRUE); + g_signal_emit(G_OBJECT(server), signals[ID_PROP_UPDATE], 0, dbusmenu_menuitem_get_id(mi), property, value, TRUE); return; } -- cgit v1.2.3 From f7a7a21c1f4365aa9857f20e420161f3df51c5af Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 21:22:37 -0600 Subject: releasing version 0.2.0~dev-0ubuntu1~ppa6~sigfix5 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 2e51ca9..cb7d187 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,8 @@ -libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix5) UNRELEASED; urgency=low +libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix5) karmic; urgency=low * string to value fix - -- Ted Gould Mon, 21 Dec 2009 21:19:11 -0600 + -- Ted Gould Mon, 21 Dec 2009 21:22:35 -0600 libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix4) karmic; urgency=low -- cgit v1.2.3 From c2e4aa4e87800be6c73c3bd3671351959fd7854f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 21:51:44 -0600 Subject: Changing the prop handler to be a pointer. --- libdbusmenu-glib/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 59494a3..8aee45e 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -499,8 +499,8 @@ build_proxies (DbusmenuClient * client) dbus_g_proxy_add_signal(priv->menuproxy, "LayoutUpdate", G_TYPE_INT, G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_connect_signal(priv->menuproxy, "LayoutUpdate", G_CALLBACK(layout_update), client, NULL); - dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__UINT_STRING_POINTER, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); - dbus_g_proxy_add_signal(priv->menuproxy, "ItemPropertyUpdated", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); + dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__UINT_STRING_POINTER, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_INVALID); + dbus_g_proxy_add_signal(priv->menuproxy, "ItemPropertyUpdated", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_INVALID); dbus_g_proxy_connect_signal(priv->menuproxy, "ItemPropertyUpdated", G_CALLBACK(id_prop_update), client, NULL); dbus_g_proxy_add_signal(priv->menuproxy, "ItemUpdated", G_TYPE_UINT, G_TYPE_INVALID); -- cgit v1.2.3 From 6fc4626f2267b38752bb0f8f09fdae21dd25e28a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 21 Dec 2009 21:57:26 -0600 Subject: releasing version 0.2.0~dev-0ubuntu1~ppa6~sigfix6 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 67b39ca..15bc87f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,8 @@ -libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix6) UNRELEASED; urgency=low +libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix6) karmic; urgency=low * Signal change - -- Ted Gould Mon, 21 Dec 2009 21:52:10 -0600 + -- Ted Gould Mon, 21 Dec 2009 21:57:24 -0600 libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix5) karmic; urgency=low -- cgit v1.2.3 From e8b9e2835c71ab60df2fd67b4d78b8d08224a975 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Dec 2009 08:01:25 -0600 Subject: Oops, that didn't work. --- libdbusmenu-glib/client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c index 8aee45e..59494a3 100644 --- a/libdbusmenu-glib/client.c +++ b/libdbusmenu-glib/client.c @@ -499,8 +499,8 @@ build_proxies (DbusmenuClient * client) dbus_g_proxy_add_signal(priv->menuproxy, "LayoutUpdate", G_TYPE_INT, G_TYPE_UINT, G_TYPE_INVALID); dbus_g_proxy_connect_signal(priv->menuproxy, "LayoutUpdate", G_CALLBACK(layout_update), client, NULL); - dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__UINT_STRING_POINTER, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_INVALID); - dbus_g_proxy_add_signal(priv->menuproxy, "ItemPropertyUpdated", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_INVALID); + dbus_g_object_register_marshaller(_dbusmenu_server_marshal_VOID__UINT_STRING_POINTER, G_TYPE_NONE, G_TYPE_UINT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); + dbus_g_proxy_add_signal(priv->menuproxy, "ItemPropertyUpdated", G_TYPE_UINT, G_TYPE_STRING, G_TYPE_VALUE, G_TYPE_INVALID); dbus_g_proxy_connect_signal(priv->menuproxy, "ItemPropertyUpdated", G_CALLBACK(id_prop_update), client, NULL); dbus_g_proxy_add_signal(priv->menuproxy, "ItemUpdated", G_TYPE_UINT, G_TYPE_INVALID); -- cgit v1.2.3 From fe1a34466dc13f83d43f2326e9f1790f83eb83fd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Dec 2009 08:10:10 -0600 Subject: releasing version 0.2.0~dev-0ubuntu1~ppa6~sigfix7 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 70df135..f7a8e50 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,8 @@ -libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix7) UNRELEASED; urgency=low +libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix7) karmic; urgency=low * Nope, bad idea. - -- Ted Gould Tue, 22 Dec 2009 08:01:39 -0600 + -- Ted Gould Tue, 22 Dec 2009 08:10:08 -0600 libdbusmenu (0.2.0~dev-0ubuntu1~ppa6~sigfix6) karmic; urgency=low -- cgit v1.2.3 From 54afa3eb635e04792bae66938ce838daffc821dd Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Dec 2009 14:40:23 -0600 Subject: releasing version 0.2.0~dev-0ubuntu1~ppa6 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 5c8483b..3be6753 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,8 +1,8 @@ -libdbusmenu (0.2.0~dev-0ubuntu1~ppa6) UNRELEASED; urgency=low +libdbusmenu (0.2.0~dev-0ubuntu1~ppa6) karmic; urgency=low * Fixing the handling of typed properties, especially bools. - -- Ted Gould Tue, 22 Dec 2009 14:38:00 -0600 + -- Ted Gould Tue, 22 Dec 2009 14:40:21 -0600 libdbusmenu (0.2.0~dev-0ubuntu1~ppa5) karmic; urgency=low -- cgit v1.2.3 From 0c85926daf6361821a4a6023e8756d1634fbfd85 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Dec 2009 20:51:37 -0600 Subject: Removing the bustle captures as we're not using them and they seem to be breaking on Hudson. --- tests/Makefile.am | 19 +++++++------------ tests/test-glib-layout-client.c | 2 +- tests/test-glib-objects.c | 3 ++- tests/test-glib-properties-client.c | 2 +- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index fa18b9d..aaa958a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -44,7 +44,7 @@ glib_server_nomenu_LDADD = \ test-glib-layout: test-glib-layout-client test-glib-layout-server Makefile.am @echo "#!/bin/bash" > $@ - @echo $(DBUS_RUNNER) -b $@.bustle --task ./test-glib-layout-client --task-name Client --task ./test-glib-layout-server --task-name Server --ignore-return >> $@ + @echo $(DBUS_RUNNER) --task ./test-glib-layout-client --task-name Client --task ./test-glib-layout-server --task-name Server --ignore-return >> $@ @chmod +x $@ test_glib_layout_server_SOURCES = \ @@ -80,7 +80,7 @@ OBJECT_XML_REPORT = test-glib-objects.xml test-glib-objects-test: test-glib-objects Makefile.am @echo "#!/bin/bash" > $@ - @echo $(DBUS_RUNNER) -b $@.bustle --task gtester --parameter -k --parameter -o --parameter $(OBJECT_XML_REPORT) --parameter ./test-glib-objects >> $@ + @echo $(DBUS_RUNNER) --task gtester --parameter --verbose --parameter -k --parameter -o --parameter $(OBJECT_XML_REPORT) --parameter ./test-glib-objects >> $@ @chmod +x $@ test_glib_objects_SOURCES = \ @@ -100,7 +100,7 @@ test_glib_objects_LDADD = \ test-glib-properties: test-glib-properties-client test-glib-properties-server Makefile.am @echo "#!/bin/bash" > $@ - @echo $(DBUS_RUNNER) -b $@.bustle --task ./test-glib-properties-client --task-name Client --task ./test-glib-properties-server --task-name Server --ignore-return >> $@ + @echo $(DBUS_RUNNER) --task ./test-glib-properties-client --task-name Client --task ./test-glib-properties-server --task-name Server --ignore-return >> $@ @chmod +x $@ test_glib_properties_server_SOURCES = \ @@ -149,7 +149,7 @@ test_glib_simple_items_LDADD = \ test-gtk-label: test-gtk-label-client test-gtk-label-server test-gtk-label.json Makefile.am @echo "#!/bin/bash" > $@ @echo $(XVFB_RUN) >> $@ - @echo $(DBUS_RUNNER) -b $@.bustle --task ./test-gtk-label-client --task-name Client --task ./test-gtk-label-server --parameter $(srcdir)/test-gtk-label.json --task-name Server --ignore-return >> $@ + @echo $(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 >> $@ @chmod +x $@ test_gtk_label_server_SOURCES = \ @@ -189,7 +189,7 @@ test_gtk_label_client_LDADD = \ test-gtk-reorder: test-gtk-label-client test-gtk-reorder-server Makefile.am @echo "#!/bin/bash" > $@ @echo $(XVFB_RUN) >> $@ - @echo $(DBUS_RUNNER) -b $@.bustle --task ./test-gtk-label-client --task-name Client --task ./test-gtk-reorder-server --parameter $(srcdir)/test-gtk-label.json --task-name Server --ignore-return >> $@ + @echo $(DBUS_RUNNER) --task ./test-gtk-label-client --task-name Client --task ./test-gtk-reorder-server --parameter $(srcdir)/test-gtk-label.json --task-name Server --ignore-return >> $@ @chmod +x $@ test_gtk_reorder_server_SOURCES = \ @@ -263,10 +263,5 @@ distclean-local: DISTCLEANFILES = \ $(TESTS) \ - $(OBJECT_XML_FILE) \ - test-glib-objects-test.bustle \ - test-glib-layout.bustle \ - test-glib-properties.bustle \ - test-glib-simple-items.bustle \ - test-gtk-label.bustle \ - test-gtk-reorder.bustle + $(OBJECT_XML_FILE) + diff --git a/tests/test-glib-layout-client.c b/tests/test-glib-layout-client.c index 6a79321..a7dd683 100644 --- a/tests/test-glib-layout-client.c +++ b/tests/test-glib-layout-client.c @@ -111,7 +111,7 @@ main (int argc, char ** argv) g_usleep(500000); - DbusmenuClient * client = dbusmenu_client_new(":1.1", "/org/test"); + DbusmenuClient * client = dbusmenu_client_new(":1.0", "/org/test"); g_signal_connect(G_OBJECT(client), DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED, G_CALLBACK(layout_updated), NULL); g_timeout_add_seconds(10, timer_func, client); diff --git a/tests/test-glib-objects.c b/tests/test-glib-objects.c index 7b22b7a..f3fbcc8 100644 --- a/tests/test-glib-objects.c +++ b/tests/test-glib-objects.c @@ -155,9 +155,10 @@ test_object_menuitem_props_swap (void) static void test_object_menuitem_props_signals_helper (DbusmenuMenuitem * mi, gchar * property, GValue * value, GValue ** out) { - /* g_debug("Signal handler got: %s", property); */ if (!g_strcmp0(property, "swapper")) { *out = value; + } else { + g_warning("Signal handler got: %s", property); } return; } diff --git a/tests/test-glib-properties-client.c b/tests/test-glib-properties-client.c index 9e257ea..39815aa 100644 --- a/tests/test-glib-properties-client.c +++ b/tests/test-glib-properties-client.c @@ -155,7 +155,7 @@ main (int argc, char ** argv) /* Make sure the server starts up and all that */ g_usleep(500000); - DbusmenuClient * client = dbusmenu_client_new(":1.1", "/org/test"); + DbusmenuClient * client = dbusmenu_client_new(":1.0", "/org/test"); g_signal_connect(G_OBJECT(client), DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED, G_CALLBACK(layout_updated), NULL); death_timer = g_timeout_add_seconds(10, timer_func, client); -- cgit v1.2.3 From 082554bfbf246c4fb4609ecae63d3bf01c85dda9 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 22 Dec 2009 20:57:36 -0600 Subject: Typo on variable name. Oh, I hate dynamically linked languages. --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index aaa958a..5297dbd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -263,5 +263,5 @@ distclean-local: DISTCLEANFILES = \ $(TESTS) \ - $(OBJECT_XML_FILE) + $(OBJECT_XML_REPORT) -- cgit v1.2.3 From 313ad876a25afef5766d9a9c560891e8bc6fa79b Mon Sep 17 00:00:00 2001 From: Aurelien Gateau Date: Thu, 24 Dec 2009 11:31:16 +0100 Subject: Implememented GetChildren --- libdbusmenu-glib/dbus-menu.xml | 6 ++++ libdbusmenu-glib/server.c | 63 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/libdbusmenu-glib/dbus-menu.xml b/libdbusmenu-glib/dbus-menu.xml index e2d872b..d2df400 100644 --- a/libdbusmenu-glib/dbus-menu.xml +++ b/libdbusmenu-glib/dbus-menu.xml @@ -88,6 +88,12 @@ An item is represented as a struct following this format: + + + + + +