From 67394e49c25cb273b53cd2034bb2d31b14a7402a Mon Sep 17 00:00:00 2001 From: Nick Dedekind Date: Thu, 15 Aug 2013 12:48:55 +0100 Subject: Added toGVariantWithSchema for UnityMenuModel::changeState --- libqmenumodel/src/unitymenumodel.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'libqmenumodel/src/unitymenumodel.cpp') diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp index e5407ab..50eff1c 100644 --- a/libqmenumodel/src/unitymenumodel.cpp +++ b/libqmenumodel/src/unitymenumodel.cpp @@ -607,13 +607,25 @@ void UnityMenuModel::activate(int index, const QVariant& parameter) void UnityMenuModel::changeState(int index, const QVariant& parameter) { GtkMenuTrackerItem* item; + GVariant* data; + GVariant* current_state; item = (GtkMenuTrackerItem *) g_sequence_get (g_sequence_get_iter_at_pos (priv->items, index)); if (!item) return; - GVariant* data = Converter::toGVariant(parameter); + current_state = gtk_menu_tracker_item_get_action_state (item); + if (current_state) { + // Attempt to convert the parameter to the expected type + data = Converter::toGVariantWithSchema(parameter, g_variant_get_type_string(current_state)); + g_variant_unref (current_state); + } else { + data = Converter::toGVariant(parameter); + } + gtk_menu_tracker_item_change_state (item, data); - g_variant_unref(data); + if (data) { + g_variant_unref(data); + } } -- cgit v1.2.3 From d83555e4e6b771e70237924bea8714df7868808a Mon Sep 17 00:00:00 2001 From: Nick Dedekind Date: Tue, 20 Aug 2013 19:30:09 +0100 Subject: new unitymenumodel attribute types --- libqmenumodel/src/unitymenumodel.cpp | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'libqmenumodel/src/unitymenumodel.cpp') diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp index e5407ab..031de9a 100644 --- a/libqmenumodel/src/unitymenumodel.cpp +++ b/libqmenumodel/src/unitymenumodel.cpp @@ -491,20 +491,34 @@ static QVariant attributeToQVariant(GVariant *value, const QString &type) QVariant result; if (type == "int") { - if (g_variant_is_of_type (value, G_VARIANT_TYPE_INT32)) + if (g_variant_is_of_type (value, G_VARIANT_TYPE_INT32)) { result = QVariant(g_variant_get_int32(value)); + } + } + else if (type == "int64") { + if (g_variant_is_of_type (value, G_VARIANT_TYPE_INT64)) { + result = QVariant((qlonglong)g_variant_get_int64(value)); + } } - if (type == "bool") { - if (g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)) + else if (type == "bool") { + if (g_variant_is_of_type (value, G_VARIANT_TYPE_BOOLEAN)) { result = QVariant(g_variant_get_boolean(value)); + } } else if (type == "string") { - if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) + if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING)) { result = QVariant(g_variant_get_string(value, NULL)); + } } - if (type == "double") { - if (g_variant_is_of_type (value, G_VARIANT_TYPE_DOUBLE)) + else if (type == "double") { + if (g_variant_is_of_type (value, G_VARIANT_TYPE_DOUBLE)) { result = QVariant(g_variant_get_double(value)); + } + } + else if (type == "variant") { + if (g_variant_is_of_type (value, G_VARIANT_TYPE_VARIANT)) { + result = Converter::toQVariant(value); + } } else if (type == "icon") { GIcon *icon = g_icon_deserialize (value); -- cgit v1.2.3