From 837528201f7761123974bcefef56b02967d758e6 Mon Sep 17 00:00:00 2001 From: Marcel Hollerbach Date: Wed, 18 Dec 2019 17:18:35 +0100 Subject: [PATCH] efl_ui_format: make this usable with the standard behaviour of accessors 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 Differential Revision: https://phab.enlightenment.org/D10909 --- src/bin/elementary/test_ui_spin_button.c | 2 +- src/lib/elementary/efl_ui_format.c | 4 ++-- src/tests/elementary/spec/efl_test_format.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bin/elementary/test_ui_spin_button.c b/src/bin/elementary/test_ui_spin_button.c index 62f7a43562..4692075b10 100644 --- a/src/bin/elementary/test_ui_spin_button.c +++ b/src/bin/elementary/test_ui_spin_button.c @@ -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)); diff --git a/src/lib/elementary/efl_ui_format.c b/src/lib/elementary/efl_ui_format.c index d3cafa1e5a..c4dc85353d 100644 --- a/src/lib/elementary/efl_ui_format.c +++ b/src/lib/elementary/efl_ui_format.c @@ -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); diff --git a/src/tests/elementary/spec/efl_test_format.c b/src/tests/elementary/spec/efl_test_format.c index c3fa7d42f5..7540829edc 100644 --- a/src/tests/elementary/spec/efl_test_format.c +++ b/src/tests/elementary/spec/efl_test_format.c @@ -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);