mirror of https://github.com/GNOME/gimp.git
libgimpwidgets: add a "value" property to GimpIntComboBox…
… and have gimp_prop_int_combo_box_new() bind to "value" instead of
"active".
The "active" property is defined by GtkComboBox and is the index of the
combo box, not its values, whereas with gimp_prop_int_combo_box_new(),
we want to bind an int property to the combobox value. Therefore the
commit 0828a371c2
was only properly working when we were creating a
combo box with values starting at 0 and incremented by 1.
By adding a "value" property to GimpIntComboBox, I allow binding any
property to the int value rather than the index.
See also !265 where the issue was raised as it affected our HEIF
plug-in.
This commit is contained in:
parent
e426cdafc4
commit
db71a8ffc7
|
@ -48,7 +48,8 @@ enum
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_ELLIPSIZE,
|
PROP_ELLIPSIZE,
|
||||||
PROP_LABEL,
|
PROP_LABEL,
|
||||||
PROP_LAYOUT
|
PROP_LAYOUT,
|
||||||
|
PROP_VALUE
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -148,6 +149,21 @@ gimp_int_combo_box_class_init (GimpIntComboBoxClass *klass)
|
||||||
GIMP_TYPE_INT_COMBO_BOX_LAYOUT,
|
GIMP_TYPE_INT_COMBO_BOX_LAYOUT,
|
||||||
GIMP_INT_COMBO_BOX_LAYOUT_ABBREVIATED,
|
GIMP_INT_COMBO_BOX_LAYOUT_ABBREVIATED,
|
||||||
GIMP_PARAM_READWRITE));
|
GIMP_PARAM_READWRITE));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GimpIntComboBox:value:
|
||||||
|
*
|
||||||
|
* The active value (different from the "active" property of
|
||||||
|
* GtkComboBox which is the active index).
|
||||||
|
*
|
||||||
|
* Since: 3.0
|
||||||
|
*/
|
||||||
|
g_object_class_install_property (object_class, PROP_VALUE,
|
||||||
|
g_param_spec_int ("value",
|
||||||
|
"Value",
|
||||||
|
"Value of active item",
|
||||||
|
G_MININT, G_MAXINT, 0,
|
||||||
|
GIMP_PARAM_READWRITE));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -217,6 +233,10 @@ gimp_int_combo_box_set_property (GObject *object,
|
||||||
gimp_int_combo_box_set_layout (GIMP_INT_COMBO_BOX (object),
|
gimp_int_combo_box_set_layout (GIMP_INT_COMBO_BOX (object),
|
||||||
g_value_get_enum (value));
|
g_value_get_enum (value));
|
||||||
break;
|
break;
|
||||||
|
case PROP_VALUE:
|
||||||
|
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (object),
|
||||||
|
g_value_get_int (value));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
@ -243,6 +263,14 @@ gimp_int_combo_box_get_property (GObject *object,
|
||||||
case PROP_LAYOUT:
|
case PROP_LAYOUT:
|
||||||
g_value_set_enum (value, priv->layout);
|
g_value_set_enum (value, priv->layout);
|
||||||
break;
|
break;
|
||||||
|
case PROP_VALUE:
|
||||||
|
{
|
||||||
|
gint v;
|
||||||
|
|
||||||
|
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (object), &v);
|
||||||
|
g_value_set_int (value, v);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
|
|
|
@ -411,7 +411,7 @@ gimp_prop_int_combo_box_new (GObject *config,
|
||||||
gimp_help_set_help_data (combo_box, blurb, NULL);
|
gimp_help_set_help_data (combo_box, blurb, NULL);
|
||||||
|
|
||||||
g_object_bind_property (config, property_name,
|
g_object_bind_property (config, property_name,
|
||||||
combo_box, "active",
|
combo_box, "value",
|
||||||
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
|
||||||
|
|
||||||
return combo_box;
|
return combo_box;
|
||||||
|
|
Loading…
Reference in New Issue