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

git pushed a commit to branch main
in repository endorse.

View the commit online.

commit 8871a8e27f1af217dd15f26b3b2e17964f9c92b0
Author: Alastair Poole <[email protected]>
AuthorDate: Sat Nov 21 21:35:42 2026 +0000

    theme: default elm theme.
---
 data/themes/endorse_theme.edc |  36 ++++++++++++-
 po/endorse.pot                |   4 ++
 src/lib/endorse.h             |   7 ++-
 src/lib/endorse_about.c       |   3 +-
 src/lib/endorse_config.c      |   5 +-
 src/lib/endorse_shuffle.c     |   5 +-
 src/lib/endorse_theme.c       | 120 +++++++++++++++++++++++++++++++++++-------
 src/lib/endorse_ui.c          |  18 ++++---
 8 files changed, 165 insertions(+), 33 deletions(-)

diff --git a/data/themes/endorse_theme.edc b/data/themes/endorse_theme.edc
index 45db994..2316e36 100644
--- a/data/themes/endorse_theme.edc
+++ b/data/themes/endorse_theme.edc
@@ -133,10 +133,44 @@ images {
          map { on: 1; smooth: 1; rotation.center: ID; rotation.z: ANGLE; } \
       } \
    }
-#define ENDORSE_INK "endorse.chrome.ink"
+#define ENDORSE_INK "/fg/normal/button"
 #define ENDORSE_LINE(ID, X, Y, W, H) ENDORSE_STROKE(ID, X, Y, W, H, 0, ENDORSE_INK)
 
+color_tree {
+   ":fg" {
+      ENDORSE_INK;
+   }
+}
+
+color_classes {
+   color_class { name: ":fg"; color: 160 160 160 255; }
+}
+
 collections {
+   group { name: "endorse/default";
+      parts {
+         /* Elementary's window content swallow does not paint a background. */
+         part { name: "endorse.background"; type: SWALLOW; mouse_events: 0;
+            description { state: "default" 0.0; }
+         }
+         part { name: "endorse.header"; type: SWALLOW;
+            description { state: "default" 0.0;
+               align: 0.5 0.0; fixed: 0 1;
+               rel1.offset: 8 8;
+               rel2.relative: 1.0 0.0; rel2.offset: -9 7;
+               offset_scale: 1;
+            }
+         }
+         part { name: "endorse.content"; type: SWALLOW;
+            description { state: "default" 0.0;
+               rel1.to_y: "endorse.header"; rel1.relative: 0.0 1.0;
+               rel1.offset: 8 8; rel2.offset: -9 -9;
+               offset_scale: 1;
+            }
+         }
+      }
+   }
+
    ENDORSE_WINDOW("endorse/post-it", 255 241 161, 168 120 41,
                   "endorse_post_it_header.svg", "endorse_post_it_footer.svg",
                   "endorse_post_it_motion.svg", .50, 4, .50, -4, .22, .31, DECELERATE)
diff --git a/po/endorse.pot b/po/endorse.pot
index 55a2201..68a788c 100644
--- a/po/endorse.pot
+++ b/po/endorse.pot
@@ -224,6 +224,10 @@ msgstr ""
 msgid "Close window"
 msgstr ""
 
+#: src/lib/endorse_theme.c:28
+msgid "Default"
+msgstr ""
+
 #: src/lib/endorse_theme.c:29
 msgid "Post-it"
 msgstr ""
diff --git a/src/lib/endorse.h b/src/lib/endorse.h
index 58ea340..283d54d 100644
--- a/src/lib/endorse.h
+++ b/src/lib/endorse.h
@@ -27,6 +27,7 @@ typedef enum
    ENDORSE_THEME_FREQUENCY,
    ENDORSE_THEME_VOLTAGE,
    ENDORSE_THEME_UNDERTOW,
+   ENDORSE_THEME_DEFAULT,
    ENDORSE_THEME_COUNT
 } Endorse_Theme;
 
@@ -49,6 +50,7 @@ typedef struct
    Elm_Object_Item *selected_item;
    Endorse_Note *selected;
    Ecore_Timer *save_timer, *date_timer;
+   Ecore_Event_Handler *theme_config_handler;
    time_t list_day;
    Eina_Bool loading, dirty, rebuilding, list_needs_sort;
 } Endorse;
@@ -64,9 +66,10 @@ Eina_Bool endorse_ui_add(Endorse *app);
 void endorse_ui_shutdown(Endorse *app);
 const char *endorse_theme_name_get(Endorse_Theme theme);
 Eina_Bool endorse_theme_set(Endorse *app, Endorse_Theme theme);
+Eina_Bool endorse_theme_config_changed(void *data, int type, void *event);
 void endorse_theme_animate(Evas_Object *frame);
-void endorse_theme_window_bind(Evas_Object *window, Evas_Object *frame);
-void endorse_theme_window_state_set(Evas_Object *window, Evas_Object *frame);
+void endorse_theme_window_bind(Evas_Object *window, Evas_Object *frame, Eina_Bool custom_controls);
+void endorse_theme_window_state_set(Evas_Object *window, Evas_Object *frame, Eina_Bool custom_controls);
 Eina_Bool endorse_theme_icon_set(Evas_Object *icon, const char *name);
 Eina_Bool endorse_theme_layout_set(Evas_Object *layout, Endorse_Theme theme);
 void endorse_theme_entry_set(Endorse *app, Evas_Object *entry, Eina_Bool bold);
diff --git a/src/lib/endorse_about.c b/src/lib/endorse_about.c
index b980bb0..f18df20 100644
--- a/src/lib/endorse_about.c
+++ b/src/lib/endorse_about.c
@@ -48,7 +48,6 @@ endorse_about_show(Endorse *app)
    if (!app->about) return;
 
    elm_win_title_set(app->about, _("About Endorse"));
-   elm_win_borderless_set(app->about, EINA_TRUE);
    elm_win_autodel_set(app->about, EINA_TRUE);
    evas_object_event_callback_add(app->about, EVAS_CALLBACK_DEL, _endorse_about_deleted, app);
 
@@ -61,7 +60,7 @@ endorse_about_show(Endorse *app)
 
    evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    elm_win_resize_object_add(app->about, frame);
-   endorse_theme_window_bind(app->about, frame);
+   endorse_theme_window_bind(app->about, frame, EINA_FALSE);
    evas_object_show(frame);
 
    box = elm_box_add(frame);
diff --git a/src/lib/endorse_config.c b/src/lib/endorse_config.c
index 0f63356..7f09f3b 100644
--- a/src/lib/endorse_config.c
+++ b/src/lib/endorse_config.c
@@ -217,7 +217,10 @@ endorse_config_load(void)
    if (stat(_endorse_config_path, &info) == 0)
       config = _endorse_eet_read(_endorse_config_path, _endorse_config_descriptor, "endorse");
    else
-      config = errno == ENOENT ? calloc(1, sizeof(Endorse_Config)) : NULL;
+      {
+         config = errno == ENOENT ? calloc(1, sizeof(Endorse_Config)) : NULL;
+         if (config) config->theme = ENDORSE_THEME_DEFAULT;
+      }
    if (!config)
       {
          closedir(directory);
diff --git a/src/lib/endorse_shuffle.c b/src/lib/endorse_shuffle.c
index fb00197..84e7909 100644
--- a/src/lib/endorse_shuffle.c
+++ b/src/lib/endorse_shuffle.c
@@ -111,7 +111,6 @@ _endorse_shuffle_window_add(Endorse *app)
    if (!app->shuffle) return EINA_FALSE;
 
    elm_win_title_set(app->shuffle, _("Random note"));
-   elm_win_borderless_set(app->shuffle, EINA_TRUE);
    elm_win_autodel_set(app->shuffle, EINA_TRUE);
    evas_object_event_callback_add(app->shuffle, EVAS_CALLBACK_DEL, _endorse_shuffle_deleted, app);
 
@@ -124,7 +123,7 @@ _endorse_shuffle_window_add(Endorse *app)
 
    evas_object_size_hint_weight_set(app->shuffle_frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    elm_win_resize_object_add(app->shuffle, app->shuffle_frame);
-   endorse_theme_window_bind(app->shuffle, app->shuffle_frame);
+   endorse_theme_window_bind(app->shuffle, app->shuffle_frame, EINA_FALSE);
    evas_object_show(app->shuffle_frame);
 
    header = elm_label_add(app->shuffle_frame);
@@ -209,7 +208,7 @@ endorse_shuffle_theme_apply(Endorse *app)
    header = evas_object_data_get(app->shuffle_frame, "endorse.shuffle.header");
 
    if (!endorse_theme_layout_set(app->shuffle_frame, app->config->theme)) return;
-   endorse_theme_window_state_set(app->shuffle, app->shuffle_frame);
+   endorse_theme_window_state_set(app->shuffle, app->shuffle_frame, EINA_FALSE);
    endorse_theme_label_set(app, header, _("Random note"), 16);
 
    endorse_theme_entry_set(app, app->shuffle_title, EINA_TRUE);
diff --git a/src/lib/endorse_theme.c b/src/lib/endorse_theme.c
index d561481..55b36f5 100644
--- a/src/lib/endorse_theme.c
+++ b/src/lib/endorse_theme.c
@@ -25,6 +25,7 @@ typedef struct
 } Endorse_Theme_Info;
 
 static const Endorse_Theme_Info _endorse_themes[ENDORSE_THEME_COUNT] = {
+   [ENDORSE_THEME_DEFAULT] = { N_("Default"), "endorse/default", NULL, { 0 } },
    [ENDORSE_THEME_POST_IT] = {
       N_("Post-it"), "endorse/post-it", "Sans",
       { 0x423017, 0x735725, 0xfff8ce, 0xffecaa, 0xfff3c0, 0xffdf79, 0xf4bf40, 0x3d2b11, 0x9b7229 }
@@ -73,7 +74,6 @@ static const struct
    Endorse_Color color;
 } _endorse_widget_colors[] = {
    { "/bg/normal/button", ENDORSE_BUTTON },
-   { "endorse.chrome.ink", ENDORSE_INK },
    { "endorse.chrome.hover", ENDORSE_BUTTON },
    { "endorse.action.fill", ENDORSE_ACCENT },
    { "endorse.action.text", ENDORSE_ACCENT_INK },
@@ -128,7 +128,7 @@ static const struct
 static Endorse_Theme
 _endorse_theme_valid(Endorse_Theme theme)
 {
-   return (unsigned int)theme < ENDORSE_THEME_COUNT ? theme : ENDORSE_THEME_POST_IT;
+   return (unsigned int)theme < ENDORSE_THEME_COUNT ? theme : ENDORSE_THEME_DEFAULT;
 }
 
 static const char *
@@ -163,13 +163,33 @@ endorse_theme_label_set(Endorse *app, Evas_Object *label, const char *text, int
    info = &_endorse_themes[_endorse_theme_valid(app->config->theme)];
    escaped = elm_entry_utf8_to_markup(text);
 
-   elm_object_text_set(label, eina_slstr_printf("<font=%s font_size=%d color=#%06x><b>%s</b></font>",
+   if (app->config->theme == ENDORSE_THEME_DEFAULT)
+      elm_object_text_set(label, escaped ? escaped : "");
+   else elm_object_text_set(label, eina_slstr_printf("<font=%s font_size=%d color=#%06x><b>%s</b></font>",
                                               info->heading_font, size, info->colors[ENDORSE_INK],
                                               escaped ? escaped : ""));
 
    free(escaped);
 }
 
+static void
+_endorse_theme_entry_colors_refresh(Evas_Object *entry)
+{
+   Evas_Object *textblock = elm_entry_textblock_get(entry);
+   Evas_Object *edje;
+
+   if (!textblock) return;
+   edje = evas_object_smart_parent_get(textblock);
+   if (!edje) return;
+
+   /* Edje invalidates cached text styles on text class changes. */
+   if (edje_object_text_class_set(edje, "entry_text", NULL, 0))
+      edje_object_text_class_del(edje, "entry_text");
+   if (edje_object_text_class_set(edje, "entry_guide_text", NULL, 0))
+      edje_object_text_class_del(edje, "entry_guide_text");
+   edje_object_calc_force(edje);
+}
+
 void
 endorse_theme_entry_set(Endorse *app, Evas_Object *entry, Eina_Bool bold)
 {
@@ -179,6 +199,11 @@ endorse_theme_entry_set(Endorse *app, Evas_Object *entry, Eina_Bool bold)
 
    /* Entry textblocks cache their resolved Edje colors until their style is reapplied. */
    if (elm_entry_text_style_user_peek(entry)) elm_entry_text_style_user_pop(entry);
+   if (app->config->theme == ENDORSE_THEME_DEFAULT)
+      {
+         _endorse_theme_entry_colors_refresh(entry);
+         return;
+      }
    elm_entry_text_style_user_push(entry,
       eina_slstr_printf("DEFAULT='%scolor=#%06x'", bold ? "font_weight=bold " : "",
                         info->colors[ENDORSE_INK]));
@@ -196,7 +221,7 @@ endorse_theme_layout_set(Evas_Object *layout, Endorse_Theme theme)
 {
    const char *file;
    const char *group;
-   Evas_Object *header, *content;
+   Evas_Object *background, *header, *content;
    Eina_Bool loaded;
 
    file = _endorse_theme_file_get();
@@ -204,11 +229,23 @@ endorse_theme_layout_set(Evas_Object *layout, Endorse_Theme theme)
 
    if (!edje_file_group_exists(file, group)) return EINA_FALSE;
 
+   background = "" "endorse.background") ?
+                elm_object_part_content_unset(layout, "endorse.background") : NULL;
    header = edje_object_part_exists(elm_layout_edje_get(layout), "endorse.header") ?
             elm_object_part_content_unset(layout, "endorse.header") : NULL;
    content = elm_object_part_content_unset(layout, "endorse.content");
 
    loaded = elm_layout_file_set(layout, file, group);
+   if (edje_object_part_exists(elm_layout_edje_get(layout), "endorse.background"))
+      {
+         if (!background) background = ""
+         if (background)
+            {
+               elm_object_part_content_set(layout, "endorse.background", background);
+               evas_object_show(background);
+            }
+      }
+   else if (background) evas_object_del(background);
    if (header) elm_object_part_content_set(layout, "endorse.header", header);
    if (content) elm_object_part_content_set(layout, "endorse.content", content);
 
@@ -245,7 +282,7 @@ _endorse_shadow_update(void *data EINA_UNUSED, Evas *canvas, Evas_Object *frame,
 }
 
 void
-endorse_theme_window_state_set(Evas_Object *window, Evas_Object *frame)
+endorse_theme_window_state_set(Evas_Object *window, Evas_Object *frame, Eina_Bool custom_controls)
 {
    Evas_Object *edje;
    Eina_Bool has_shadow;
@@ -256,7 +293,10 @@ endorse_theme_window_state_set(Evas_Object *window, Evas_Object *frame)
    has_shadow = edje_object_part_exists(edje, "endorse.shadow");
    canvas = evas_object_evas_get(frame);
 
-   elm_win_alpha_set(window, has_shadow);
+   if (elm_win_alpha_get(window) != (custom_controls || has_shadow))
+      elm_win_alpha_set(window, custom_controls || has_shadow);
+   if (elm_win_borderless_get(window) != (custom_controls || has_shadow))
+      elm_win_borderless_set(window, custom_controls || has_shadow);
    if (has_shadow)
       {
          elm_layout_signal_emit(frame, elm_win_maximized_get(window) ?
@@ -272,25 +312,17 @@ endorse_theme_window_state_set(Evas_Object *window, Evas_Object *frame)
 }
 
 void
-endorse_theme_window_bind(Evas_Object *window, Evas_Object *frame)
+endorse_theme_window_bind(Evas_Object *window, Evas_Object *frame, Eina_Bool custom_controls)
 {
    evas_object_event_callback_add(frame, EVAS_CALLBACK_RESIZE, _endorse_shadow_update, NULL);
-   endorse_theme_window_state_set(window, frame);
+   endorse_theme_window_state_set(window, frame, custom_controls);
 }
 
-Eina_Bool
-endorse_theme_set(Endorse *app, Endorse_Theme theme)
+static void
+_endorse_theme_colors_apply(const Endorse_Theme_Info *info)
 {
-   const Endorse_Theme_Info *info;
    unsigned int i, color;
 
-   theme = _endorse_theme_valid(theme);
-   if (!endorse_theme_layout_set(app->frame, theme)) return EINA_FALSE;
-
-   if (!app->title) elm_theme_extension_add(NULL, _endorse_theme_file_get());
-   else endorse_theme_window_state_set(app->win, app->frame);
-
-   info = &_endorse_themes[theme];
    for (i = 0; i < EINA_C_ARRAY_LENGTH(_endorse_widget_colors); ++i)
       {
          color = info->colors[_endorse_widget_colors[i].color];
@@ -303,6 +335,52 @@ endorse_theme_set(Endorse *app, Endorse_Theme theme)
    edje_color_class_set("/bg/normal/list/group", (color >> 16) * 7 / 8,
                         ((color >> 8) & 255) * 7 / 8, (color & 255) * 7 / 8, 255,
                         255, 255, 255, 255, 255, 255, 255, 255);
+}
+
+Eina_Bool
+endorse_theme_config_changed(void *data, int type EINA_UNUSED, void *event EINA_UNUSED)
+{
+   Endorse *app = data;
+
+   /* Elementary replaces the shared widget color classes on palette reload. */
+   if (app->config->theme != ENDORSE_THEME_DEFAULT)
+      _endorse_theme_colors_apply(&_endorse_themes[_endorse_theme_valid(app->config->theme)]);
+   endorse_theme_editor_set(app);
+   if (app->shuffle)
+      {
+         endorse_theme_entry_set(app, app->shuffle_title, EINA_TRUE);
+         endorse_theme_entry_set(app, app->shuffle_description, EINA_FALSE);
+      }
+
+   return ECORE_CALLBACK_PASS_ON;
+}
+
+Eina_Bool
+endorse_theme_set(Endorse *app, Endorse_Theme theme)
+{
+   Eina_Bool was_default, use_default;
+
+   theme = _endorse_theme_valid(theme);
+   if (!endorse_theme_layout_set(app->frame, theme)) return EINA_FALSE;
+
+   was_default = app->config->theme == ENDORSE_THEME_DEFAULT;
+   use_default = theme == ENDORSE_THEME_DEFAULT;
+   if (use_default && app->title && !was_default)
+      {
+         for (unsigned int i = 0; i < EINA_C_ARRAY_LENGTH(_endorse_widget_colors); ++i)
+            edje_color_class_del(_endorse_widget_colors[i].name);
+         edje_color_class_del("/bg/normal/list/group");
+         elm_config_palette_set(elm_config_palette_get());
+         elm_theme_extension_del(NULL, _endorse_theme_file_get());
+      }
+   else if (!use_default)
+      {
+         if (!app->title || was_default)
+            elm_theme_extension_add(NULL, _endorse_theme_file_get());
+         _endorse_theme_colors_apply(&_endorse_themes[theme]);
+      }
+
+   if (app->title) endorse_theme_window_state_set(app->win, app->frame, EINA_TRUE);
 
    app->config->theme = theme;
    if (app->title && app->description)
@@ -310,6 +388,12 @@ endorse_theme_set(Endorse *app, Endorse_Theme theme)
          endorse_theme_editor_set(app);
          endorse_theme_animate(app->frame);
       }
+   if (app->status)
+      {
+         char *status = elm_entry_markup_to_utf8(elm_object_text_get(app->status));
+         endorse_theme_label_set(app, app->status, status ? status : "", 11);
+         free(status);
+      }
    if (app->sidebar_label) endorse_theme_label_set(app, app->sidebar_label, _("Notes"), 15);
    if (app->grip) endorse_theme_label_set(app, app->grip, "◢", 11);
 
diff --git a/src/lib/endorse_ui.c b/src/lib/endorse_ui.c
index 6032b76..5be2fac 100644
--- a/src/lib/endorse_ui.c
+++ b/src/lib/endorse_ui.c
@@ -556,9 +556,11 @@ _endorse_menu_theme(void *data, Evas_Object *object EINA_UNUSED, void *event)
 {
    Endorse *app;
    Endorse_Theme theme;
+   int index;
 
    app = data;
-   theme = elm_menu_item_index_get(event);
+   index = elm_menu_item_index_get(event);
+   theme = index == 0 ? ENDORSE_THEME_DEFAULT : index - 1;
 
    if (!endorse_theme_set(app, theme))
       _endorse_status_set(app, _("Could not load the theme."));
@@ -581,7 +583,9 @@ _endorse_menu_clicked(void *data, Evas_Object *button, void *event EINA_UNUSED)
          app->menu = elm_menu_add(app->win);
          elm_menu_item_add(app->menu, NULL, "document-new", _("New note"), _endorse_add_clicked, app);
          themes = elm_menu_item_add(app->menu, NULL, NULL, _("Themes"), NULL, NULL);
-         for (theme = ENDORSE_THEME_POST_IT; theme < ENDORSE_THEME_COUNT; ++theme)
+         elm_menu_item_add(app->menu, themes, NULL, endorse_theme_name_get(ENDORSE_THEME_DEFAULT),
+                           _endorse_menu_theme, app);
+         for (theme = ENDORSE_THEME_POST_IT; theme < ENDORSE_THEME_DEFAULT; ++theme)
             elm_menu_item_add(app->menu, themes, NULL, endorse_theme_name_get(theme),
                               _endorse_menu_theme, app);
          elm_menu_item_separator_add(app->menu, NULL);
@@ -633,7 +637,7 @@ _endorse_maximized_changed(void *data, Evas_Object *object, void *event EINA_UNU
    elm_object_tooltip_text_set(app->maximize, label);
    elm_object_access_info_set(app->maximize, label);
 
-   endorse_theme_window_state_set(app->win, app->frame);
+   endorse_theme_window_state_set(app->win, app->frame, EINA_TRUE);
 }
 
 static void
@@ -645,7 +649,7 @@ _endorse_drag(void *data, Evas *evas EINA_UNUSED, Evas_Object *object EINA_UNUSE
    app = data;
    mouse = event;
 
-   if (mouse->button != 1) return;
+   if (mouse->button != 1 || !elm_win_borderless_get(app->win)) return;
    if (mouse->flags & EVAS_BUTTON_DOUBLE_CLICK)
       _endorse_maximize(app, NULL, NULL);
    else elm_win_move_resize_start(app->win, ELM_WIN_MOVE_RESIZE_MOVE);
@@ -729,7 +733,6 @@ endorse_ui_add(Endorse *app)
    app->win = elm_win_add(NULL, "endorse", ELM_WIN_BASIC);
    if (!app->win) return EINA_FALSE;
    elm_win_title_set(app->win, "Endorse");
-   elm_win_borderless_set(app->win, EINA_TRUE);
    evas_object_smart_callback_add(app->win, "delete,request", _endorse_close, app);
 
    icon = elm_icon_add(app->win);
@@ -748,7 +751,7 @@ endorse_ui_add(Endorse *app)
    evas_object_size_hint_weight_set(app->frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
    evas_object_size_hint_min_set(app->frame, ELM_SCALE_SIZE(520), ELM_SCALE_SIZE(340));
    elm_win_resize_object_add(app->win, app->frame);
-   endorse_theme_window_bind(app->win, app->frame);
+   endorse_theme_window_bind(app->win, app->frame, EINA_TRUE);
    evas_object_show(app->frame);
 
    root = elm_box_add(app->frame);
@@ -829,6 +832,8 @@ endorse_ui_add(Endorse *app)
 
    _endorse_list_rebuild(app, NULL);
    app->date_timer = ecore_timer_add(60.0, _endorse_date_tick, app);
+   app->theme_config_handler = ecore_event_handler_add(ELM_EVENT_CONFIG_ALL_CHANGED,
+                                                       endorse_theme_config_changed, app);
 
    evas_object_resize(app->win, app->config->width > 0 ? app->config->width : ELM_SCALE_SIZE(820),
                        app->config->height > 0 ? app->config->height : ELM_SCALE_SIZE(540));
@@ -845,6 +850,7 @@ endorse_ui_shutdown(Endorse *app)
 {
    if (app->save_timer) ecore_timer_del(app->save_timer);
    if (app->date_timer) ecore_timer_del(app->date_timer);
+   if (app->theme_config_handler) ecore_event_handler_del(app->theme_config_handler);
    if (!elm_win_maximized_get(app->win))
       evas_object_geometry_get(app->win, NULL, NULL, &app->config->width, &app->config->height);
    if (app->dirty && !_endorse_save(app))

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

Reply via email to