set the theme to objects.

This commit is contained in:
Daniel Juyung Seo 2012-11-30 16:21:32 +09:00
parent 121ed76b14
commit 617288f755
4 changed files with 30 additions and 1 deletions

3
main.c
View File

@ -23,11 +23,14 @@ elm_main(int argc, char **argv)
// TODO: run this in a background
theme_init();
theme_load(edje_file);
theme_set(edje_file);
gui_create(edje_file);
gui_widget_load();
elm_run();
theme_unset(edje_file);
elm_shutdown();
return 0;

23
theme.c
View File

@ -1,4 +1,4 @@
#include <Edje.h>
#include <Elementary.h>
#include "log.h"
#include "theme.h"
@ -13,6 +13,7 @@ char *widgets[] = {
"scroller", "segment_control", "separator", "slider", "slideshow",
"spinner", "thumb", "toolbar", "tooltip", "video", "win", NULL };
Eina_List *widget_list;
Elm_Theme *th;
void
theme_init(void)
@ -22,6 +23,7 @@ theme_init(void)
if (widget_list) return;
// TODO : create only necessary widget data. do not create all wd for unused widgets.
while (widgets[i])
{
wd = (Widget_Data *)calloc(1, sizeof(Widget_Data));
@ -32,6 +34,25 @@ theme_init(void)
INF("Theme Init Done");
}
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);
}
void
theme_load(const char *edje_file)
{

View File

@ -2,6 +2,7 @@
#define __INCLUDE_THEME__
extern Eina_List *widget_list;
extern Elm_Theme *th;
typedef struct _Widget_Data Widget_Data;
struct _Widget_Data
@ -11,6 +12,8 @@ struct _Widget_Data
};
void theme_init(void);
void theme_set(const char *edje_file);
void theme_unset(const char *edje_file);
void theme_load(const char *edje_file);
Eina_List * theme_widget_styles_get(const char *widget);
void theme_widget_styles_print(const char *widget);

View File

@ -2,6 +2,7 @@
#include "common.h"
#include "gui.h"
#include "log.h"
#include "theme.h"
static const char *
_parse_style(const char *orig_style)
@ -106,5 +107,6 @@ widget_create(const char *widget, const char *orig_style)
o = _widget_frame_create(style);
else
o = _widget_bg_create(NULL);
elm_object_theme_set(o, th);
return o;
}