aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel/src/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'libqmenumodel/src/gtk')
-rw-r--r--libqmenumodel/src/gtk/gtkmenutrackeritem.c43
-rw-r--r--libqmenumodel/src/gtk/gtkmenutrackeritem.h8
2 files changed, 51 insertions, 0 deletions
diff --git a/libqmenumodel/src/gtk/gtkmenutrackeritem.c b/libqmenumodel/src/gtk/gtkmenutrackeritem.c
index fb856c9..e2ed1f0 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,6 +242,8 @@ 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);
@@ -612,6 +617,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)
{
@@ -661,6 +682,28 @@ gtk_menu_tracker_item_activated (GtkMenuTrackerItem *self)
g_variant_unref (action_target);
}
+void
+gtk_menu_tracker_item_change_state (GtkMenuTrackerItem *self,
+ GVariant *value)
+{
+ const gchar *action_name;
+
+ g_return_if_fail (GTK_IS_MENU_TRACKER_ITEM (self));
+
+ g_menu_item_get_attribute (self->item, G_MENU_ATTRIBUTE_ACTION, "&s", &action_name);
+
+ if (self->action_namespace)
+ {
+ gchar *full_action;
+
+ full_action = g_strjoin (".", self->action_namespace, action_name, NULL);
+ g_action_group_change_action_state (G_ACTION_GROUP (self->observable), full_action, g_variant_ref(value));
+ g_free (full_action);
+ }
+ else
+ g_action_group_change_action_state (G_ACTION_GROUP (self->observable), action_name, g_variant_ref(value));
+}
+
typedef struct
{
GtkMenuTrackerItem *item;
diff --git a/libqmenumodel/src/gtk/gtkmenutrackeritem.h b/libqmenumodel/src/gtk/gtkmenutrackeritem.h
index 16c4415..59a7080 100644
--- a/libqmenumodel/src/gtk/gtkmenutrackeritem.h
+++ b/libqmenumodel/src/gtk/gtkmenutrackeritem.h
@@ -76,11 +76,19 @@ gboolean gtk_menu_tracker_item_get_should_request_show (GtkMenu
void gtk_menu_tracker_item_activated (GtkMenuTrackerItem *self);
+void gtk_menu_tracker_item_change_state (GtkMenuTrackerItem *self,
+ GVariant *value);
+
+
+
+
void gtk_menu_tracker_item_request_submenu_shown (GtkMenuTrackerItem *self,
gboolean shown);
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,