aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2011-03-10 11:03:04 -0600
committerTed Gould <ted@gould.cx>2011-03-10 11:03:04 -0600
commitcec350b1d24eeeb308fd02846bf637d4ec92fbb5 (patch)
tree1feb2b5bf966ab936d3bfa0c8598ce50e3651612 /libdbusmenu-glib
parenta66d4b41bfd368a4ac3c25be748cf64203147007 (diff)
parent5df1c8111987669e7f450141b50f056dc30cb4f9 (diff)
downloadlibdbusmenu-cec350b1d24eeeb308fd02846bf637d4ec92fbb5.tar.gz
libdbusmenu-cec350b1d24eeeb308fd02846bf637d4ec92fbb5.tar.bz2
libdbusmenu-cec350b1d24eeeb308fd02846bf637d4ec92fbb5.zip
Import upstream version 0.3.101
Diffstat (limited to 'libdbusmenu-glib')
-rw-r--r--libdbusmenu-glib/Makefile.in7
-rw-r--r--libdbusmenu-glib/client.c41
-rw-r--r--libdbusmenu-glib/enum-types.c.in2
-rw-r--r--libdbusmenu-glib/enum-types.h.in5
-rw-r--r--libdbusmenu-glib/menuitem.c20
-rw-r--r--libdbusmenu-glib/server.c6
6 files changed, 59 insertions, 22 deletions
diff --git a/libdbusmenu-glib/Makefile.in b/libdbusmenu-glib/Makefile.in
index e2b9157..5c19fc4 100644
--- a/libdbusmenu-glib/Makefile.in
+++ b/libdbusmenu-glib/Makefile.in
@@ -61,12 +61,7 @@ DIST_COMMON = $(libdbusmenu_glibinclude_HEADERS) $(srcdir)/Makefile.am \
@HAVE_INTROSPECTION_TRUE@ $(vapi_DATA)
subdir = libdbusmenu-glib
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/m4/gnome-doc-utils.m4 \
- $(top_srcdir)/m4/gtk-doc.m4 $(top_srcdir)/m4/intltool.m4 \
- $(top_srcdir)/m4/introspection.m4 $(top_srcdir)/m4/libtool.m4 \
- $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
- $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
- $(top_srcdir)/configure.ac
+am__aclocal_m4_deps = $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c
index c95b161..16e832d 100644
--- a/libdbusmenu-glib/client.c
+++ b/libdbusmenu-glib/client.c
@@ -1056,10 +1056,39 @@ menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data)
}
priv->text_direction = dbusmenu_text_direction_get_value_from_nick(g_variant_get_string(str, NULL));
+ g_object_notify(G_OBJECT(user_data), DBUSMENU_CLIENT_PROP_TEXT_DIRECTION);
g_variant_unref(textdir);
}
+ /* Check the status if available */
+ GVariant * status = g_dbus_proxy_get_cached_property(priv->menuproxy, "Status");
+ if (textdir != NULL) {
+ GVariant * str = status;
+ if (g_variant_is_of_type(str, G_VARIANT_TYPE_VARIANT)) {
+ str = g_variant_get_variant(str);
+ }
+
+ priv->status = dbusmenu_status_get_value_from_nick(g_variant_get_string(str, NULL));
+ g_object_notify(G_OBJECT(user_data), DBUSMENU_CLIENT_PROP_STATUS);
+
+ g_variant_unref(status);
+ }
+
+ /* Get the icon theme directories if available */
+ GVariant * icon_dirs = g_dbus_proxy_get_cached_property(priv->menuproxy, "IconThemePath");
+ if (icon_dirs != NULL) {
+ if (priv->icon_dirs != NULL) {
+ g_strfreev(priv->icon_dirs);
+ priv->icon_dirs = NULL;
+ }
+
+ priv->icon_dirs = g_variant_dup_strv(icon_dirs, NULL);
+ g_signal_emit(G_OBJECT(client), signals[ICON_THEME_DIRS], 0, priv->icon_dirs, TRUE);
+
+ g_variant_unref(icon_dirs);
+ }
+
/* If we get here, we don't need the DBus proxy */
if (priv->dbusproxy != 0) {
g_bus_unwatch_name(priv->dbusproxy);
@@ -1213,7 +1242,9 @@ menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVarian
while (g_variant_iter_next(&properties, "s", &property)) {
/* g_debug("Removing property '%s' on %d", property, id); */
dbusmenu_menuitem_property_remove(menuitem, property);
+ g_free(property);
}
+ g_variant_unref(ritem);
}
GVariantIter items;
@@ -1304,12 +1335,11 @@ menuitem_get_properties_replace_cb (GVariant * properties, GError * error, gpoin
have_error = TRUE;
}
- GList * current_props = NULL;
+ GList * current_props = dbusmenu_menuitem_properties_list(DBUSMENU_MENUITEM(data));
+ GList * tmp = NULL;
- for (current_props = dbusmenu_menuitem_properties_list(DBUSMENU_MENUITEM(data));
- current_props != NULL && have_error == FALSE;
- current_props = g_list_next(current_props)) {
- dbusmenu_menuitem_property_remove(DBUSMENU_MENUITEM(data), (const gchar *)current_props->data);
+ for (tmp = current_props; tmp != NULL && have_error == FALSE; tmp = g_list_next(tmp)) {
+ dbusmenu_menuitem_property_remove(DBUSMENU_MENUITEM(data), (const gchar *)tmp->data);
}
g_list_free(current_props);
@@ -1823,6 +1853,7 @@ static void
update_layout (DbusmenuClient * client)
{
DbusmenuClientPrivate * priv = DBUSMENU_CLIENT_GET_PRIVATE(client);
+ g_return_if_fail(priv->layout_props != NULL);
if (priv->menuproxy == NULL) {
return;
diff --git a/libdbusmenu-glib/enum-types.c.in b/libdbusmenu-glib/enum-types.c.in
index 9395f5f..40f1759 100644
--- a/libdbusmenu-glib/enum-types.c.in
+++ b/libdbusmenu-glib/enum-types.c.in
@@ -31,7 +31,7 @@ License version 3 and version 2.1 along with this program. If not, see
/*** END file-header ***/
/*** BEGIN file-production ***/
-#include "@filename@"
+#include "@basename@"
/*** END file-production ***/
/*** BEGIN value-header ***/
diff --git a/libdbusmenu-glib/enum-types.h.in b/libdbusmenu-glib/enum-types.h.in
index 488b615..5758438 100644
--- a/libdbusmenu-glib/enum-types.h.in
+++ b/libdbusmenu-glib/enum-types.h.in
@@ -44,13 +44,16 @@ G_END_DECLS
/*** BEGIN file-production ***/
/* Enumerations from file: "@filename@" */
-#include "@filename@"
+#include "@basename@"
+
/*** END file-production ***/
/*** BEGIN value-header ***/
+
GType @enum_name@_get_type (void) G_GNUC_CONST;
const gchar * @enum_name@_get_nick (@EnumName@ value) G_GNUC_CONST;
@EnumName@ @enum_name@_get_value_from_nick (const gchar * nick) G_GNUC_CONST;
+
/**
DBUSMENU_TYPE_@ENUMSHORT@:
diff --git a/libdbusmenu-glib/menuitem.c b/libdbusmenu-glib/menuitem.c
index f7867e4..2e5a345 100644
--- a/libdbusmenu-glib/menuitem.c
+++ b/libdbusmenu-glib/menuitem.c
@@ -1180,17 +1180,23 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro
}
}
-
gboolean replaced = FALSE;
gboolean remove = FALSE;
- gpointer currentval = g_hash_table_lookup(priv->properties, property);
+ gchar * hash_key = NULL;
+ GVariant * hash_variant = NULL;
+ gboolean inhash = g_hash_table_lookup_extended(priv->properties, property, (gpointer *)&hash_key, (gpointer *)&hash_variant);
+
+ if (inhash && hash_variant == NULL) {
+ g_warning("The property '%s' is in the hash with a NULL variant", property);
+ inhash = FALSE;
+ }
if (value != NULL) {
/* NOTE: We're only marking this as replaced if this is true
but we're actually replacing it no matter. This is so that
the variant passed in sticks around which the caller may
expect. They shouldn't, but it's low cost to remove bugs. */
- if (currentval == NULL || !g_variant_equal((GVariant*)currentval, value)) {
+ if (!inhash || !g_variant_equal(hash_variant, value)) {
replaced = TRUE;
}
@@ -1204,7 +1210,7 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro
bad value */
g_hash_table_insert(priv->properties, lprop, value);
} else {
- if (currentval != NULL) {
+ if (inhash) {
/* So the question you should be asking if you're paying attention
is "Why not just do the remove here?" It's a good question with
an interesting answer. Bascially it's the same reason as above,
@@ -1213,6 +1219,7 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro
it) after the signal emition */
remove = TRUE;
replaced = TRUE;
+ g_hash_table_steal(priv->properties, property);
}
}
@@ -1220,7 +1227,7 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro
becuse it has been unref'd when replaced in the hash
table. But the fact that there was a value is
the imporant part. */
- if (currentval == NULL || replaced) {
+ if (!inhash || replaced) {
GVariant * signalval = value;
if (signalval == NULL) {
@@ -1233,7 +1240,8 @@ dbusmenu_menuitem_property_set_variant (DbusmenuMenuitem * mi, const gchar * pro
}
if (remove) {
- g_hash_table_remove(priv->properties, property);
+ g_free(hash_key);
+ g_variant_unref(hash_variant);
}
return TRUE;
diff --git a/libdbusmenu-glib/server.c b/libdbusmenu-glib/server.c
index ca39ea3..a41e6ce 100644
--- a/libdbusmenu-glib/server.c
+++ b/libdbusmenu-glib/server.c
@@ -511,7 +511,7 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec)
GVariantBuilder params;
g_variant_builder_init(&params, G_VARIANT_TYPE_TUPLE);
g_variant_builder_add_value(&params, g_variant_new_string(DBUSMENU_INTERFACE));
- GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("TextDirection"), g_variant_new_string(dbusmenu_text_direction_get_nick(priv->text_direction)));
+ GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("TextDirection"), g_variant_new_variant(g_variant_new_string(dbusmenu_text_direction_get_nick(priv->text_direction))));
g_variant_builder_add_value(&params, g_variant_new_array(NULL, &dict, 1));
g_variant_builder_add_value(&params, g_variant_new_array(G_VARIANT_TYPE_STRING, NULL, 0));
GVariant * vparams = g_variant_builder_end(&params);
@@ -535,7 +535,7 @@ set_property (GObject * obj, guint id, const GValue * value, GParamSpec * pspec)
GVariantBuilder params;
g_variant_builder_init(&params, G_VARIANT_TYPE_TUPLE);
g_variant_builder_add_value(&params, g_variant_new_string(DBUSMENU_INTERFACE));
- GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("Status"), g_variant_new_string(dbusmenu_status_get_nick(instatus)));
+ GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("Status"), g_variant_new_variant(g_variant_new_string(dbusmenu_status_get_nick(instatus))));
g_variant_builder_add_value(&params, g_variant_new_array(NULL, &dict, 1));
g_variant_builder_add_value(&params, g_variant_new_array(G_VARIANT_TYPE_STRING, NULL, 0));
GVariant * vparams = g_variant_builder_end(&params);
@@ -1773,7 +1773,7 @@ dbusmenu_server_set_icon_paths (DbusmenuServer * server, GStrv icon_paths)
g_variant_builder_add_value(&params, g_variant_new_string(DBUSMENU_INTERFACE));
GVariant * items = NULL;
if (priv->icon_dirs != NULL) {
- GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("IconThemePath"), g_variant_new_strv((const gchar * const *)priv->icon_dirs, -1));
+ GVariant * dict = g_variant_new_dict_entry(g_variant_new_string("IconThemePath"), g_variant_new_variant(g_variant_new_strv((const gchar * const *)priv->icon_dirs, -1)));
items = g_variant_new_array(NULL, &dict, 1);
} else {
items = g_variant_new_array(G_VARIANT_TYPE("{sv}"), NULL, 0);