This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch eolian/improvements
in repository efl.
View the commit online.
commit dd43b550120a66b7bf8d167aa742c3e2faa6ea45
Author: [email protected] <[email protected]>
AuthorDate: Mon Oct 26 16:34:18 2026 -0600
elementary: widgets declare the theme styles they offer
The default theme has styles for Efl.Ui widgets that no class declared,
so bindings and documentation could not offer them. The ones meant for
applications are now in their classes' styles {} blocks:
- Efl.Ui.Check: toggle
- Efl.Ui.Button: anchor
- Efl.Ui.Scroller: noclip
The rest are not for applications and stay undeclared: button:video,
which Efl.Ui.Video sets on its play button, and
scroller:popup/no_inset_shadow, which the scrollable content sets on
its scroller.
efl-ui-theme-styles now checks both ways and fails on a theme style no
class declares. The report it replaces counted a style against every
class sharing a theme name -- the textbox's styles against the internal
text scroller -- and missed the style a class sets on itself. A theme
name's styles are now those any class loading it declares or sets on
itself, and the internal ones are listed in the test with who uses
them.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/elementary/efl_ui_button.eo | 4 +
src/lib/elementary/efl_ui_check.eo | 5 +
src/lib/elementary/efl_ui_scroller.eo | 4 +
src/tests/elementary/efl_ui_theme_styles.c | 156 +++++++++++++++++++----------
4 files changed, 115 insertions(+), 54 deletions(-)
diff --git a/src/lib/elementary/efl_ui_button.eo b/src/lib/elementary/efl_ui_button.eo
index e7ff444d33..361d7eb2db 100644
--- a/src/lib/elementary/efl_ui_button.eo
+++ b/src/lib/elementary/efl_ui_button.eo
@@ -13,6 +13,10 @@ class Efl.Ui.Button extends Efl.Ui.Layout_Base implements Efl.Input.Clickable, E
@since 1.23
]]
+ styles {
+ anchor; [[Drawn as a link: underlined text and no frame, for an action
+ inside a line of text.]]
+ }
implements {
class.constructor;
Efl.Object.constructor;
diff --git a/src/lib/elementary/efl_ui_check.eo b/src/lib/elementary/efl_ui_check.eo
index 87d9d7e9d4..3f9d8afb0f 100644
--- a/src/lib/elementary/efl_ui_check.eo
+++ b/src/lib/elementary/efl_ui_check.eo
@@ -15,6 +15,11 @@ class Efl.Ui.Check extends Efl.Ui.Layout_Base
]]
methods {
}
+ styles {
+ toggle; [[A sliding switch rather than a box with a tick, with a text on
+ each side of the knob for the two states: parts $[efl.ontext]
+ and $[efl.offtext].]]
+ }
implements {
Efl.Object.constructor;
Efl.Ui.Widget.on_access_activate;
diff --git a/src/lib/elementary/efl_ui_scroller.eo b/src/lib/elementary/efl_ui_scroller.eo
index 46f256382d..9bdbac016a 100644
--- a/src/lib/elementary/efl_ui_scroller.eo
+++ b/src/lib/elementary/efl_ui_scroller.eo
@@ -20,6 +20,10 @@ class Efl.Ui.Scroller extends Efl.Ui.Layout_Base implements
@since 1.23
]]
+ styles {
+ noclip; [[Its content is not cut at its edges: what is scrolled out of the
+ scroller stays visible around it.]]
+ }
implements {
Efl.Object.constructor;
Efl.Object.finalize;
diff --git a/src/tests/elementary/efl_ui_theme_styles.c b/src/tests/elementary/efl_ui_theme_styles.c
index f6f58f417c..9653f8f3e2 100644
--- a/src/tests/elementary/efl_ui_theme_styles.c
+++ b/src/tests/elementary/efl_ui_theme_styles.c
@@ -1,4 +1,5 @@
-/* Every theme style a class declares in its .eo file is in the default theme.
+/* Every theme style a class declares in its .eo file is in the default theme,
+ * and every style the default theme has for a class is declared.
*
* A class lists its styles -- the values Efl.Ui.Widget.style accepts -- in a
* styles {} block, and bindings and documentation offer exactly those. A style
@@ -8,9 +9,10 @@
* fails the check. Going through the widget rather than guessing group names
* keeps the check honest about how a class names its theme groups.
*
- * The other way round is a report rather than a check, with --undeclared:
- * the styles the default theme has for a widget class that the class does
- * not declare, which is most of them until classes catch up.
+ * The other way round, a theme group efl/<name>:<style> is declared when a
+ * class whose widgets load their theme as <name> declares the style, or sets
+ * it on itself (as Efl.Ui.List_Placeholder_Item does), or when it is one of
+ * the few styles EFL sets on widgets of its own, listed below.
*
* Arguments are the -I directories eolian_gen is given.
*/
@@ -29,6 +31,18 @@
typedef const Efl_Class *(*Class_Get)(void);
+/* Styles the widgets set on parts of themselves, which no application is
+ meant to ask for. Not declared, so not offered. */
+static const struct
+{
+ const char *group;
+ const char *user;
+} _internal[] = {
+ { "efl/button:video", "Efl.Ui.Video, for its play button" },
+ { "efl/scroller:popup/no_inset_shadow", "Efl.Ui.Widget_Scrollable_Content, for its scroller" },
+ { NULL, NULL }
+};
+
static int
_class_check(const Eolian_Class *cl, Eo *win, int *checked)
{
@@ -73,51 +87,91 @@ _class_check(const Eolian_Class *cl, Eo *win, int *checked)
return missing;
}
-/* Prints the styles the theme has for cl's widgets that cl and its parents
- do not declare. */
-static int
-_class_report(const Eolian_Class *cl, Eo *win, Eina_List *groups)
+/* Notes, under the name cl's widgets load their theme as, the styles cl
+ declares, its parents' and the one it sets on itself. */
+static void
+_class_collect(const Eolian_Class *cl, Eo *win, Eina_Hash *declared)
{
Eina_Stringshare *getter = eolian_class_c_get_function_name_get(cl);
Class_Get get = (Class_Get) dlsym(RTLD_DEFAULT, getter);
- const char *klass, *group;
- char prefix[256];
- Eina_List *l;
- int n = 0;
+ const Eolian_Class *c;
+ const char *klass, *own;
+ char group[256];
Eo *obj;
eina_stringshare_del(getter);
- if (!get || (eolian_class_type_get(cl) != EOLIAN_CLASS_REGULAR)) return 0;
- if (!efl_isa(get(), EFL_UI_WIDGET_CLASS) || efl_isa(get(), EFL_UI_WIN_CLASS)) return 0;
+ if (!get || (eolian_class_type_get(cl) != EOLIAN_CLASS_REGULAR)) return;
+ if (!efl_isa(get(), EFL_UI_WIDGET_CLASS) || efl_isa(get(), EFL_UI_WIN_CLASS)) return;
obj = efl_add(get(), win);
klass = obj ? elm_widget_theme_klass_get(obj) : NULL;
- if (klass)
+ if (!klass) goto end;
+
+ own = efl_ui_widget_style_get(obj);
+ if (own && strcmp(own, "default"))
{
- snprintf(prefix, sizeof(prefix), "efl/%s:", klass);
- EINA_LIST_FOREACH(groups, l, group)
- {
- const Eolian_Class *c;
- Eina_Bool declared = EINA_FALSE;
- const char *style;
-
- if (strncmp(group, prefix, strlen(prefix))) continue;
- style = group + strlen(prefix);
- for (c = cl; c && !declared; c = eolian_class_parent_get(c))
- {
- Eina_Iterator *styles = eolian_class_styles_get(c);
- const Eolian_Style *st;
-
- EINA_ITERATOR_FOREACH(styles, st)
- if (!strcmp(eolian_style_name_get(st), style)) declared = EINA_TRUE;
- eina_iterator_free(styles);
- }
- if (declared) continue;
- printf("%s: style '%s' (%s) is not declared\n", eolian_class_name_get(cl), style, group);
- n++;
- }
+ snprintf(group, sizeof(group), "efl/%s:%s", klass, own);
+ eina_hash_set(declared, group, eolian_class_name_get(cl));
}
+ for (c = cl; c; c = eolian_class_parent_get(c))
+ {
+ Eina_Iterator *styles = eolian_class_styles_get(c);
+ const Eolian_Style *st;
+
+ EINA_ITERATOR_FOREACH(styles, st)
+ {
+ snprintf(group, sizeof(group), "efl/%s:%s", klass, eolian_style_name_get(st));
+ eina_hash_set(declared, group, eolian_class_name_get(cl));
+ }
+ eina_iterator_free(styles);
+ }
+ /* The name itself, so groups of names no class loads are left alone. */
+ snprintf(group, sizeof(group), "efl/%s:", klass);
+ eina_hash_set(declared, group, eolian_class_name_get(cl));
+
+ end:
efl_del(obj);
+}
+
+static Eina_Bool
+_internal_is(const char *group)
+{
+ int i;
+
+ for (i = 0; _internal[i].group; i++)
+ if (!strcmp(_internal[i].group, group)) return EINA_TRUE;
+ return EINA_FALSE;
+}
+
+/* Says which styles of the default theme are for a class but declared by
+ none, and returns how many. */
+static int
+_undeclared(Eina_Hash *declared)
+{
+ Eina_List *groups = edje_file_collection_list(elm_theme_list_item_path_get("default", NULL));
+ const char *group, *colon;
+ char klass[256];
+ Eina_List *l;
+ int n = 0;
+
+ EINA_LIST_FOREACH(groups, l, group)
+ {
+ const char *who;
+
+ if (strncmp(group, "efl/", 4)) continue;
+ colon = strchr(group, ':');
+ if (!colon || ((size_t)(colon - group) + 2 > sizeof(klass))) continue;
+ memcpy(klass, group, colon - group + 1);
+ klass[colon - group + 1] = '\0';
+ who = eina_hash_find(declared, klass);
+ if (!who) continue;
+ if (eina_hash_find(declared, group) || _internal_is(group)) continue;
+
+ fprintf(stderr, "%s: the default theme has %s, which no class declares\n",
+ who, group);
+ n++;
+ }
+ edje_file_collection_list_free(groups);
return n;
}
@@ -127,8 +181,8 @@ main(int argc, char **argv)
const Eolian_Class *cl;
Eolian_State *eos;
Eina_Iterator *classes;
- int i, missing = 0, checked = 0;
- Eina_Bool report = EINA_FALSE;
+ int i, missing = 0, checked = 0, undeclared;
+ Eina_Hash *declared;
Eo *win;
setenv("ELM_ENGINE", "buffer", 1);
@@ -138,8 +192,6 @@ main(int argc, char **argv)
{
if (!strcmp(argv[i], "-I") && (i + 1 < argc))
eolian_state_directory_add(eos, argv[++i]);
- else if (!strcmp(argv[i], "--undeclared"))
- report = EINA_TRUE;
}
if (!eolian_state_all_eo_files_parse(eos))
{
@@ -151,18 +203,14 @@ main(int argc, char **argv)
win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
efl_ui_win_type_set(efl_added, EFL_UI_WIN_TYPE_BASIC));
- if (report)
- {
- Eina_List *groups = edje_file_collection_list(elm_theme_list_item_path_get("default", NULL));
- int n = 0;
-
- classes = eolian_state_classes_get(eos);
- EINA_ITERATOR_FOREACH(classes, cl)
- n += _class_report(cl, win, groups);
- eina_iterator_free(classes);
- edje_file_collection_list_free(groups);
- printf("%d styles in the default theme not declared by their class\n", n);
- }
+ declared = eina_hash_string_superfast_new(NULL);
+ classes = eolian_state_classes_get(eos);
+ EINA_ITERATOR_FOREACH(classes, cl)
+ _class_collect(cl, win, declared);
+ eina_iterator_free(classes);
+ undeclared = _undeclared(declared);
+ eina_hash_free(declared);
+ printf("%d styles in the default theme not declared\n", undeclared);
classes = eolian_state_classes_get(eos);
EINA_ITERATOR_FOREACH(classes, cl)
@@ -177,5 +225,5 @@ main(int argc, char **argv)
eolian_shutdown();
/* nothing declared is a check that checked nothing */
- return (missing || !checked) ? 1 : 0;
+ return (missing || undeclared || !checked) ? 1 : 0;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.