aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel
diff options
context:
space:
mode:
Diffstat (limited to 'libqmenumodel')
-rw-r--r--libqmenumodel/src/gtk/gtkmenutrackeritem.c6
-rw-r--r--libqmenumodel/src/gtk/gtkmenutrackeritem.h2
-rw-r--r--libqmenumodel/src/unitymenumodel.cpp28
-rw-r--r--libqmenumodel/src/unitymenumodel.h1
4 files changed, 37 insertions, 0 deletions
diff --git a/libqmenumodel/src/gtk/gtkmenutrackeritem.c b/libqmenumodel/src/gtk/gtkmenutrackeritem.c
index 3dc1d13..34e168a 100644
--- a/libqmenumodel/src/gtk/gtkmenutrackeritem.c
+++ b/libqmenumodel/src/gtk/gtkmenutrackeritem.c
@@ -649,6 +649,12 @@ gtk_menu_tracker_item_get_action_state (GtkMenuTrackerItem *self)
return NULL;
}
+const gchar *
+gtk_menu_tracker_item_get_action_namespace (GtkMenuTrackerItem *self)
+{
+ return self->action_namespace;
+}
+
static void
gtk_menu_tracker_item_set_submenu_shown (GtkMenuTrackerItem *self,
gboolean submenu_shown)
diff --git a/libqmenumodel/src/gtk/gtkmenutrackeritem.h b/libqmenumodel/src/gtk/gtkmenutrackeritem.h
index c0d61f0..dc62bf1 100644
--- a/libqmenumodel/src/gtk/gtkmenutrackeritem.h
+++ b/libqmenumodel/src/gtk/gtkmenutrackeritem.h
@@ -91,6 +91,8 @@ gchar * gtk_menu_tracker_item_get_action_name (GtkMen
GVariant * gtk_menu_tracker_item_get_action_state (GtkMenuTrackerItem *self);
+const gchar * gtk_menu_tracker_item_get_action_namespace (GtkMenuTrackerItem *self);
+
gboolean gtk_menu_tracker_item_get_attribute (GtkMenuTrackerItem *self,
const gchar *attribute,
const gchar *format,
diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp
index ff65e69..026cb93 100644
--- a/libqmenumodel/src/unitymenumodel.cpp
+++ b/libqmenumodel/src/unitymenumodel.cpp
@@ -641,6 +641,34 @@ QVariant UnityMenuModel::get(int row, const QByteArray &role)
return this->data(this->index(row, 0), priv->roles[role]);
}
+UnityMenuAction * UnityMenuModel::getAction(int row, const QByteArray &name)
+{
+ GSequenceIter *iter;
+ GtkMenuTrackerItem *item;
+ const gchar *action_namespace;
+ gchar *action_name;
+ UnityMenuAction *action;
+
+ iter = g_sequence_get_iter_at_pos (priv->items, row);
+ if (g_sequence_iter_is_end (iter))
+ return NULL;
+
+ item = (GtkMenuTrackerItem *) g_sequence_get (iter);
+ action_namespace = gtk_menu_tracker_item_get_action_namespace (item);
+ if (action_namespace != NULL)
+ action_name = g_strjoin (".", action_namespace, name.constData(), NULL);
+ else
+ action_name = g_strdup (name.constData());
+
+ action = new UnityMenuAction(this);
+ action->setModel(this);
+ action->setName(action_name);
+
+ g_free (action_name);
+
+ return action;
+}
+
void UnityMenuModel::activate(int index, const QVariant& parameter)
{
GtkMenuTrackerItem *item;
diff --git a/libqmenumodel/src/unitymenumodel.h b/libqmenumodel/src/unitymenumodel.h
index a229f09..1391b27 100644
--- a/libqmenumodel/src/unitymenumodel.h
+++ b/libqmenumodel/src/unitymenumodel.h
@@ -58,6 +58,7 @@ public:
Q_INVOKABLE QObject * submenu(int position, QQmlComponent* actionStateParser = NULL);
Q_INVOKABLE bool loadExtendedAttributes(int position, const QVariantMap &schema);
Q_INVOKABLE QVariant get(int row, const QByteArray &role);
+ Q_INVOKABLE UnityMenuAction * getAction(int row, const QByteArray &name);
Q_INVOKABLE void activate(int index, const QVariant& parameter = QVariant());
Q_INVOKABLE void changeState(int index, const QVariant& parameter);