aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel/src/unitymenumodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libqmenumodel/src/unitymenumodel.cpp')
-rw-r--r--libqmenumodel/src/unitymenumodel.cpp33
1 files changed, 27 insertions, 6 deletions
diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp
index 8e0f0d1..8045d57 100644
--- a/libqmenumodel/src/unitymenumodel.cpp
+++ b/libqmenumodel/src/unitymenumodel.cpp
@@ -42,7 +42,9 @@ enum MenuRoles {
IconRole,
TypeRole,
ExtendedAttributesRole,
- ActionRole
+ ActionRole,
+ IsCheckRole,
+ IsRadioRole
};
class UnityMenuModelPrivate
@@ -106,14 +108,18 @@ public:
return d->itemState(item);
}
- virtual void activate()
+ virtual void activate(const QVariant &parameter)
{
GtkMenuTrackerItem* item;
+ gchar *action;
item = (GtkMenuTrackerItem *) g_sequence_get (g_sequence_get_iter_at_pos (d->items, index()));
if (!item) return;
- gtk_menu_tracker_item_activated (item);
+ gtk_menu_tracker_item_get_attribute (item, "action", "s", &action);
+ g_action_group_activate_action (G_ACTION_GROUP (d->muxer), action, Converter::toGVariant(parameter));
+
+ g_free (action);
}
virtual void changeState(const QVariant& vvalue)
@@ -278,7 +284,6 @@ void UnityMenuModelPrivate::menuItemChanged(GObject *object, GParamSpec *pspec,
model = (UnityMenuModel *) g_object_get_qdata (G_OBJECT (item), unity_menu_model_quark ());
position = g_sequence_iter_get_position (it);
- // FIXME
UnityMenuModelDataChangeEvent ummdce(position);
QCoreApplication::sendEvent(model, &ummdce);
}
@@ -416,10 +421,10 @@ QVariant UnityMenuModel::data(const QModelIndex &index, int role) const
return gtk_menu_tracker_item_get_label (item);
case SensitiveRole:
- return gtk_menu_tracker_item_get_sensitive (item);
+ return gtk_menu_tracker_item_get_sensitive (item) == TRUE ? true : false;
case IsSeparatorRole:
- return gtk_menu_tracker_item_get_is_separator (item);
+ return gtk_menu_tracker_item_get_is_separator (item) == TRUE ? true : false;
case IconRole: {
GIcon *icon = gtk_menu_tracker_item_get_icon (item);
@@ -451,6 +456,12 @@ QVariant UnityMenuModel::data(const QModelIndex &index, int role) const
case ActionRole:
return QVariant::fromValue(new UnityGtkMenuTrackerItemAction(index.row(), priv));
+ case IsCheckRole:
+ return gtk_menu_tracker_item_get_role (item) == GTK_MENU_TRACKER_ITEM_ROLE_CHECK;
+
+ case IsRadioRole:
+ return gtk_menu_tracker_item_get_role (item) == GTK_MENU_TRACKER_ITEM_ROLE_RADIO;
+
default:
return QVariant();
}
@@ -478,6 +489,8 @@ QHash<int, QByteArray> UnityMenuModel::roleNames() const
names[TypeRole] = "type";
names[ExtendedAttributesRole] = "ext";
names[ActionRole] = "action";
+ names[IsCheckRole] = "isCheck";
+ names[IsRadioRole] = "isRadio";
return names;
}
@@ -623,6 +636,14 @@ QVariant UnityMenuModel::get(int row, const QByteArray &role)
return this->data(this->index(row, 0), priv->roles[role]);
}
+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);
+}
+
bool UnityMenuModel::event(QEvent* e)
{
if (e->type() == UnityMenuModelClearEvent::eventType) {