efl_ui_format: make this usable with the standard behaviour of accessors accepted/tizen/unified/20191219.143707 submit/tizen/20191218.210005
authorMarcel Hollerbach <mail@marcel-hollerbach.de>
Wed, 18 Dec 2019 16:18:35 +0000 (17:18 +0100)
committerJongmin Lee <jm105.lee@samsung.com>
Wed, 18 Dec 2019 20:56:57 +0000 (05:56 +0900)
a accessor is never delivering a value, only the pointer to a value.
This makes format working with accessors for list array carray.

Reviewed-by: Cedric BAIL <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D10909

src/bin/elementary/test_ui_spin_button.c
src/lib/elementary/efl_ui_format.c
src/tests/elementary/spec/efl_test_format.c

index 62f7a43..4692075 100644 (file)
@@ -57,7 +57,7 @@ test_ui_spin_button(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *
            efl_ui_range_limits_set(efl_added, 1, 12),
            efl_ui_range_value_set(efl_added, 1),
            efl_ui_spin_button_direct_text_input_set(efl_added, EINA_FALSE),
-           efl_ui_format_values_set(efl_added, EINA_C_ARRAY_ACCESSOR_NEW(special_values)),
+           efl_ui_format_values_set(efl_added, EINA_C_ARRAY_ACCESSOR_PTR_NEW(special_values)),
            efl_ui_layout_orientation_set(efl_added, EFL_UI_LAYOUT_ORIENTATION_VERTICAL),
            efl_pack(bx, efl_added));
 
index d3cafa1..c4dc853 100644 (file)
@@ -195,7 +195,7 @@ _value_compare(const Efl_Ui_Format_Value *val1, const Efl_Ui_Format_Value *val2)
 EOLIAN static void
 _efl_ui_format_format_values_set(Eo *obj, Efl_Ui_Format_Data *pd, Eina_Accessor *values)
 {
-   Efl_Ui_Format_Value v;
+   Efl_Ui_Format_Value *v;
    int i;
    if (pd->format_values)
      {
@@ -219,7 +219,7 @@ _efl_ui_format_format_values_set(Eo *obj, Efl_Ui_Format_Data *pd, Eina_Accessor
    pd->format_values = eina_inarray_new(sizeof(Efl_Ui_Format_Value), 4);
    EINA_ACCESSOR_FOREACH(values, i, v)
      {
-        Efl_Ui_Format_Value vcopy = { v.value, eina_stringshare_add(v.text) };
+        Efl_Ui_Format_Value vcopy = { v->value, eina_stringshare_add(v->text) };
         eina_inarray_insert_sorted(pd->format_values, &vcopy, (Eina_Compare_Cb)_value_compare);
      }
    eina_accessor_free(values);
index c3fa7d4..7540829 100644 (file)
@@ -24,7 +24,7 @@ EFL_START_TEST(format_values)
   Eina_Strbuf *buf = eina_strbuf_new();
   Eina_Value eina_val;
 
-  efl_ui_format_values_set(widget, EINA_C_ARRAY_ACCESSOR_NEW(values));
+  efl_ui_format_values_set(widget, EINA_C_ARRAY_ACCESSOR_PTR_NEW(values));
   eina_val = eina_value_int_init(17);
   efl_ui_format_formatted_value_get(widget, buf, eina_val);
   ck_assert_str_eq(eina_strbuf_string_get(buf), "seventeen"); // Check that value works
@@ -141,7 +141,7 @@ EFL_START_TEST(format_mixed)
 
   // Now we check combinations of different options
   // Each one should be used in turn when the previous one fails: values, func, string, fallback
-  efl_ui_format_values_set(widget, EINA_C_ARRAY_ACCESSOR_NEW(values));
+  efl_ui_format_values_set(widget, EINA_C_ARRAY_ACCESSOR_PTR_NEW(values));
   efl_ui_format_func_set(widget, NULL, _partial_format_func, NULL);
   efl_ui_format_string_set(widget, "%d rabbits", EFL_UI_FORMAT_STRING_TYPE_SIMPLE);