widget_style, theme, gui: Saved more information about each style.

Save group name, manipulated style, and real style name on theme load.
This commit is contained in:
Daniel Juyung Seo 2014-03-20 03:21:43 +09:00
parent fe1e46f8bb
commit de406e5b38
5 changed files with 48 additions and 24 deletions

View File

@ -524,10 +524,10 @@ _style_list_sel_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
{
Style_Data *sd = data;
if (!data || !sd->widget_type || !sd->style) return;
INF("%s %s", widget_name_get_by_type(sd->widget_type), sd->style);
if (!data || !sd->widget_type || !sd->wds->style) return;
INF("%s %s", widget_name_get_by_type(sd->widget_type), sd->wds->style);
_preview_create(sd->widget_type, sd->style);
_preview_create(sd->widget_type, sd->wds->style);
widget_option_content_update(sd->widget_type);
}
@ -601,24 +601,23 @@ _gui_widget_style_load(Evas_Object *parent, Widget_Type type)
{
Evas_Object *o = NULL;
Eina_List *styles = NULL, *l = NULL;
const char *style = NULL;
Widget_Data_Style *wds = NULL;
Style_Data *sd = NULL;
// widget styles list
o = elm_list_add(parent);
elm_list_select_mode_set(o, ELM_OBJECT_SELECT_MODE_ALWAYS);
styles = theme_widget_styles_get(type);
EINA_LIST_FOREACH(styles, l, style)
EINA_LIST_FOREACH(styles, l, wds)
{
if (_gui_widget_style_exclude_check(type, style))
if (_gui_widget_style_exclude_check(type, wds->style))
continue;
// TODO: sd needs to be freed properly
sd = (Style_Data *)calloc(1, sizeof(Style_Data));
sd->widget_type = type;
sd->style = style;
style = widget_style_filter(sd);
elm_list_item_append(o, style, NULL, NULL, _style_list_sel_cb, sd);
sd->wds = wds;
elm_list_item_append(o, wds->style, NULL, NULL, _style_list_sel_cb, sd);
}
// add additional hacky custom styles for special reasons

View File

@ -27,12 +27,16 @@ void
theme_shutdown(void)
{
Widget_Data *wd = NULL;
char *style = NULL;
Widget_Data_Style *wds = NULL;
EINA_LIST_FREE(widget_list, wd)
{
EINA_LIST_FREE(wd->styles, style)
eina_stringshare_del(style);
EINA_LIST_FREE(wd->styles, wds)
{
eina_stringshare_del(wds->group);
eina_stringshare_del(wds->style);
eina_stringshare_del(wds->simple);
}
free(wd);
}
}
@ -56,6 +60,15 @@ theme_unset(const char *edje_file)
elm_theme_free(th);
}
static int
_style_compare_cb(const void *data1, const void *data2)
{
const Widget_Data_Style *wds1 = data1;
const Widget_Data_Style *wds2 = data2;
return strcmp(wds1->style, wds2->style);
}
void
theme_load(const char *edje_file)
{
@ -64,7 +77,8 @@ theme_load(const char *edje_file)
char *style = NULL;
char buf[PATH_MAX] = {0, };
Widget_Data *wd = NULL;
Eina_Compare_Cb cmp_func = (Eina_Compare_Cb)strcmp;
Widget_Data_Style *wds = NULL;
Eina_Compare_Cb cmp_func = (Eina_Compare_Cb)_style_compare_cb;
if (!edje_file) return;
@ -105,10 +119,13 @@ theme_load(const char *edje_file)
style++;
//INF("%s %s %p", group, style, wd);
wd->styles = eina_list_sorted_insert(
wd->styles,
cmp_func,
eina_stringshare_add(style));
wds = (Widget_Data_Style *)calloc(1, sizeof(Widget_Data_Style));
wds->group = eina_stringshare_add(group);
wds->style = eina_stringshare_add(style);
wds->simple = eina_stringshare_add(
widget_style_filter(wd->type, style));
wd->styles = eina_list_sorted_insert(wd->styles, cmp_func, wds);
}
edje_file_collection_list_free(groups);

View File

@ -73,6 +73,14 @@ struct _Widget
const char *desc;
};
typedef struct _Widget_Data_Style Widget_Data_Style;
struct _Widget_Data_Style
{
Eina_Stringshare *group; // original group name ex) elm/button/base/default
Eina_Stringshare *style; // manipulated style name ex) base/default
Eina_Stringshare *simple; // real style name ex) default
};
typedef struct _Widget_Data Widget_Data;
struct _Widget_Data
{

View File

@ -56,11 +56,11 @@ _split_style(const char *style EINA_UNUSED, const char **style1 EINA_UNUSED, con
const char *
widget_style_filter(const Style_Data *sd)
widget_style_filter(Widget_Type type, const char *orig_style)
{
const char *style = NULL;
switch (sd->widget_type)
switch (type)
{
case ETV_ID_ACTIONSLIDER:
case ETV_ID_BG:
@ -88,7 +88,7 @@ widget_style_filter(const Style_Data *sd)
case ETV_ID_THUMB:
case ETV_ID_TOOLTIP:
case ETV_ID_VIDEO:
style = sd->style + strlen("base/");
style = orig_style + strlen("base/");
break;
case ETV_ID_BUBBLE:
@ -120,12 +120,12 @@ widget_style_filter(const Style_Data *sd)
case ETV_ID_TOOLBAR: // base, item, more, object, separator
case ETV_ID_WIN: // base, inwin
default:
//style = _style_split_2(sd->style);
//style = _style_split_2(orig_style);
break;
}
if (style)
return style;
else
return sd->style;
return orig_style;
}

View File

@ -5,11 +5,11 @@ typedef struct _Style_Data Style_Data;
struct _Style_Data
{
Widget_Type widget_type;
const char *style;
Widget_Data_Style *wds;
};
void _style_split_1(const char *orig_style, char style[PATH_MAX]);
const char * _style_split_2(const char *orig_style);
const char * widget_style_filter(const Style_Data *sd);
const char * widget_style_filter(Widget_Type type, const char *orig_style);
#endif