[gimp] libgimpwidgets: GtkComboBox "active" property must trigger…
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpwidgets: GtkComboBox "active" property must trigger…
- Date: Tue, 29 Sep 2020 15:11:51 +0000 (UTC)
commit b326b68b32be8d64c0c9099c3678d46fb1c551d8
Author: Jehan <jehan girinstud io>
Date: Tue Sep 29 17:02:21 2020 +0200
libgimpwidgets: GtkComboBox "active" property must trigger…
… GimpIntComboBox "value" property.
For this, I connect to the "changed" signal, which is equivalent anyway.
Otherwise the link was not bidirectionnal, so selecting a new item in
the combo list was not actually changing the internal value, hence the
binding set by gimp_prop_int_combo_box_new() was not complete either.
Not sure how I missed that. Hopefully not missing anything else!
libgimpwidgets/gimpintcombobox.c | 33 ++++++++++++++++++++++++++++++---
1 file changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/libgimpwidgets/gimpintcombobox.c b/libgimpwidgets/gimpintcombobox.c
index 364972181d..694cd812ee 100644
--- a/libgimpwidgets/gimpintcombobox.c
+++ b/libgimpwidgets/gimpintcombobox.c
@@ -80,6 +80,9 @@ static void gimp_int_combo_box_get_property (GObject *object,
GValue *value,
GParamSpec *pspec);
+static void gimp_int_combo_box_changed (GtkComboBox *combo_box,
+ gpointer user_data);
+
static void gimp_int_combo_box_create_cells (GimpIntComboBox *combo_box);
static void gimp_int_combo_box_data_func (GtkCellLayout *layout,
GtkCellRenderer *cell,
@@ -179,6 +182,10 @@ gimp_int_combo_box_init (GimpIntComboBox *combo_box)
g_object_unref (store);
priv->layout = GIMP_INT_COMBO_BOX_LAYOUT_ABBREVIATED;
+
+ g_signal_connect (combo_box, "changed",
+ G_CALLBACK (gimp_int_combo_box_changed),
+ NULL);
}
static void
@@ -463,8 +470,8 @@ gimp_int_combo_box_append (GimpIntComboBox *combo_box,
* Looks up the item that belongs to the given @value and makes it the
* selected item in the @combo_box.
*
- * Returns: %TRUE on success or %FALSE if there was no item for
- * this value.
+ * Returns: %TRUE on success (value changed or not) or %FALSE if there
+ * was no item for this value.
*
* Since: 2.2
**/
@@ -474,12 +481,21 @@ gimp_int_combo_box_set_active (GimpIntComboBox *combo_box,
{
GtkTreeModel *model;
GtkTreeIter iter;
+ gint current_value;
g_return_val_if_fail (GIMP_IS_INT_COMBO_BOX (combo_box), FALSE);
model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box));
- if (gimp_int_store_lookup_by_value (model, value, &iter))
+ if (gimp_int_combo_box_get_active (combo_box, ¤t_value) &&
+ value == current_value)
+ {
+ /* Guard for identical value to not loop forever between
+ * GimpIntComboBox "value" and GtkComboBox "active" properties.
+ */
+ return TRUE;
+ }
+ else if (gimp_int_store_lookup_by_value (model, value, &iter))
{
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (combo_box), &iter);
return TRUE;
@@ -795,6 +811,17 @@ gimp_int_combo_box_set_sensitivity (GimpIntComboBox *combo_box,
/* private functions */
+static void
+gimp_int_combo_box_changed (GtkComboBox *combo_box,
+ gpointer user_data)
+{
+ gint value;
+
+ gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (combo_box),
+ &value);
+ g_object_set (combo_box, "value", value, NULL);
+}
+
static void
gimp_int_combo_box_create_cells (GimpIntComboBox *combo_box)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]