cedric pushed a commit to branch master. http://git.enlightenment.org/core/elementary.git/commit/?id=5c7933b4ad412c318ee789d670868300c75ee6c3
commit 5c7933b4ad412c318ee789d670868300c75ee6c3 Author: Cedric Bail <cedric.b...@samsung.com> Date: Mon Nov 4 14:26:05 2013 +0900 elm_theme: Add API to specify exactly the Eina_File to be used as extension or overlay. --- src/lib/elm_theme.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++ src/lib/elm_theme.h | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 134 insertions(+) diff --git a/src/lib/elm_theme.c b/src/lib/elm_theme.c index 17e25aa..3bb3858 100644 --- a/src/lib/elm_theme.c +++ b/src/lib/elm_theme.c @@ -114,6 +114,31 @@ _elm_theme_file_item_del(Elm_Theme_Files *files, const char *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) { const char *item; @@ -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/src/lib/elm_theme.h b/src/lib/elm_theme.h index b4467d9..5aa3b31 100644 --- a/src/lib/elm_theme.h +++ b/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 */ @@ -197,6 +198,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 * * @param th The theme from which to get the overlays @@ -244,6 +279,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 * * @param th The theme from which to get the extensions --