return;
}
-TIZEN_PROD_STATIC void _value_inc(NavigatorData *nd, int diff)
+TIZEN_PROD_STATIC AtspiValue *_get_value_interface(NavigatorData *nd)
{
AtspiAccessible *current_widget = NULL;
- GError *err = NULL;
if (!nd || !nd->current_obj)
- return;
+ return NULL;
current_widget = _get_currently_controlled_accessible(nd->current_obj);
AtspiValue *value_interface = atspi_accessible_get_value_iface(current_widget);
g_object_unref(current_widget);
- if (value_interface) {
- DEBUG("Value interface supported!\n");
- gdouble current_val = atspi_value_get_current_value(value_interface, &err);
- GERROR_CHECK(err)
- DEBUG("Current value: %f\n ", (double)current_val);
- gdouble minimum_inc = atspi_value_get_minimum_increment(value_interface, &err);
- DEBUG("Minimum increment: %f\n ", (double)minimum_inc);
- GERROR_CHECK(err)
- gdouble maximum_val = atspi_value_get_maximum_value(value_interface, &err);
- GERROR_CHECK(err)
- if (diff)
- atspi_value_set_current_value(value_interface, ((current_val + diff * nd->slider_offset) > maximum_val) ? maximum_val : (current_val + diff * nd->slider_offset), &err);
- else
- atspi_value_set_current_value(value_interface, current_val + minimum_inc, &err);
+ return value_interface;
+}
+
+TIZEN_PROD_STATIC void _value_inc(NavigatorData *nd, int diff)
+{
+ AtspiValue *value_interface = _get_value_interface(nd);
+ GError *err = NULL;
+
+ if (!value_interface) {
+ ERROR("No value interface supported!\n");
+ return;
+ }
+
+ DEBUG("Value interface supported!\n");
+ gdouble current_val = atspi_value_get_current_value(value_interface, &err);
+ if (err) {
GERROR_CHECK(err)
g_object_unref(value_interface);
return;
}
- ERROR("No value interface supported!\n");
+
+ DEBUG("Current value: %f\n ", (double)current_val);
+ gdouble minimum_inc = atspi_value_get_minimum_increment(value_interface, &err);
+ GERROR_CHECK(err)
+ DEBUG("Minimum increment: %f\n ", (double)minimum_inc);
+ gdouble maximum_val = atspi_value_get_maximum_value(value_interface, &err);
+ GERROR_CHECK(err)
+ DEBUG("Maximum value: %f\n ", (double)maximum_val);
+
+ gdouble val = current_val;
+ if (diff){
+ val += diff * nd->slider_offset;
+ DEBUG("new value slide %f", (double)val);
+ } else {
+ if (minimum_inc <= 0.001) {
+ gdouble minimum_val = atspi_value_get_minimum_value(value_interface, &err);
+ GERROR_CHECK(err)
+ minimum_inc = (maximum_val - minimum_val) / 20.0; // 5%
+ DEBUG("adjust min inc %f", (double)minimum_inc);
+ }
+
+ val += minimum_inc;
+ DEBUG("new value %f", (double)val);
+ }
+
+ if (val > maximum_val) {
+ val = maximum_val;
+ DEBUG("max value %f", (double)val);
+ }
+
+ if (val != current_val) {
+ atspi_value_set_current_value(value_interface, val, &err);
+ GERROR_CHECK(err)
+ }
+ g_object_unref(value_interface);
+
+ return;
}
TIZEN_PROD_STATIC void _value_dec(NavigatorData *nd, int diff)
{
- AtspiAccessible *current_widget = NULL;
+ AtspiValue *value_interface = _get_value_interface(nd);
GError *err = NULL;
- if (nd->current_obj == NULL)
+ if (!value_interface) {
+ ERROR("No value interface supported!\n");
return;
+ }
- current_widget = _get_currently_controlled_accessible(nd->current_obj);
- AtspiValue *value_interface = atspi_accessible_get_value_iface(current_widget);
- g_object_unref(current_widget);
+ DEBUG("Value interface supported!\n");
- if (value_interface) {
- DEBUG("Value interface supported!\n");
- gdouble current_val = atspi_value_get_current_value(value_interface, &err);
- GERROR_CHECK(err)
- DEBUG("Current value: %f\n ", (double)current_val);
- gdouble minimum_inc = atspi_value_get_minimum_increment(value_interface, &err);
- GERROR_CHECK(err)
- DEBUG("Minimum increment: %f\n ", (double)minimum_inc);
- gdouble minimum_val = atspi_value_get_minimum_value(value_interface, &err);
- GERROR_CHECK(err)
- if (diff)
- atspi_value_set_current_value(value_interface, ((current_val - diff * nd->slider_offset) < minimum_val) ? minimum_val : (current_val - diff * nd->slider_offset), &err);
- else
- atspi_value_set_current_value(value_interface, current_val - minimum_inc, &err);
+ gdouble current_val = atspi_value_get_current_value(value_interface, &err);
+ GERROR_CHECK(err)
+ DEBUG("Current value: %f\n ", (double)current_val);
+ gdouble minimum_inc = atspi_value_get_minimum_increment(value_interface, &err);
+ GERROR_CHECK(err)
+ DEBUG("Minimum increment: %f\n ", (double)minimum_inc);
+ gdouble minimum_val = atspi_value_get_minimum_value(value_interface, &err);
+ GERROR_CHECK(err)
+ DEBUG("Minimum value: %f\n ", (double)minimum_val);
+
+ gdouble val = current_val;
+ if (diff){
+ val -= diff * nd->slider_offset;
+ DEBUG("new value slide %f", (double)val);
+ } else {
+ if (minimum_inc <= 0.001) {
+ gdouble maximum_val = atspi_value_get_maximum_value(value_interface, &err);
+ GERROR_CHECK(err)
+ minimum_inc = (maximum_val - minimum_val) / 20.0; // 5%
+ DEBUG("adjust min inc %f", (double)minimum_inc);
+ }
+
+ val -= minimum_inc;
+ DEBUG("new value %f", (double)val);
+ }
+
+ if (val < minimum_val) {
+ val = minimum_val;
+ DEBUG("min value %f", (double)val);
+ }
+
+ if (val != current_val) {
+ atspi_value_set_current_value(value_interface, val, &err);
GERROR_CHECK(err)
- g_object_unref(value_interface);
- return;
}
- ERROR("No value interface supported!\n");
+ g_object_unref(value_interface);
+ return;
}
TIZEN_PROD_STATIC void _activate_widget(NavigatorData *nd)