Add support for increase,decrease action when value text is set 02/316202/2
authorYoungsun Suh <youngsun.suh@samsung.com>
Fri, 16 Aug 2024 00:00:31 +0000 (09:00 +0900)
committerYoungsun Suh <youngsun.suh@samsung.com>
Mon, 19 Aug 2024 08:07:58 +0000 (17:07 +0900)
Change-Id: I57d7dd80654e559f47b8951802b7df211b3cd247

src/navigator.c

index 1b88fbe03ad91d0295ae9693152cbcf23f99741f..c9b958f71a5e93022443ef9cd349ca4a24827432 100644 (file)
@@ -1320,6 +1320,21 @@ TIZEN_PROD_STATIC void _value_dec(NavigatorData *nd, int diff)
        g_object_unref(value_interface);
 }
 
+TIZEN_PROD_STATIC void _do_action_name(NavigatorData *nd, char *action_name)
+{
+       DEBUG("START");
+       AtspiAccessible *obj = NULL;
+
+       if (nd->current_obj == NULL)
+               return;
+
+       obj = _get_currently_controlled_accessible(nd->current_obj);
+       if (obj) {
+               _do_action(obj, action_name);
+               g_object_unref(obj);
+       }
+}
+
 TIZEN_PROD_STATIC void _activate_widget(NavigatorData *nd)
 {
        //activate the widget
@@ -1872,24 +1887,40 @@ TIZEN_PROD_STATIC void _direct_scroll_to_last(NavigatorData *nd)
        DEBUG("END");
 }
 
-TIZEN_PROD_STATIC Eina_Bool _has_value(NavigatorData *nd)
+TIZEN_PROD_STATIC Eina_Bool _has_value_interface(NavigatorData *nd)
+{
+       DEBUG("START");
+       AtspiValue *value_interface = _get_value_interface(nd);
+       if (value_interface) {
+               g_object_unref(value_interface);
+               return EINA_TRUE;
+       }
+
+       return EINA_FALSE;
+}
+
+TIZEN_PROD_STATIC Eina_Bool _has_value_text_attr(NavigatorData *nd)
 {
        DEBUG("START");
        AtspiAccessible *obj = NULL;
+       Eina_Bool has_value_text = EINA_FALSE;
 
        if (nd->current_obj == NULL)
                return EINA_FALSE;
 
        obj = _get_currently_controlled_accessible(nd->current_obj);
-       AtspiValue *value = atspi_accessible_get_value_iface(obj);
-       g_object_unref(obj);
-
-       if (value) {
-               g_object_unref(value);
-               return EINA_TRUE;
+       if (obj) {
+               GHashTable *hash_table = atspi_accessible_get_attributes(obj, NULL);
+               if (hash_table) {
+                       if (get_value_format(hash_table) == ACCESSIBLE_VALUE_FORMAT_TEXT) {
+                               has_value_text = EINA_TRUE;
+                       }
+                       g_hash_table_unref(hash_table);
+               }
+               g_object_unref(obj);
        }
 
-       return EINA_FALSE;
+       return has_value_text;
 }
 
 TIZEN_PROD_STATIC Eina_Bool _is_enabled(NavigatorData *nd)
@@ -1983,6 +2014,12 @@ TIZEN_PROD_STATIC void _move_slider(NavigatorData *nd, Gesture_Info *gi)
                return;
        }
 
+       if (!_has_value_interface(nd)) {
+               DEBUG("no value interface");
+               nd->prepared = false;
+               return;
+       }
+
        if (gi == NULL) {
                ERROR("NULL gesture");
                return;
@@ -2339,9 +2376,11 @@ TIZEN_PROD_STATIC void on_gesture_detected(void *data, const Eldbus_Message *msg
                                _caret_move_backward(nd);
                        else
                                _select_text_forward(nd, EINA_FALSE);
-               } else if (_has_value(nd) && _is_enabled(nd))
+               } else if (_has_value_interface(nd) && _is_enabled(nd)) {
                        _value_inc(nd, 0);
-               else {
+               } else if (_has_value_text_attr(nd) && _is_enabled(nd)) {
+                       _do_action_name(nd, "increment");
+               } else {
                        if (_granularity_text_read(nd, EINA_FALSE)) break;
                        _focus_prev(nd);
                }
@@ -2352,9 +2391,11 @@ TIZEN_PROD_STATIC void on_gesture_detected(void *data, const Eldbus_Message *msg
                                _caret_move_forward(nd);
                        else
                                _select_text_forward(nd, EINA_TRUE);
-               } else if (_has_value(nd) && _is_enabled(nd))
+               } else if (_has_value_interface(nd) && _is_enabled(nd)) {
                        _value_dec(nd, 0);
-               else {
+               } else if (_has_value_text_attr(nd) && _is_enabled(nd)) {
+                       _do_action_name(nd, "decrement");
+               } else {
                        if (_granularity_text_read(nd, EINA_TRUE)) break;
                        _focus_next(nd);
                }