diff options
author | Nick Dedekind <nicholas.dedekind@gmail.com> | 2013-07-30 20:49:44 +0100 |
---|---|---|
committer | Nick Dedekind <nicholas.dedekind@gmail.com> | 2013-07-30 20:49:44 +0100 |
commit | 37e62467aaa50babb48a45dcba8ab3ce5f5a7ec8 (patch) | |
tree | 8c280e13bf8e256ece6556a572cc964eba728750 /libqmenumodel/src/unitymenumodel.cpp | |
parent | 56374f1cfdbe68658a139cfad9dac8936f6ae60e (diff) | |
download | qmenumodel-37e62467aaa50babb48a45dcba8ab3ce5f5a7ec8.tar.gz qmenumodel-37e62467aaa50babb48a45dcba8ab3ce5f5a7ec8.tar.bz2 qmenumodel-37e62467aaa50babb48a45dcba8ab3ce5f5a7ec8.zip |
Added menu action updateState
Diffstat (limited to 'libqmenumodel/src/unitymenumodel.cpp')
-rw-r--r-- | libqmenumodel/src/unitymenumodel.cpp | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp index 7c5d597..9cad955 100644 --- a/libqmenumodel/src/unitymenumodel.cpp +++ b/libqmenumodel/src/unitymenumodel.cpp @@ -87,22 +87,44 @@ public: } virtual QString name() const { - GtkMenuTrackerItem* item = (GtkMenuTrackerItem *) g_sequence_get (g_sequence_get_iter_at_pos (d->items, index())); - if (!item) { - return ""; - } + GtkMenuTrackerItem* item; + + item = (GtkMenuTrackerItem *) g_sequence_get (g_sequence_get_iter_at_pos (d->items, index())); + if (!item) return QString(); + return gtk_menu_tracker_item_get_action_name(item); } virtual QVariant state() const { - GtkMenuTrackerItem* item = (GtkMenuTrackerItem *) g_sequence_get (g_sequence_get_iter_at_pos (d->items, index())); - if (!item) { - return QVariant(); - } + GtkMenuTrackerItem* item; + + item = (GtkMenuTrackerItem *) g_sequence_get (g_sequence_get_iter_at_pos (d->items, index())); + if (!item) return QVariant(); + return d->itemState(item); } - virtual void updateState(const QVariant& param = QVariant()) { } + virtual void activate() + { + GtkMenuTrackerItem* item; + + item = (GtkMenuTrackerItem *) g_sequence_get (g_sequence_get_iter_at_pos (d->items, index())); + if (!item) return; + + gtk_menu_tracker_item_activated (item); + } + + virtual void updateState(const QVariant& vvalue) + { + GtkMenuTrackerItem* item; + + item = (GtkMenuTrackerItem *) g_sequence_get (g_sequence_get_iter_at_pos (d->items, index())); + if (!item) return; + + GVariant* data = Converter::toGVariant(vvalue); + gtk_menu_tracker_item_update_state (item, data); + g_variant_unref(data); + } private: UnityMenuModelPrivate* d; @@ -512,14 +534,6 @@ QObject * UnityMenuModel::submenu(int position, QQmlComponent* actionStateParser return model; } -void UnityMenuModel::activate(int index) -{ - GtkMenuTrackerItem *item; - - item = (GtkMenuTrackerItem *) g_sequence_get (g_sequence_get_iter_at_pos (priv->items, index)); - gtk_menu_tracker_item_activated (item); -} - static void freeExtendedAttrs(gpointer data) { QVariantMap *extendedAttrs = (QVariantMap *) data; |