aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel
diff options
context:
space:
mode:
Diffstat (limited to 'libqmenumodel')
-rw-r--r--libqmenumodel/src/unitymenumodel.cpp27
-rw-r--r--libqmenumodel/src/unitymenumodel.h8
2 files changed, 19 insertions, 16 deletions
diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp
index 58b9fda..81f5121 100644
--- a/libqmenumodel/src/unitymenumodel.cpp
+++ b/libqmenumodel/src/unitymenumodel.cpp
@@ -53,7 +53,7 @@ public:
QByteArray busName;
QByteArray nameOwner;
guint nameWatchId;
- QByteArray actionObjectPath;
+ QVariantMap actions;
QByteArray menuObjectPath;
static void nameAppeared(GDBusConnection *connection, const gchar *name, const gchar *owner, gpointer user_data);
@@ -124,17 +124,20 @@ void UnityMenuModelPrivate::clearName()
void UnityMenuModelPrivate::updateActions()
{
- if (!this->nameOwner.isEmpty()) {
+ Q_FOREACH (QString prefix, this->actions.keys())
+ gtk_action_muxer_remove (this->muxer, prefix.toUtf8());
+
+ if (this->nameOwner.isEmpty())
+ return;
+
+ for (QVariantMap::const_iterator it = this->actions.constBegin(); it != this->actions.constEnd(); ++it) {
GDBusActionGroup *actions;
- actions = g_dbus_action_group_get (this->connection, this->nameOwner, this->actionObjectPath.constData());
- gtk_action_muxer_insert (this->muxer, "indicator", G_ACTION_GROUP (actions));
+ actions = g_dbus_action_group_get (this->connection, this->nameOwner, it.value().toByteArray());
+ gtk_action_muxer_insert (this->muxer, it.key().toUtf8(), G_ACTION_GROUP (actions));
g_object_unref (actions);
}
- else {
- gtk_action_muxer_remove (this->muxer, "indicator");
- }
}
void UnityMenuModelPrivate::updateMenuModel()
@@ -147,7 +150,7 @@ void UnityMenuModelPrivate::updateMenuModel()
menu = g_dbus_menu_model_get (this->connection, this->nameOwner, this->menuObjectPath.constData());
this->menutracker = gtk_menu_tracker_new (GTK_ACTION_OBSERVABLE (this->muxer),
- G_MENU_MODEL (menu), TRUE, "indicator",
+ G_MENU_MODEL (menu), TRUE, NULL,
menuItemInserted, menuItemRemoved, this);
g_object_unref (menu);
@@ -244,14 +247,14 @@ void UnityMenuModel::setBusName(const QByteArray &name)
priv, NULL);
}
-QByteArray UnityMenuModel::actionObjectPath() const
+QVariantMap UnityMenuModel::actions() const
{
- return priv->actionObjectPath;
+ return priv->actions;
}
-void UnityMenuModel::setActionObjectPath(const QByteArray &path)
+void UnityMenuModel::setActions(const QVariantMap &actions)
{
- priv->actionObjectPath = path;
+ priv->actions = actions;
priv->updateActions();
}
diff --git a/libqmenumodel/src/unitymenumodel.h b/libqmenumodel/src/unitymenumodel.h
index 27a9fff..896c806 100644
--- a/libqmenumodel/src/unitymenumodel.h
+++ b/libqmenumodel/src/unitymenumodel.h
@@ -25,7 +25,7 @@ class UnityMenuModel: public QAbstractListModel
{
Q_OBJECT
Q_PROPERTY(QByteArray busName READ busName WRITE setBusName NOTIFY busNameChanged)
- Q_PROPERTY(QByteArray actionObjectPath READ actionObjectPath WRITE setActionObjectPath NOTIFY actionObjectPathChanged)
+ Q_PROPERTY(QVariantMap actions READ actions WRITE setActions NOTIFY actionsChanged)
Q_PROPERTY(QByteArray menuObjectPath READ menuObjectPath WRITE setMenuObjectPath NOTIFY menuObjectPathChanged)
public:
@@ -35,8 +35,8 @@ public:
QByteArray busName() const;
void setBusName(const QByteArray &name);
- QByteArray actionObjectPath() const;
- void setActionObjectPath(const QByteArray &path);
+ QVariantMap actions() const;
+ void setActions(const QVariantMap &actions);
QByteArray menuObjectPath() const;
void setMenuObjectPath(const QByteArray &path);
@@ -52,7 +52,7 @@ public:
Q_SIGNALS:
void busNameChanged(const QByteArray &name);
- void actionObjectPathChanged(const QByteArray &path);
+ void actionsChanged(const QByteArray &path);
void menuObjectPathChanged(const QByteArray &path);
public Q_SLOTS: