From 7ed68c1550b1c2b24c2c2a0dc33a6784837aaf85 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Wed, 16 Sep 2020 15:35:43 +0200 Subject: Whitespace fix --- src/idoswitchmenuitem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/idoswitchmenuitem.c b/src/idoswitchmenuitem.c index bd00e1d..5a068f4 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. **/ -- cgit v1.2.3 From 6a4bf3d40364bcac5b8a5b4a5bd701544f5b2863 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Wed, 16 Sep 2020 15:39:07 +0200 Subject: idoswitchmenuitem.c: Pass the switch activation state in the action signal --- src/idoswitchmenuitem.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/idoswitchmenuitem.c b/src/idoswitchmenuitem.c index 5a068f4..c33e6ee 100644 --- a/src/idoswitchmenuitem.c +++ b/src/idoswitchmenuitem.c @@ -224,6 +224,14 @@ 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) +{ + 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 +271,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); -- cgit v1.2.3 From d318463089e889f2e0abfd41812648449dd7a268 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Fri, 25 Sep 2020 00:09:24 +0200 Subject: Add sanity-check in ido_switch_menu_item_activate --- src/idoswitchmenuitem.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/idoswitchmenuitem.c b/src/idoswitchmenuitem.c index c33e6ee..1f898e1 100644 --- a/src/idoswitchmenuitem.c +++ b/src/idoswitchmenuitem.c @@ -226,6 +226,8 @@ ido_source_menu_item_state_changed (IdoActionHelper *helper, 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)); -- cgit v1.2.3