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 2667bb70136631b907ed9cd758f855135b25164a
Author: Alastair Poole <[email protected]>
AuthorDate: Tue Nov 24 12:24:24 2026 +0000

    ui: add default elementary (no CSD)
---
 src/fe-efl/elaro_config.c        |   1 +
 src/fe-efl/elaro_config.h        |   3 +
 src/fe-efl/ui/elaro_ui.c         |  31 +++----
 src/fe-efl/ui/elaro_ui_about.c   |  22 ++++-
 src/fe-efl/ui/elaro_ui_about.h   |   1 +
 src/fe-efl/ui/elaro_ui_options.c |  19 ++--
 src/fe-efl/ui/elaro_ui_options.h |   1 +
 src/fe-efl/ui/elaro_ui_private.h |   4 +-
 src/fe-efl/ui/elaro_ui_theme.h   | 189 +++++++++++++++++++++++++++++----------
 src/fe-efl/ui/elaro_ui_util.c    |  53 +++++++----
 src/fe-efl/ui/elaro_ui_util.h    |   4 +
 src/fe-efl/ui/elaro_ui_window.c  | 119 ++++++++++++++++++++----
 tests/fe-efl/meson.build         |   4 +
 tests/fe-efl/test-themes.c       |  67 +++++++++++++-
 14 files changed, 410 insertions(+), 108 deletions(-)

diff --git a/src/fe-efl/elaro_config.c b/src/fe-efl/elaro_config.c
index 801a6d0..8cf8a61 100644
--- a/src/fe-efl/elaro_config.c
+++ b/src/fe-efl/elaro_config.c
@@ -153,6 +153,7 @@ _defaults(void)
    c->buffer_panel_ratio = 0.20;
    c->user_panel_ratio = 0.18;
    c->window_opacity = ELARO_OPACITY_MAX;
+   c->theme = ELARO_THEME_DEFAULT;
    c->port = 6697;
    c->tls = EINA_TRUE;
    c->host = strdup("irc.libera.chat");
diff --git a/src/fe-efl/elaro_config.h b/src/fe-efl/elaro_config.h
index 81d93d5..ce0ed97 100644
--- a/src/fe-efl/elaro_config.h
+++ b/src/fe-efl/elaro_config.h
@@ -6,6 +6,9 @@
 #define ELARO_OPACITY_MIN 25
 #define ELARO_OPACITY_MAX 100
 
+/* Preserve the saved values of the original four themes. */
+enum { ELARO_THEME_DEFAULT = 4, ELARO_THEME_COUNT };
+
 typedef struct _Elaro_Config
 {
    Eina_List *connections;
diff --git a/src/fe-efl/ui/elaro_ui.c b/src/fe-efl/ui/elaro_ui.c
index b073272..01d6f1c 100644
--- a/src/fe-efl/ui/elaro_ui.c
+++ b/src/fe-efl/ui/elaro_ui.c
@@ -255,7 +255,6 @@ elaro_ui_run(int argc, char **argv)
 
    _theme_apply(&ui);
    ui.win = elm_win_add(NULL, "elaro", ELM_WIN_BASIC);
-   elm_win_borderless_set(ui.win, EINA_TRUE);
    elm_win_title_set(ui.win, _("Elaro — IRC"));
 
    icon = elm_icon_add(ui.win);
@@ -278,16 +277,8 @@ elaro_ui_run(int argc, char **argv)
    box = ui.content = elm_box_add(ui.win);
    elm_box_padding_set(box, 0, 0);
    elaro_ui_expand(box);
-   ui.frame = elm_layout_add(ui.win);
-   elm_layout_file_set(ui.frame, ui.theme_path, "elaro/frame");
-   elaro_ui_expand(ui.frame);
-   elm_win_resize_object_add(ui.win, ui.frame);
-   elm_object_part_content_set(ui.frame, "elaro.content", box);
-   elaro_ui_opacity_apply(&ui);
-   elaro_ui_window_shadow_bind(ui.win, ui.frame);
-   _frame_bind(&ui);
-
-   bar = elm_box_add(ui.win);
+   elm_win_resize_object_add(ui.win, box);
+   bar = ui.toolbar = elm_box_add(ui.win);
    elm_box_horizontal_set(bar, EINA_TRUE);
    elm_box_align_set(bar, 0, 0.5);
    elaro_ui_box_padding_set(bar, 5, 0);
@@ -298,13 +289,13 @@ elaro_ui_run(int argc, char **argv)
    elm_box_pack_end(box, bar);
    evas_object_show(bar);
 
-   connection
+   connection = ui.menu_button
        = elaro_ui_icon_button_add(ui.win, "menu", _("Application menu"), _menu_show, &ui);
    elaro_ui_window_control_style_set(connection, EINA_FALSE);
    evas_object_size_hint_align_set(connection, EVAS_HINT_FILL, EVAS_HINT_FILL);
    elm_box_pack_end(bar, connection);
 
-   Evas_Object *settings = elaro_ui_icon_button_add(ui.win, "add", _("Settings"),
+   Evas_Object *settings = ui.settings_button = elaro_ui_icon_button_add(ui.win, "add", _("Settings"),
                                                    elaro_ui_connection_show, &ui);
    elaro_ui_window_control_style_set(settings, EINA_FALSE);
    elm_box_pack_end(bar, settings);
@@ -336,17 +327,20 @@ elaro_ui_run(int argc, char **argv)
    elm_box_pack_end(bar, icon);
    evas_object_show(icon);
 
+   ui.window_controls = elm_box_add(bar);
+   elm_box_horizontal_set(ui.window_controls, EINA_TRUE);
+   elaro_ui_box_padding_set(ui.window_controls, 5, 0);
    about = elaro_ui_icon_button_add(ui.win, "minimize", _("Minimize"), _window_minimize, &ui);
    elaro_ui_window_control_style_set(about, EINA_FALSE);
-   elm_box_pack_end(bar, about);
+   elm_box_pack_end(ui.window_controls, about);
    about = elaro_ui_icon_button_add(ui.win, "maximize", _("Maximize or restore"), _window_maximize, &ui);
    elaro_ui_window_control_style_set(about, EINA_FALSE);
-   elm_box_pack_end(bar, about);
+   elm_box_pack_end(ui.window_controls, about);
    about = elaro_ui_icon_button_add(ui.win, "close", _("Close Elaro"), _close_window_cb, &ui);
    elaro_ui_window_control_style_set(about, EINA_TRUE);
-   elm_box_pack_end(bar, about);
+   elm_box_pack_end(ui.window_controls, about);
 
-   shadow = _shadow_add(ui.win, "elaro/header/shadow");
+   shadow = ui.header_shadow = _shadow_add(ui.win, "elaro/header/shadow");
    elm_box_pack_end(box, shadow);
 
    split = ui.buffer_panes = elm_panes_add(ui.win);
@@ -391,7 +385,7 @@ elaro_ui_run(int argc, char **argv)
    elaro_ui_users_init(&ui);
    elm_object_part_content_set(right, "right", ui.nicks);
 
-   shadow = _shadow_add(ui.win, "elaro/input/shadow");
+   shadow = ui.input_shadow = _shadow_add(ui.win, "elaro/input/shadow");
    elm_box_pack_end(box, shadow);
 
    ui.input = elaro_ui_entry_add(ui.win, EINA_FALSE);
@@ -409,6 +403,7 @@ elaro_ui_run(int argc, char **argv)
                                       ECORE_FD_READ, _receive_events_cb, &ui,
                                       NULL, NULL);
    if (!events) EINA_LOG_CRIT("Cannot watch engine events");
+   _main_frame_apply(&ui);
    elaro_ui_layout_restore(&ui);
    evas_object_event_callback_add(ui.win, EVAS_CALLBACK_RESIZE, _window_resized_cb, &ui);
    evas_object_smart_callback_add(ui.win, "moved", _layout_changed_cb, &ui);
diff --git a/src/fe-efl/ui/elaro_ui_about.c b/src/fe-efl/ui/elaro_ui_about.c
index ef790da..54caa0c 100644
--- a/src/fe-efl/ui/elaro_ui_about.c
+++ b/src/fe-efl/ui/elaro_ui_about.c
@@ -75,6 +75,23 @@ _about_close_cb(void *data, Evas_Object *obj, void *info)
    elaro_ui_popup_close(popup);
 }
 
+void
+elaro_ui_about_theme_apply(Elaro_Ui *ui)
+{
+   Evas_Object *hero = evas_object_data_get(ui->about, "hero");
+   Evas_Object *release = evas_object_data_get(ui->about, "release");
+   Evas_Object *box = elm_object_content_get(ui->about);
+
+   elm_box_unpack(box, hero);
+   if (ui->theme_path)
+     {
+        elm_layout_file_set(hero, ui->theme_path, "elaro/about/hero");
+        elm_box_pack_before(box, hero, release);
+        evas_object_show(hero);
+     }
+   else evas_object_hide(hero);
+}
+
 void
 elaro_ui_about_show(void *data, Evas_Object *obj, void *info)
 {
@@ -103,12 +120,9 @@ elaro_ui_about_show(void *data, Evas_Object *obj, void *info)
    evas_object_show(box);
 
    hero = elm_layout_add(box);
-   if (ui->theme_path) elm_layout_file_set(hero, ui->theme_path, "elaro/about/hero");
    elaro_ui_size_min_set(hero, 315, 131);
    evas_object_size_hint_weight_set(hero, EVAS_HINT_EXPAND, 0);
    evas_object_size_hint_align_set(hero, EVAS_HINT_FILL, 0.5);
-   elm_box_pack_end(box, hero);
-   evas_object_show(hero);
    evas_object_data_set(ui->about, "hero", hero);
 
    release = elm_label_add(box);
@@ -117,6 +131,8 @@ elaro_ui_about_show(void *data, Evas_Object *obj, void *info)
    free(version);
    elm_box_pack_end(box, release);
    evas_object_show(release);
+   evas_object_data_set(ui->about, "release", release);
+   elaro_ui_about_theme_apply(ui);
 
    tabs = elaro_ui_tabs_add(box);
    overview = elm_segment_control_item_add(tabs, NULL, _("Overview"));
diff --git a/src/fe-efl/ui/elaro_ui_about.h b/src/fe-efl/ui/elaro_ui_about.h
index 946a75e..59fd8c7 100644
--- a/src/fe-efl/ui/elaro_ui_about.h
+++ b/src/fe-efl/ui/elaro_ui_about.h
@@ -3,6 +3,7 @@
 
 #include "elaro_ui.h"
 
+void elaro_ui_about_theme_apply(Elaro_Ui *ui);
 void
 elaro_ui_about_show(void *data, Evas_Object *obj, void *info);
 
diff --git a/src/fe-efl/ui/elaro_ui_options.c b/src/fe-efl/ui/elaro_ui_options.c
index f8aebd6..8e660d6 100644
--- a/src/fe-efl/ui/elaro_ui_options.c
+++ b/src/fe-efl/ui/elaro_ui_options.c
@@ -1,12 +1,21 @@
 #include "elaro_ui_private.h"
 
+void
+elaro_ui_options_transparency_update(Elaro_Ui *ui)
+{
+   Eina_Bool custom = ui->theme_path != NULL;
+   elm_object_disabled_set(ui->connection.transparent, !custom);
+   elm_object_disabled_set(ui->connection.opacity,
+                           !custom || !elm_check_state_get(ui->connection.transparent));
+   if (custom) elm_object_tooltip_unset(ui->connection.transparent);
+   else elm_object_tooltip_text_set(ui->connection.transparent,
+                                   _("Window transparency is available with Elaro themes."));
+}
+
 static void
 _transparency_changed_cb(void *data, Evas_Object *obj, void *info)
 {
-   Elaro_Ui *ui;
-
-   ui = data;
-   elm_object_disabled_set(ui->connection.opacity, !elm_check_state_get(obj));
+   elaro_ui_options_transparency_update(data);
 }
 
 static Evas_Object *
@@ -130,7 +139,7 @@ elaro_ui_options_add(Elaro_Ui *ui, Evas_Object *parent)
    elm_slider_indicator_visible_mode_set(ui->connection.opacity,
                                          ELM_SLIDER_INDICATOR_VISIBLE_MODE_NONE);
    elm_slider_value_set(ui->connection.opacity, ui->config->window_opacity);
-   elm_object_disabled_set(ui->connection.opacity, !ui->config->window_transparent);
+   elaro_ui_options_transparency_update(ui);
    evas_object_size_hint_align_set(ui->connection.opacity, EVAS_HINT_FILL, 0.5);
    evas_object_size_hint_weight_set(ui->connection.opacity, EVAS_HINT_EXPAND, 0);
    elm_box_pack_end(options, ui->connection.opacity);
diff --git a/src/fe-efl/ui/elaro_ui_options.h b/src/fe-efl/ui/elaro_ui_options.h
index 2d3101e..cf8eee0 100644
--- a/src/fe-efl/ui/elaro_ui_options.h
+++ b/src/fe-efl/ui/elaro_ui_options.h
@@ -5,6 +5,7 @@
 
 void
 elaro_ui_options_add(Elaro_Ui *ui, Evas_Object *parent);
+void elaro_ui_options_transparency_update(Elaro_Ui *ui);
 void
 elaro_ui_options_save(Elaro_Ui *ui);
 
diff --git a/src/fe-efl/ui/elaro_ui_private.h b/src/fe-efl/ui/elaro_ui_private.h
index 98edb49..cfcfa43 100644
--- a/src/fe-efl/ui/elaro_ui_private.h
+++ b/src/fe-efl/ui/elaro_ui_private.h
@@ -52,7 +52,9 @@ struct _Elaro_Ui
    char *theme_path;
    Ecore_Event_Handler *theme_config_handler;
    Evas_Object *resize_grips[8];
-   Evas_Object *frame, *app_menu, *theme_buttons[4], *theme_status;
+   Evas_Object *frame, *app_menu, *theme_buttons[ELARO_THEME_COUNT], *theme_status;
+   Evas_Object *toolbar, *menu_button, *settings_button, *window_controls;
+   Evas_Object *header_shadow, *input_shadow;
    Evas_Object *content, *reconnect;
    Evas_Object *buffer_panes, *user_panes;
    Ecore_Animator *user_panel_animator;
diff --git a/src/fe-efl/ui/elaro_ui_theme.h b/src/fe-efl/ui/elaro_ui_theme.h
index f30f8b8..40e6988 100644
--- a/src/fe-efl/ui/elaro_ui_theme.h
+++ b/src/fe-efl/ui/elaro_ui_theme.h
@@ -1,16 +1,22 @@
 #ifndef ELARO_UI_THEME_H
 #define ELARO_UI_THEME_H
 #include "elaro_ui_palette.h"
+#include "elaro_ui_options.h"
 
 static void _frame_bind(Elaro_Ui *ui);
+static void _main_frame_apply(Elaro_Ui *ui);
 
-/* These helpers belong to the main window; dialogs inherit its theme. */
-static const char *theme_names[] = { "midnight", "porcelain", "verdigris", "ember" };
-static const char *theme_labels[] = { "Midnight", "Porcelain", "Verdigris", "Ember" };
+static const char *theme_names[ELARO_THEME_DEFAULT] = {
+   "midnight", "porcelain", "verdigris", "ember"
+};
+static const char *theme_labels[ELARO_THEME_COUNT] = {
+   "Midnight", "Porcelain", "Verdigris", "Ember", N_("Default")
+};
 
 static void
 _theme_palette_apply(Elaro_Ui *ui)
 {
+   if (!ui->theme_path) return;
    for (unsigned int i = 0; i < EINA_C_ARRAY_LENGTH(palette_classes); i++)
      {
         char *value = edje_file_data_get(ui->theme_path, palette_classes[i]);
@@ -40,55 +46,83 @@ _theme_shutdown(Elaro_Ui *ui)
    ui->theme_path = NULL;
 }
 
-static void
-_theme_apply(Elaro_Ui *ui)
+static char *
+_theme_path_get(Elaro_Ui *ui)
 {
-   char *name, *path, *build_dir;
-   Eina_Bool development;
-   Eina_List *l;
-   Evas_Object *icon, *content = NULL;
-   int index = ELARO_CLAMP(ui->config->theme, 0, 3);
-   name = elaro_string_printf("%s.edj", theme_names[index]);
+   int index = ui->config->theme;
+   if (index < 0 || index >= ELARO_THEME_DEFAULT) return NULL;
+
+   char *name = elaro_string_printf("%s.edj", theme_names[index]);
    /* A checkout must not silently use older, installed theme archives. */
-   build_dir = ecore_file_dir_get(ELARO_ASSET_BUILD_DIR);
-   development = !ui->binary || (build_dir && !strncmp(ui->binary, build_dir, strlen(build_dir))
-                                  && ui->binary[strlen(build_dir)] == '/');
+   char *build_dir = ecore_file_dir_get(ELARO_ASSET_BUILD_DIR);
+   Eina_Bool development = !ui->binary ||
+       (build_dir && !strncmp(ui->binary, build_dir, strlen(build_dir))
+        && ui->binary[strlen(build_dir)] == '/');
    free(build_dir);
-   path = elaro_path_join(development ? ELARO_ASSET_BUILD_DIR : ELARO_DATA_DIR, name, NULL);
+   char *path = elaro_path_join(development ? ELARO_ASSET_BUILD_DIR : ELARO_DATA_DIR, name, NULL);
    if (!ecore_file_exists(path))
      {
         free(path);
         path = elaro_path_join(development ? ELARO_DATA_DIR : ELARO_ASSET_BUILD_DIR, name, NULL);
+        if (!ecore_file_exists(path))
+          {
+             free(path);
+             path = NULL;
+          }
      }
    free(name);
-   /* Install the replacement before removing the old overlay, so widgets
-    * never briefly re-theme through the desktop fallback. */
-   if (!ui->theme_path || strcmp(ui->theme_path, path))
-     {
-        elm_theme_overlay_add(NULL, path);
-        if (ui->theme_path) elm_theme_overlay_del(NULL, ui->theme_path);
-     }
-   free(ui->theme_path);
+   return path;
+}
+
+static void
+_theme_apply(Elaro_Ui *ui)
+{
+   char *path = _theme_path_get(ui);
+   char *previous = ui->theme_path;
+   Eina_Bool changed = previous ? (!path || strcmp(path, previous)) : path != NULL;
    ui->theme_path = path;
+   if (changed)
+     {
+        if (path) elm_theme_overlay_add(NULL, path);
+        else
+          for (unsigned int i = 0; i < EINA_C_ARRAY_LENGTH(palette_classes); i++)
+             edje_color_class_del(palette_classes[i]);
+        if (previous) elm_theme_overlay_del(NULL, previous);
+     }
+   free(previous);
+
    _theme_palette_apply(ui);
    if (!ui->theme_config_handler)
       ui->theme_config_handler = ecore_event_handler_add(ELM_EVENT_CONFIG_ALL_CHANGED,
                                                          _theme_config_changed, ui);
-   if (ui->frame)
+   if (ui->content) _main_frame_apply(ui);
+   if (ui->connection.popup) elaro_ui_options_transparency_update(ui);
+   if (ui->about) elaro_ui_about_theme_apply(ui);
+   elaro_ui_icons_refresh(ui);
+   if (changed) elaro_ui_dialog_frames_refresh();
+}
+
+static void
+_theme_menu_selection_update(Elaro_Ui *ui)
+{
+   for (int i = 0; i < ELARO_THEME_COUNT; i++)
      {
-        content = elm_object_part_content_unset(ui->frame, "elaro.content");
-        elm_layout_file_set(ui->frame, path, "elaro/frame");
-        if (content) elm_object_part_content_set(ui->frame, "elaro.content", content);
-        elaro_ui_window_shadow_sync(ui->win, ui->frame);
-        _frame_bind(ui);
+        Evas_Object *button = ui->theme_buttons[i];
+        if (!button) continue;
+
+        Eina_Bool selected = i == ui->config->theme;
+        elm_object_signal_emit(button, selected ? "elaro,selected,on" : "elaro,selected,off",
+                               "elaro");
+        Evas_Object *label = evas_object_data_get(button, "menu-label");
+        const char *text = _(theme_labels[i]);
+        if (selected && !ui->theme_path)
+          {
+             char *markup = elaro_string_printf("<b>%s</b>", text);
+             elm_object_text_set(label, markup);
+             free(markup);
+          }
+        else elm_object_text_set(label, text);
      }
-   if (ui->about)
-     {
-        Evas_Object *hero = evas_object_data_get(ui->about, "hero");
-        if (hero) elm_layout_file_set(hero, path, "elaro/about/hero");
-     }
-   EINA_LIST_FOREACH(ui->theme_icons, l, icon)
-     elm_image_file_set(icon, path, evas_object_data_get(icon, "elaro-icon-group"));
 }
 
 static void
@@ -97,16 +131,12 @@ _theme_selected(void *data, Evas_Object *obj, void *info)
    Elaro_Ui *ui = data;
    Eina_Error error = 0;
    int index = (int)(intptr_t)evas_object_data_get(obj, "theme-index");
-   if (index < 0 || index >= 4) return;
+   if (index < 0 || index >= ELARO_THEME_COUNT) return;
    ui->config->theme = index;
    _theme_apply(ui);
    elaro_ui_buffers_recreate(ui);
    if (ui->nicks) elm_genlist_realized_items_update(ui->nicks);
-   for (int i = 0; i < 4; i++)
-     {
-        Evas_Object *button = ui->theme_buttons[i];
-        if (button) elm_object_signal_emit(button, i == index ? "elaro,selected,on" : "elaro,selected,off", "elaro");
-     }
+   _theme_menu_selection_update(ui);
    if (!elaro_config_save(ui->config, &error))
      {
         elm_object_text_set(ui->theme_status, _("Theme applied. Could not save your preference."));
@@ -137,7 +167,7 @@ _frame_move(void *data, Evas *evas, Evas_Object *obj, void *info)
 {
    Elaro_Ui *ui = data;
    Evas_Event_Mouse_Down *ev = info;
-   if (ev->button != 1) return;
+   if (!ui->frame || ev->button != 1) return;
    if (ev->flags & EVAS_BUTTON_DOUBLE_CLICK)
      elm_win_maximized_set(ui->win, !elm_win_maximized_get(ui->win));
    else elm_win_move_resize_start(ui->win, ELM_WIN_MOVE_RESIZE_MOVE);
@@ -223,6 +253,71 @@ _frame_bind(Elaro_Ui *ui)
    evas_object_event_callback_add(surface, EVAS_CALLBACK_MOUSE_DOWN, _frame_move, ui);
 }
 
+static void
+_main_frame_apply(Elaro_Ui *ui)
+{
+   Eina_Bool custom = ui->theme_path != NULL;
+
+   if (ui->toolbar)
+     {
+        elm_object_style_set(ui->menu_button, custom ? "elaro/window-control" : "default");
+        elm_object_style_set(ui->settings_button, custom ? "elaro/window-control" : "default");
+        elm_object_style_set(ui->reconnect, custom ? "elaro/window-control" : "default");
+        elm_box_unpack(ui->content, ui->header_shadow);
+        elm_box_unpack(ui->content, ui->input_shadow);
+        evas_object_hide(ui->header_shadow);
+        evas_object_hide(ui->input_shadow);
+        if (custom)
+          {
+             elm_box_unpack(ui->toolbar, ui->window_controls);
+             elm_box_pack_end(ui->toolbar, ui->window_controls);
+             evas_object_show(ui->window_controls);
+             elm_box_pack_after(ui->content, ui->header_shadow, ui->toolbar);
+             elm_box_pack_before(ui->content, ui->input_shadow, ui->input);
+             evas_object_show(ui->header_shadow);
+             evas_object_show(ui->input_shadow);
+          }
+        else
+          {
+             elm_box_unpack(ui->toolbar, ui->window_controls);
+             evas_object_hide(ui->window_controls);
+          }
+     }
+   if (custom)
+     {
+        if (!ui->frame)
+          {
+             elm_win_resize_object_del(ui->win, ui->content);
+             ui->frame = elm_layout_add(ui->win);
+             elaro_ui_expand(ui->frame);
+             elm_win_resize_object_add(ui->win, ui->frame);
+             elaro_ui_window_custom_set(ui->win);
+          }
+        else elm_object_part_content_unset(ui->frame, "elaro.content");
+
+        elm_layout_file_set(ui->frame, ui->theme_path, "elaro/frame");
+        elm_object_part_content_set(ui->frame, "elaro.content", ui->content);
+        elaro_ui_opacity_apply(ui);
+        evas_object_show(ui->frame);
+        if (!ui->resize_grips[0]) elaro_ui_window_shadow_bind(ui->win, ui->frame);
+        else elaro_ui_window_shadow_sync(ui->win, ui->frame);
+        _frame_bind(ui);
+     }
+   else
+     {
+        if (ui->frame)
+          {
+             elm_object_part_content_unset(ui->frame, "elaro.content");
+             elm_win_resize_object_del(ui->win, ui->frame);
+             evas_object_del(ui->frame);
+             ui->frame = NULL;
+             elm_win_resize_object_add(ui->win, ui->content);
+          }
+        elaro_ui_window_native_set(ui->win);
+     }
+   evas_object_show(ui->content);
+}
+
 static void
 _window_minimize(void *data, Evas_Object *obj, void *info)
 {
@@ -277,6 +372,7 @@ _menu_button(Elaro_Ui *ui, Evas_Object *parent, const char *asset,
    elaro_ui_size_min_set(icon, 15, 15);
    elaro_ui_size_max_set(icon, 15, 15);
    elm_object_text_set(label, text);
+   evas_object_data_set(button, "menu-label", label);
    evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, 0);
    evas_object_size_hint_align_set(label, 0, 0.5);
    elm_box_pack_end(row, icon);
@@ -309,13 +405,14 @@ _menu_show(void *data, Evas_Object *obj, void *info)
    evas_object_size_hint_align_set(heading, 0, 0.5);
    elm_box_pack_end(box, heading);
    evas_object_show(heading);
-   for (i = 0; i < 4; i++)
+   for (int row = 0; row < ELARO_THEME_COUNT; row++)
      {
-        button = ui->theme_buttons[i] = _menu_button(ui, box, "theme", theme_labels[i], _theme_selected);
+        i = (row + ELARO_THEME_DEFAULT) % ELARO_THEME_COUNT;
+        button = ui->theme_buttons[i] = _menu_button(ui, box, "theme", _(theme_labels[i]), _theme_selected);
         evas_object_data_set(button, "theme-index", (void *)(intptr_t)i);
-        if (i == ui->config->theme) elm_object_signal_emit(button, "elaro,selected,on", "elaro");
         elm_box_pack_end(box, button);
      }
+   _theme_menu_selection_update(ui);
    Evas_Object *separator = elm_separator_add(box);
    elm_separator_horizontal_set(separator, EINA_TRUE);
    evas_object_size_hint_weight_set(separator, EVAS_HINT_EXPAND, 0);
diff --git a/src/fe-efl/ui/elaro_ui_util.c b/src/fe-efl/ui/elaro_ui_util.c
index 864df82..5e6e83a 100644
--- a/src/fe-efl/ui/elaro_ui_util.c
+++ b/src/fe-efl/ui/elaro_ui_util.c
@@ -193,25 +193,48 @@ _theme_icon_deleted(void *data, Evas *evas, Evas_Object *obj, void *info)
 {
    Elaro_Ui *ui = data;
    ui->theme_icons = eina_list_remove(ui->theme_icons, obj);
-   free(evas_object_data_get(obj, "elaro-icon-group"));
+}
+
+static Eina_Bool
+_theme_icon_apply(Elaro_Ui *ui, Evas_Object *icon, const char *asset)
+{
+   if (ui->theme_path)
+     {
+        char group[64];
+        snprintf(group, sizeof(group), "elaro/icons/%s", asset);
+        if (elm_image_file_set(icon, ui->theme_path, group)) return EINA_TRUE;
+     }
+
+   static const struct { const char *asset, *standard; } aliases[] = {
+      { "menu", "open-menu" }, { "add", "list-add" }, { "close", "window-close" },
+      { "minimize", "window-minimize" }, { "maximize", "window-maximize" },
+      { "theme", "preferences-desktop-theme" }, { "settings", "preferences-system" },
+      { "application", "help-about" }, { "chat", "mail-message-new" },
+      { "info", "dialog-information" },
+   };
+   if (elm_icon_standard_set(icon, asset)) return EINA_TRUE;
+   for (size_t i = 0; i < EINA_C_ARRAY_LENGTH(aliases); i++)
+      if (!strcmp(asset, aliases[i].asset))
+         return elm_icon_standard_set(icon, aliases[i].standard);
+   return EINA_FALSE;
 }
 
 Eina_Bool
 elaro_ui_icon_set(Elaro_Ui *ui, Evas_Object *icon, const char *asset)
 {
-   char *group;
-   Eina_Bool ok;
-   if (!ui->theme_path) return elm_icon_standard_set(icon, asset);
-   group = elaro_string_printf("elaro/icons/%s", asset);
-   ok = elm_image_file_set(icon, ui->theme_path, group);
-   if (ok)
-     {
-        evas_object_data_set(icon, "elaro-icon-group", group);
-        ui->theme_icons = eina_list_append(ui->theme_icons, icon);
-        evas_object_event_callback_add(icon, EVAS_CALLBACK_DEL, _theme_icon_deleted, ui);
-     }
-   else free(group);
-   return ok;
+   evas_object_data_set(icon, "elaro-icon-asset", asset);
+   ui->theme_icons = eina_list_append(ui->theme_icons, icon);
+   evas_object_event_callback_add(icon, EVAS_CALLBACK_DEL, _theme_icon_deleted, ui);
+   return _theme_icon_apply(ui, icon, asset);
+}
+
+void
+elaro_ui_icons_refresh(Elaro_Ui *ui)
+{
+   Eina_List *node;
+   Evas_Object *icon;
+   EINA_LIST_FOREACH (ui->theme_icons, node, icon)
+      _theme_icon_apply(ui, icon, evas_object_data_get(icon, "elaro-icon-asset"));
 }
 
 Evas_Object *
@@ -294,7 +317,7 @@ elaro_ui_opacity_apply(Elaro_Ui *ui)
 
    opacity = ELARO_CLAMP(ui->config->window_opacity, ELARO_OPACITY_MIN, ELARO_OPACITY_MAX);
    alpha = ui->config->window_transparent ? (255 * opacity + 50) / 100 : 255;
-   evas_object_color_set(ui->frame, alpha, alpha, alpha, alpha);
+   if (ui->frame) evas_object_color_set(ui->frame, alpha, alpha, alpha, alpha);
 }
 
 /* Panes use proportions so restored widths also adapt to a different display. */
diff --git a/src/fe-efl/ui/elaro_ui_util.h b/src/fe-efl/ui/elaro_ui_util.h
index 2463881..a723a79 100644
--- a/src/fe-efl/ui/elaro_ui_util.h
+++ b/src/fe-efl/ui/elaro_ui_util.h
@@ -12,6 +12,7 @@ void elaro_ui_entry_auto_scroll_enable(Evas_Object *entry);
 
 Eina_Bool
 elaro_ui_icon_set(Elaro_Ui *ui, Evas_Object *icon, const char *asset);
+void elaro_ui_icons_refresh(Elaro_Ui *ui);
 void
 elaro_ui_layout_capture(Elaro_Ui *ui);
 void
@@ -41,6 +42,9 @@ void elaro_ui_popup_close(Evas_Object *popup);
 Evas_Object *elaro_ui_tabs_add(Evas_Object *parent);
 void elaro_ui_window_shadow_bind(Evas_Object *win, Evas_Object *frame);
 void elaro_ui_window_shadow_sync(Evas_Object *win, Evas_Object *frame);
+void elaro_ui_window_native_set(Evas_Object *win);
+void elaro_ui_window_custom_set(Evas_Object *win);
+void elaro_ui_dialog_frames_refresh(void);
 Evas_Object *elaro_ui_window_content_add(Evas_Object *win);
 void elaro_ui_window_control_style_set(Evas_Object *button, Eina_Bool close);
 void elaro_ui_view_reveal(Evas_Object *view);
diff --git a/src/fe-efl/ui/elaro_ui_window.c b/src/fe-efl/ui/elaro_ui_window.c
index 1abd274..8ffd4b5 100644
--- a/src/fe-efl/ui/elaro_ui_window.c
+++ b/src/fe-efl/ui/elaro_ui_window.c
@@ -63,6 +63,37 @@ elaro_ui_window_shadow_bind(Evas_Object *win, Evas_Object *frame)
    elaro_ui_window_shadow_sync(win, frame);
 }
 
+void
+elaro_ui_window_native_set(Evas_Object *win)
+{
+   Ecore_Evas *surface = ecore_evas_ecore_evas_get(evas_object_evas_get(win));
+   if (surface) ecore_evas_shadow_geometry_set(surface, 0, 0, 0, 0);
+   elm_win_alpha_set(win, EINA_FALSE);
+   elm_win_borderless_set(win, EINA_FALSE);
+   if (!evas_object_data_get(win, "elaro-native-background"))
+     {
+        Evas_Object *background = ""
+        evas_object_size_hint_weight_set(background, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+        evas_object_pass_events_set(background, EINA_TRUE);
+        elm_win_resize_object_add(win, background);
+        evas_object_lower(background);
+        evas_object_show(background);
+        evas_object_data_set(win, "elaro-native-background", background);
+     }
+}
+
+void
+elaro_ui_window_custom_set(Evas_Object *win)
+{
+   Evas_Object *background = "" "elaro-native-background");
+   if (background)
+     {
+        elm_win_resize_object_del(win, background);
+        evas_object_del(background);
+     }
+   elm_win_borderless_set(win, EINA_TRUE);
+}
+
 void
 elaro_ui_window_control_style_set(Evas_Object *button, Eina_Bool close)
 {
@@ -170,28 +201,15 @@ static void _window_close(void *data, Evas_Object *obj, void *info)
    evas_object_del(data);
 }
 
-Evas_Object *
-elaro_ui_window_content_add(Evas_Object *win)
+static void
+_window_frame_create(Evas_Object *win, Evas_Object *body, const char *path)
 {
-   const char *path = elm_theme_group_path_find(NULL, "elaro/dialog/frame");
-   Evas_Object *body = elm_box_add(win);
-   evas_object_size_hint_weight_set(body, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
-   evas_object_size_hint_align_set(body, EVAS_HINT_FILL, EVAS_HINT_FILL);
-   evas_object_show(body);
-   /* Retain native decorations if the application theme is unavailable. */
-   if (!path)
-     {
-        elm_win_resize_object_add(win, body);
-        return body;
-     }
    Window_Frame *frame = calloc(1, sizeof(*frame));
-   if (!frame)
-     {
-        elm_win_resize_object_add(win, body);
-        return body;
-     }
+   if (!frame) return;
+
+   elm_win_resize_object_del(win, body);
    frame->win = win;
-   elm_win_borderless_set(win, EINA_TRUE);
+   elaro_ui_window_custom_set(win);
    frame->frame = elm_layout_add(win);
    elm_layout_file_set(frame->frame, path, "elaro/dialog/frame");
    evas_object_size_hint_weight_set(frame->frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@@ -266,5 +284,68 @@ elaro_ui_window_content_add(Evas_Object *win)
    evas_object_smart_callback_add(win, "theme,changed", _window_theme_changed, frame);
    evas_object_data_set(win, "elaro-window-drag", drag);
    evas_object_data_set(win, "elaro-window-frame", frame->frame);
+}
+
+static Eina_List *dialog_windows;
+
+static void
+_window_deleted(void *data, Evas *evas, Evas_Object *win, void *info)
+{
+   dialog_windows = eina_list_remove(dialog_windows, win);
+}
+
+static void
+_window_frame_apply(Evas_Object *win)
+{
+   Evas_Object *body = evas_object_data_get(win, "elaro-window-body");
+   Evas_Object *frame = evas_object_data_get(win, "elaro-window-frame");
+   const char *path = elm_theme_group_path_find(NULL, "elaro/dialog/frame");
+
+   if (path)
+     {
+        if (!frame) _window_frame_create(win, body, path);
+        return;
+     }
+   if (!frame)
+     {
+        elaro_ui_window_native_set(win);
+        return;
+     }
+
+   Evas_Object *root = elm_object_part_content_get(frame, "elaro.content");
+   elm_box_unpack(root, body);
+   evas_object_data_del(win, "elaro-window-frame");
+   evas_object_data_del(win, "elaro-window-drag");
+   for (size_t i = 0; i < EINA_C_ARRAY_LENGTH(window_icons); i++)
+      evas_object_data_del(win, window_icons[i]);
+   elm_win_resize_object_del(win, frame);
+   evas_object_del(frame);
+   elaro_ui_padding_set(body, 0, 0, 0, 0);
+   elaro_ui_window_native_set(win);
+   elm_win_resize_object_add(win, body);
+   evas_object_show(body);
+}
+
+void
+elaro_ui_dialog_frames_refresh(void)
+{
+   Eina_List *node;
+   Evas_Object *win;
+   EINA_LIST_FOREACH (dialog_windows, node, win)
+      _window_frame_apply(win);
+}
+
+Evas_Object *
+elaro_ui_window_content_add(Evas_Object *win)
+{
+   Evas_Object *body = elm_box_add(win);
+   evas_object_size_hint_weight_set(body, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+   evas_object_size_hint_align_set(body, EVAS_HINT_FILL, EVAS_HINT_FILL);
+   elm_win_resize_object_add(win, body);
+   evas_object_show(body);
+   evas_object_data_set(win, "elaro-window-body", body);
+   evas_object_event_callback_add(win, EVAS_CALLBACK_DEL, _window_deleted, NULL);
+   dialog_windows = eina_list_append(dialog_windows, win);
+   _window_frame_apply(win);
    return body;
 }
diff --git a/tests/fe-efl/meson.build b/tests/fe-efl/meson.build
index bc417bc..6dd5486 100644
--- a/tests/fe-efl/meson.build
+++ b/tests/fe-efl/meson.build
@@ -260,3 +260,7 @@ themes_test = executable('test-themes', 'test-themes.c',
 test('Application themes and live switching', python,
   args : [files('isolated.py'), themes_test], timeout : 60,
   env : ['ELARO_TEST_TIMEOUT=55', 'ELM_ENGINE=buffer', 'ECORE_NO_SYSTEM_MODULES=1', 'EINA_LOG_LEVEL=0'])
+
+test('Elementary default theme and native window decorations', python,
+  args : [files('isolated.py'), themes_test, '--default'], timeout : 15,
+  env : ['ELM_ENGINE=buffer', 'ECORE_NO_SYSTEM_MODULES=1', 'EINA_LOG_LEVEL=0'])
diff --git a/tests/fe-efl/test-themes.c b/tests/fe-efl/test-themes.c
index ff1ec0c..09ddb4c 100644
--- a/tests/fe-efl/test-themes.c
+++ b/tests/fe-efl/test-themes.c
@@ -17,7 +17,6 @@ Eina_Bool elm_win_move_resize_start(Evas_Object *window, Elm_Win_Move_Resize_Mod
 }
 
 /* Exercise actual canvas pointer delivery without an IRC engine. */
-static void _close_window_cb(void *data, Evas_Object *obj, void *info) {}
 void elaro_engine_submit(Elaro_Engine *engine, Elaro_Engine_Command *command)
 {
    elaro_engine_command_free(command);
@@ -673,6 +672,62 @@ _resize_check(Elaro_Ui *ui)
      }
 }
 
+static void
+_default_theme_check(Elaro_Ui *ui)
+{
+   assert(ui->config->theme == ELARO_THEME_DEFAULT);
+   ui->content = elm_box_add(ui->win);
+   elaro_ui_expand(ui->content);
+   elm_win_resize_object_add(ui->win, ui->content);
+   _theme_apply(ui);
+   assert(!ui->theme_path && !ui->frame);
+   assert(!elm_win_borderless_get(ui->win));
+   Evas_Object *background = "" "elaro-native-background");
+   assert(background && evas_object_visible_get(background));
+
+   Evas_Object *entry = elaro_ui_entry_add(ui->content, EINA_FALSE);
+   elm_box_pack_end(ui->content, entry);
+   elm_entry_entry_set(entry, "Unsent draft");
+   Evas_Object *dialog = elm_win_add(ui->win, "dialog", ELM_WIN_DIALOG_BASIC);
+   Evas_Object *body = elaro_ui_window_content_add(dialog);
+   Evas_Object *label = elm_label_add(body);
+   elm_object_text_set(label, "Dialog content");
+   elm_box_pack_end(body, label);
+   evas_object_show(label);
+   assert(!elm_win_borderless_get(dialog));
+   assert(evas_object_data_get(dialog, "elaro-native-background"));
+
+   evas_object_resize(ui->win, 900, 760);
+   evas_object_show(ui->win);
+   evas_object_show(dialog);
+   _menu_show(ui, NULL, NULL);
+   _settle();
+   int window_width, window_height, background_width, background_height;
+   evas_object_geometry_get(ui->win, NULL, NULL, &window_width, &window_height);
+   evas_object_geometry_get(background, NULL, NULL, &background_width, &background_height);
+   assert(background_width == window_width && background_height == window_height);
+   _click(ui->theme_buttons[0]);
+   assert(ui->theme_path && ui->frame);
+   assert(elm_win_borderless_get(ui->win) && elm_win_borderless_get(dialog));
+   assert(!evas_object_data_get(ui->win, "elaro-native-background"));
+   assert(evas_object_data_get(dialog, "elaro-window-frame"));
+   _click(ui->theme_buttons[ELARO_THEME_DEFAULT]);
+   assert(!ui->theme_path && !ui->frame);
+   assert(!elm_win_borderless_get(ui->win) && !elm_win_borderless_get(dialog));
+   assert(evas_object_data_get(ui->win, "elaro-native-background"));
+   assert(evas_object_data_get(dialog, "elaro-native-background"));
+   assert(!evas_object_data_get(dialog, "elaro-window-frame"));
+   assert(!strcmp(elm_entry_entry_get(entry), "Unsent draft"));
+   assert(!strcmp(elm_object_text_get(label), "Dialog content"));
+
+   Eina_Error error = 0;
+   Elaro_Config *saved = elaro_config_load(&error);
+   assert(saved && !error && saved->theme == ELARO_THEME_DEFAULT);
+   elaro_config_free(saved);
+   _menu_close(ui, NULL, NULL);
+   evas_object_del(dialog);
+}
+
 int main(int argc, char **argv)
 {
    Eina_Error error = 0;
@@ -694,6 +749,16 @@ int main(int argc, char **argv)
    ui.win = elm_win_add(NULL, "themes", ELM_WIN_BASIC);
    assert(ui.win);
    test_canvas = ecore_evas_ecore_evas_get(evas_object_evas_get(ui.win));
+   if (argc > 1 && !strcmp(argv[1], "--default"))
+     {
+        _default_theme_check(&ui);
+        evas_object_del(ui.win);
+        _theme_shutdown(&ui);
+        elaro_config_free(ui.config);
+        elm_shutdown();
+        return 0;
+     }
+   ui.config->theme = 0;
    _theme_apply(&ui);
    ui.frame = elm_layout_add(ui.win);
    assert(elm_layout_file_set(ui.frame, ui.theme_path, "elaro/frame"));

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

Reply via email to