aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2020-09-27 15:46:19 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2020-09-27 15:46:19 +0200
commitbbcbd080b4b39fa61b6805f6fe11773805d9c580 (patch)
tree37c6226de4f405980c4420accb347077713aa689 /src
parentd580f61c5cce53d8cbe1862cf0abed0e942c3550 (diff)
parentd318463089e889f2e0abfd41812648449dd7a268 (diff)
downloadayatana-ido-bbcbd080b4b39fa61b6805f6fe11773805d9c580.tar.gz
ayatana-ido-bbcbd080b4b39fa61b6805f6fe11773805d9c580.tar.bz2
ayatana-ido-bbcbd080b4b39fa61b6805f6fe11773805d9c580.zip
Merge branch 'tari01-pr/switch-state-fix'
Attributes GH PR #15: https://github.com/AyatanaIndicators/ayatana-ido/pull/15
Diffstat (limited to 'src')
-rw-r--r--src/idoswitchmenuitem.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/idoswitchmenuitem.c b/src/idoswitchmenuitem.c
index bd00e1d..1f898e1 100644
--- a/src/idoswitchmenuitem.c
+++ b/src/idoswitchmenuitem.c
@@ -28,7 +28,7 @@ static gboolean ido_switch_menu_button_release_event (GtkWidget * widget,
GdkEventButton * event);
-typedef struct
+typedef struct
{
GtkWidget * box;
GtkWidget * content_area;
@@ -179,7 +179,7 @@ ido_switch_menu_item_set_label (IdoSwitchMenuItem *item,
/**
* ido_switch_menu_item_set_icon:
* @item: a #IdoSwitchMenuItem.
- * @icon: (allow-none): a #GIcon
+ * @icon: (allow-none): a #GIcon
*
* Set the icon of @item to @icon.
**/
@@ -224,6 +224,16 @@ ido_source_menu_item_state_changed (IdoActionHelper *helper,
g_variant_get_boolean (state));
}
+static void ido_switch_menu_item_activate(IdoSwitchMenuItem *self, gpointer user_data)
+{
+ g_return_if_fail(IDO_IS_SWITCH_MENU_ITEM(self));
+
+ IdoActionHelper *helper = user_data;
+ IdoSwitchMenuItemPrivate *priv = ido_switch_menu_item_get_instance_private(self);
+ gboolean active = gtk_switch_get_active(GTK_SWITCH(priv->switch_w));
+ ido_action_helper_activate_with_parameter(helper, g_variant_new_boolean(active));
+}
+
GtkMenuItem *
ido_switch_menu_item_new_from_menu_model (GMenuItem *menuitem,
GActionGroup *actions)
@@ -263,9 +273,7 @@ ido_switch_menu_item_new_from_menu_model (GMenuItem *menuitem,
helper = ido_action_helper_new (GTK_WIDGET (item), actions, action, NULL);
g_signal_connect (helper, "action-state-changed",
G_CALLBACK (ido_source_menu_item_state_changed), item);
- g_signal_connect_object (item, "activate",
- G_CALLBACK (ido_action_helper_activate), helper,
- G_CONNECT_SWAPPED);
+ g_signal_connect(item, "activate", G_CALLBACK(ido_switch_menu_item_activate), helper);
g_signal_connect_swapped (item, "destroy", G_CALLBACK (g_object_unref), helper);
g_free (action);