diff --git a/legacy/elementary/src/lib/elm_theme.c b/legacy/elementary/src/lib/elm_theme.c index 17e25aa716..3bb3858ea6 100644 --- a/legacy/elementary/src/lib/elm_theme.c +++ b/legacy/elementary/src/lib/elm_theme.c @@ -113,6 +113,31 @@ _elm_theme_file_item_del(Elm_Theme_Files *files, const char *str) eina_stringshare_del(str); } +static void +_elm_theme_file_mmap_del(Elm_Theme_Files *files, const Eina_File *file) +{ + Eina_List *l, *ll; + Eina_List *l2, *ll2; + Eina_File *f; + + l2 = files->items; + EINA_LIST_FOREACH_SAFE(files->handles, l, ll, f) + { + ll2 = l2->next; + + if (f == file) + { + eina_file_close(f); + eina_stringshare_del(eina_list_data_get(l2)); + + files->handles = eina_list_remove_list(files->handles, l); + files->items = eina_list_remove_list(files->items, l2); + } + + l2 = ll2; + } +} + static void _elm_theme_file_clean(Elm_Theme_Files *files) { @@ -533,6 +558,25 @@ elm_theme_overlay_del(Elm_Theme *th, const char *item) elm_theme_flush(th); } +EAPI void +elm_theme_overlay_mmap_add(Elm_Theme *th, const Eina_File *f) +{ + Eina_File *file = eina_file_dup(f); + + if (!th) th = &(theme_default); + _elm_theme_item_finalize(&th->overlay, eina_file_filename_get(file), file); + elm_theme_flush(th); +} + +EAPI void +elm_theme_overlay_mmap_del(Elm_Theme *th, const Eina_File *f) +{ + if (!f) return ; + if (!th) th = &(theme_default); + _elm_theme_file_mmap_del(&th->overlay, f); + elm_theme_flush(th); +} + EAPI const Eina_List * elm_theme_overlay_list_get(const Elm_Theme *th) { @@ -558,6 +602,26 @@ elm_theme_extension_del(Elm_Theme *th, const char *item) elm_theme_flush(th); } +EAPI void +elm_theme_extension_mmap_add(Elm_Theme *th, const Eina_File *f) +{ + Eina_File *file = eina_file_dup(f); + + if (!f) return ; + if (!th) th = &(theme_default); + _elm_theme_item_finalize(&th->overlay, eina_file_filename_get(file), file); + elm_theme_flush(th); +} + +EAPI void +elm_theme_extension_mmap_del(Elm_Theme *th, const Eina_File *f) +{ + if (!f) return ; + if (!th) th = &(theme_default); + _elm_theme_file_mmap_del(&th->extension, f); + elm_theme_flush(th); +} + EAPI const Eina_List * elm_theme_extension_list_get(const Elm_Theme *th) { diff --git a/legacy/elementary/src/lib/elm_theme.h b/legacy/elementary/src/lib/elm_theme.h index b4467d91d3..5aa3b31db3 100644 --- a/legacy/elementary/src/lib/elm_theme.h +++ b/legacy/elementary/src/lib/elm_theme.h @@ -179,6 +179,7 @@ EAPI Elm_Theme *elm_theme_default_get(void); * of trouble. * * @see elm_theme_extension_add() + * @see elm_theme_overlay_mmap_add() * * @ingroup Theme */ @@ -196,6 +197,40 @@ EAPI void elm_theme_overlay_add(Elm_Theme *th, const char *item); */ EAPI void elm_theme_overlay_del(Elm_Theme *th, const char *item); +/** + * Prepends a theme overlay to the list of overlays + * + * @param th The theme to add to, or if NULL, the default theme + * @param f The Edje file handle to be used + * + * Use this if your application needs to provide some custom overlay theme + * (An Edje file that replaces some default styles of widgets) where adding + * new styles, or changing system theme configuration is not possible. Do + * NOT use this instead of a proper system theme configuration. Use proper + * configuration files, profiles, environment variables etc. to set a theme + * so that the theme can be altered by simple configuration by a user. Using + * this call to achieve that effect is abusing the API and will create lots + * of trouble. + * + * @see elm_theme_extension_add() + * @see elm_theme_overlay_add() + * + * @ingroup Theme + */ +EAPI void elm_theme_overlay_mmap_add(Elm_Theme *th, const Eina_File *f); + +/** + * Delete a theme overlay from the list of overlays + * + * @param th The theme to delete from, or if NULL, the default theme + * @param f The file handle of the theme overlay + * + * @see elm_theme_overlay_mmap_add() + * + * @ingroup Theme + */ +EAPI void elm_theme_overlay_mmap_del(Elm_Theme *th, const Eina_File *f); + /** * Get the list of registered overlays for the given theme * @@ -243,6 +278,41 @@ EAPI void elm_theme_extension_add(Elm_Theme *th, const char *item); */ EAPI void elm_theme_extension_del(Elm_Theme *th, const char *item); +/** + * Appends a theme extension to the list of extensions. + * + * @param th The theme to add to, or if NULL, the default theme + * @param f The Edje file handle to be used + * + * This is intended when an application needs more styles of widgets or new + * widget themes that the default does not provide (or may not provide). The + * application has "extended" usage by coming up with new custom style names + * for widgets for specific uses, but as these are not "standard", they are + * not guaranteed to be provided by a default theme. This means the + * application is required to provide these extra elements itself in specific + * Edje files. This call adds one of those Edje files to the theme search + * path to be search after the default theme. The use of this call is + * encouraged when default styles do not meet the needs of the application. + * Use this call instead of elm_theme_overlay_add() for almost all cases. + * + * @see elm_object_style_set() + * + * @ingroup Theme + */ +EAPI void elm_theme_extension_mmap_add(Elm_Theme *th, const Eina_File *f); + +/** + * Deletes a theme extension from the list of extensions. + * + * @param th The theme to delete from, or if NULL, the default theme + * @param f The file handle of the theme extension + * + * @see elm_theme_extension_add() + * + * @ingroup Theme + */ +EAPI void elm_theme_extension_mmap_del(Elm_Theme *th, const Eina_File *f); + /** * Get the list of registered extensions for the given theme *