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 <cedric.bail@free.fr>
Differential Revision: https://phab.enlightenment.org/D10909
This commit is contained in:
Marcel Hollerbach 2019-12-18 17:18:35 +01:00
parent 9ccc66b900
commit 837528201f
3 changed files with 5 additions and 5 deletions

View 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));

View 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);

View 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);