aboutsummaryrefslogtreecommitdiff
path: root/src/idoscalemenuitem.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/idoscalemenuitem.c')
-rw-r--r--src/idoscalemenuitem.c16
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);