2013-04-25 22:13:00 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
|
2008-09-29 23:58:56 -07:00
|
|
|
#include <Elementary.h>
|
2013-04-25 22:13:00 -07:00
|
|
|
|
2008-09-29 23:58:56 -07:00
|
|
|
#include "elm_priv.h"
|
|
|
|
|
2010-05-11 18:03:46 -07:00
|
|
|
static Elm_Theme theme_default =
|
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
{ NULL, NULL }, { NULL, NULL }, { NULL, NULL },
|
2014-03-18 01:18:09 -07:00
|
|
|
NULL, NULL, NULL, NULL, NULL, 1, NULL
|
2010-05-11 18:03:46 -07:00
|
|
|
};
|
|
|
|
|
2009-01-13 01:20:53 -08:00
|
|
|
static Eina_List *themes = NULL;
|
2010-05-11 18:03:46 -07:00
|
|
|
|
2013-11-03 19:17:58 -08:00
|
|
|
static Eina_File *
|
|
|
|
_elm_theme_find_try(Elm_Theme *th, Eina_File *f, const char *group)
|
|
|
|
{
|
|
|
|
if (edje_mmap_group_exists(f, group))
|
|
|
|
{
|
|
|
|
eina_hash_add(th->cache, group, eina_file_dup(f));
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
_elm_theme_item_finalize(Elm_Theme_Files *files,
|
|
|
|
const char *item,
|
2014-03-14 20:01:56 -07:00
|
|
|
Eina_File *f,
|
2014-03-28 00:17:38 -07:00
|
|
|
Eina_Bool prepend,
|
|
|
|
Eina_Bool istheme)
|
2013-11-03 19:17:58 -08:00
|
|
|
{
|
2014-03-14 19:44:20 -07:00
|
|
|
if (!f) return;
|
2014-03-28 00:17:38 -07:00
|
|
|
if (istheme)
|
2014-03-26 02:06:08 -07:00
|
|
|
{
|
2014-03-28 00:17:38 -07:00
|
|
|
char *version;
|
|
|
|
|
|
|
|
if (!(version = edje_mmap_data_get(f, "version"))) return;
|
|
|
|
if (atoi(version) < 110) // bump this version number when we need to
|
|
|
|
{
|
|
|
|
free(version);
|
|
|
|
return;
|
|
|
|
}
|
2014-03-26 02:06:08 -07:00
|
|
|
free(version);
|
|
|
|
}
|
2014-03-14 20:01:56 -07:00
|
|
|
if (prepend)
|
|
|
|
{
|
|
|
|
files->items = eina_list_prepend(files->items,
|
|
|
|
eina_stringshare_add(item));
|
|
|
|
files->handles = eina_list_prepend(files->handles, f);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
files->items = eina_list_append(files->items,
|
|
|
|
eina_stringshare_add(item));
|
|
|
|
files->handles = eina_list_append(files->handles, f);
|
|
|
|
}
|
2013-11-03 19:17:58 -08:00
|
|
|
}
|
|
|
|
|
2010-05-11 18:03:46 -07:00
|
|
|
static void
|
2014-03-28 00:17:38 -07:00
|
|
|
_elm_theme_file_item_add(Elm_Theme_Files *files, const char *item, Eina_Bool prepend, Eina_Bool istheme)
|
2010-05-11 18:03:46 -07:00
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
Eina_Strbuf *buf = NULL;
|
|
|
|
Eina_File *f = NULL;
|
|
|
|
const char *home;
|
2013-05-29 05:08:05 -07:00
|
|
|
|
2015-05-14 12:26:44 -07:00
|
|
|
home = eina_environment_home_get();
|
2013-11-03 19:17:58 -08:00
|
|
|
buf = eina_strbuf_new();
|
|
|
|
|
|
|
|
if ((item[0] == '/') ||
|
|
|
|
((item[0] == '.') && (item[1] == '/')) ||
|
|
|
|
((item[0] == '.') && (item[1] == '.') && (item[2] == '/')) ||
|
|
|
|
((isalpha(item[0])) && (item[1] == ':')))
|
2011-04-01 04:20:18 -07:00
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
f = eina_file_open(item, EINA_FALSE);
|
|
|
|
if (!f) goto on_error;
|
|
|
|
}
|
|
|
|
else if (((item[0] == '~') && (item[1] == '/')))
|
|
|
|
{
|
|
|
|
eina_strbuf_append_printf(buf, "%s/%s", home, item + 2);
|
|
|
|
|
|
|
|
f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE);
|
|
|
|
if (!f) goto on_error;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
eina_strbuf_append_printf(buf,
|
|
|
|
"%s/"ELEMENTARY_BASE_DIR"/themes/%s.edj",
|
|
|
|
home, item);
|
|
|
|
f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE);
|
2014-03-28 00:17:38 -07:00
|
|
|
_elm_theme_item_finalize(files, item, f, prepend, istheme);
|
2013-11-03 19:17:58 -08:00
|
|
|
|
|
|
|
eina_strbuf_reset(buf);
|
2016-03-23 22:48:45 -07:00
|
|
|
|
|
|
|
eina_strbuf_append_printf(buf,
|
|
|
|
"%s/themes/%s.edj",
|
|
|
|
getenv("ELM_DATA_DIR"), item);
|
|
|
|
f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE);
|
|
|
|
_elm_theme_item_finalize(files, item, f, prepend, istheme);
|
|
|
|
|
|
|
|
eina_strbuf_reset(buf);
|
|
|
|
|
2013-11-03 19:17:58 -08:00
|
|
|
eina_strbuf_append_printf(buf,
|
|
|
|
"%s/themes/%s.edj",
|
|
|
|
_elm_data_dir, item);
|
|
|
|
f = eina_file_open(eina_strbuf_string_get(buf), EINA_FALSE);
|
|
|
|
/* Finalize will be done by the common one */
|
2011-04-01 04:20:18 -07:00
|
|
|
}
|
2013-11-03 19:17:58 -08:00
|
|
|
|
2014-03-28 00:17:38 -07:00
|
|
|
_elm_theme_item_finalize(files, item, f, prepend, istheme);
|
2013-11-03 19:17:58 -08:00
|
|
|
|
|
|
|
on_error:
|
|
|
|
if (buf) eina_strbuf_free(buf);
|
2010-05-11 18:03:46 -07:00
|
|
|
}
|
2009-01-13 01:20:53 -08:00
|
|
|
|
2013-11-03 19:17:58 -08:00
|
|
|
static void
|
|
|
|
_elm_theme_file_item_del(Elm_Theme_Files *files, const char *str)
|
2009-02-23 00:40:58 -08:00
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
Eina_List *l, *ll;
|
|
|
|
Eina_List *l2, *ll2;
|
|
|
|
const char *item;
|
|
|
|
|
|
|
|
str = eina_stringshare_add(str);
|
|
|
|
l2 = files->handles;
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2013-11-03 19:17:58 -08:00
|
|
|
EINA_LIST_FOREACH_SAFE(files->items, l, ll, item)
|
2009-02-23 00:40:58 -08:00
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
ll2 = l2->next;
|
|
|
|
|
|
|
|
if (item == str)
|
2011-04-01 04:20:18 -07:00
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
eina_file_close(eina_list_data_get(l2));
|
|
|
|
eina_stringshare_del(item);
|
|
|
|
|
|
|
|
files->handles = eina_list_remove_list(files->handles, l2);
|
|
|
|
files->items = eina_list_remove_list(files->items, l);
|
2011-04-01 04:20:18 -07:00
|
|
|
}
|
2013-11-03 19:17:58 -08:00
|
|
|
|
|
|
|
l2 = ll2;
|
2009-02-23 00:40:58 -08:00
|
|
|
}
|
2013-11-03 19:17:58 -08:00
|
|
|
|
|
|
|
eina_stringshare_del(str);
|
2009-02-23 00:40:58 -08:00
|
|
|
}
|
|
|
|
|
2013-11-03 21:26:05 -08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-03 19:17:58 -08:00
|
|
|
static void
|
|
|
|
_elm_theme_file_clean(Elm_Theme_Files *files)
|
2009-02-23 00:40:58 -08:00
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
const char *item;
|
|
|
|
Eina_File *f;
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2013-11-03 19:17:58 -08:00
|
|
|
EINA_LIST_FREE(files->items, item)
|
|
|
|
eina_stringshare_del(item);
|
|
|
|
EINA_LIST_FREE(files->handles, f)
|
|
|
|
eina_file_close(f);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_elm_theme_clear(Elm_Theme *th)
|
|
|
|
{
|
|
|
|
_elm_theme_file_clean(&th->themes);
|
|
|
|
_elm_theme_file_clean(&th->overlay);
|
|
|
|
_elm_theme_file_clean(&th->extension);
|
|
|
|
|
|
|
|
ELM_SAFE_FREE(th->cache, eina_hash_free);
|
|
|
|
ELM_SAFE_FREE(th->cache_data, eina_hash_free);
|
2014-03-18 01:18:09 -07:00
|
|
|
ELM_SAFE_FREE(th->cache_style_load_failed, eina_hash_free);
|
2013-11-03 19:17:58 -08:00
|
|
|
ELM_SAFE_FREE(th->theme, eina_stringshare_del);
|
|
|
|
if (th->ref_theme)
|
2009-02-23 00:40:58 -08:00
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
th->ref_theme->referrers =
|
|
|
|
eina_list_remove(th->ref_theme->referrers, th);
|
|
|
|
elm_theme_free(th->ref_theme);
|
|
|
|
th->ref_theme = NULL;
|
2009-02-23 00:40:58 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-03 19:17:58 -08:00
|
|
|
static Eina_File *
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_group_file_find(Elm_Theme *th, const char *group)
|
2009-01-13 01:20:53 -08:00
|
|
|
{
|
2009-02-25 11:50:45 -08:00
|
|
|
const Eina_List *l;
|
2013-11-03 19:17:58 -08:00
|
|
|
Eina_File *file = eina_hash_find(th->cache, group);
|
2009-10-27 12:32:50 -07:00
|
|
|
|
2009-01-13 01:20:53 -08:00
|
|
|
if (file) return file;
|
2013-11-03 19:17:58 -08:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(th->overlay.handles, l, file)
|
2009-02-23 00:40:58 -08:00
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
file = _elm_theme_find_try(th, file, group);
|
2011-04-01 04:20:18 -07:00
|
|
|
if (file) return file;
|
2009-02-23 00:40:58 -08:00
|
|
|
}
|
2013-11-03 19:17:58 -08:00
|
|
|
EINA_LIST_FOREACH(th->themes.handles, l, file)
|
2009-01-13 01:20:53 -08:00
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
file = _elm_theme_find_try(th, file, group);
|
2011-04-01 04:20:18 -07:00
|
|
|
if (file) return file;
|
2009-02-23 00:40:58 -08:00
|
|
|
}
|
2013-11-03 19:17:58 -08:00
|
|
|
EINA_LIST_FOREACH(th->extension.handles, l, file)
|
2009-02-23 00:40:58 -08:00
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
file = _elm_theme_find_try(th, file, group);
|
2011-04-01 04:20:18 -07:00
|
|
|
if (file) return file;
|
2009-01-13 01:20:53 -08:00
|
|
|
}
|
2010-11-05 01:37:31 -07:00
|
|
|
if (th->ref_theme) return _elm_theme_group_file_find(th->ref_theme, group);
|
2009-01-13 01:20:53 -08:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-09-11 18:05:07 -07:00
|
|
|
static const char *
|
2013-11-03 19:17:58 -08:00
|
|
|
_elm_theme_find_data_try(Elm_Theme *th, const Eina_File *f, const char *key)
|
2011-09-11 18:05:07 -07:00
|
|
|
{
|
|
|
|
char *data;
|
|
|
|
const char *t;
|
|
|
|
|
2013-11-03 19:17:58 -08:00
|
|
|
data = edje_mmap_data_get(f, key);
|
2011-09-11 18:05:07 -07:00
|
|
|
t = eina_stringshare_add(data);
|
|
|
|
free(data);
|
|
|
|
if (t)
|
|
|
|
{
|
|
|
|
eina_hash_add(th->cache, key, t);
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *
|
|
|
|
_elm_theme_data_find(Elm_Theme *th, const char *key)
|
|
|
|
{
|
|
|
|
const Eina_List *l;
|
2013-11-03 19:17:58 -08:00
|
|
|
const Eina_File *f;
|
2011-09-11 18:05:07 -07:00
|
|
|
|
2013-11-03 19:17:58 -08:00
|
|
|
const char *data = eina_hash_find(th->cache_data, key);
|
2011-09-11 18:05:07 -07:00
|
|
|
if (data) return data;
|
2013-11-03 19:17:58 -08:00
|
|
|
|
|
|
|
EINA_LIST_FOREACH(th->overlay.handles, l, f)
|
2011-09-11 18:05:07 -07:00
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
data = _elm_theme_find_data_try(th, f, key);
|
2011-09-11 18:05:07 -07:00
|
|
|
if (data) return data;
|
|
|
|
}
|
2013-11-03 19:17:58 -08:00
|
|
|
EINA_LIST_FOREACH(th->themes.handles, l, f)
|
2011-09-11 18:05:07 -07:00
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
data = _elm_theme_find_data_try(th, f, key);
|
2011-09-11 18:05:07 -07:00
|
|
|
if (data) return data;
|
|
|
|
}
|
2013-11-03 19:17:58 -08:00
|
|
|
EINA_LIST_FOREACH(th->extension.handles, l, f)
|
2011-09-11 18:05:07 -07:00
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
data = _elm_theme_find_data_try(th, f, key);
|
2011-09-11 18:05:07 -07:00
|
|
|
if (data) return data;
|
|
|
|
}
|
|
|
|
if (th->ref_theme) return _elm_theme_data_find(th->ref_theme, key);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
theme: return enum from elm_widget_style_set instead of bool
Summary:
if trying to apply incorrect theme, widget apply default theme and return TRUE.
so there is no way to check it really apply correct theme.
To resolve this problem, _elm_theme_set return three type enum
* related history : 4ca3ef45146e05908a13d1010909abeba9693ad6
* elm_object_style_set is public api, so I didn't change it.
* typedef name [ Theme_Apply ] is temporarily, please suggest better one.
@fix
Reviewers: singh.amitesh, herb, Hermet, cedric, jpeg, raster
Subscribers: cedric, jpeg
Differential Revision: https://phab.enlightenment.org/D4073
2016-06-30 23:09:42 -07:00
|
|
|
Elm_Theme_Apply
|
2013-02-25 20:26:22 -08:00
|
|
|
_elm_theme_object_set(Evas_Object *parent, Evas_Object *o, const char *clas, const char *group, const char *style)
|
2010-05-11 18:03:46 -07:00
|
|
|
{
|
|
|
|
Elm_Theme *th = NULL;
|
2012-05-09 03:46:14 -07:00
|
|
|
|
2010-05-11 18:03:46 -07:00
|
|
|
if (parent) th = elm_widget_theme_get(parent);
|
theme: return enum from elm_widget_style_set instead of bool
Summary:
if trying to apply incorrect theme, widget apply default theme and return TRUE.
so there is no way to check it really apply correct theme.
To resolve this problem, _elm_theme_set return three type enum
* related history : 4ca3ef45146e05908a13d1010909abeba9693ad6
* elm_object_style_set is public api, so I didn't change it.
* typedef name [ Theme_Apply ] is temporarily, please suggest better one.
@fix
Reviewers: singh.amitesh, herb, Hermet, cedric, jpeg, raster
Subscribers: cedric, jpeg
Differential Revision: https://phab.enlightenment.org/D4073
2016-06-30 23:09:42 -07:00
|
|
|
return _elm_theme_set(th, o, clas, group, style);
|
2010-05-11 18:03:46 -07:00
|
|
|
}
|
|
|
|
|
2012-05-25 12:53:59 -07:00
|
|
|
/* only issued by elm_icon.c */
|
2010-10-21 11:58:37 -07:00
|
|
|
Eina_Bool
|
2012-05-25 12:53:59 -07:00
|
|
|
_elm_theme_object_icon_set(Evas_Object *o,
|
|
|
|
const char *group,
|
|
|
|
const char *style)
|
2010-05-11 18:03:46 -07:00
|
|
|
{
|
2012-05-25 12:53:59 -07:00
|
|
|
Elm_Theme *th = elm_widget_theme_get(o);
|
|
|
|
|
2010-05-11 18:03:46 -07:00
|
|
|
return _elm_theme_icon_set(th, o, group, style);
|
|
|
|
}
|
|
|
|
|
theme: return enum from elm_widget_style_set instead of bool
Summary:
if trying to apply incorrect theme, widget apply default theme and return TRUE.
so there is no way to check it really apply correct theme.
To resolve this problem, _elm_theme_set return three type enum
* related history : 4ca3ef45146e05908a13d1010909abeba9693ad6
* elm_object_style_set is public api, so I didn't change it.
* typedef name [ Theme_Apply ] is temporarily, please suggest better one.
@fix
Reviewers: singh.amitesh, herb, Hermet, cedric, jpeg, raster
Subscribers: cedric, jpeg
Differential Revision: https://phab.enlightenment.org/D4073
2016-06-30 23:09:42 -07:00
|
|
|
Elm_Theme_Apply
|
2013-02-25 20:26:22 -08:00
|
|
|
_elm_theme_set(Elm_Theme *th, Evas_Object *o, const char *clas, const char *group, const char *style)
|
2010-05-11 18:03:46 -07:00
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
Eina_File *file;
|
2010-05-11 18:03:46 -07:00
|
|
|
char buf2[1024];
|
|
|
|
|
2013-02-25 20:26:22 -08:00
|
|
|
if ((!clas) || (!group) || (!style)) return EINA_FALSE;
|
2010-05-11 18:03:46 -07:00
|
|
|
if (!th) th = &(theme_default);
|
|
|
|
snprintf(buf2, sizeof(buf2), "elm/%s/%s/%s", clas, group, style);
|
2014-03-18 01:18:09 -07:00
|
|
|
if (!eina_hash_find(th->cache_style_load_failed, buf2))
|
2010-05-11 18:03:46 -07:00
|
|
|
{
|
2014-03-18 01:18:09 -07:00
|
|
|
file = _elm_theme_group_file_find(th, buf2);
|
|
|
|
if (file)
|
2013-02-19 00:22:15 -08:00
|
|
|
{
|
theme: return enum from elm_widget_style_set instead of bool
Summary:
if trying to apply incorrect theme, widget apply default theme and return TRUE.
so there is no way to check it really apply correct theme.
To resolve this problem, _elm_theme_set return three type enum
* related history : 4ca3ef45146e05908a13d1010909abeba9693ad6
* elm_object_style_set is public api, so I didn't change it.
* typedef name [ Theme_Apply ] is temporarily, please suggest better one.
@fix
Reviewers: singh.amitesh, herb, Hermet, cedric, jpeg, raster
Subscribers: cedric, jpeg
Differential Revision: https://phab.enlightenment.org/D4073
2016-06-30 23:09:42 -07:00
|
|
|
if (edje_object_mmap_set(o, file, buf2)) return ELM_THEME_APPLY_SUCCESS;
|
2014-03-18 01:18:09 -07:00
|
|
|
else
|
|
|
|
{
|
2016-03-23 22:48:45 -07:00
|
|
|
INF("could not set theme group '%s' from file '%s': %s",
|
2014-03-18 01:18:09 -07:00
|
|
|
buf2,
|
|
|
|
eina_file_filename_get(file),
|
|
|
|
edje_load_error_str(edje_object_load_error_get(o)));
|
|
|
|
}
|
2013-02-19 00:22:15 -08:00
|
|
|
}
|
2014-03-18 01:18:09 -07:00
|
|
|
//style not found, add to the not found list
|
|
|
|
eina_hash_add(th->cache_style_load_failed, buf2, (void *)1);
|
2010-05-11 18:03:46 -07:00
|
|
|
}
|
2013-02-19 00:22:15 -08:00
|
|
|
|
2013-02-25 20:26:22 -08:00
|
|
|
//Use the elementary default theme.
|
2010-05-11 18:03:46 -07:00
|
|
|
snprintf(buf2, sizeof(buf2), "elm/%s/%s/default", clas, group);
|
2014-03-18 01:18:09 -07:00
|
|
|
if (!eina_hash_find(th->cache_style_load_failed, buf2))
|
|
|
|
{
|
|
|
|
file = _elm_theme_group_file_find(th, buf2);
|
|
|
|
if (file)
|
|
|
|
{
|
2015-11-22 23:26:52 -08:00
|
|
|
if (edje_object_mmap_set(o, file, buf2))
|
|
|
|
{
|
2016-03-23 22:48:45 -07:00
|
|
|
INF("could not set theme style '%s', fallback to default",
|
2015-11-22 23:26:52 -08:00
|
|
|
style);
|
theme: return enum from elm_widget_style_set instead of bool
Summary:
if trying to apply incorrect theme, widget apply default theme and return TRUE.
so there is no way to check it really apply correct theme.
To resolve this problem, _elm_theme_set return three type enum
* related history : 4ca3ef45146e05908a13d1010909abeba9693ad6
* elm_object_style_set is public api, so I didn't change it.
* typedef name [ Theme_Apply ] is temporarily, please suggest better one.
@fix
Reviewers: singh.amitesh, herb, Hermet, cedric, jpeg, raster
Subscribers: cedric, jpeg
Differential Revision: https://phab.enlightenment.org/D4073
2016-06-30 23:09:42 -07:00
|
|
|
return ELM_THEME_APPLY_DEFAULT;
|
2015-11-22 23:26:52 -08:00
|
|
|
}
|
2014-03-18 01:18:09 -07:00
|
|
|
else
|
|
|
|
{
|
2016-03-23 22:48:45 -07:00
|
|
|
INF("could not set theme group '%s' from file '%s': %s",
|
2014-03-18 01:18:09 -07:00
|
|
|
buf2,
|
|
|
|
eina_file_filename_get(file),
|
|
|
|
edje_load_error_str(edje_object_load_error_get(o)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//style not found, add to the not found list
|
|
|
|
eina_hash_add(th->cache_style_load_failed, buf2, (void *)1);
|
|
|
|
}
|
theme: return enum from elm_widget_style_set instead of bool
Summary:
if trying to apply incorrect theme, widget apply default theme and return TRUE.
so there is no way to check it really apply correct theme.
To resolve this problem, _elm_theme_set return three type enum
* related history : 4ca3ef45146e05908a13d1010909abeba9693ad6
* elm_object_style_set is public api, so I didn't change it.
* typedef name [ Theme_Apply ] is temporarily, please suggest better one.
@fix
Reviewers: singh.amitesh, herb, Hermet, cedric, jpeg, raster
Subscribers: cedric, jpeg
Differential Revision: https://phab.enlightenment.org/D4073
2016-06-30 23:09:42 -07:00
|
|
|
return ELM_THEME_APPLY_FAILED;
|
2010-05-11 18:03:46 -07:00
|
|
|
}
|
|
|
|
|
2010-10-21 11:58:37 -07:00
|
|
|
Eina_Bool
|
2012-05-25 12:53:59 -07:00
|
|
|
_elm_theme_icon_set(Elm_Theme *th,
|
|
|
|
Evas_Object *o,
|
|
|
|
const char *group,
|
|
|
|
const char *style)
|
2010-05-11 18:03:46 -07:00
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
Eina_File *file;
|
2010-05-11 18:03:46 -07:00
|
|
|
char buf2[1024];
|
|
|
|
int w, h;
|
|
|
|
|
2016-04-28 02:27:56 -07:00
|
|
|
if (eo_isa((o), ELM_ICON_CLASS) && elm_icon_standard_get(o) &&
|
|
|
|
strcmp(elm_config_icon_theme_get(), ELM_CONFIG_ICON_THEME_ELEMENTARY))
|
|
|
|
{
|
|
|
|
elm_icon_standard_set(o, elm_icon_standard_get(o));
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2010-05-11 18:03:46 -07:00
|
|
|
if (!th) th = &(theme_default);
|
|
|
|
snprintf(buf2, sizeof(buf2), "elm/icon/%s/%s", group, style);
|
|
|
|
file = _elm_theme_group_file_find(th, buf2);
|
|
|
|
if (file)
|
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
elm_image_mmap_set(o, file, buf2);
|
2012-05-28 14:50:11 -07:00
|
|
|
elm_image_object_size_get(o, &w, &h);
|
2011-04-01 04:20:18 -07:00
|
|
|
if (w > 0) return EINA_TRUE;
|
2010-05-11 18:03:46 -07:00
|
|
|
}
|
|
|
|
snprintf(buf2, sizeof(buf2), "elm/icon/%s/default", group);
|
|
|
|
file = _elm_theme_group_file_find(th, buf2);
|
2012-05-25 12:53:59 -07:00
|
|
|
|
2010-10-21 11:58:37 -07:00
|
|
|
if (!file) return EINA_FALSE;
|
2012-05-25 12:53:59 -07:00
|
|
|
|
2013-11-03 19:17:58 -08:00
|
|
|
elm_image_mmap_set(o, file, buf2);
|
2012-05-28 14:50:11 -07:00
|
|
|
elm_image_object_size_get(o, &w, &h);
|
2012-05-25 12:53:59 -07:00
|
|
|
|
|
|
|
return w > 0;
|
2010-05-11 18:03:46 -07:00
|
|
|
}
|
|
|
|
|
2010-10-21 11:58:37 -07:00
|
|
|
Eina_Bool
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_parse(Elm_Theme *th, const char *theme)
|
|
|
|
{
|
|
|
|
Eina_List *names = NULL;
|
2013-11-03 19:17:58 -08:00
|
|
|
Eina_File *f;
|
2010-05-11 18:03:46 -07:00
|
|
|
const char *p, *pe;
|
|
|
|
|
|
|
|
if (!th) th = &(theme_default);
|
|
|
|
if (theme)
|
|
|
|
{
|
2012-09-25 01:04:17 -07:00
|
|
|
Eina_Strbuf *buf;
|
|
|
|
|
|
|
|
buf = eina_strbuf_new();
|
|
|
|
|
2010-05-11 18:03:46 -07:00
|
|
|
p = theme;
|
|
|
|
pe = p;
|
|
|
|
for (;;)
|
|
|
|
{
|
2012-09-25 01:04:17 -07:00
|
|
|
if ((pe[0] == '\\') && (pe[1] == ':'))
|
|
|
|
{
|
|
|
|
eina_strbuf_append_char(buf, ':');
|
|
|
|
pe += 2;
|
|
|
|
}
|
2015-08-24 22:07:30 -07:00
|
|
|
else if ((pe[0] == ':') && (pe[1] == '\\'))
|
2015-08-24 21:10:33 -07:00
|
|
|
{
|
|
|
|
eina_strbuf_append_char(buf, *pe);
|
|
|
|
pe++;
|
|
|
|
eina_strbuf_append_char(buf, *pe);
|
|
|
|
pe++;
|
|
|
|
}
|
2012-09-25 01:04:17 -07:00
|
|
|
else if ((*pe == ':') || (!*pe))
|
2010-05-11 18:03:46 -07:00
|
|
|
{ // p -> pe == 'name:'
|
|
|
|
if (pe > p)
|
|
|
|
{
|
2012-09-25 01:04:17 -07:00
|
|
|
const char *nn;
|
|
|
|
|
|
|
|
nn = eina_stringshare_add(eina_strbuf_string_get(buf));
|
|
|
|
if (nn) names = eina_list_append(names, nn);
|
|
|
|
eina_strbuf_reset(buf);
|
2010-05-11 18:03:46 -07:00
|
|
|
}
|
2010-10-22 14:41:27 -07:00
|
|
|
if (!*pe) break;
|
2010-05-11 18:03:46 -07:00
|
|
|
p = pe + 1;
|
|
|
|
pe = p;
|
|
|
|
}
|
|
|
|
else
|
2012-09-25 01:04:17 -07:00
|
|
|
{
|
|
|
|
eina_strbuf_append_char(buf, *pe);
|
|
|
|
pe++;
|
|
|
|
}
|
2010-05-11 18:03:46 -07:00
|
|
|
}
|
2012-09-25 01:04:17 -07:00
|
|
|
|
|
|
|
eina_strbuf_free(buf);
|
2010-05-11 18:03:46 -07:00
|
|
|
}
|
|
|
|
p = eina_list_data_get(eina_list_last(names));
|
|
|
|
if ((!p) || ((p) && (strcmp(p, "default"))))
|
|
|
|
{
|
2011-04-01 04:20:18 -07:00
|
|
|
p = eina_stringshare_add("default");
|
|
|
|
if (p) names = eina_list_append(names, p);
|
2010-05-11 18:03:46 -07:00
|
|
|
}
|
|
|
|
if (th->cache) eina_hash_free(th->cache);
|
2013-11-03 19:17:58 -08:00
|
|
|
th->cache = eina_hash_string_superfast_new(EINA_FREE_CB(eina_file_close));
|
2011-09-11 18:05:07 -07:00
|
|
|
if (th->cache_data) eina_hash_free(th->cache_data);
|
|
|
|
th->cache_data = eina_hash_string_superfast_new(EINA_FREE_CB(eina_stringshare_del));
|
2014-03-18 01:18:09 -07:00
|
|
|
if (th->cache_style_load_failed) eina_hash_free(th->cache_style_load_failed);
|
|
|
|
th->cache_style_load_failed = eina_hash_string_superfast_new(NULL);
|
2013-11-03 19:17:58 -08:00
|
|
|
EINA_LIST_FREE(th->themes.items, p) eina_stringshare_del(p);
|
|
|
|
EINA_LIST_FREE(th->themes.handles, f) eina_file_close(f);
|
2010-05-11 18:03:46 -07:00
|
|
|
|
2013-11-03 19:17:58 -08:00
|
|
|
EINA_LIST_FREE(names, p)
|
2014-03-28 00:17:38 -07:00
|
|
|
_elm_theme_file_item_add(&th->themes, p, EINA_FALSE, EINA_TRUE);
|
2010-10-21 11:58:37 -07:00
|
|
|
return EINA_TRUE;
|
2010-05-11 18:03:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_elm_theme_shutdown(void)
|
|
|
|
{
|
2013-07-10 19:34:21 -07:00
|
|
|
Elm_Theme *th;
|
2010-05-11 18:03:46 -07:00
|
|
|
_elm_theme_clear(&(theme_default));
|
2013-07-10 19:34:21 -07:00
|
|
|
EINA_LIST_FREE(themes, th)
|
|
|
|
{
|
|
|
|
_elm_theme_clear(th);
|
|
|
|
free(th);
|
|
|
|
}
|
2010-05-11 18:03:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Elm_Theme *
|
|
|
|
elm_theme_new(void)
|
|
|
|
{
|
|
|
|
Elm_Theme *th = calloc(1, sizeof(Elm_Theme));
|
|
|
|
if (!th) return NULL;
|
|
|
|
th->ref = 1;
|
2014-03-28 00:17:38 -07:00
|
|
|
_elm_theme_file_item_add(&th->themes, "default", EINA_FALSE, EINA_TRUE);
|
2010-05-11 18:03:46 -07:00
|
|
|
themes = eina_list_append(themes, th);
|
|
|
|
return th;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_theme_free(Elm_Theme *th)
|
|
|
|
{
|
2010-12-03 06:08:33 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(th);
|
2010-05-11 18:03:46 -07:00
|
|
|
th->ref--;
|
|
|
|
if (th->ref < 1)
|
|
|
|
{
|
|
|
|
_elm_theme_clear(th);
|
|
|
|
themes = eina_list_remove(themes, th);
|
|
|
|
free(th);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-03 19:17:58 -08:00
|
|
|
static void
|
|
|
|
elm_theme_files_copy(Elm_Theme_Files *dst, Elm_Theme_Files *src)
|
2010-11-05 01:37:31 -07:00
|
|
|
{
|
|
|
|
const Eina_List *l;
|
2013-11-03 19:17:58 -08:00
|
|
|
const Eina_File *f;
|
|
|
|
const char *item;
|
2011-04-01 04:20:18 -07:00
|
|
|
|
2013-11-03 19:17:58 -08:00
|
|
|
EINA_LIST_FOREACH(src->items, l, item)
|
|
|
|
dst->items = eina_list_append(dst->items,
|
|
|
|
eina_stringshare_ref(item));
|
|
|
|
EINA_LIST_FOREACH(src->handles, l, f)
|
|
|
|
dst->handles = eina_list_append(dst->handles,
|
|
|
|
eina_file_dup(f));
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_theme_copy(Elm_Theme *th, Elm_Theme *thdst)
|
|
|
|
{
|
2010-11-05 01:37:31 -07:00
|
|
|
if (!th) th = &(theme_default);
|
|
|
|
if (!thdst) thdst = &(theme_default);
|
|
|
|
_elm_theme_clear(thdst);
|
|
|
|
if (th->ref_theme)
|
|
|
|
{
|
2011-04-01 04:20:18 -07:00
|
|
|
thdst->ref_theme = th->ref_theme;
|
|
|
|
thdst->ref_theme->referrers =
|
|
|
|
eina_list_append(thdst->ref_theme->referrers, thdst);
|
|
|
|
thdst->ref_theme->ref++;
|
2010-11-05 01:37:31 -07:00
|
|
|
}
|
2013-11-03 19:17:58 -08:00
|
|
|
elm_theme_files_copy(&thdst->overlay, &th->overlay);
|
|
|
|
elm_theme_files_copy(&thdst->themes, &th->themes);
|
|
|
|
elm_theme_files_copy(&thdst->extension, &th->extension);
|
|
|
|
|
2010-11-05 01:37:31 -07:00
|
|
|
if (th->theme) thdst->theme = eina_stringshare_add(th->theme);
|
|
|
|
elm_theme_flush(thdst);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_theme_ref_set(Elm_Theme *th, Elm_Theme *thref)
|
|
|
|
{
|
|
|
|
if (!th) th = &(theme_default);
|
|
|
|
if (!thref) thref = &(theme_default);
|
|
|
|
if (th->ref_theme == thref) return;
|
|
|
|
_elm_theme_clear(th);
|
|
|
|
if (thref)
|
|
|
|
{
|
2011-04-01 04:20:18 -07:00
|
|
|
thref->referrers = eina_list_append(thref->referrers, th);
|
|
|
|
thref->ref++;
|
2010-11-05 01:37:31 -07:00
|
|
|
}
|
|
|
|
th->ref_theme = thref;
|
|
|
|
elm_theme_flush(th);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Elm_Theme *
|
2015-06-08 10:44:29 -07:00
|
|
|
elm_theme_ref_get(const Elm_Theme *th)
|
2010-11-05 01:37:31 -07:00
|
|
|
{
|
|
|
|
if (!th) th = &(theme_default);
|
|
|
|
return th->ref_theme;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Elm_Theme *
|
|
|
|
elm_theme_default_get(void)
|
|
|
|
{
|
|
|
|
return &theme_default;
|
|
|
|
}
|
|
|
|
|
2009-02-23 00:40:58 -08:00
|
|
|
EAPI void
|
2010-05-11 18:03:46 -07:00
|
|
|
elm_theme_overlay_add(Elm_Theme *th, const char *item)
|
2009-02-23 00:40:58 -08:00
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
if (!item) return;
|
2010-05-11 18:03:46 -07:00
|
|
|
if (!th) th = &(theme_default);
|
2014-03-28 00:17:38 -07:00
|
|
|
_elm_theme_file_item_add(&th->overlay, item, EINA_TRUE, EINA_FALSE);
|
2010-05-11 18:03:46 -07:00
|
|
|
elm_theme_flush(th);
|
2009-10-23 07:42:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2010-05-11 18:03:46 -07:00
|
|
|
elm_theme_overlay_del(Elm_Theme *th, const char *item)
|
2009-10-23 07:42:39 -07:00
|
|
|
{
|
2014-03-14 19:44:20 -07:00
|
|
|
if (!item) return;
|
2010-05-11 18:03:46 -07:00
|
|
|
if (!th) th = &(theme_default);
|
2013-11-03 19:17:58 -08:00
|
|
|
_elm_theme_file_item_del(&th->overlay, item);
|
2010-05-11 18:03:46 -07:00
|
|
|
elm_theme_flush(th);
|
2009-02-23 00:40:58 -08:00
|
|
|
}
|
|
|
|
|
2013-11-03 21:26:05 -08:00
|
|
|
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);
|
2014-03-28 00:17:38 -07:00
|
|
|
_elm_theme_item_finalize(&th->overlay, eina_file_filename_get(file), file, EINA_TRUE, EINA_FALSE);
|
2013-11-03 21:26:05 -08:00
|
|
|
elm_theme_flush(th);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_theme_overlay_mmap_del(Elm_Theme *th, const Eina_File *f)
|
|
|
|
{
|
2014-03-14 19:44:20 -07:00
|
|
|
if (!f) return;
|
2013-11-03 21:26:05 -08:00
|
|
|
if (!th) th = &(theme_default);
|
|
|
|
_elm_theme_file_mmap_del(&th->overlay, f);
|
|
|
|
elm_theme_flush(th);
|
|
|
|
}
|
|
|
|
|
2012-03-05 13:48:32 -08:00
|
|
|
EAPI const Eina_List *
|
2012-03-05 16:19:31 -08:00
|
|
|
elm_theme_overlay_list_get(const Elm_Theme *th)
|
2012-03-05 13:48:32 -08:00
|
|
|
{
|
|
|
|
if (!th) th = &(theme_default);
|
2013-11-03 19:17:58 -08:00
|
|
|
return th->overlay.items;
|
2012-03-05 13:48:32 -08:00
|
|
|
}
|
|
|
|
|
2009-02-23 00:40:58 -08:00
|
|
|
EAPI void
|
2010-05-11 18:03:46 -07:00
|
|
|
elm_theme_extension_add(Elm_Theme *th, const char *item)
|
2009-02-23 00:40:58 -08:00
|
|
|
{
|
2014-03-14 19:44:20 -07:00
|
|
|
if (!item) return;
|
2010-05-11 18:03:46 -07:00
|
|
|
if (!th) th = &(theme_default);
|
2014-03-28 00:17:38 -07:00
|
|
|
_elm_theme_file_item_add(&th->extension, item, EINA_FALSE, EINA_FALSE);
|
2010-05-11 18:03:46 -07:00
|
|
|
elm_theme_flush(th);
|
2009-10-23 07:42:39 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
2010-05-11 18:03:46 -07:00
|
|
|
elm_theme_extension_del(Elm_Theme *th, const char *item)
|
2009-10-23 07:42:39 -07:00
|
|
|
{
|
2014-03-14 19:44:20 -07:00
|
|
|
if (!item) return;
|
2010-05-11 18:03:46 -07:00
|
|
|
if (!th) th = &(theme_default);
|
2013-11-03 19:17:58 -08:00
|
|
|
_elm_theme_file_item_del(&th->extension, item);
|
2010-05-11 18:03:46 -07:00
|
|
|
elm_theme_flush(th);
|
|
|
|
}
|
|
|
|
|
2013-11-03 21:26:05 -08:00
|
|
|
EAPI void
|
|
|
|
elm_theme_extension_mmap_add(Elm_Theme *th, const Eina_File *f)
|
|
|
|
{
|
|
|
|
Eina_File *file = eina_file_dup(f);
|
|
|
|
|
2014-03-14 19:44:20 -07:00
|
|
|
if (!f) return;
|
2013-11-03 21:26:05 -08:00
|
|
|
if (!th) th = &(theme_default);
|
2014-03-28 00:17:38 -07:00
|
|
|
_elm_theme_item_finalize(&th->overlay, eina_file_filename_get(file), file, EINA_FALSE, EINA_FALSE);
|
2013-11-03 21:26:05 -08:00
|
|
|
elm_theme_flush(th);
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_theme_extension_mmap_del(Elm_Theme *th, const Eina_File *f)
|
|
|
|
{
|
2014-03-14 19:44:20 -07:00
|
|
|
if (!f) return;
|
2013-11-03 21:26:05 -08:00
|
|
|
if (!th) th = &(theme_default);
|
|
|
|
_elm_theme_file_mmap_del(&th->extension, f);
|
|
|
|
elm_theme_flush(th);
|
|
|
|
}
|
|
|
|
|
2012-03-05 13:48:32 -08:00
|
|
|
EAPI const Eina_List *
|
2012-03-05 16:19:31 -08:00
|
|
|
elm_theme_extension_list_get(const Elm_Theme *th)
|
2012-03-05 13:48:32 -08:00
|
|
|
{
|
|
|
|
if (!th) th = &(theme_default);
|
2013-11-03 19:17:58 -08:00
|
|
|
return th->extension.items;
|
2012-03-05 13:48:32 -08:00
|
|
|
}
|
|
|
|
|
2010-05-11 18:03:46 -07:00
|
|
|
EAPI void
|
|
|
|
elm_theme_set(Elm_Theme *th, const char *theme)
|
|
|
|
{
|
|
|
|
if (!th) th = &(theme_default);
|
|
|
|
_elm_theme_parse(th, theme);
|
2013-05-29 05:08:05 -07:00
|
|
|
ELM_SAFE_FREE(th->theme, eina_stringshare_del);
|
2010-05-11 18:03:46 -07:00
|
|
|
elm_theme_flush(th);
|
2012-03-05 04:39:22 -08:00
|
|
|
if (th == &(theme_default))
|
|
|
|
eina_stringshare_replace(&_elm_config->theme, theme);
|
2010-05-11 18:03:46 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI const char *
|
|
|
|
elm_theme_get(Elm_Theme *th)
|
|
|
|
{
|
2010-09-23 22:11:33 -07:00
|
|
|
if (!th) th = &(theme_default);
|
2010-05-11 18:03:46 -07:00
|
|
|
if (!th->theme)
|
|
|
|
{
|
2012-09-25 01:04:17 -07:00
|
|
|
Eina_Strbuf *buf;
|
2010-05-11 18:03:46 -07:00
|
|
|
Eina_List *l;
|
|
|
|
const char *f;
|
2010-10-25 07:34:22 -07:00
|
|
|
|
2012-09-25 01:04:17 -07:00
|
|
|
buf = eina_strbuf_new();
|
2013-11-03 19:17:58 -08:00
|
|
|
EINA_LIST_FOREACH(th->themes.items, l, f)
|
2010-05-11 18:03:46 -07:00
|
|
|
{
|
2012-09-25 01:04:17 -07:00
|
|
|
while (*f)
|
|
|
|
{
|
|
|
|
if (*f == ':')
|
|
|
|
eina_strbuf_append_char(buf, '\\');
|
|
|
|
eina_strbuf_append_char(buf, *f);
|
|
|
|
|
|
|
|
f++;
|
|
|
|
}
|
|
|
|
if (l->next) eina_strbuf_append_char(buf, ':');
|
2010-05-11 18:03:46 -07:00
|
|
|
}
|
2012-09-25 01:04:17 -07:00
|
|
|
th->theme = eina_stringshare_add(eina_strbuf_string_get(buf));
|
|
|
|
eina_strbuf_free(buf);
|
2010-05-11 18:03:46 -07:00
|
|
|
}
|
|
|
|
return th->theme;
|
2009-10-23 07:42:39 -07:00
|
|
|
}
|
|
|
|
|
2010-09-23 22:11:33 -07:00
|
|
|
EAPI const Eina_List *
|
2010-10-25 07:34:22 -07:00
|
|
|
elm_theme_list_get(const Elm_Theme *th)
|
2010-09-23 22:11:33 -07:00
|
|
|
{
|
|
|
|
if (!th) th = &(theme_default);
|
2013-11-03 19:17:58 -08:00
|
|
|
return th->themes.items;
|
2010-09-23 22:11:33 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI char *
|
|
|
|
elm_theme_list_item_path_get(const char *f, Eina_Bool *in_search_path)
|
|
|
|
{
|
|
|
|
static const char *home = NULL;
|
|
|
|
char buf[PATH_MAX];
|
2011-04-01 04:20:18 -07:00
|
|
|
|
2010-09-23 22:11:33 -07:00
|
|
|
if (!f)
|
|
|
|
{
|
|
|
|
if (in_search_path) *in_search_path = EINA_FALSE;
|
|
|
|
return NULL;
|
|
|
|
}
|
2011-04-01 04:20:18 -07:00
|
|
|
|
2010-09-23 22:11:33 -07:00
|
|
|
if (!home)
|
|
|
|
{
|
2015-05-14 12:26:44 -07:00
|
|
|
home = eina_environment_home_get();
|
2011-04-01 04:20:18 -07:00
|
|
|
if (!home) home = "";
|
2010-09-23 22:11:33 -07:00
|
|
|
}
|
2011-04-01 04:20:18 -07:00
|
|
|
|
2010-09-23 22:11:33 -07:00
|
|
|
if ((f[0] == '/') || ((f[0] == '.') && (f[1] == '/')) ||
|
|
|
|
((f[0] == '.') && (f[1] == '.') && (f[2] == '/')) ||
|
2010-10-22 14:41:22 -07:00
|
|
|
((isalpha(f[0])) && (f[1] == ':')))
|
2010-09-23 22:11:33 -07:00
|
|
|
{
|
|
|
|
if (in_search_path) *in_search_path = EINA_FALSE;
|
|
|
|
return strdup(f);
|
|
|
|
}
|
|
|
|
else if (((f[0] == '~') && (f[1] == '/')))
|
|
|
|
{
|
|
|
|
if (in_search_path) *in_search_path = EINA_FALSE;
|
2011-04-01 04:20:18 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", home, f + 2);
|
2010-09-23 22:11:33 -07:00
|
|
|
return strdup(buf);
|
|
|
|
}
|
2012-01-19 09:12:15 -08:00
|
|
|
snprintf(buf, sizeof(buf), "%s/"ELEMENTARY_BASE_DIR"/themes/%s.edj", home, f);
|
2010-09-23 22:11:33 -07:00
|
|
|
if (ecore_file_exists(buf))
|
|
|
|
{
|
|
|
|
if (in_search_path) *in_search_path = EINA_TRUE;
|
|
|
|
return strdup(buf);
|
|
|
|
}
|
2011-04-01 04:20:18 -07:00
|
|
|
|
2010-09-23 22:11:33 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/themes/%s.edj", _elm_data_dir, f);
|
|
|
|
if (ecore_file_exists(buf))
|
|
|
|
{
|
|
|
|
if (in_search_path) *in_search_path = EINA_TRUE;
|
|
|
|
return strdup(buf);
|
|
|
|
}
|
2011-04-01 04:20:18 -07:00
|
|
|
|
2010-09-23 22:11:33 -07:00
|
|
|
if (in_search_path) *in_search_path = EINA_FALSE;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-10-23 07:42:39 -07:00
|
|
|
EAPI void
|
2010-05-11 18:03:46 -07:00
|
|
|
elm_theme_flush(Elm_Theme *th)
|
2009-10-23 07:42:39 -07:00
|
|
|
{
|
2010-05-11 18:03:46 -07:00
|
|
|
if (!th) th = &(theme_default);
|
|
|
|
if (th->cache) eina_hash_free(th->cache);
|
2013-11-03 19:17:58 -08:00
|
|
|
th->cache = eina_hash_string_superfast_new(EINA_FREE_CB(eina_file_close));
|
2011-09-11 18:05:07 -07:00
|
|
|
if (th->cache_data) eina_hash_free(th->cache_data);
|
|
|
|
th->cache_data = eina_hash_string_superfast_new(EINA_FREE_CB(eina_stringshare_del));
|
2014-03-18 01:18:09 -07:00
|
|
|
if (th->cache_style_load_failed) eina_hash_free(th->cache_style_load_failed);
|
|
|
|
th->cache_style_load_failed = eina_hash_string_superfast_new(NULL);
|
2010-11-05 01:37:31 -07:00
|
|
|
_elm_win_rescale(th, EINA_TRUE);
|
2011-10-05 15:18:22 -07:00
|
|
|
_elm_ews_wm_rescale(th, EINA_TRUE);
|
2010-11-05 01:37:31 -07:00
|
|
|
if (th->referrers)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Elm_Theme *th2;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(th->referrers, l, th2) elm_theme_flush(th2);
|
|
|
|
}
|
2009-02-23 00:40:58 -08:00
|
|
|
}
|
|
|
|
|
2010-05-11 18:03:46 -07:00
|
|
|
EAPI void
|
|
|
|
elm_theme_full_flush(void)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Elm_Theme *th;
|
2011-04-01 04:20:18 -07:00
|
|
|
|
2010-05-11 18:03:46 -07:00
|
|
|
EINA_LIST_FOREACH(themes, l, th)
|
|
|
|
{
|
|
|
|
elm_theme_flush(th);
|
|
|
|
}
|
|
|
|
elm_theme_flush(&(theme_default));
|
|
|
|
}
|
|
|
|
|
2010-09-23 22:11:33 -07:00
|
|
|
EAPI Eina_List *
|
|
|
|
elm_theme_name_available_list_new(void)
|
|
|
|
{
|
|
|
|
Eina_List *list = NULL;
|
|
|
|
Eina_List *dir, *l;
|
|
|
|
char buf[PATH_MAX], *file, *s, *th;
|
|
|
|
static const char *home = NULL;
|
2011-04-01 04:20:18 -07:00
|
|
|
|
2010-09-23 22:11:33 -07:00
|
|
|
if (!home)
|
|
|
|
{
|
2015-05-14 12:26:44 -07:00
|
|
|
home = eina_environment_home_get();
|
2010-09-23 22:11:33 -07:00
|
|
|
if (!home) home = "";
|
|
|
|
}
|
2011-04-01 04:20:18 -07:00
|
|
|
|
2012-01-19 09:12:15 -08:00
|
|
|
snprintf(buf, sizeof(buf), "%s/"ELEMENTARY_BASE_DIR"/themes", home);
|
2010-09-23 22:11:33 -07:00
|
|
|
dir = ecore_file_ls(buf);
|
|
|
|
EINA_LIST_FREE(dir, file)
|
|
|
|
{
|
2012-01-19 09:12:15 -08:00
|
|
|
snprintf(buf, sizeof(buf), "%s/"ELEMENTARY_BASE_DIR"/themes/%s", home, file);
|
2010-09-23 22:11:33 -07:00
|
|
|
if ((!ecore_file_is_dir(buf)) && (ecore_file_size(buf) > 0))
|
|
|
|
{
|
2015-08-04 06:39:36 -07:00
|
|
|
if (eina_str_has_extension(file, "edj"))
|
2010-09-23 22:11:33 -07:00
|
|
|
{
|
|
|
|
th = strdup(file);
|
2015-08-04 06:39:36 -07:00
|
|
|
s = strrchr(th, '.');
|
2010-09-23 22:11:33 -07:00
|
|
|
*s = 0;
|
|
|
|
list = eina_list_append(list, th);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(file);
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/themes", _elm_data_dir);
|
|
|
|
dir = ecore_file_ls(buf);
|
|
|
|
EINA_LIST_FREE(dir, file)
|
|
|
|
{
|
|
|
|
snprintf(buf, sizeof(buf), "%s/themes/%s", _elm_data_dir, file);
|
|
|
|
if ((!ecore_file_is_dir(buf)) && (ecore_file_size(buf) > 0))
|
|
|
|
{
|
2015-08-04 06:39:36 -07:00
|
|
|
if (eina_str_has_extension(file, "edj"))
|
2010-09-23 22:11:33 -07:00
|
|
|
{
|
2012-03-07 00:19:55 -08:00
|
|
|
int dupp;
|
2011-04-01 04:20:18 -07:00
|
|
|
|
2010-09-23 22:11:33 -07:00
|
|
|
th = strdup(file);
|
2015-08-04 06:39:36 -07:00
|
|
|
s = strrchr(th, '.');
|
2010-09-23 22:11:33 -07:00
|
|
|
*s = 0;
|
2012-03-07 00:19:55 -08:00
|
|
|
dupp = 0;
|
2010-09-23 22:11:33 -07:00
|
|
|
EINA_LIST_FOREACH(list, l, s)
|
|
|
|
{
|
|
|
|
if (!strcmp(s, th))
|
|
|
|
{
|
2012-03-07 00:19:55 -08:00
|
|
|
dupp = 1;
|
2010-09-23 22:11:33 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2012-03-07 00:19:55 -08:00
|
|
|
if (dupp) free(th);
|
2010-09-23 22:11:33 -07:00
|
|
|
else list = eina_list_append(list, th);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
free(file);
|
|
|
|
}
|
|
|
|
list = eina_list_sort(list, 0, EINA_COMPARE_CB(strcasecmp));
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_theme_name_available_list_free(Eina_List *list)
|
|
|
|
{
|
|
|
|
char *s;
|
|
|
|
EINA_LIST_FREE(list, s) free(s);
|
|
|
|
}
|
|
|
|
|
2010-05-11 18:03:46 -07:00
|
|
|
EAPI void
|
|
|
|
elm_object_theme_set(Evas_Object *obj, Elm_Theme *th)
|
2009-01-13 01:20:53 -08:00
|
|
|
{
|
2010-12-03 06:08:33 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN(obj);
|
2010-05-11 18:03:46 -07:00
|
|
|
elm_widget_theme_set(obj, th);
|
2009-01-13 01:20:53 -08:00
|
|
|
}
|
2010-04-28 16:14:04 -07:00
|
|
|
|
2010-05-11 18:03:46 -07:00
|
|
|
EAPI Elm_Theme *
|
2010-10-25 07:34:22 -07:00
|
|
|
elm_object_theme_get(const Evas_Object *obj)
|
2010-04-28 16:14:04 -07:00
|
|
|
{
|
2010-12-03 06:08:33 -08:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(obj, NULL);
|
2010-05-11 18:03:46 -07:00
|
|
|
return elm_widget_theme_get(obj);
|
2010-04-28 16:14:04 -07:00
|
|
|
}
|
2011-09-11 18:05:07 -07:00
|
|
|
|
|
|
|
EAPI const char *
|
|
|
|
elm_theme_data_get(Elm_Theme *th, const char *key)
|
|
|
|
{
|
|
|
|
if (!th) th = &(theme_default);
|
|
|
|
return _elm_theme_data_find(th, key);
|
|
|
|
}
|
2013-10-31 07:22:18 -07:00
|
|
|
|
|
|
|
EAPI const char *
|
|
|
|
elm_theme_group_path_find(Elm_Theme *th, const char *group)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(group, NULL);
|
2013-12-22 21:49:50 -08:00
|
|
|
Eina_File *th_file = NULL;
|
2013-10-31 07:22:18 -07:00
|
|
|
if (!th) th = &(theme_default);
|
2013-12-22 21:49:50 -08:00
|
|
|
|
|
|
|
th_file = _elm_theme_group_file_find(th, group);
|
|
|
|
if (th_file)
|
|
|
|
return eina_file_filename_get(th_file);
|
|
|
|
return NULL;
|
2013-10-31 07:22:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_List *
|
2013-11-03 19:17:58 -08:00
|
|
|
_elm_theme_file_group_base_list(Eina_List *list,
|
|
|
|
Eina_List *handles,
|
|
|
|
const char *base, int len)
|
2013-10-31 07:22:18 -07:00
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
Eina_Stringshare *c, *c2;
|
|
|
|
Eina_List *coll;
|
|
|
|
Eina_List *in, *l, *ll;
|
|
|
|
Eina_File *f;
|
2013-10-31 07:22:18 -07:00
|
|
|
|
2013-11-03 19:17:58 -08:00
|
|
|
EINA_LIST_FOREACH(handles, l, f)
|
2013-10-31 07:22:18 -07:00
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
coll = edje_mmap_collection_list(f);
|
|
|
|
EINA_LIST_FOREACH(coll, ll, c)
|
|
|
|
{
|
|
|
|
// if base == start of collection str
|
|
|
|
if (!strncmp(c, base, len))
|
|
|
|
{
|
|
|
|
// check if already in list
|
|
|
|
EINA_LIST_FOREACH(list, in, c2)
|
|
|
|
if (c == c2)
|
|
|
|
break;
|
|
|
|
|
|
|
|
// if not already in list append shared str to list
|
|
|
|
if (!in)
|
|
|
|
list = eina_list_append(list, eina_stringshare_ref(c));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
edje_mmap_collection_list_free(coll);
|
2013-10-31 07:22:18 -07:00
|
|
|
}
|
2013-11-03 19:17:58 -08:00
|
|
|
|
2013-10-31 07:22:18 -07:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_List *
|
|
|
|
elm_theme_group_base_list(Elm_Theme *th, const char *base)
|
|
|
|
{
|
2013-11-03 19:17:58 -08:00
|
|
|
Eina_List *list;
|
2013-10-31 07:22:18 -07:00
|
|
|
int len;
|
2013-11-03 19:17:58 -08:00
|
|
|
|
2013-10-31 07:22:18 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(base, NULL);
|
|
|
|
if (!th) th = &(theme_default);
|
|
|
|
|
|
|
|
// XXX: look results up in a hash for speed
|
|
|
|
len = strlen(base);
|
|
|
|
// go through all possible theme files and find collections that match
|
2013-11-03 19:17:58 -08:00
|
|
|
list = _elm_theme_file_group_base_list(NULL, th->overlay.handles,
|
|
|
|
base, len);
|
|
|
|
list = _elm_theme_file_group_base_list(list, th->themes.handles,
|
|
|
|
base, len);
|
|
|
|
list = _elm_theme_file_group_base_list(list, th->extension.handles,
|
|
|
|
base, len);
|
|
|
|
|
2013-10-31 07:22:18 -07:00
|
|
|
// sort the list nicely at the end
|
|
|
|
list = eina_list_sort(list, 0, EINA_COMPARE_CB(strcmp));
|
|
|
|
// XXX: store results in hash for fast lookup...
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI const char *
|
|
|
|
elm_theme_system_dir_get(void)
|
|
|
|
{
|
|
|
|
static char *path = NULL;
|
|
|
|
char buf[PATH_MAX];
|
2013-12-02 02:43:46 -08:00
|
|
|
|
2013-10-31 07:22:18 -07:00
|
|
|
if (path) return path;
|
2014-05-03 14:18:44 -07:00
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s/themes", _elm_data_dir);
|
|
|
|
path = strdup(buf);
|
|
|
|
|
2013-10-31 07:22:18 -07:00
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI const char *
|
|
|
|
elm_theme_user_dir_get(void)
|
|
|
|
{
|
|
|
|
static char *path = NULL;
|
|
|
|
char buf[PATH_MAX];
|
2015-05-14 12:26:44 -07:00
|
|
|
const char *home;
|
2013-12-02 02:43:46 -08:00
|
|
|
|
2013-10-31 07:22:18 -07:00
|
|
|
if (path) return path;
|
2013-12-02 02:43:46 -08:00
|
|
|
|
2015-05-14 12:26:44 -07:00
|
|
|
home = eina_environment_home_get();
|
2014-05-03 14:18:44 -07:00
|
|
|
snprintf(buf, sizeof(buf), "%s/"ELEMENTARY_BASE_DIR"/themes", home);
|
|
|
|
path = strdup(buf);
|
|
|
|
|
2013-10-31 07:22:18 -07:00
|
|
|
return path;
|
|
|
|
}
|