aboutsummaryrefslogtreecommitdiff
path: root/libdbusmenu-glib/client.c
diff options
context:
space:
mode:
Diffstat (limited to 'libdbusmenu-glib/client.c')
-rw-r--r--libdbusmenu-glib/client.c57
1 files changed, 50 insertions, 7 deletions
diff --git a/libdbusmenu-glib/client.c b/libdbusmenu-glib/client.c
index f3e332c..83ca056 100644
--- a/libdbusmenu-glib/client.c
+++ b/libdbusmenu-glib/client.c
@@ -33,6 +33,7 @@ License version 3 and version 2.1 along with this program. If not, see
#include <gio/gio.h>
#include "client.h"
+#include "client-private.h"
#include "menuitem.h"
#include "menuitem-private.h"
#include "client-menuitem.h"
@@ -82,6 +83,7 @@ struct _DbusmenuClientPrivate
GCancellable * menuproxy_cancel;
GCancellable * layoutcall;
+ GVariant * layout_props;
gint current_revision;
gint my_revision;
@@ -333,6 +335,15 @@ dbusmenu_client_init (DbusmenuClient *self)
priv->layoutcall = NULL;
+ gchar * layout_props[5];
+ layout_props[0] = DBUSMENU_MENUITEM_PROP_TYPE;
+ layout_props[1] = DBUSMENU_MENUITEM_PROP_LABEL;
+ layout_props[2] = DBUSMENU_MENUITEM_PROP_VISIBLE;
+ layout_props[3] = DBUSMENU_MENUITEM_PROP_ENABLED;
+ layout_props[4] = NULL;
+ priv->layout_props = g_variant_new_strv((const gchar * const *)layout_props, 4);
+ g_variant_ref_sink(priv->layout_props);
+
priv->current_revision = 0;
priv->my_revision = 0;
@@ -400,6 +411,11 @@ dbusmenu_client_dispose (GObject *object)
priv->layoutcall = NULL;
}
+ if (priv->layout_props != NULL) {
+ g_variant_unref(priv->layout_props);
+ priv->layout_props = NULL;
+ }
+
/* Bring down the menu proxy, ensure we're not
looking for one at the same time. */
if (priv->menuproxy_cancel != NULL) {
@@ -1010,7 +1026,7 @@ menuproxy_build_cb (GObject * object, GAsyncResult * res, gpointer user_data)
}
/* Check the text direction if available */
- GVariant * textdir = g_dbus_proxy_get_cached_property(priv->menuproxy, "text-direction");
+ GVariant * textdir = g_dbus_proxy_get_cached_property(priv->menuproxy, "TextDirection");
if (textdir != NULL) {
GVariant * str = textdir;
if (g_variant_is_of_type(str, G_VARIANT_TYPE_VARIANT)) {
@@ -1053,10 +1069,10 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva
gchar * invalid;
gint i = 0;
for (invalid = invalidated[i]; invalid != NULL; invalid = invalidated[++i]) {
- if (g_strcmp0(invalid, "text-direction") == 0) {
+ if (g_strcmp0(invalid, "TextDirection") == 0) {
priv->text_direction = DBUSMENU_TEXT_DIRECTION_NONE;
}
- if (g_strcmp0(invalid, "status") == 0) {
+ if (g_strcmp0(invalid, "Status") == 0) {
priv->status = DBUSMENU_STATUS_NORMAL;
}
}
@@ -1066,7 +1082,7 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva
gchar * key; GVariant * value;
g_variant_iter_init(&iters, properties);
while (g_variant_iter_next(&iters, "{sv}", &key, &value)) {
- if (g_strcmp0(key, "text-direction") == 0) {
+ if (g_strcmp0(key, "TextDirection") == 0) {
GVariant * str = value;
if (g_variant_is_of_type(str, G_VARIANT_TYPE_VARIANT)) {
str = g_variant_get_variant(str);
@@ -1074,7 +1090,7 @@ menuproxy_prop_changed_cb (GDBusProxy * proxy, GVariant * properties, GStrv inva
priv->text_direction = dbusmenu_text_direction_get_value_from_nick(g_variant_get_string(str, NULL));
}
- if (g_strcmp0(key, "status") == 0) {
+ if (g_strcmp0(key, "Status") == 0) {
GVariant * str = value;
if (g_variant_is_of_type(str, G_VARIANT_TYPE_VARIANT)) {
str = g_variant_get_variant(str);
@@ -1152,7 +1168,7 @@ menuproxy_signal_cb (GDBusProxy * proxy, gchar * sender, gchar * signal, GVarian
gchar * property;
while (g_variant_iter_next(&properties, "s", &property)) {
- g_debug("Removing property '%s' on %d", property, id);
+ /* g_debug("Removing property '%s' on %d", property, id); */
dbusmenu_menuitem_property_remove(menuitem, property);
}
}
@@ -1570,6 +1586,33 @@ parse_layout_xml(DbusmenuClient * client, GVariant * layout, DbusmenuMenuitem *
parse_layout_update(childmi, client);
}
+ /* Apply known properties sent in the structure to the
+ menu item. Sometimes they may just be copies */
+ if (childmi != NULL) {
+ GVariantIter iter;
+ gchar * prop;
+ GVariant * value;
+
+ /* Set the type first as it can manage the behavior of
+ all other properties. */
+ g_variant_iter_init(&iter, g_variant_get_child_value(child, 1));
+ while (g_variant_iter_next(&iter, "{sv}", &prop, &value)) {
+ if (g_strcmp0(prop, DBUSMENU_MENUITEM_PROP_TYPE) == 0) {
+ dbusmenu_menuitem_property_set_variant(childmi, prop, value);
+ }
+ g_free(prop);
+ g_variant_unref(value);
+ }
+
+ /* Now go through and do all the properties. */
+ g_variant_iter_init(&iter, g_variant_get_child_value(child, 1));
+ while (g_variant_iter_next(&iter, "{sv}", &prop, &value)) {
+ dbusmenu_menuitem_property_set_variant(childmi, prop, value);
+ g_free(prop);
+ g_variant_unref(value);
+ }
+ }
+
position++;
}
@@ -1759,7 +1802,7 @@ update_layout (DbusmenuClient * client)
g_variant_builder_add_value(&tupleb, g_variant_new_int32(0)); // root
g_variant_builder_add_value(&tupleb, g_variant_new_int32(-1)); // recurse
- g_variant_builder_add_value(&tupleb, g_variant_new_array(G_VARIANT_TYPE_STRING, NULL, 0)); // props
+ g_variant_builder_add_value(&tupleb, priv->layout_props); // props
GVariant * args = g_variant_builder_end(&tupleb);
// g_debug("Args (type: %s): %s", g_variant_get_type_string(args), g_variant_print(args, TRUE));