2012-11-29 23:21:32 -08:00
|
|
|
#include <Elementary.h>
|
2012-08-14 23:05:19 -07:00
|
|
|
#include "log.h"
|
2012-08-14 23:30:39 -07:00
|
|
|
#include "theme.h"
|
2012-08-12 19:55:07 -07:00
|
|
|
|
2012-08-13 04:23:49 -07:00
|
|
|
char *widgets[] = {
|
2012-08-14 23:50:17 -07:00
|
|
|
"access", "actionslider", "bg", "border", "bubble", "button", "calendar",
|
|
|
|
"check", "clock", "colorselector", "conformant", "ctxpopup", "datetime",
|
|
|
|
"dayselector", "diskselector", "entry", "ews", "fileselector",
|
2012-11-29 18:11:50 -08:00
|
|
|
"fileselector_entry", "flipselector", "focus_highlight", "frame",
|
|
|
|
"gengrid", "genlist", "hover", "icon", "index", "label", "layout", "list",
|
|
|
|
"map", "menu", "multibuttonentry", "naviframe", "notify", "panel", "panes",
|
|
|
|
"photo", "photocam", "player", "pointer", "popup", "progressbar", "radio",
|
|
|
|
"scroller", "segment_control", "separator", "slider", "slideshow",
|
|
|
|
"spinner", "thumb", "toolbar", "tooltip", "video", "win", NULL };
|
2012-11-29 11:21:16 -08:00
|
|
|
Eina_List *widget_list;
|
2012-11-29 23:21:32 -08:00
|
|
|
Elm_Theme *th;
|
2012-08-13 04:23:49 -07:00
|
|
|
|
|
|
|
void
|
|
|
|
theme_init(void)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
Widget_Data *wd = NULL;
|
|
|
|
|
2012-11-29 11:21:16 -08:00
|
|
|
if (widget_list) return;
|
|
|
|
|
2012-11-29 23:21:32 -08:00
|
|
|
// TODO : create only necessary widget data. do not create all wd for unused widgets.
|
2012-11-29 11:21:16 -08:00
|
|
|
while (widgets[i])
|
|
|
|
{
|
|
|
|
wd = (Widget_Data *)calloc(1, sizeof(Widget_Data));
|
|
|
|
wd->widget = widgets[i];
|
|
|
|
widget_list = eina_list_append(widget_list, wd);
|
|
|
|
i++;
|
|
|
|
}
|
2012-08-14 23:05:19 -07:00
|
|
|
INF("Theme Init Done");
|
2012-08-13 04:23:49 -07:00
|
|
|
}
|
|
|
|
|
2012-11-29 23:21:32 -08:00
|
|
|
void
|
|
|
|
theme_set(const char *edje_file)
|
|
|
|
{
|
|
|
|
if (!edje_file) return;
|
|
|
|
|
|
|
|
th = elm_theme_new();
|
|
|
|
elm_theme_ref_set(th, NULL);
|
|
|
|
elm_theme_overlay_add(th, edje_file);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
theme_unset(const char *edje_file)
|
|
|
|
{
|
|
|
|
if (!edje_file) return;
|
|
|
|
|
|
|
|
elm_theme_overlay_del(th, edje_file);
|
|
|
|
elm_theme_free(th);
|
|
|
|
}
|
|
|
|
|
2012-08-12 19:55:07 -07:00
|
|
|
void
|
2012-11-29 08:53:38 -08:00
|
|
|
theme_load(const char *edje_file)
|
2012-08-12 19:55:07 -07:00
|
|
|
{
|
2012-08-13 05:23:00 -07:00
|
|
|
Eina_List *l = NULL, *ll = NULL;
|
|
|
|
char *group = NULL, *token = NULL;
|
|
|
|
char *style = NULL;
|
|
|
|
char buf[PATH_MAX] = {0, };
|
|
|
|
Widget_Data *wd = NULL;
|
2012-08-14 23:30:39 -07:00
|
|
|
Eina_Compare_Cb cmp_func = (Eina_Compare_Cb)strcmp;
|
2012-08-12 19:55:07 -07:00
|
|
|
|
2012-11-29 08:53:38 -08:00
|
|
|
if (!edje_file) return;
|
|
|
|
|
|
|
|
l = edje_file_collection_list(edje_file);
|
2012-08-12 19:55:07 -07:00
|
|
|
if (!l) return;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(l, ll, group)
|
2012-08-13 05:23:00 -07:00
|
|
|
{
|
|
|
|
strncpy(buf, group, sizeof(buf));
|
|
|
|
|
|
|
|
token = strtok(buf, "/");
|
2012-08-14 23:33:30 -07:00
|
|
|
if (strncmp("elm", token, 5))
|
|
|
|
{
|
2012-11-29 11:21:16 -08:00
|
|
|
//ERR("%s is not a proper elementary style.", token);
|
2012-08-14 23:33:30 -07:00
|
|
|
continue;
|
|
|
|
}
|
2012-08-13 05:23:00 -07:00
|
|
|
|
2012-08-14 23:30:39 -07:00
|
|
|
// get the widget name
|
2012-08-13 05:23:00 -07:00
|
|
|
token = strtok(NULL, "/");
|
|
|
|
if (!token) continue;
|
|
|
|
|
2012-08-14 23:30:39 -07:00
|
|
|
// get the widget data of the widget
|
2012-11-29 11:21:16 -08:00
|
|
|
wd = NULL;
|
|
|
|
EINA_LIST_FOREACH(widget_list, l, wd)
|
|
|
|
{
|
2012-11-29 19:21:56 -08:00
|
|
|
if (!strcmp(wd->widget, token))
|
|
|
|
break;
|
2012-11-29 11:21:16 -08:00
|
|
|
}
|
2012-08-14 23:33:30 -07:00
|
|
|
if (!wd)
|
|
|
|
{
|
2012-11-29 09:50:12 -08:00
|
|
|
//ERR("%s is not a proper elementary widget.", token);
|
2012-08-14 23:33:30 -07:00
|
|
|
continue;
|
|
|
|
}
|
2012-08-13 05:23:00 -07:00
|
|
|
|
2012-08-14 23:30:39 -07:00
|
|
|
// get the style name
|
2012-08-13 05:23:00 -07:00
|
|
|
style = strstr(group, "/");
|
|
|
|
style = strstr(style + 1, "/");
|
|
|
|
style++;
|
|
|
|
|
2012-11-29 09:50:12 -08:00
|
|
|
//INF("%s %s %p", group, style, wd);
|
2012-08-14 23:30:39 -07:00
|
|
|
wd->styles = eina_list_sorted_insert(wd->styles, cmp_func, style);
|
2012-08-13 05:23:00 -07:00
|
|
|
}
|
2012-08-12 19:55:07 -07:00
|
|
|
|
2012-11-30 01:25:53 -08:00
|
|
|
//edje_file_collection_list_free(l); // TODO
|
2012-08-14 23:05:19 -07:00
|
|
|
|
|
|
|
INF("Theme Load Done");
|
2012-08-12 19:55:07 -07:00
|
|
|
}
|
2012-08-14 23:30:39 -07:00
|
|
|
|
2012-11-30 01:23:45 -08:00
|
|
|
void
|
|
|
|
theme_widgets_print(void)
|
|
|
|
{
|
|
|
|
Eina_List *l;
|
|
|
|
Widget_Data *wd;
|
|
|
|
|
|
|
|
EINA_LIST_FOREACH(widget_list, l, wd)
|
|
|
|
INF("%s %d", wd->widget, eina_list_count(wd->styles));
|
|
|
|
}
|
|
|
|
|
2012-11-29 10:50:01 -08:00
|
|
|
Eina_List *
|
2012-11-29 22:15:44 -08:00
|
|
|
theme_widget_styles_get(const char *widget)
|
2012-11-29 10:50:01 -08:00
|
|
|
{
|
|
|
|
Widget_Data *wd = NULL;
|
2012-11-29 11:21:16 -08:00
|
|
|
Eina_List *l;
|
|
|
|
|
|
|
|
if (!widget) return NULL;
|
2012-11-29 10:50:01 -08:00
|
|
|
|
2012-11-29 11:21:16 -08:00
|
|
|
EINA_LIST_FOREACH(widget_list, l, wd)
|
|
|
|
{
|
|
|
|
if (!strcmp(widget, wd->widget))
|
|
|
|
break;
|
|
|
|
}
|
2012-11-29 10:50:01 -08:00
|
|
|
return wd->styles;
|
|
|
|
}
|
|
|
|
|
2012-08-14 23:30:39 -07:00
|
|
|
void
|
2012-11-29 22:15:44 -08:00
|
|
|
theme_widget_styles_print(const char *widget)
|
2012-08-14 23:30:39 -07:00
|
|
|
{
|
|
|
|
Eina_List *l = NULL;
|
|
|
|
Widget_Data *wd = NULL;
|
|
|
|
char *style = NULL;
|
|
|
|
|
2012-11-29 11:21:16 -08:00
|
|
|
EINA_LIST_FOREACH(widget_list, l, wd)
|
|
|
|
{
|
|
|
|
if (!strcmp(widget, wd->widget))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-08-14 23:30:39 -07:00
|
|
|
EINA_LIST_FOREACH(wd->styles, l, style)
|
|
|
|
INF("%s", style);
|
|
|
|
}
|