This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch main
in repository elaro.

View the commit online.

commit c6044f634cefe095e84bf66ec84da231fdf2a21d
Author: Alastair Poole <[email protected]>
AuthorDate: Sat Nov 28 14:33:24 2026 +0000

    image: hide progress on load. show open browser
---
 NEWS                           |  12 ++-
 src/fe-efl/ui/elaro_ui_image.c | 225 ++++++++++++++++++++++++++---------------
 tests/fe-efl/meson.build       |   3 +-
 tests/fe-efl/test-links.c      |  49 ++++++++-
 4 files changed, 201 insertions(+), 88 deletions(-)

diff --git a/NEWS b/NEWS
index 5cd2ca4..a332887 100644
--- a/NEWS
+++ b/NEWS
@@ -1,11 +1,17 @@
+===========
+Elaro 0.1.4
+===========
+
+  * The chat history uses full-height themed dividers with padding between the timestamp, nickname, and message columns.
+  * Chat nicknames appear without angle brackets and use colors from the active theme’s palette.
+  * Default Elementary popups use a compact, flat close button in the top-right corner.
+  * Image previews fill the available space and can open the original image in the browser.
+
 ===========
 Elaro 0.1.3
 ===========
 
   * Icons now match each theme’s accent color.
-  * The chat history uses full-height themed dividers with padding between the timestamp, nickname, and message columns.
-  * Chat nicknames appear without angle brackets and use colors from the active theme’s palette.
-  * Default Elementary popups use a compact, flat close button in the top-right corner.
 
 ===========
 Elaro 0.1.2
diff --git a/src/fe-efl/ui/elaro_ui_image.c b/src/fe-efl/ui/elaro_ui_image.c
index b877ad6..c4d1f7d 100644
--- a/src/fe-efl/ui/elaro_ui_image.c
+++ b/src/fe-efl/ui/elaro_ui_image.c
@@ -1,143 +1,202 @@
 #include "elaro_ui_private.h"
 
+typedef struct
+{
+   Elaro_Ui *ui;
+   char *url;
+   Evas_Object *box, *size, *status, *pulse;
+   int image_width, image_height;
+} Image_Preview;
+
+static void
+_preview_resize_cb(void *data, Evas *evas, Evas_Object *obj, void *info)
+{
+   Image_Preview *preview = data;
+   int width, height;
+
+   evas_object_geometry_get(preview->ui->win, NULL, NULL, &width, &height);
+   if (preview->image_width > 0 && preview->image_height > 0)
+     {
+        double scale;
+
+        /* Leave space for the popup header, browser action, and theme insets. */
+        width = MAX(1, width - ELM_SCALE_SIZE(64));
+        height = MAX(1, height - ELM_SCALE_SIZE(112));
+        scale = MIN((double) width / preview->image_width, (double) height / preview->image_height);
+        width = MAX(1, (int) (preview->image_width * scale + 0.5));
+        height = MAX(1, (int) (preview->image_height * scale + 0.5));
+     }
+   else
+     {
+        width = MIN(ELM_SCALE_SIZE(390), MAX(1, width - ELM_SCALE_SIZE(64)));
+        height = MIN(ELM_SCALE_SIZE(270), MAX(1, height - ELM_SCALE_SIZE(150)));
+     }
+   evas_object_size_hint_min_set(preview->size, width, height);
+}
+
 static void
 _preview_deleted_cb(void *data, Evas *evas, Evas_Object *obj, void *info)
 {
-   ((Elaro_Ui *) data)->preview = NULL;
+   Image_Preview *preview = data;
+
+   preview->ui->preview = NULL;
+   evas_object_event_callback_del_full(preview->ui->win, EVAS_CALLBACK_RESIZE,
+                                       _preview_resize_cb, preview);
+}
+
+static void
+_preview_free_cb(void *data, Evas *evas, Evas_Object *obj, void *info)
+{
+   Image_Preview *preview = data;
+
+   free(preview->url);
+   free(preview);
 }
 
 static void
 _preview_close_cb(void *data, Evas_Object *obj, void *info)
 {
-   Elaro_Ui *ui;
-
-   ui = data;
+   Elaro_Ui *ui = data;
 
    if (ui->preview) evas_object_del(ui->preview);
 }
 
 static void
-_image_progress_show(Evas_Object *progress)
+_preview_open_cb(void *data, Evas_Object *obj, void *info)
 {
-   Evas_Object *pulse;
-   Evas_Object *box;
+   Image_Preview *preview = data;
 
-   pulse = evas_object_data_get(progress, "pulse");
+   elaro_ui_external_link_open(preview->ui, preview->url);
+}
 
-   if (!pulse) return;
-
-   box = elm_object_parent_widget_get(progress);
-   elm_box_pack_before(box, progress, pulse);
-   elm_box_unpack(box, pulse);
-   evas_object_del(pulse);
-   evas_object_data_del(progress, "pulse");
-   evas_object_show(progress);
+static void
+_image_progress_show(Image_Preview *preview)
+{
+   if (!preview->pulse) return;
+   elm_box_pack_before(preview->box, preview->status, preview->pulse);
+   evas_object_del(preview->pulse);
+   preview->pulse = NULL;
+   evas_object_show(preview->status);
 }
 
 static void
 _image_done_cb(void *data, Evas_Object *obj, void *info)
 {
-   _image_progress_show(data);
-   elm_progressbar_value_set(data, 1.0);
-   elm_object_text_set(data, _("Image ready"));
+   Image_Preview *preview = data;
+
+   if (!preview->status) return;
+   elm_image_object_size_get(obj, &preview->image_width, &preview->image_height);
+   if (preview->image_width <= 0 || preview->image_height <= 0) return;
+   if (preview->pulse) evas_object_del(preview->pulse);
+   evas_object_del(preview->status);
+   preview->pulse = NULL;
+   preview->status = NULL;
+   _preview_resize_cb(preview, NULL, NULL, NULL);
 }
 
 static void
 _image_error_cb(void *data, Evas_Object *obj, void *info)
 {
-   _image_progress_show(data);
-   elm_progressbar_value_set(data, 0.0);
-   elm_progressbar_unit_format_set(data, "");
-   elm_object_text_set(data, _("Image unavailable"));
-   elm_object_tooltip_text_set(data, _("Could not load this image."));
+   Image_Preview *preview = data;
+
+   if (!preview->status) return;
+   _image_progress_show(preview);
+   elm_progressbar_value_set(preview->status, 0.0);
+   elm_progressbar_unit_format_set(preview->status, "");
+   elm_object_text_set(preview->status, _("Image unavailable"));
+   elm_object_tooltip_text_set(preview->status, _("Could not load this image."));
 }
 
 static void
 _image_progress_cb(void *data, Evas_Object *obj, void *info)
 {
-   Elm_Image_Progress *progress;
+   Image_Preview *preview = data;
+   Elm_Image_Progress *progress = info;
 
-   progress = info;
-
-   if (!progress || progress->total <= 0) return;
-
-   _image_progress_show(data);
-   elm_progressbar_value_set(data, ELARO_CLAMP(progress->now / progress->total, 0.0, 0.99));
+   if (!preview->status || !progress || progress->total <= 0) return;
+   _image_progress_show(preview);
+   elm_progressbar_value_set(preview->status, ELARO_CLAMP(progress->now / progress->total, 0.0, 0.99));
 }
 
 void
 elaro_ui_image_preview(Elaro_Ui *ui, const char *url)
 {
-   Evas_Object *box;
+   Image_Preview *preview;
    Evas_Object *viewport;
-   Evas_Object *size;
    Evas_Object *image;
-   Evas_Object *status;
-   Evas_Object *pulse;
-   int width;
-   int height;
+   Evas_Object *open;
+
+   preview = calloc(1, sizeof(*preview));
+   if (!preview) return;
+   preview->url = ""
+   if (!preview->url)
+     {
+        free(preview);
+        return;
+     }
+   preview->ui = ui;
 
    if (ui->preview) evas_object_del(ui->preview);
-
    ui->preview = elm_popup_add(ui->win);
    elm_object_part_text_set(ui->preview, "title,text", _("Image preview"));
    evas_object_smart_callback_add(ui->preview, "dismissed", _preview_close_cb, ui);
-   evas_object_event_callback_add(ui->preview, EVAS_CALLBACK_DEL, _preview_deleted_cb, ui);
+   evas_object_event_callback_add(ui->preview, EVAS_CALLBACK_DEL, _preview_deleted_cb, preview);
+   evas_object_event_callback_add(ui->preview, EVAS_CALLBACK_FREE, _preview_free_cb, preview);
 
-   box = elaro_ui_media_box_add(ui->preview, url, _("Image"));
+   preview->box = elm_box_add(ui->preview);
+   elaro_ui_box_padding_set(preview->box, 0, 6);
+   elm_object_content_set(ui->preview, preview->box);
+   evas_object_show(preview->box);
 
-   viewport = elm_table_add(box);
-   evas_object_size_hint_weight_set(viewport, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-   evas_object_size_hint_align_set(viewport, EVAS_HINT_FILL, EVAS_HINT_FILL);
-
-   evas_object_geometry_get(ui->win, NULL, NULL, &width, &height);
-
-   size = evas_object_rectangle_add(evas_object_evas_get(viewport));
-   evas_object_color_set(size, 0, 0, 0, 0);
-   evas_object_pass_events_set(size, EINA_TRUE);
-   elaro_ui_size_min_set(size,
-                                 MIN(390, MAX(75, width - 102)),
-                                 MIN(270, MAX(75, height - 225)));
-   elm_table_pack(viewport, size, 0, 0, 1, 1);
-   evas_object_show(size);
+   viewport = elm_table_add(preview->box);
+   elaro_ui_expand(viewport);
+   preview->size = evas_object_rectangle_add(evas_object_evas_get(viewport));
+   evas_object_color_set(preview->size, 0, 0, 0, 0);
+   evas_object_pass_events_set(preview->size, EINA_TRUE);
+   elm_table_pack(viewport, preview->size, 0, 0, 1, 1);
+   evas_object_show(preview->size);
 
    image = elm_image_add(viewport);
-   elm_image_resizable_set(image, EINA_FALSE, EINA_TRUE);
+   elm_image_resizable_set(image, EINA_TRUE, EINA_TRUE);
    elm_image_aspect_fixed_set(image, EINA_TRUE);
-   evas_object_size_hint_weight_set(image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-   evas_object_size_hint_align_set(image, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   elaro_ui_expand(image);
    elm_table_pack(viewport, image, 0, 0, 1, 1);
    evas_object_show(image);
-   elm_box_pack_end(box, viewport);
+   elm_box_pack_end(preview->box, viewport);
    evas_object_show(viewport);
 
-   status = elm_progressbar_add(box);
-   evas_object_size_hint_weight_set(status, EVAS_HINT_EXPAND, 0);
-   evas_object_size_hint_align_set(status, EVAS_HINT_FILL, 0.5);
-   /* Span sizes are logical pixels; Elementary applies the UI scale itself. */
-   elm_progressbar_span_size_set(status, 135);
-   elm_progressbar_unit_format_set(status, "%.0f%%");
-   elm_object_text_set(status, _("Loading image…"));
-   /* Keep pulse and fraction widgets separate so theme animation state cannot leak. */
+   preview->status = elm_progressbar_add(preview->box);
+   evas_object_size_hint_weight_set(preview->status, EVAS_HINT_EXPAND, 0);
+   evas_object_size_hint_align_set(preview->status, EVAS_HINT_FILL, 0.5);
+   elm_progressbar_span_size_set(preview->status, 135);
+   elm_progressbar_unit_format_set(preview->status, "%.0f%%");
+   elm_object_text_set(preview->status, _("Loading image…"));
 
-   pulse = elm_progressbar_add(box);
-   evas_object_size_hint_weight_set(pulse, EVAS_HINT_EXPAND, 0);
-   evas_object_size_hint_align_set(pulse, EVAS_HINT_FILL, 0.5);
-   elm_progressbar_span_size_set(pulse, elm_progressbar_span_size_get(status));
-   elm_object_text_set(pulse, _("Loading image…"));
-   elm_progressbar_pulse_set(pulse, EINA_TRUE);
-   elm_progressbar_pulse(pulse, EINA_TRUE);
-   evas_object_data_set(status, "pulse", pulse);
-   elm_box_pack_end(box, pulse);
-   evas_object_show(pulse);
-   /* Elementary downloads HTTP(S) images asynchronously and cancels on deletion. */
-   evas_object_smart_callback_add(image, "download,progress", _image_progress_cb, status);
-   evas_object_smart_callback_add(image, "download,done", _image_done_cb, status);
-   evas_object_smart_callback_add(image, "download,error", _image_error_cb, status);
-   evas_object_smart_callback_add(image, "load,error", _image_error_cb, status);
-   evas_object_smart_callback_add(image, "load,ready", _image_done_cb, status);
+   /* Keep pulse and fraction widgets separate so theme animation state cannot leak. */
+   preview->pulse = elm_progressbar_add(preview->box);
+   evas_object_size_hint_weight_set(preview->pulse, EVAS_HINT_EXPAND, 0);
+   evas_object_size_hint_align_set(preview->pulse, EVAS_HINT_FILL, 0.5);
+   elm_progressbar_span_size_set(preview->pulse, elm_progressbar_span_size_get(preview->status));
+   elm_object_text_set(preview->pulse, _("Loading image…"));
+   elm_progressbar_pulse_set(preview->pulse, EINA_TRUE);
+   elm_progressbar_pulse(preview->pulse, EINA_TRUE);
+   elm_box_pack_end(preview->box, preview->pulse);
+   evas_object_show(preview->pulse);
+
+   open = elm_button_add(preview->box);
+   elm_object_text_set(open, _("Open image in browser"));
+   evas_object_smart_callback_add(open, "clicked", _preview_open_cb, preview);
+   elm_box_pack_end(preview->box, open);
+   evas_object_show(open);
    elaro_ui_popup_close_button_add(ui, ui->preview, _preview_close_cb, ui);
 
-   if (!elm_image_file_set(image, url, NULL)) _image_error_cb(status, image, NULL);
+   evas_object_event_callback_add(ui->win, EVAS_CALLBACK_RESIZE, _preview_resize_cb, preview);
+   _preview_resize_cb(preview, NULL, NULL, NULL);
+   /* Elementary downloads HTTP(S) images asynchronously and cancels on deletion. */
+   evas_object_smart_callback_add(image, "download,progress", _image_progress_cb, preview);
+   evas_object_smart_callback_add(image, "download,error", _image_error_cb, preview);
+   evas_object_smart_callback_add(image, "load,error", _image_error_cb, preview);
+   evas_object_smart_callback_add(image, "load,ready", _image_done_cb, preview);
+   if (!elm_image_file_set(image, url, NULL)) _image_error_cb(preview, image, NULL);
    evas_object_show(ui->preview);
 }
diff --git a/tests/fe-efl/meson.build b/tests/fe-efl/meson.build
index e19dc1f..1269c4c 100644
--- a/tests/fe-efl/meson.build
+++ b/tests/fe-efl/meson.build
@@ -74,12 +74,13 @@ test('Music playback helper', python,
   args : [files('music.py'), elaro_efl], timeout : 40)
 
 links_test = executable('test-links', 'test-links.c',
+  '../../src/fe-efl/ui/elaro_ui_image.c',
   '../../src/fe-efl/ui/elaro_ui_util.c',
   include_directories : rootinc,
   link_with : config_lib,
   dependencies : [dep[0], elementary_dep, eet_dep, ecore_file_dep])
 test('External link confirmation', python,
-  args : [files('isolated.py'), links_test], timeout : 15,
+  args : [files('isolated.py'), links_test, files('../../data/images/elaro-128.png')], timeout : 15,
   env : ['ELM_ENGINE=buffer', 'ECORE_NO_SYSTEM_MODULES=1', 'EINA_LOG_LEVEL=0'])
 
 ecore_dep = dependency('ecore')
diff --git a/tests/fe-efl/test-links.c b/tests/fe-efl/test-links.c
index a43c41b..5ccadb3 100644
--- a/tests/fe-efl/test-links.c
+++ b/tests/fe-efl/test-links.c
@@ -31,7 +31,6 @@ static Ecore_Exe *capture_spawn(const char *command, Ecore_Exe_Flags flags, cons
 #undef elm_popup_add
 #undef ecore_exe_pipe_run
 
-void elaro_ui_image_preview(Elaro_Ui *ui, const char *url) {}
 void elaro_ui_music_show(Elaro_Ui *ui, const char *url) {}
 Eina_Bool elaro_ui_text_image_url_check(const char *url) { return FALSE; }
 Eina_Bool elaro_ui_text_audio_url_check(const char *url) { return FALSE; }
@@ -40,6 +39,51 @@ static void click(const char *part)
 {
     evas_object_smart_callback_call(elm_object_part_content_get(popup, part), "clicked", NULL);
 }
+
+static void check_image_preview(Elaro_Ui *ui, const char *path)
+{
+    evas_object_resize(ui->win, 800, 650);
+    evas_object_show(ui->win);
+    elaro_ui_image_preview(ui, path);
+    Evas_Object *box = elm_object_content_get(ui->preview);
+    Eina_List *items = NULL;
+    for (unsigned int i = 0; i < 200; i++) {
+        ecore_main_loop_iterate_may_block(EINA_FALSE);
+        evas_render(evas_object_evas_get(ui->win));
+        eina_list_free(items);
+        items = elm_box_children_get(box);
+        if (eina_list_count(items) == 2) break;
+        g_usleep(1000);
+    }
+    g_assert_cmpuint(eina_list_count(items), ==, 2);
+    Evas_Object *viewport = eina_list_nth(items, 0);
+    Evas_Object *open = eina_list_nth(items, 1);
+    Eina_Iterator *contents = efl_children_iterator_new(viewport);
+    Evas_Object *child, *image = NULL;
+    EINA_ITERATOR_FOREACH(contents, child) {
+        if (!g_strcmp0(elm_object_widget_type_get(child), "Elm_Image")) {
+            image = child;
+            break;
+        }
+    }
+    eina_iterator_free(contents);
+    g_assert_nonnull(image);
+    int width, height, image_width, image_height;
+    evas_object_geometry_get(viewport, NULL, NULL, &width, &height);
+    evas_object_geometry_get(elm_image_object_get(image), NULL, NULL, &image_width, &image_height);
+    g_assert_cmpint(width, >, 390);
+    g_assert_cmpint(abs(image_width - width), <=, 1);
+    g_assert_cmpint(abs(image_height - height), <=, 1);
+    g_assert_cmpstr(elm_object_text_get(open), ==, "Open image in browser");
+    evas_object_smart_callback_call(open, "clicked", NULL);
+    g_assert_cmpstr(elm_object_part_text_get(popup, "title,text"), ==, "Open link in browser?");
+    click("button2");
+    g_assert_nonnull(ui->preview);
+    evas_object_del(ui->preview);
+    g_assert_null(ui->preview);
+    eina_list_free(items);
+}
+
 int main(int argc, char **argv)
 {
     ecore_main_loop_glib_always_integrate_disable();
@@ -52,6 +96,9 @@ int main(int argc, char **argv)
     click("button2");
     g_assert_cmpuint(launches, ==, 0);
     g_assert_false(ui.config->always_allow_external_links);
+    g_assert_cmpint(argc, ==, 2);
+    check_image_preview(&ui, argv[1]);
+    g_assert_cmpuint(launches, ==, 0);
     _external_confirm(&ui, test_url);
     click("button1");
     g_assert_cmpuint(launches, ==, 1);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to