aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libqmenumodel/src/gtk/gtkmenutrackeritem.c24
-rw-r--r--libqmenumodel/src/gtk/gtkmenutrackeritem.h2
-rw-r--r--libqmenumodel/src/unitymenuaction.h4
-rw-r--r--libqmenumodel/src/unitymenumodel.cpp12
4 files changed, 42 insertions, 0 deletions
diff --git a/libqmenumodel/src/gtk/gtkmenutrackeritem.c b/libqmenumodel/src/gtk/gtkmenutrackeritem.c
index fb856c9..c14bbb8 100644
--- a/libqmenumodel/src/gtk/gtkmenutrackeritem.c
+++ b/libqmenumodel/src/gtk/gtkmenutrackeritem.c
@@ -106,6 +106,7 @@ enum {
PROP_TOGGLED,
PROP_ACCEL,
PROP_SUBMENU_SHOWN,
+ PROP_ACTION_NAME,
PROP_ACTION_STATE,
N_PROPS
};
@@ -179,6 +180,8 @@ gtk_menu_tracker_item_get_property (GObject *object,
case PROP_SUBMENU_SHOWN:
g_value_set_boolean (value, gtk_menu_tracker_item_get_submenu_shown (self));
break;
+ case PROP_ACTION_NAME:
+ g_value_set_string (value, gtk_menu_tracker_item_get_action_name (self));
case PROP_ACTION_STATE:
g_value_set_variant (value, self->action_state);
break;
@@ -239,12 +242,16 @@ gtk_menu_tracker_item_class_init (GtkMenuTrackerItemClass *class)
g_param_spec_string ("accel", "", "", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE);
gtk_menu_tracker_item_pspecs[PROP_SUBMENU_SHOWN] =
g_param_spec_boolean ("submenu-shown", "", "", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE);
+ gtk_menu_tracker_item_pspecs[PROP_ACTION_NAME] =
+ g_param_spec_boolean ("action-name", "", "", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE);
gtk_menu_tracker_item_pspecs[PROP_ACTION_STATE] =
g_param_spec_boolean ("action-state", "", "", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE);
g_object_class_install_properties (class, N_PROPS, gtk_menu_tracker_item_pspecs);
}
+#include <stdio.h>
+
static void
gtk_menu_tracker_item_action_added (GtkActionObserver *observer,
GtkActionObservable *observable,
@@ -268,6 +275,7 @@ gtk_menu_tracker_item_action_added (GtkActionObserver *observer,
g_variant_unref (action_target);
return;
}
+ printf("INDICATORS: activateable %p\n", action_target);
self->sensitive = enabled;
@@ -612,6 +620,22 @@ gtk_menu_tracker_item_get_submenu_shown (GtkMenuTrackerItem *self)
return self->submenu_shown;
}
+/**
+ * gtk_menu_tracker_item_get_action_name:
+ * @self: A #GtkMenuTrackerItem instance
+ *
+ * Returns the action name
+ */
+const gchar *
+gtk_menu_tracker_item_get_action_name (GtkMenuTrackerItem *self)
+{
+ const gchar *action_name = NULL;
+
+ g_menu_item_get_attribute (self->item, G_MENU_ATTRIBUTE_ACTION, "&s", &action_name);
+
+ return action_name;
+}
+
GVariant *
gtk_menu_tracker_item_get_action_state (GtkMenuTrackerItem *self)
{
diff --git a/libqmenumodel/src/gtk/gtkmenutrackeritem.h b/libqmenumodel/src/gtk/gtkmenutrackeritem.h
index 16c4415..8b0afae 100644
--- a/libqmenumodel/src/gtk/gtkmenutrackeritem.h
+++ b/libqmenumodel/src/gtk/gtkmenutrackeritem.h
@@ -81,6 +81,8 @@ void gtk_menu_tracker_item_request_submenu_shown (GtkMenu
gboolean gtk_menu_tracker_item_get_submenu_shown (GtkMenuTrackerItem *self);
+const gchar * gtk_menu_tracker_item_get_action_name (GtkMenuTrackerItem *self);
+
GVariant * gtk_menu_tracker_item_get_action_state (GtkMenuTrackerItem *self);
gboolean gtk_menu_tracker_item_get_attribute (GtkMenuTrackerItem *self,
diff --git a/libqmenumodel/src/unitymenuaction.h b/libqmenumodel/src/unitymenuaction.h
index 26be02b..4dea311 100644
--- a/libqmenumodel/src/unitymenuaction.h
+++ b/libqmenumodel/src/unitymenuaction.h
@@ -29,6 +29,7 @@ class UnityMenuModel;
class UnityMenuAction : public QObject
{
Q_OBJECT
+ Q_PROPERTY(QVariant name READ name NOTIFY nameChanged)
Q_PROPERTY(QVariant state READ state WRITE updateState NOTIFY stateChanged)
Q_PROPERTY(int index READ index WRITE setIndex NOTIFY indexChanged)
Q_PROPERTY(UnityMenuModel* model READ model WRITE setModel NOTIFY modelChanged)
@@ -41,10 +42,13 @@ public:
UnityMenuModel* model() const;
void setModel(UnityMenuModel* model);
+ virtual QString name() const = 0;
+
virtual QVariant state() const = 0;
Q_INVOKABLE virtual void updateState(const QVariant& = QVariant()) = 0;
Q_SIGNALS:
+ void nameChanged();
void stateChanged();
void indexChanged(int index);
void modelChanged(UnityMenuModel* model);
diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp
index 72a5985..7c5d597 100644
--- a/libqmenumodel/src/unitymenumodel.cpp
+++ b/libqmenumodel/src/unitymenumodel.cpp
@@ -86,6 +86,14 @@ public:
setIndex(index);
}
+ virtual QString name() const {
+ GtkMenuTrackerItem* item = (GtkMenuTrackerItem *) g_sequence_get (g_sequence_get_iter_at_pos (d->items, index()));
+ if (!item) {
+ return "";
+ }
+ 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) {
@@ -534,6 +542,10 @@ static QVariant attributeToQVariant(GVariant *value, const QString &type)
if (g_variant_is_of_type (value, G_VARIANT_TYPE_STRING))
result = QVariant(g_variant_get_string(value, NULL));
}
+ if (type == "double") {
+ if (g_variant_is_of_type (value, G_VARIANT_TYPE_DOUBLE))
+ result = QVariant(g_variant_get_double(value));
+ }
else if (type == "icon") {
GIcon *icon = g_icon_deserialize (value);
if (icon) {