diff options
author | Robert Tari <robert@tari.in> | 2024-07-17 04:21:36 +0200 |
---|---|---|
committer | Robert Tari <robert@tari.in> | 2024-07-17 04:21:36 +0200 |
commit | 4446a18d34f335aadacdbbf0c6f4fee5c5255b16 (patch) | |
tree | 968f43318fbb9328a4ad607969ee6e7cb805e02a /src/idoscalemenuitem.c | |
parent | 1eaf28c93056710c2d0eb64ab6afe9f150bdf243 (diff) | |
download | ayatana-ido-4446a18d34f335aadacdbbf0c6f4fee5c5255b16.tar.gz ayatana-ido-4446a18d34f335aadacdbbf0c6f4fee5c5255b16.tar.bz2 ayatana-ido-4446a18d34f335aadacdbbf0c6f4fee5c5255b16.zip |
src/idoscalemenuitem.c: Add ability to close the menu when the slider's value changes
Diffstat (limited to 'src/idoscalemenuitem.c')
-rw-r--r-- | src/idoscalemenuitem.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/idoscalemenuitem.c b/src/idoscalemenuitem.c index 9bdfbad..50c323a 100644 --- a/src/idoscalemenuitem.c +++ b/src/idoscalemenuitem.c @@ -78,6 +78,7 @@ typedef struct { IdoRangeStyle range_style; gboolean ignore_value_changed; gboolean has_focus; + gboolean bCloseOnChange; } IdoScaleMenuItemPrivate; enum { @@ -143,8 +144,16 @@ ido_scale_menu_item_scale_value_changed (GtkRange *range, /* The signal is not sent when it was set through * ido_scale_menu_item_set_value(). */ - if (!priv->ignore_value_changed) - g_signal_emit (self, signals[VALUE_CHANGED], 0, gtk_range_get_value (range)); + if (!priv->ignore_value_changed) + { + g_signal_emit (self, signals[VALUE_CHANGED], 0, gtk_range_get_value (range)); + + if (priv->bCloseOnChange) + { + GtkWidget *pParent = gtk_widget_get_parent (GTK_WIDGET (self)); + gtk_menu_shell_deactivate (GTK_MENU_SHELL (pParent)); + } + } } static void @@ -367,7 +376,7 @@ static void ido_scale_menu_item_init (IdoScaleMenuItem *self) { IdoScaleMenuItemPrivate *priv = ido_scale_menu_item_get_instance_private (self); - + priv->bCloseOnChange = FALSE; priv->reverse_scroll = TRUE; gtk_widget_set_size_request (GTK_WIDGET (self), 200, -1); @@ -1118,6 +1127,7 @@ ido_scale_menu_item_new_from_model (GMenuItem *menuitem, g_signal_connect (pPrivate->scale, "format-value", G_CALLBACK (onFormatValue), NULL); } + g_menu_item_get_attribute (menuitem, "close-on-change", "b", &pPrivate->bCloseOnChange); min_icon = menu_item_get_icon (menuitem, "min-icon"); max_icon = menu_item_get_icon (menuitem, "max-icon"); ido_scale_menu_item_set_icons (IDO_SCALE_MENU_ITEM (item), min_icon, max_icon); |