aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-01-21 11:56:15 -0600
committerTed Gould <ted@gould.cx>2011-01-21 11:56:15 -0600
commit7cddccbdd648ea01f9184bc975bb762b7a032c45 (patch)
tree38d96fd5174b1573ef3c70805b7663b8f1157dcb /libdbusmenu-glib
parentaea42d14c645517cc32611ab0e8580223948aad3 (diff)
parent4bb9903a560f83b1b8a19c7801efab80d677ab46 (diff)
downloadlibdbusmenu-7cddccbdd648ea01f9184bc975bb762b7a032c45.tar.gz
libdbusmenu-7cddccbdd648ea01f9184bc975bb762b7a032c45.tar.bz2
libdbusmenu-7cddccbdd648ea01f9184bc975bb762b7a032c45.zip
Updating to trunk
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r--libdbusmenu-glib/Makefile.am5
-rw-r--r--libdbusmenu-glib/client.c15
-rw-r--r--libdbusmenu-glib/dbusmenu-glib.h37
-rw-r--r--libdbusmenu-glib/server.c61
4 files changed, 103 insertions, 15 deletions
diff --git a/libdbusmenu-glib/Makefile.am b/libdbusmenu-glib/Makefile.am
index f502fb3..a139f7c 100644
--- a/libdbusmenu-glib/Makefile.am
+++ b/libdbusmenu-glib/Makefile.am
@@ -15,6 +15,7 @@ lib_LTLIBRARIES = \
libdbusmenu_glibincludedir=$(includedir)/libdbusmenu-0.4/libdbusmenu-glib/
libdbusmenu_glibinclude_HEADERS = \
+ dbusmenu-glib.h \
menuitem.h \
menuitem-proxy.h \
server.h \
@@ -119,12 +120,14 @@ INTROSPECTION_GIRS =
if INTROSPECTION_TEN
INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) \
+ --warn-all \
--add-include-path=$(srcdir) \
$(addprefix --c-include=libdbusmenu-glib/, $(introspection_sources)) \
--symbol-prefix=dbusmenu \
--identifier-prefix=Dbusmenu
else
INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) \
+ --warn-all \
--add-include-path=$(srcdir) \
$(addprefix --c-include=libdbusmenu-glib/, $(introspection_sources))
endif
@@ -138,7 +141,7 @@ introspection_sources = $(libdbusmenu_glibinclude_HEADERS)
Dbusmenu_Glib-0.4.gir: libdbusmenu-glib.la
Dbusmenu_Glib_0_4_gir_INCLUDES = \
GObject-2.0
-Dbusmenu_Glib_0_4_gir_CFLAGS = $(DBUSMENUGLIB_CFLAGS)
+Dbusmenu_Glib_0_4_gir_CFLAGS = $(DBUSMENUGLIB_CFLAGS) -I$(top_srcdir)
Dbusmenu_Glib_0_4_gir_LIBS = libdbusmenu-glib.la
Dbusmenu_Glib_0_4_gir_FILES = $(addprefix $(srcdir)/, $(introspection_sources))
Dbusmenu_Glib_0_4_gir_NAMESPACE = Dbusmenu
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c
index f84d6e0..ea0f0f7 100644
--- a/libdbusmenu-glib/client.c
+++ b/libdbusmenu-glib/client.c
@@ -1548,6 +1548,14 @@ parse_layout (DbusmenuClient * client, const gchar * layout)
static void
update_layout_cb (GObject * proxy, GAsyncResult * res, gpointer data)
{
+ DbusmenuClient * client = DBUSMENU_CLIENT(data);
+ DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client);
+
+ if (priv->layoutcall != NULL) {
+ g_object_unref(priv->layoutcall);
+ priv->layoutcall = NULL;
+ }
+
GError * error = NULL;
GVariant * params = NULL;
@@ -1564,9 +1572,6 @@ update_layout_cb (GObject * proxy, GAsyncResult * res, gpointer data)
g_variant_get(params, "(us)", &rev, &xml);
g_variant_unref(params);
- DbusmenuClient * client = DBUSMENU_CLIENT(data);
- DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client);
-
guint parseable = parse_layout(client, xml);
g_free(xml);
@@ -1577,10 +1582,6 @@ update_layout_cb (GObject * proxy, GAsyncResult * res, gpointer data)
priv->my_revision = rev;
/* g_debug("Root is now: 0x%X", (unsigned int)priv->root); */
- if (priv->layoutcall != NULL) {
- g_object_unref(priv->layoutcall);
- priv->layoutcall = NULL;
- }
#ifdef MASSIVEDEBUGGING
g_debug("Client signaling layout has changed.");
#endif
diff --git a/libdbusmenu-glib/dbusmenu-glib.h b/libdbusmenu-glib/dbusmenu-glib.h
new file mode 100644
index 0000000..9c377ca
--- /dev/null
+++ b/libdbusmenu-glib/dbusmenu-glib.h
@@ -0,0 +1,37 @@
+/*
+A library to communicate a menu object set accross DBus and
+track updates and maintain consistency.
+
+Copyright 2011 Canonical Ltd.
+
+Authors:
+ Ted Gould <ted@canonical.com>
+
+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
+<http://www.gnu.org/licenses/>
+*/
+
+#ifndef __DBUSMENU_GLIB_H__
+#define __DBUSMENU_GLIB_H__
+
+#include <libdbusmenu-glib/client.h>
+#include <libdbusmenu-glib/menuitem.h>
+#include <libdbusmenu-glib/menuitem-proxy.h>
+#include <libdbusmenu-glib/server.h>
+
+#endif /* __DBUSMENU_GLIB_H__ */
diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c
index 100eb14..095f333 100644
--- a/libdbusmenu-glib/server.c
+++ b/libdbusmenu-glib/server.c
@@ -506,6 +506,19 @@ register_object (DbusmenuServer * server)
if (error != NULL) {
g_warning("Unable to register object on bus: %s", error->message);
g_error_free(error);
+ return;
+ }
+
+ /* If we've got it registered let's tell everyone about it */
+ g_signal_emit(G_OBJECT(server), signals[LAYOUT_UPDATED], 0, priv->layout_revision, 0, TRUE);
+ if (priv->dbusobject != NULL && priv->bus != NULL) {
+ g_dbus_connection_emit_signal(priv->bus,
+ NULL,
+ priv->dbusobject,
+ DBUSMENU_INTERFACE,
+ "LayoutUpdated",
+ g_variant_new("(ui)", priv->layout_revision, 0),
+ NULL);
}
return;
@@ -894,20 +907,31 @@ bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMetho
g_variant_iter_init(&ids, g_variant_get_child_value(params, 0));
GVariantBuilder builder;
- g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
+ gboolean builder_init = FALSE;
gint id;
while (g_variant_iter_next(&ids, "i", &id)) {
DbusmenuMenuitem * mi = dbusmenu_menuitem_find_id(priv->root, id);
if (mi == NULL) continue;
+ if (!builder_init) {
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
+ builder_init = TRUE;
+ }
+
GVariantBuilder wbuilder;
g_variant_builder_init(&wbuilder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_add(&wbuilder, "i", id);
GVariant * props = dbusmenu_menuitem_properties_variant(mi);
if (props == NULL) {
- props = g_variant_parse(g_variant_type_new("a{sv}"), "{}", NULL, NULL, NULL);
+ GError * error = NULL;
+ props = g_variant_parse(g_variant_type_new("a{sv}"), "{}", NULL, NULL, &error);
+ if (error != NULL) {
+ g_warning("Unable to parse '{}' as a 'a{sv}': %s", error->message);
+ g_error_free(error);
+ props = NULL;
+ }
}
g_variant_builder_add_value(&wbuilder, props);
@@ -916,11 +940,28 @@ bus_get_group_properties (DbusmenuServer * server, GVariant * params, GDBusMetho
g_variant_builder_add_value(&builder, mi_data);
}
- GVariant * ret = g_variant_builder_end(&builder);
+ GVariant * ret = NULL;
+
+ if (builder_init) {
+ ret = g_variant_builder_end(&builder);
+ } else {
+ GError * error = NULL;
+ ret = g_variant_parse(g_variant_type_new("a(ia(sv))"), "[]", NULL, NULL, NULL);
+ if (error != NULL) {
+ g_warning("Unable to parse '[]' as a 'a(ia(sv))': %s", error->message);
+ g_error_free(error);
+ ret = NULL;
+ }
+ }
- g_variant_builder_init(&builder, G_VARIANT_TYPE_TUPLE);
- g_variant_builder_add_value(&builder, ret);
- GVariant * final = g_variant_builder_end(&builder);
+ GVariant * final = NULL;
+ if (ret != NULL) {
+ g_variant_builder_init(&builder, G_VARIANT_TYPE_TUPLE);
+ g_variant_builder_add_value(&builder, ret);
+ final = g_variant_builder_end(&builder);
+ } else {
+ g_warning("Error building property list, final variant is NULL");
+ }
g_dbus_method_invocation_return_value(invocation, final);
@@ -981,7 +1022,13 @@ bus_get_children (DbusmenuServer * server, GVariant * params, GDBusMethodInvocat
ret = g_variant_new("(a(ia{svg}))", g_variant_builder_end(&builder));
} else {
- ret = g_variant_parse(g_variant_type_new("(a(ia{sv}))"), "([(0, {})],)", NULL, NULL, NULL);
+ GError * error = NULL;
+ ret = g_variant_parse(g_variant_type_new("(a(ia{sv}))"), "([(0, {})],)", NULL, NULL, &error);
+ if (error != NULL) {
+ g_warning("Unable to parse '([(0, {})],)' as a '(a(ia{sv}))': %s", error->message);
+ g_error_free(error);
+ ret = NULL;
+ }
}
g_dbus_method_invocation_return_value(invocation, ret);