aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libqmenumodel/src/gtk/gtkmenutrackeritem.c19
-rw-r--r--libqmenumodel/src/gtk/gtkmenutrackeritem.h2
-rw-r--r--libqmenumodel/src/unitymenumodel.cpp8
3 files changed, 20 insertions, 9 deletions
diff --git a/libqmenumodel/src/gtk/gtkmenutrackeritem.c b/libqmenumodel/src/gtk/gtkmenutrackeritem.c
index e2ed1f0..3dc1d13 100644
--- a/libqmenumodel/src/gtk/gtkmenutrackeritem.c
+++ b/libqmenumodel/src/gtk/gtkmenutrackeritem.c
@@ -181,7 +181,7 @@ gtk_menu_tracker_item_get_property (GObject *object,
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));
+ g_value_take_string (value, gtk_menu_tracker_item_get_action_name (self));
case PROP_ACTION_STATE:
g_value_set_variant (value, self->action_state);
break;
@@ -621,16 +621,23 @@ gtk_menu_tracker_item_get_submenu_shown (GtkMenuTrackerItem *self)
* gtk_menu_tracker_item_get_action_name:
* @self: A #GtkMenuTrackerItem instance
*
- * Returns the action name
+ * Returns a newly-allocated string containing the name of the action
+ * associated with this menu item.
+ *
+ * Returns: (transfer full): the action name, free it with g_free()
*/
-const gchar *
+gchar *
gtk_menu_tracker_item_get_action_name (GtkMenuTrackerItem *self)
{
- const gchar *action_name = NULL;
+ const gchar *action_name;
- g_menu_item_get_attribute (self->item, G_MENU_ATTRIBUTE_ACTION, "&s", &action_name);
+ if (!g_menu_item_get_attribute (self->item, G_MENU_ATTRIBUTE_ACTION, "&s", &action_name))
+ return NULL;
- return action_name;
+ if (self->action_namespace)
+ return g_strjoin (".", self->action_namespace, action_name, NULL);
+ else
+ return g_strdup (action_name);
}
GVariant *
diff --git a/libqmenumodel/src/gtk/gtkmenutrackeritem.h b/libqmenumodel/src/gtk/gtkmenutrackeritem.h
index 59a7080..c0d61f0 100644
--- a/libqmenumodel/src/gtk/gtkmenutrackeritem.h
+++ b/libqmenumodel/src/gtk/gtkmenutrackeritem.h
@@ -87,7 +87,7 @@ 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);
+gchar * gtk_menu_tracker_item_get_action_name (GtkMenuTrackerItem *self);
GVariant * gtk_menu_tracker_item_get_action_state (GtkMenuTrackerItem *self);
diff --git a/libqmenumodel/src/unitymenumodel.cpp b/libqmenumodel/src/unitymenumodel.cpp
index d457cad..5144127 100644
--- a/libqmenumodel/src/unitymenumodel.cpp
+++ b/libqmenumodel/src/unitymenumodel.cpp
@@ -432,8 +432,12 @@ QVariant UnityMenuModel::data(const QModelIndex &index, int role) const
return map ? *map : QVariant();
}
- case ActionRole:
- return gtk_menu_tracker_item_get_action_name (item);
+ case ActionRole: {
+ gchar *action_name = gtk_menu_tracker_item_get_action_name (item);
+ QString v(action_name);
+ g_free(action_name);
+ return v;
+ }
case ActionStateRole:
return priv->itemState(item);