Implement GailAdjustment::get_minimium_increment

...and use it in GailRange and GailSpinButton. Bug 625953.
This commit is contained in:
Szilárd Pfeiffer 2010-08-09 21:12:46 -04:00 committed by Matthias Clasen
parent 2686af2fbb
commit 93fa95e79f
3 changed files with 84 additions and 0 deletions

View File

@ -38,6 +38,8 @@ static void gail_adjustment_get_maximum_value (AtkValue *obj,
GValue *value);
static void gail_adjustment_get_minimum_value (AtkValue *obj,
GValue *value);
static void gail_adjustment_get_minimum_increment (AtkValue *obj,
GValue *value);
static gboolean gail_adjustment_set_current_value (AtkValue *obj,
const GValue *value);
@ -101,6 +103,7 @@ atk_value_interface_init (AtkValueIface *iface)
iface->get_current_value = gail_adjustment_get_current_value;
iface->get_maximum_value = gail_adjustment_get_maximum_value;
iface->get_minimum_value = gail_adjustment_get_minimum_value;
iface->get_minimum_increment = gail_adjustment_get_minimum_increment;
iface->set_current_value = gail_adjustment_set_current_value;
}
@ -164,6 +167,47 @@ gail_adjustment_get_minimum_value (AtkValue *obj,
g_value_set_double (value, minimum_value);
}
static void
gail_adjustment_get_minimum_increment (AtkValue *obj,
GValue *value)
{
GtkAdjustment* adjustment;
gdouble minimum_increment;
adjustment = GAIL_ADJUSTMENT (obj)->adjustment;
if (adjustment == NULL)
{
/* State is defunct */
return;
}
if (adjustment->step_increment != 0 &&
adjustment->page_increment != 0)
{
if (ABS (adjustment->step_increment) < ABS (adjustment->page_increment))
minimum_increment = adjustment->step_increment;
else
minimum_increment = adjustment->page_increment;
}
else if (adjustment->step_increment == 0 &&
adjustment->page_increment == 0)
{
minimum_increment = 0;
}
else if (adjustment->step_increment == 0)
{
minimum_increment = adjustment->page_increment;
}
else
{
minimum_increment = adjustment->step_increment;
}
memset (value, 0, sizeof (GValue));
g_value_init (value, G_TYPE_DOUBLE);
g_value_set_double (value, minimum_increment);
}
static gboolean
gail_adjustment_set_current_value (AtkValue *obj,
const GValue *value)

View File

@ -48,6 +48,8 @@ static void gail_range_get_maximum_value (AtkValue *obj,
GValue *value);
static void gail_range_get_minimum_value (AtkValue *obj,
GValue *value);
static void gail_range_get_minimum_increment (AtkValue *obj,
GValue *value);
static gboolean gail_range_set_current_value (AtkValue *obj,
const GValue *value);
static void gail_range_value_changed (GtkAdjustment *adjustment,
@ -159,6 +161,7 @@ atk_value_interface_init (AtkValueIface *iface)
iface->get_current_value = gail_range_get_current_value;
iface->get_maximum_value = gail_range_get_maximum_value;
iface->get_minimum_value = gail_range_get_minimum_value;
iface->get_minimum_increment = gail_range_get_minimum_increment;
iface->set_current_value = gail_range_set_current_value;
}
@ -216,6 +219,23 @@ gail_range_get_minimum_value (AtkValue *obj,
atk_value_get_minimum_value (ATK_VALUE (range->adjustment), value);
}
static void
gail_range_get_minimum_increment (AtkValue *obj, GValue *value)
{
GailRange *range;
g_return_if_fail (GAIL_IS_RANGE (obj));
range = GAIL_RANGE (obj);
if (range->adjustment == NULL)
/*
* Adjustment has not been specified
*/
return;
atk_value_get_minimum_increment (ATK_VALUE (range->adjustment), value);
}
static gboolean gail_range_set_current_value (AtkValue *obj,
const GValue *value)
{

View File

@ -42,6 +42,8 @@ static void gail_spin_button_get_maximum_value (AtkValue *obj,
GValue *value);
static void gail_spin_button_get_minimum_value (AtkValue *obj,
GValue *value);
static void gail_spin_button_get_minimum_increment (AtkValue *obj,
GValue *value);
static gboolean gail_spin_button_set_current_value (AtkValue *obj,
const GValue *value);
static void gail_spin_button_value_changed (GtkAdjustment *adjustment,
@ -108,6 +110,7 @@ atk_value_interface_init (AtkValueIface *iface)
iface->get_current_value = gail_spin_button_get_current_value;
iface->get_maximum_value = gail_spin_button_get_maximum_value;
iface->get_minimum_value = gail_spin_button_get_minimum_value;
iface->get_minimum_increment = gail_spin_button_get_minimum_increment;
iface->set_current_value = gail_spin_button_set_current_value;
}
@ -165,6 +168,23 @@ gail_spin_button_get_minimum_value (AtkValue *obj,
atk_value_get_minimum_value (ATK_VALUE (spin_button->adjustment), value);
}
static void
gail_spin_button_get_minimum_increment (AtkValue *obj, GValue *value)
{
GailSpinButton *spin_button;
g_return_if_fail (GAIL_IS_SPIN_BUTTON (obj));
spin_button = GAIL_SPIN_BUTTON (obj);
if (spin_button->adjustment == NULL)
/*
* Adjustment has not been specified
*/
return;
atk_value_get_minimum_increment (ATK_VALUE (spin_button->adjustment), value);
}
static gboolean
gail_spin_button_set_current_value (AtkValue *obj,
const GValue *value)