scalebutton: Add an active property
This is set to TRUE while the popup is visible. We will use it to prevent the button from being hidden while the user is interacting with it.
This commit is contained in:
@@ -98,7 +98,8 @@ enum
|
||||
PROP_VALUE,
|
||||
PROP_SIZE,
|
||||
PROP_ADJUSTMENT,
|
||||
PROP_ICONS
|
||||
PROP_ICONS,
|
||||
PROP_ACTIVE
|
||||
};
|
||||
|
||||
typedef struct
|
||||
@@ -248,6 +249,13 @@ gtk_scale_button_class_init (GtkScaleButtonClass *klass)
|
||||
G_TYPE_STRV,
|
||||
GTK_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_ACTIVE,
|
||||
g_param_spec_boolean ("active",
|
||||
P_("Active"),
|
||||
P_("Active"),
|
||||
FALSE,
|
||||
G_PARAM_READABLE));
|
||||
/**
|
||||
* GtkScaleButton::value-changed:
|
||||
* @button: the object which received the signal
|
||||
@@ -403,6 +411,14 @@ gtk_scale_button_closed (GtkScaleButton *button)
|
||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->button), FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
notify_active (GObject *object,
|
||||
GParamSpec *pspec,
|
||||
GObject *button)
|
||||
{
|
||||
g_object_notify (button, "active");
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_scale_button_init (GtkScaleButton *button)
|
||||
{
|
||||
@@ -416,6 +432,9 @@ gtk_scale_button_init (GtkScaleButton *button)
|
||||
gtk_widget_init_template (GTK_WIDGET (button));
|
||||
gtk_widget_set_parent (priv->dock, GTK_WIDGET (button));
|
||||
|
||||
g_signal_connect (priv->dock, "notify::visible",
|
||||
G_CALLBACK (notify_active), button);
|
||||
|
||||
/* Need a local reference to the adjustment */
|
||||
priv->adjustment = gtk_adjustment_new (0, 0, 100, 2, 20, 0);
|
||||
g_object_ref_sink (priv->adjustment);
|
||||
@@ -503,6 +522,9 @@ gtk_scale_button_get_property (GObject *object,
|
||||
case PROP_ICONS:
|
||||
g_value_set_boxed (value, priv->icon_list);
|
||||
break;
|
||||
case PROP_ACTIVE:
|
||||
g_value_set_boolean (value, gtk_widget_get_visible (priv->dock));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user