2012-08-12 19:55:07 -07:00
|
|
|
#include <Edje.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
|
|
|
typedef struct _Widget_Data Widget_Data;
|
|
|
|
struct _Widget_Data
|
|
|
|
{
|
|
|
|
Eina_List *styles;
|
|
|
|
};
|
|
|
|
|
|
|
|
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",
|
|
|
|
"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-08-13 04:23:49 -07:00
|
|
|
Eina_Hash *widget_list;
|
|
|
|
|
|
|
|
static void
|
|
|
|
_widget_entry_free_cb(void *data)
|
|
|
|
{
|
|
|
|
free(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
theme_init(void)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
Widget_Data *wd = NULL;
|
|
|
|
|
|
|
|
widget_list = eina_hash_string_superfast_new(_widget_entry_free_cb);
|
|
|
|
while (widgets[i])
|
|
|
|
{
|
|
|
|
// TODO : free the data when it's not used anymore.
|
|
|
|
wd = (Widget_Data *)calloc(1, sizeof(Widget_Data));
|
|
|
|
eina_hash_add(widget_list, widgets[i], wd);
|
2012-08-14 23:33:30 -07:00
|
|
|
//INF("%s", widgets[i]);
|
2012-08-14 23:05:37 -07:00
|
|
|
i++;
|
2012-08-13 04:23:49 -07:00
|
|
|
}
|
2012-08-14 23:05:19 -07:00
|
|
|
INF("Theme Init Done");
|
2012-08-13 04:23:49 -07:00
|
|
|
}
|
|
|
|
|
2012-08-12 19:55:07 -07:00
|
|
|
void
|
|
|
|
theme_load(void)
|
|
|
|
{
|
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
|
|
|
|
|
|
|
l = edje_file_collection_list("/usr/local/share/elementary/themes/default.edj");
|
|
|
|
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))
|
|
|
|
{
|
|
|
|
ERR("%s is not a proper elementary style.", token);
|
|
|
|
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-08-13 05:23:00 -07:00
|
|
|
wd = eina_hash_find(widget_list, token);
|
2012-08-14 23:33:30 -07:00
|
|
|
if (!wd)
|
|
|
|
{
|
|
|
|
ERR("%s is not a proper elementary widget.", token);
|
|
|
|
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-08-14 23:33:30 -07:00
|
|
|
//INF(stderr, "%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
|
|
|
|
|
|
|
edje_file_collection_list_free(l);
|
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
|
|
|
|
|
|
|
void
|
|
|
|
widget_style_print(const char *widget)
|
|
|
|
{
|
|
|
|
Eina_List *l = NULL;
|
|
|
|
Widget_Data *wd = NULL;
|
|
|
|
char *style = NULL;
|
|
|
|
|
|
|
|
wd = eina_hash_find(widget_list, widget);
|
|
|
|
EINA_LIST_FOREACH(wd->styles, l, style)
|
|
|
|
INF("%s", style);
|
|
|
|
}
|