aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel/src/gtk
diff options
context:
space:
mode:
authorLars Uebernickel <lars.uebernickel@canonical.com>2013-07-25 06:09:59 +0200
committerLars Uebernickel <lars.uebernickel@canonical.com>2013-07-25 06:09:59 +0200
commitca81974f1fe8454c725e80aa943705d40398a2ad (patch)
treef6549c3fdddef6ef2ae7bfd4aecc4106be389d4d /libqmenumodel/src/gtk
parent6aaafd55328c1860fd1b734fa29ff77673538a2b (diff)
downloadqmenumodel-ca81974f1fe8454c725e80aa943705d40398a2ad.tar.gz
qmenumodel-ca81974f1fe8454c725e80aa943705d40398a2ad.tar.bz2
qmenumodel-ca81974f1fe8454c725e80aa943705d40398a2ad.zip
unitymenumodel: expose type and extended attributes to qml
Diffstat (limited to 'libqmenumodel/src/gtk')
-rw-r--r--libqmenumodel/src/gtk/gtkmenutrackeritem.c41
-rw-r--r--libqmenumodel/src/gtk/gtkmenutrackeritem.h9
2 files changed, 50 insertions, 0 deletions
diff --git a/libqmenumodel/src/gtk/gtkmenutrackeritem.c b/libqmenumodel/src/gtk/gtkmenutrackeritem.c
index 2d712a1..356422d 100644
--- a/libqmenumodel/src/gtk/gtkmenutrackeritem.c
+++ b/libqmenumodel/src/gtk/gtkmenutrackeritem.c
@@ -786,3 +786,44 @@ gtk_menu_tracker_item_request_submenu_shown (GtkMenuTrackerItem *self,
else
gtk_menu_tracker_item_set_submenu_shown (self, shown);
}
+
+gboolean
+gtk_menu_tracker_item_get_attribute (GtkMenuTrackerItem *self,
+ const gchar *attribute,
+ const gchar *format,
+ ...)
+{
+ gboolean success = FALSE;
+ GVariant *value;
+
+ g_return_val_if_fail (GTK_IS_MENU_TRACKER_ITEM (self), FALSE);
+ g_return_val_if_fail (attribute != NULL, FALSE);
+ g_return_val_if_fail (format != NULL, FALSE);
+
+ value = g_menu_item_get_attribute_value (self->item, attribute, NULL);
+ if (value)
+ {
+ if (g_variant_check_format_string (value, format, TRUE))
+ {
+ va_list args;
+
+ va_start (args, format);
+ g_variant_get_va (value, format, NULL, &args);
+ va_end (args);
+
+ success = TRUE;
+ }
+
+ g_variant_unref (value);
+ }
+
+ return success;
+}
+
+GVariant *
+gtk_menu_tracker_item_get_attribute_value (GtkMenuTrackerItem *self,
+ const gchar *attribute,
+ const GVariantType *expected_type)
+{
+ return g_menu_item_get_attribute_value (self->item, attribute, expected_type);
+}
diff --git a/libqmenumodel/src/gtk/gtkmenutrackeritem.h b/libqmenumodel/src/gtk/gtkmenutrackeritem.h
index 9db30eb..7e98a55 100644
--- a/libqmenumodel/src/gtk/gtkmenutrackeritem.h
+++ b/libqmenumodel/src/gtk/gtkmenutrackeritem.h
@@ -81,4 +81,13 @@ void gtk_menu_tracker_item_request_submenu_shown (GtkMenu
gboolean gtk_menu_tracker_item_get_submenu_shown (GtkMenuTrackerItem *self);
+gboolean gtk_menu_tracker_item_get_attribute (GtkMenuTrackerItem *self,
+ const gchar *attribute,
+ const gchar *format,
+ ...);
+
+GVariant * gtk_menu_tracker_item_get_attribute_value (GtkMenuTrackerItem *self,
+ const gchar *attribute,
+ const GVariantType *expected_type);
+
#endif