mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-13 04:10:13 +00:00
Revert "spinbutton: Tangential refactoring, small fix"
This reverts commit 3d898af736
.
The commit caused a regression where, depending on the update policy,
we would not apply value changes at all.
Fixes: #6599
This commit is contained in:
parent
40dd81e1a4
commit
fcb6c8e447
@ -295,7 +295,7 @@ static void gtk_spin_button_activate (GtkText *entry,
|
|||||||
static void gtk_spin_button_unset_adjustment (GtkSpinButton *spin_button);
|
static void gtk_spin_button_unset_adjustment (GtkSpinButton *spin_button);
|
||||||
static void gtk_spin_button_set_orientation (GtkSpinButton *spin_button,
|
static void gtk_spin_button_set_orientation (GtkSpinButton *spin_button,
|
||||||
GtkOrientation orientation);
|
GtkOrientation orientation);
|
||||||
static double gtk_spin_button_snap (GtkSpinButton *spin_button,
|
static void gtk_spin_button_snap (GtkSpinButton *spin_button,
|
||||||
double val);
|
double val);
|
||||||
static void gtk_spin_button_insert_text (GtkEditable *editable,
|
static void gtk_spin_button_insert_text (GtkEditable *editable,
|
||||||
const char *new_text,
|
const char *new_text,
|
||||||
@ -1519,7 +1519,7 @@ gtk_spin_button_real_change_value (GtkSpinButton *spin,
|
|||||||
gtk_widget_error_bell (GTK_WIDGET (spin));
|
gtk_widget_error_bell (GTK_WIDGET (spin));
|
||||||
}
|
}
|
||||||
|
|
||||||
static double
|
static void
|
||||||
gtk_spin_button_snap (GtkSpinButton *spin_button,
|
gtk_spin_button_snap (GtkSpinButton *spin_button,
|
||||||
double val)
|
double val)
|
||||||
{
|
{
|
||||||
@ -1528,7 +1528,7 @@ gtk_spin_button_snap (GtkSpinButton *spin_button,
|
|||||||
|
|
||||||
inc = gtk_adjustment_get_step_increment (spin_button->adjustment);
|
inc = gtk_adjustment_get_step_increment (spin_button->adjustment);
|
||||||
if (inc == 0)
|
if (inc == 0)
|
||||||
return val;
|
return;
|
||||||
|
|
||||||
tmp = (val - gtk_adjustment_get_lower (spin_button->adjustment)) / inc;
|
tmp = (val - gtk_adjustment_get_lower (spin_button->adjustment)) / inc;
|
||||||
if (tmp - floor (tmp) < ceil (tmp) - tmp)
|
if (tmp - floor (tmp) < ceil (tmp) - tmp)
|
||||||
@ -1536,7 +1536,7 @@ gtk_spin_button_snap (GtkSpinButton *spin_button,
|
|||||||
else
|
else
|
||||||
val = gtk_adjustment_get_lower (spin_button->adjustment) + ceil (tmp) * inc;
|
val = gtk_adjustment_get_lower (spin_button->adjustment) + ceil (tmp) * inc;
|
||||||
|
|
||||||
return val;
|
gtk_spin_button_set_value (spin_button, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -2538,22 +2538,26 @@ gtk_spin_button_update (GtkSpinButton *spin_button)
|
|||||||
else if (return_val == GTK_INPUT_ERROR)
|
else if (return_val == GTK_INPUT_ERROR)
|
||||||
error = 1;
|
error = 1;
|
||||||
|
|
||||||
const double lower = gtk_adjustment_get_lower (spin_button->adjustment);
|
|
||||||
const double upper = gtk_adjustment_get_upper (spin_button->adjustment);
|
|
||||||
|
|
||||||
if (spin_button->update_policy == GTK_UPDATE_ALWAYS)
|
if (spin_button->update_policy == GTK_UPDATE_ALWAYS)
|
||||||
{
|
{
|
||||||
val = CLAMP (val, lower, upper);
|
if (val < gtk_adjustment_get_lower (spin_button->adjustment))
|
||||||
|
val = gtk_adjustment_get_lower (spin_button->adjustment);
|
||||||
if (spin_button->snap_to_ticks)
|
else if (val > gtk_adjustment_get_upper (spin_button->adjustment))
|
||||||
val = gtk_spin_button_snap (spin_button, val);
|
val = gtk_adjustment_get_upper (spin_button->adjustment);
|
||||||
|
|
||||||
gtk_spin_button_set_value (spin_button, val);
|
|
||||||
}
|
}
|
||||||
else if (error || val < lower || val > upper)
|
else if ((spin_button->update_policy == GTK_UPDATE_IF_VALID) &&
|
||||||
|
(error ||
|
||||||
|
val < gtk_adjustment_get_lower (spin_button->adjustment) ||
|
||||||
|
val > gtk_adjustment_get_upper (spin_button->adjustment)))
|
||||||
{
|
{
|
||||||
gtk_spin_button_value_changed (spin_button->adjustment, spin_button);
|
gtk_spin_button_value_changed (spin_button->adjustment, spin_button);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (spin_button->snap_to_ticks)
|
||||||
|
gtk_spin_button_snap (spin_button, val);
|
||||||
|
else
|
||||||
|
gtk_spin_button_set_value (spin_button, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkText *
|
GtkText *
|
||||||
@ -2561,3 +2565,4 @@ gtk_spin_button_get_text_widget (GtkSpinButton *spin_button)
|
|||||||
{
|
{
|
||||||
return GTK_TEXT (spin_button->entry);
|
return GTK_TEXT (spin_button->entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user