This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch master
in repository efl.
View the commit online.
commit 502af2fd9bd8db6abeaaaafea0a6388d8bc63bdc
Author: Cedric BAIL <[email protected]>
AuthorDate: Mon Oct 26 10:59:36 2026 -0600
elementary: an image factory binds the key it is given, so icons work
Efl.Ui.Image_Factory took a key in property_bind and ignored it,
always binding each image's "filename". A view could show files that
way but not named icons, which Efl.Ui.Image itself binds with the key
"icon" -- a list of weather conditions, of file types, of anything
with a standard icon had to resolve every name to a path first.
The key now says what the property holds, as it does for every other
factory: "icon" for an icon name, "filename" for a file. No key keeps
meaning a file, which is what the examples pass. Nothing tested the
factory before; the test builds an item each way.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/elementary/efl_ui_image_factory.c | 11 ++++-
src/lib/elementary/efl_ui_image_factory.eo | 10 +++-
src/tests/elementary/efl_ui_test_image.c | 78 ++++++++++++++++++++++++++++++
3 files changed, 96 insertions(+), 3 deletions(-)
diff --git a/src/lib/elementary/efl_ui_image_factory.c b/src/lib/elementary/efl_ui_image_factory.c
index f8034040aa..7e0e48f8a9 100644
--- a/src/lib/elementary/efl_ui_image_factory.c
+++ b/src/lib/elementary/efl_ui_image_factory.c
@@ -12,6 +12,7 @@
typedef struct _Efl_Ui_Image_Factory_Data
{
+ Eina_Stringshare *key; /* what of the image is bound: its file or its icon */
Eina_Stringshare *property;
} Efl_Ui_Image_Factory_Data;
@@ -21,7 +22,7 @@ _efl_ui_image_factory_building(void *data, const Efl_Event *ev)
Efl_Ui_Image_Factory_Data *pd = data;
Efl_Gfx_Entity *ui_view = ev->info;
- efl_ui_property_bind(ui_view, "filename", pd->property);
+ efl_ui_property_bind(ui_view, pd->key ? pd->key : "filename", pd->property);
}
EOLIAN static Eo *
@@ -40,6 +41,8 @@ _efl_ui_image_factory_efl_object_constructor(Eo *obj, Efl_Ui_Image_Factory_Data
EOLIAN static void
_efl_ui_image_factory_efl_object_destructor(Eo *obj EINA_UNUSED, Efl_Ui_Image_Factory_Data *pd)
{
+ eina_stringshare_del(pd->key);
+ pd->key = NULL;
eina_stringshare_del(pd->property);
pd->property = NULL;
@@ -55,8 +58,12 @@ _efl_ui_image_factory_efl_ui_factory_create(Eo *obj, Efl_Ui_Image_Factory_Data *
}
EOLIAN static Eina_Error
-_efl_ui_image_factory_efl_ui_property_bind_property_bind(Eo *obj EINA_UNUSED, Efl_Ui_Image_Factory_Data *pd, const char *key EINA_UNUSED, const char *property)
+_efl_ui_image_factory_efl_ui_property_bind_property_bind(Eo *obj EINA_UNUSED, Efl_Ui_Image_Factory_Data *pd, const char *key, const char *property)
{
+ /* The key is what of each image the property sets: "icon" for a named
+ icon, "filename" or no key for a file. */
+ if (!key || !key[0]) key = "filename";
+ eina_stringshare_replace(&pd->key, key);
eina_stringshare_replace(&pd->property, property);
return 0;
}
diff --git a/src/lib/elementary/efl_ui_image_factory.eo b/src/lib/elementary/efl_ui_image_factory.eo
index 5ebcc1cd32..02b2732556 100644
--- a/src/lib/elementary/efl_ui_image_factory.eo
+++ b/src/lib/elementary/efl_ui_image_factory.eo
@@ -1,6 +1,14 @@
class @beta Efl.Ui.Image_Factory extends Efl.Ui.Caching_Factory
{
- [[Efl UI image factory class]]
+ [[An @Efl.Ui.Factory that builds @Efl.Ui.Image objects from a model.
+
+ Bind a model property with @Efl.Ui.Property_Bind.property_bind and the
+ images it names are what the view shows. The key says what the property
+ holds: "filename" (or no key) for a file's path, "icon" for an icon's
+ name, as @Efl.Ui.Image.icon takes it. Being an @Efl.Ui.Caching_Factory,
+ it keeps the objects it has built for reuse, which is what makes
+ scrolling a long list of images affordable.
+ ]]
implements {
Efl.Object.constructor;
Efl.Object.destructor;
diff --git a/src/tests/elementary/efl_ui_test_image.c b/src/tests/elementary/efl_ui_test_image.c
index 0160684132..6923d4d55c 100644
--- a/src/tests/elementary/efl_ui_test_image.c
+++ b/src/tests/elementary/efl_ui_test_image.c
@@ -30,6 +30,83 @@ EFL_START_TEST(efl_ui_image_test_icon)
}
EFL_END_TEST
+typedef struct
+{
+ const char *icon;
+ const char *file;
+ int built;
+} Factory_Check;
+
+static Eina_Value
+_factory_built(Eo *o EINA_UNUSED, void *data, const Eina_Value v)
+{
+ Factory_Check *check = data;
+ unsigned int i, len;
+ Eo *item;
+
+ EINA_VALUE_ARRAY_FOREACH(&v, len, i, item)
+ {
+ if (check->icon)
+ ck_assert_str_eq(efl_ui_image_icon_get(item), check->icon);
+ if (check->file)
+ ck_assert_str_eq(efl_file_get(item), check->file);
+ check->built++;
+ }
+ efl_loop_quit(efl_main_loop_get(), EINA_VALUE_EMPTY);
+ return v;
+}
+
+static Eina_Value
+_factory_failed(Eo *o EINA_UNUSED, void *data EINA_UNUSED, Eina_Error err)
+{
+ efl_loop_quit(efl_main_loop_get(), EINA_VALUE_EMPTY);
+ return eina_value_error_init(err);
+}
+
+static void
+_factory_build(Eo *factory, Eo *child, Factory_Check *check)
+{
+ Eo *models[] = { child };
+ Eina_Future *f;
+
+ f = efl_ui_view_factory_create_with_event(factory, EINA_C_ARRAY_ITERATOR_NEW(models));
+ efl_future_then(factory, f, .success = _factory_built, .error = _factory_failed,
+ .success_type = EINA_VALUE_TYPE_ARRAY, .data = ""
+ ecore_main_loop_begin();
+}
+
+/* An image factory binds the property its key names, as every factory does:
+ "icon" shows a named icon, and a file -- the key "filename", or none -- is
+ what it always did. */
+EFL_START_TEST(efl_ui_image_factory_binds_its_key)
+{
+ Factory_Check by_icon = { "folder", NULL, 0 };
+ Factory_Check by_file = { NULL, ELM_IMAGE_DATA_DIR"/images/logo.png", 0 };
+ Eo *win, *model, *child, *factory;
+ Eina_Value *v;
+
+ win = win_add(NULL, "image", EFL_UI_WIN_TYPE_BASIC);
+ model = efl_add(EFL_GENERIC_MODEL_CLASS, win);
+ child = efl_model_child_add(model);
+ v = eina_value_string_new("folder");
+ efl_model_property_set(child, "sky", v);
+ eina_value_free(v);
+ v = eina_value_string_new(ELM_IMAGE_DATA_DIR"/images/logo.png");
+ efl_model_property_set(child, "path", v);
+ eina_value_free(v);
+
+ factory = efl_add(EFL_UI_IMAGE_FACTORY_CLASS, win);
+ efl_ui_property_bind(factory, "icon", "sky");
+ _factory_build(factory, child, &by_icon);
+ ck_assert_int_eq(by_icon.built, 1);
+
+ factory = efl_add(EFL_UI_IMAGE_FACTORY_CLASS, win);
+ efl_ui_property_bind(factory, "", "path");
+ _factory_build(factory, child, &by_file);
+ ck_assert_int_eq(by_file.built, 1);
+}
+EFL_END_TEST
+
extern Eo *elm_image_object_get(Eo*);
EFL_START_TEST(efl_ui_image_test_border_insets_before_load)
{
@@ -170,6 +247,7 @@ void efl_ui_test_image(TCase *tc)
{
tcase_add_test(tc, efl_ui_image_test_icon);
tcase_add_test(tc, efl_ui_image_test_border_insets_before_load);
+ tcase_add_test(tc, efl_ui_image_factory_binds_its_key);
tcase_add_test(tc, efl_ui_image_test_scale_method);
tcase_add_test(tc, efl_ui_image_test_load_size_bounds_the_decode);
tcase_add_test(tc, efl_ui_image_test_mmap_set_null);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.