Add support for increase,decrease action when value text is set 82/316982/1
authorYoungsun Suh <youngsun.suh@samsung.com>
Fri, 16 Aug 2024 00:00:31 +0000 (09:00 +0900)
committerYoungsun Suh <youngsun.suh@samsung.com>
Mon, 2 Sep 2024 06:46:18 +0000 (06:46 +0000)
Change-Id: I57d7dd80654e559f47b8951802b7df211b3cd247
(cherry picked from commit 2829bf8356d8b5940477d11fcebe6c0ce1a434b4)

src/navigator.c

index e9eab4d832b6bc0c3d943ed5887fab8e08000a79..22d4c156aae73ef0ea02c7fdc4f73a5e8e0c19cd 100644 (file)
@@ -1290,6 +1290,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
@@ -1842,24 +1857,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)
@@ -1953,6 +1984,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;
@@ -2312,9 +2349,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);
                }
@@ -2325,9 +2364,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);
                }