summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2009-01-13 09:20:53 +0000
committerCarsten Haitzler <raster@rasterman.com>2009-01-13 09:20:53 +0000
commit16999e1bd5c9ad62dd6e237536b4ab2c8587873d (patch)
treeab70f21d195d0bd20980a6b3dc0f7ef1e0b46e37
parentb817fd41a97d8a7d791ff0b182dd8ee7d344f9c1 (diff)
1. add carousel start - does nothnig. ignore. copy of toolbar atm to start with
2. make elementary be able to determine theme from PREFIX/share/elementary/themes or ~/.elementary/themes (~/ takes preference) currently using a delimited list of theme names in order to check like: mytheme/fallback/morestuff/default (if the last theme entry is on default it is added explicitly). this allows multiple theme files bascially to work a bit like a fontset - try the first one - if not there, try the next and so on. set $ELM_THEME to your theme setting 3. determine prefix and thus data dir - where system themes go. if it can't rely on dladdr, or the compiled-in prefix/data dir, you can set $ELM_PREFIX and/or $ELM_DATA_DIR accordingly. SVN revision: 38568
Diffstat (limited to '')
-rw-r--r--configure.in17
-rw-r--r--elementary.pc.in2
-rw-r--r--src/lib/Elementary.h.in11
-rw-r--r--src/lib/Makefile.am3
-rw-r--r--src/lib/elm_carousel.c259
-rw-r--r--src/lib/elm_main.c78
-rw-r--r--src/lib/elm_priv.h5
-rw-r--r--src/lib/elm_theme.c141
-rw-r--r--src/lib/elm_toolbar.c2
9 files changed, 492 insertions, 26 deletions
diff --git a/configure.in b/configure.in
index 4bb00dacb..47d7c2c86 100644
--- a/configure.in
+++ b/configure.in
@@ -45,7 +45,9 @@ case "$host_os" in
45 AC_DEFINE(ELEMENTARY_BUILD, 1, [Define to mention that evas is built]) 45 AC_DEFINE(ELEMENTARY_BUILD, 1, [Define to mention that evas is built])
46 lt_enable_auto_import="-Wl,--enable-auto-import" 46 lt_enable_auto_import="-Wl,--enable-auto-import"
47 ELM_WINCE_DEF="#define" 47 ELM_WINCE_DEF="#define"
48 ;; 48dnl managed by evil
49 AC_DEFINE(HAVE_DLADDR)
50 ;;
49 mingw*) 51 mingw*)
50 PKG_CHECK_MODULES([EVIL], [evil]) 52 PKG_CHECK_MODULES([EVIL], [evil])
51 AC_DEFINE(HAVE_EVIL, 1, [Set to 1 if evil package is installed.]) 53 AC_DEFINE(HAVE_EVIL, 1, [Set to 1 if evil package is installed.])
@@ -56,8 +58,21 @@ case "$host_os" in
56 ;; 58 ;;
57 *) 59 *)
58 ELM_UNIX_DEF="#define" 60 ELM_UNIX_DEF="#define"
61 AC_CHECK_FUNCS(dlopen, res=yes, res=no)
62 if test "x$res" = "xyes"; then
63 AC_CHECK_FUNCS(dladdr, AC_DEFINE(HAVE_DLADDR))
64 else
65 AC_CHECK_LIB(dl, dlopen, res=yes, res=no)
66 if test "x$res" = "xyes"; then
67 AC_CHECK_LIB(dl, dladdr, AC_DEFINE(HAVE_DLADDR))
68 dlopen_libs=-ldl
69 else
70 AC_MSG_ERROR(Cannot find dlopen)
71 fi
72 fi
59 ;; 73 ;;
60esac 74esac
75AC_SUBST(dlopen_libs)
61AC_SUBST(lt_enable_auto_import) 76AC_SUBST(lt_enable_auto_import)
62AC_SUBST(ELM_UNIX_DEF) 77AC_SUBST(ELM_UNIX_DEF)
63AC_SUBST(ELM_WIN32_DEF) 78AC_SUBST(ELM_WIN32_DEF)
diff --git a/elementary.pc.in b/elementary.pc.in
index 2ea55aa25..0564b12e5 100644
--- a/elementary.pc.in
+++ b/elementary.pc.in
@@ -8,5 +8,5 @@ Description: Mobile device touchscreen widget library
8Requires: evas ecore ecore-x ecore-evas ecore-job ecore-txt ecore-file eet edje 8Requires: evas ecore ecore-x ecore-evas ecore-job ecore-txt ecore-file eet edje
9Version: @VERSION@ 9Version: @VERSION@
10Libs: -L${libdir} -lelementary 10Libs: -L${libdir} -lelementary
11Libs.private: @my_libs@ @ELEMENTARY_LIBS@ @ELEMENTARY_X_LIBS@ @ELEMENTARY_FB_LIBS@ @ELEMENTARY_WINCE_LIBS@ @ELEMENTARY_EDBUS_LIBS@ 11Libs.private: @dlopen_libs@ @my_libs@ @ELEMENTARY_LIBS@ @ELEMENTARY_X_LIBS@ @ELEMENTARY_FB_LIBS@ @ELEMENTARY_WINCE_LIBS@ @ELEMENTARY_EDBUS_LIBS@
12Cflags: -I${includedir} -I${includedir}/elementary @ELEMENTARY_CFLAGS@ @ELEMENTARY_X_CFLAGS@ @ELEMENTARY_FB_CFLAGS@ @ELEMENTARY_WINCE_CFLAGS@ @ELEMENTARY_EDBUS_CFLAGS@ 12Cflags: -I${includedir} -I${includedir}/elementary @ELEMENTARY_CFLAGS@ @ELEMENTARY_X_CFLAGS@ @ELEMENTARY_FB_CFLAGS@ @ELEMENTARY_WINCE_CFLAGS@ @ELEMENTARY_EDBUS_CFLAGS@
diff --git a/src/lib/Elementary.h.in b/src/lib/Elementary.h.in
index 79c97f295..123e8d00f 100644
--- a/src/lib/Elementary.h.in
+++ b/src/lib/Elementary.h.in
@@ -432,7 +432,16 @@ extern "C" {
432 * "selected" - when the user selected an item 432 * "selected" - when the user selected an item
433 * "unselected" - when the user selected an item 433 * "unselected" - when the user selected an item
434 */ 434 */
435 435
436 typedef struct _Elm_Carousel_Item Elm_Carousel_Item;
437 EAPI Evas_Object *elm_carousel_add(Evas_Object *parent);
438 EAPI Elm_Carousel_Item *elm_carousel_item_add(Evas_Object *obj, Evas_Object *icon, const char *label, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data);
439 EAPI void elm_carousel_item_del(Elm_Carousel_Item *item);
440 EAPI void elm_carousel_item_select(Elm_Carousel_Item *item);
441 /* smart callbacks called:
442 * "clicked" - when the user clicks on a carousel item and becomes selected
443 */
444
436 //////////////////////////////////////////////////////////////////////////// 445 ////////////////////////////////////////////////////////////////////////////
437 /// FIXME: TODO LIST /////////////////////////////////////////////////////// 446 /// FIXME: TODO LIST ///////////////////////////////////////////////////////
438//////////////////////////////////////////////////////////////////////////// 447////////////////////////////////////////////////////////////////////////////
diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am
index dfbd39340..0998a7a99 100644
--- a/src/lib/Makefile.am
+++ b/src/lib/Makefile.am
@@ -41,6 +41,7 @@ elm_bubble.c \
41elm_photo.c \ 41elm_photo.c \
42elm_toolbar.c \ 42elm_toolbar.c \
43elm_list.c \ 43elm_list.c \
44elm_carousel.c \
44\ 45\
45elc_notepad.c \ 46elc_notepad.c \
46elc_anchorview.c \ 47elc_anchorview.c \
@@ -60,5 +61,5 @@ els_icon.h
60 61
61 62
62libelementary_la_CFLAGS = 63libelementary_la_CFLAGS =
63libelementary_la_LIBADD = @ELEMENTARY_LIBS@ @ELEMENTARY_X_LIBS@ @ELEMENTARY_FB_LIBS@ @ELEMENTARY_WINCE_LIBS@ @ELEMENTARY_EDBUS_LIBS@ @my_libs@ 64libelementary_la_LIBADD = @my_libs@ @dlopen_libs@ @ELEMENTARY_LIBS@ @ELEMENTARY_X_LIBS@ @ELEMENTARY_FB_LIBS@ @ELEMENTARY_WINCE_LIBS@ @ELEMENTARY_EDBUS_LIBS@
64libelementary_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@ 65libelementary_la_LDFLAGS = -no-undefined @lt_enable_auto_import@ -version-info @version_info@
diff --git a/src/lib/elm_carousel.c b/src/lib/elm_carousel.c
new file mode 100644
index 000000000..02af673c7
--- /dev/null
+++ b/src/lib/elm_carousel.c
@@ -0,0 +1,259 @@
1#include <Elementary.h>
2#include "elm_priv.h"
3
4// FIXME: this is NOT the carousel - yet!
5
6typedef struct _Widget_Data Widget_Data;
7typedef struct _Item Item;
8
9struct _Widget_Data
10{
11 Evas_Object *scr, *bx;
12 Eina_List *items;
13 int icon_size;
14 Evas_Bool scrollable : 1;
15};
16
17struct _Item
18{
19 Evas_Object *obj;
20 Evas_Object *base;
21 const char *label;
22 Evas_Object *icon;
23 void (*func) (void *data, Evas_Object *obj, void *event_info);
24 const void *data;
25 Evas_Bool selected : 1;
26};
27
28static void _del_hook(Evas_Object *obj);
29static void _theme_hook(Evas_Object *obj);
30static void _sizing_eval(Evas_Object *obj);
31
32static void
33_item_show(Item *it)
34{
35 Widget_Data *wd = elm_widget_data_get(it->obj);
36 Evas_Coord x, y, w, h, bx, by;
37
38 evas_object_geometry_get(wd->bx, &bx, &by, NULL, NULL);
39 evas_object_geometry_get(it->base, &x, &y, &w, &h);
40 elm_smart_scroller_child_region_show(wd->scr, x - bx, y - by, w, h);
41}
42
43static void
44_item_select(Item *it)
45{
46 Item *it2;
47 Widget_Data *wd = elm_widget_data_get(it->obj);
48 Evas_Object *obj2;
49 Eina_List *l;
50 if (it->selected) return;
51 for (l = wd->items; l; l = l->next)
52 {
53 it2 = l->data;
54 if (it2->selected)
55 {
56 it2->selected = 0;
57 edje_object_signal_emit(it2->base, "elm,state,unselected", "elm");
58 break;
59 }
60 }
61 it->selected = 1;
62 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
63 _item_show(it);
64 obj2 = it->obj;
65 if (it->func) it->func((void *)(it->data), it->obj, it);
66 evas_object_smart_callback_call(obj2, "clicked", it);
67}
68
69static void
70_del_hook(Evas_Object *obj)
71{
72 Widget_Data *wd = elm_widget_data_get(obj);
73 free(wd);
74}
75
76static void
77_theme_hook(Evas_Object *obj)
78{
79 Widget_Data *wd = elm_widget_data_get(obj);
80 Eina_List *l;
81 Item *it;
82 Evas_Coord mw, mh;
83 for (l = wd->items; l; l = l->next)
84 {
85 it = l->data;
86 if (it->selected)
87 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
88 _elm_theme_set(it->base, "carousel", "item", "default");
89 if (it->icon)
90 {
91 edje_extern_object_min_size_set(it->icon,
92 (double)wd->icon_size * _elm_config->scale,
93 (double)wd->icon_size * _elm_config->scale);
94 edje_object_part_swallow(it->base, "elm.swallow.icon", it->icon);
95 }
96 edje_object_part_text_set(it->base, "elm.text", it->label);
97 edje_object_size_min_calc(it->base, &mw, &mh);
98 evas_object_size_hint_min_set(it->base, mw, mh);
99 evas_object_size_hint_max_set(it->base, 9999, mh);
100 }
101 _sizing_eval(obj);
102}
103
104static void
105_sizing_eval(Evas_Object *obj)
106{
107 Widget_Data *wd = elm_widget_data_get(obj);
108 Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
109 Evas_Coord vw = 0, vh = 0;
110
111 edje_object_size_min_calc(elm_smart_scroller_edje_object_get(wd->scr), &minw, &minh);
112 evas_object_resize(wd->scr, 500, 500);
113 evas_object_size_hint_min_get(wd->bx, &minw, &minh);
114 evas_object_resize(wd->bx, minw, minh);
115 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
116 if (wd->scrollable)
117 {
118 minw = 500 - vw;
119 minh = minh + (500 - vh);
120 }
121 else
122 {
123 minw = minw + (500 - vw);
124 minh = minh + (500 - vh);
125 }
126 evas_object_size_hint_min_set(obj, minw, minh);
127 evas_object_size_hint_max_set(obj, maxw, maxh);
128}
129
130static void
131_resize(void *data, Evas *e, Evas_Object *obj, void *event_info)
132{
133 Widget_Data *wd = elm_widget_data_get(data);
134 Evas_Coord mw, mh, vw, vh, w, h;
135 Eina_List *l;
136 Item *it;
137
138 elm_smart_scroller_child_viewport_size_get(wd->scr, &vw, &vh);
139 evas_object_size_hint_min_get(wd->bx, &mw, &mh);
140 evas_object_geometry_get(wd->bx, NULL, NULL, &w, &h);
141 if (vw >= mw)
142 {
143 if (w != vw) evas_object_resize(wd->bx, vw, h);
144 }
145 for (l = wd->items; l; l = l->next)
146 {
147 it = l->data;
148 if (it->selected)
149 {
150 _item_show(it);
151 break;
152 }
153 }
154
155}
156
157static void
158_select(void *data, Evas_Object *obj, const char *emission, const char *source)
159{
160 _item_select(data);
161}
162
163EAPI Evas_Object *
164elm_carousel_add(Evas_Object *parent)
165{
166 Evas_Object *obj;
167 Evas *e;
168 Widget_Data *wd;
169
170 wd = ELM_NEW(Widget_Data);
171 e = evas_object_evas_get(parent);
172 obj = elm_widget_add(e);
173 elm_widget_data_set(obj, wd);
174 elm_widget_del_hook_set(obj, _del_hook);
175 elm_widget_theme_hook_set(obj, _theme_hook);
176 elm_widget_can_focus_set(obj, 0);
177
178 wd->scr = elm_smart_scroller_add(e);
179 elm_smart_scroller_theme_set(wd->scr, "carousel", "base", "default");
180 elm_widget_resize_object_set(obj, wd->scr);
181 elm_smart_scroller_policy_set(wd->scr,
182 ELM_SMART_SCROLLER_POLICY_AUTO,
183 ELM_SMART_SCROLLER_POLICY_OFF);
184
185 wd->icon_size = 32;
186 wd->scrollable = 1;
187
188 wd->bx = _els_smart_box_add(e);
189 _els_smart_box_orientation_set(wd->bx, 1);
190 _els_smart_box_homogenous_set(wd->bx, 1);
191 elm_widget_sub_object_add(obj, wd->bx);
192 elm_smart_scroller_child_set(wd->scr, wd->bx);
193 evas_object_show(wd->bx);
194
195 evas_object_event_callback_add(wd->scr, EVAS_CALLBACK_RESIZE,
196 _resize, obj);
197
198 _sizing_eval(obj);
199 return obj;
200}
201
202EAPI Elm_Carousel_Item *
203elm_carousel_item_add(Evas_Object *obj, Evas_Object *icon, const char *label, void (*func) (void *data, Evas_Object *obj, void *event_info), const void *data)
204{
205 Widget_Data *wd = elm_widget_data_get(obj);
206 Evas_Coord mw, mh;
207 Item *it = calloc(1, sizeof(Item));
208 if (!it) return NULL;
209 wd->items = eina_list_append(wd->items, it);
210 it->obj = obj;
211 it->label = eina_stringshare_add(label);
212 it->icon = icon;
213 it->func = func;
214 it->data = data;
215 it->base = edje_object_add(evas_object_evas_get(obj));
216 _elm_theme_set(it->base, "carousel", "item", "default");
217 edje_object_signal_callback_add(it->base, "elm,action,click", "elm",
218 _select, it);
219 elm_widget_sub_object_add(obj, it->base);
220 if (it->icon)
221 {
222 edje_extern_object_min_size_set(it->icon,
223 (double)wd->icon_size * _elm_config->scale,
224 (double)wd->icon_size * _elm_config->scale);
225 edje_object_part_swallow(it->base, "elm.swallow.icon", it->icon);
226 evas_object_show(it->icon);
227 elm_widget_sub_object_add(obj, it->icon);
228 }
229 edje_object_part_text_set(it->base, "elm.text", it->label);
230 edje_object_size_min_calc(it->base, &mw, &mh);
231 evas_object_size_hint_weight_set(it->base, 0.0, 0.0);
232 evas_object_size_hint_align_set(it->base, -1.0, -1.0);
233 evas_object_size_hint_min_set(it->base, mw, mh);
234 evas_object_size_hint_max_set(it->base, 9999, mh);
235 _els_smart_box_pack_end(wd->bx, it->base);
236 evas_object_show(it->base);
237 _sizing_eval(obj);
238 return (Elm_Carousel_Item *)it;
239}
240
241EAPI void
242elm_carousel_item_del(Elm_Carousel_Item *item)
243{
244 Item *it = (Item *)item;
245 Widget_Data *wd = elm_widget_data_get(it->obj);
246 Evas_Object *obj2 = it->obj;
247 wd->items = eina_list_remove(wd->items, it);
248 eina_stringshare_del(it->label);
249 if (it->icon) evas_object_del(it->icon);
250 evas_object_del(it->base);
251 free(it);
252 _theme_hook(obj2);
253}
254
255EAPI void
256elm_carousel_item_select(Elm_Carousel_Item *item)
257{
258 _item_select(item);
259}
diff --git a/src/lib/elm_main.c b/src/lib/elm_main.c
index da8fd92bb..ab6ddf340 100644
--- a/src/lib/elm_main.c
+++ b/src/lib/elm_main.c
@@ -1,3 +1,9 @@
1#ifndef _GNU_SOURCE
2# define _GNU_SOURCE
3#endif
4
5#include <dlfcn.h> /* dlopen,dlclose,etc */
6
1#ifdef HAVE_CONFIG_H 7#ifdef HAVE_CONFIG_H
2# include "elementary_config.h" 8# include "elementary_config.h"
3#endif 9#endif
@@ -9,6 +15,7 @@
9#include <Elementary.h> 15#include <Elementary.h>
10#include "elm_priv.h" 16#include "elm_priv.h"
11 17
18
12static int _elm_signal_exit(void *data, int ev_type, void *ev); 19static int _elm_signal_exit(void *data, int ev_type, void *ev);
13#ifdef HAVE_ELEMENTARY_X 20#ifdef HAVE_ELEMENTARY_X
14static int _elm_window_property_change(void *data, int ev_type, void *ev); 21static int _elm_window_property_change(void *data, int ev_type, void *ev);
@@ -17,9 +24,11 @@ static void _elm_rescale(void);
17 24
18char *_elm_appname = NULL; 25char *_elm_appname = NULL;
19Elm_Config *_elm_config = NULL; 26Elm_Config *_elm_config = NULL;
20Ecore_Event_Handler *_elm_event_property_change = NULL; 27const char *_elm_data_dir = NULL;
28
29static Ecore_Event_Handler *_elm_event_property_change = NULL;
21#ifdef HAVE_ELEMENTARY_X 30#ifdef HAVE_ELEMENTARY_X
22Ecore_X_Atom _elm_atom_enlightenment_scale = 0; 31static Ecore_X_Atom _elm_atom_enlightenment_scale = 0;
23#endif 32#endif
24 33
25static int 34static int
@@ -68,7 +77,8 @@ EAPI void
68elm_init(int argc, char **argv) 77elm_init(int argc, char **argv)
69{ 78{
70 int i; 79 int i;
71 const char *elm_engine, *elm_scale; 80 const char *elm_engine, *elm_scale, *elm_theme, *elm_prefix, *elm_data_dir;
81 char buf[PATH_MAX];
72 82
73 eet_init(); 83 eet_init();
74 ecore_init(); 84 ecore_init();
@@ -84,7 +94,56 @@ elm_init(int argc, char **argv)
84 94
85 elm_engine = getenv("ELM_ENGINE"); 95 elm_engine = getenv("ELM_ENGINE");
86 elm_scale = getenv("ELM_SCALE"); 96 elm_scale = getenv("ELM_SCALE");
97 elm_theme = getenv("ELM_THEME");
98 elm_prefix = getenv("ELM_PREFIX");
99 elm_data_dir = getenv("ELM_DATA_DIR");
87 100
101 if (!_elm_data_dir)
102 {
103 _elm_data_dir = eina_stringshare_add(elm_data_dir);
104 }
105 if (!_elm_data_dir)
106 {
107 if (elm_prefix)
108 {
109 snprintf(buf, sizeof(buf), "%s/share/elementary", elm_prefix);
110 _elm_data_dir = eina_stringshare_add(buf);
111 }
112 }
113#ifdef HAVE_DLADDR
114 if (!_elm_data_dir)
115 {
116 Dl_info elementary_dl;
117 // libelementary.so/../../share/elementary/
118 if (dladdr(elm_init, &elementary_dl))
119 {
120 char *dir, *dir2;
121
122 dir = ecore_file_dir_get(elementary_dl.dli_fname);
123 if (dir)
124 {
125 dir2 = ecore_file_dir_get(dir);
126 if (dir2)
127 {
128 snprintf(buf, sizeof(buf), "%s/share/elementary", dir2);
129 if (ecore_file_is_dir(buf))
130 _elm_data_dir = eina_stringshare_add(buf);
131 free(dir2);
132 }
133 free(dir);
134 }
135 }
136 }
137#endif
138 if (!_elm_data_dir)
139 {
140 _elm_data_dir = eina_stringshare_add(PACKAGE_DATA_DIR);
141 }
142 if (!_elm_data_dir)
143 {
144 _elm_data_dir = eina_stringshare_add("/");
145 }
146
88 // FIXME: actually load config 147 // FIXME: actually load config
89 _elm_config = ELM_NEW(Elm_Config); 148 _elm_config = ELM_NEW(Elm_Config);
90 _elm_config->engine = ELM_SOFTWARE_X11; 149 _elm_config->engine = ELM_SOFTWARE_X11;
@@ -157,9 +216,13 @@ elm_init(int argc, char **argv)
157 } 216 }
158 217
159 if (elm_scale) 218 if (elm_scale)
160 { 219 _elm_config->scale = atof(elm_scale);
161 _elm_config->scale = atof(elm_scale); 220
162 } 221 if (elm_theme)
222 _elm_theme_parse(elm_theme);
223 else
224 _elm_theme_parse("default");
225
163 /* FIXME: implement quickstart below */ 226 /* FIXME: implement quickstart below */
164 /* if !quickstart return 227 /* if !quickstart return
165 * else 228 * else
@@ -200,6 +263,9 @@ elm_shutdown(void)
200 ecore_x_shutdown(); 263 ecore_x_shutdown();
201#endif 264#endif
202 } 265 }
266
267 eina_stringshare_del(_elm_data_dir);
268 _elm_data_dir = NULL;
203 269
204 free(_elm_config); 270 free(_elm_config);
205 free(_elm_appname); 271 free(_elm_appname);
diff --git a/src/lib/elm_priv.h b/src/lib/elm_priv.h
index cd30d335f..dbbb1d6c5 100644
--- a/src/lib/elm_priv.h
+++ b/src/lib/elm_priv.h
@@ -52,7 +52,8 @@ void _elm_win_rescale(void);
52 52
53int _elm_theme_set(Evas_Object *o, const char *clas, const char *group, const char *style); 53int _elm_theme_set(Evas_Object *o, const char *clas, const char *group, const char *style);
54int _elm_theme_icon_set(Evas_Object *o, const char *group, const char *style); 54int _elm_theme_icon_set(Evas_Object *o, const char *group, const char *style);
55 55int _elm_theme_parse(const char *theme);
56
56/* FIXME: should this be public? for now - private (but public symbols) */ 57/* FIXME: should this be public? for now - private (but public symbols) */
57EAPI Evas_Object *elm_widget_add(Evas *evas); 58EAPI Evas_Object *elm_widget_add(Evas *evas);
58EAPI void elm_widget_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj)); 59EAPI void elm_widget_del_hook_set(Evas_Object *obj, void (*func) (Evas_Object *obj));
@@ -92,7 +93,7 @@ EAPI void elm_widget_scroll_hold_pop(Evas_Object *obj);
92EAPI int elm_widget_scroll_hold_get(Evas_Object *obj); 93EAPI int elm_widget_scroll_hold_get(Evas_Object *obj);
93 94
94extern char *_elm_appname; 95extern char *_elm_appname;
95
96extern Elm_Config *_elm_config; 96extern Elm_Config *_elm_config;
97extern const char *_elm_data_dir;
97 98
98#endif 99#endif
diff --git a/src/lib/elm_theme.c b/src/lib/elm_theme.c
index 60dff7882..6e51f4f1e 100644
--- a/src/lib/elm_theme.c
+++ b/src/lib/elm_theme.c
@@ -1,39 +1,154 @@
1#include <Elementary.h> 1#include <Elementary.h>
2#include "elm_priv.h" 2#include "elm_priv.h"
3 3
4static Eina_List *themes = NULL;
5static Eina_Hash *cache = NULL;
6
7static const char *
8_elm_theme_group_file_find(const char *group)
9{
10 Eina_List *l;
11 char buf[PATH_MAX];
12 char *p;
13 static const char *home = NULL;
14 const char *file = eina_hash_find(cache, group);
15 if (file) return file;
16 if (!home)
17 {
18 home = getenv("HOME");
19 if (!home) home = "";
20 }
21 for (l = themes; l; l = l->next)
22 {
23 snprintf(buf, sizeof(buf), "%s/.elementary/themes/%s.edj", home, l->data);
24 if (edje_file_group_exists(buf, group))
25 {
26 file = eina_stringshare_add(buf);
27 if (file)
28 {
29 eina_hash_add(cache, group, file);
30 return file;
31 }
32 }
33 snprintf(buf, sizeof(buf), "%s/themes/%s.edj", PACKAGE_DATA_DIR, l->data);
34 if (edje_file_group_exists(buf, group))
35 {
36 file = eina_stringshare_add(buf);
37 if (file)
38 {
39 eina_hash_add(cache, group, file);
40 return file;
41 }
42 }
43 }
44 return NULL;
45}
46
4int 47int
5_elm_theme_set(Evas_Object *o, const char *clas, const char *group, const char *style) 48_elm_theme_set(Evas_Object *o, const char *clas, const char *group, const char *style)
6{ 49{
7 char buf[PATH_MAX]; 50 const char *file;
8 char buf2[1024]; 51 char buf2[1024];
9 int ok; 52 int ok;
10 53
11 // FIXME: actually handle themes for real
12 snprintf(buf, sizeof(buf), "%s/themes/%s.edj", PACKAGE_DATA_DIR, "default");
13 snprintf(buf2, sizeof(buf2), "elm/%s/%s/%s", clas, group, style); 54 snprintf(buf2, sizeof(buf2), "elm/%s/%s/%s", clas, group, style);
14 ok = edje_object_file_set(o, buf, buf2); 55 file = _elm_theme_group_file_find(buf2);
15 if (ok) return 1; 56 if (file)
57 {
58 ok = edje_object_file_set(o, file, buf2);
59 if (ok) return 1;
60 }
16 snprintf(buf2, sizeof(buf2), "elm/%s/%s/default", clas, group); 61 snprintf(buf2, sizeof(buf2), "elm/%s/%s/default", clas, group);
17 ok = edje_object_file_set(o, buf, buf2); 62 file = _elm_theme_group_file_find(buf2);
63 if (!file) return 0;
64 ok = edje_object_file_set(o, file, buf2);
18 return ok; 65 return ok;
19} 66}
20 67
21int 68int
22_elm_theme_icon_set(Evas_Object *o, const char *group, const char *style) 69_elm_theme_icon_set(Evas_Object *o, const char *group, const char *style)
23{ 70{
24 char buf[PATH_MAX]; 71 const char *file;
25 char buf2[1024]; 72 char buf2[1024];
26 int w, h; 73 int w, h;
27 int ok; 74 int ok;
28 75
29 // FIXME: actually handle themes for real
30 snprintf(buf, sizeof(buf), "%s/themes/%s.edj", PACKAGE_DATA_DIR, "default");
31 snprintf(buf2, sizeof(buf2), "elm/icon/%s/%s", group, style); 76 snprintf(buf2, sizeof(buf2), "elm/icon/%s/%s", group, style);
32 _els_smart_icon_file_edje_set(o, buf, buf2); 77 file = _elm_theme_group_file_find(buf2);
33 _els_smart_icon_size_get(o, &w, &h); 78 if (file)
34 if (w > 0) return 1; 79 {
80 _els_smart_icon_file_edje_set(o, file, buf2);
81 _els_smart_icon_size_get(o, &w, &h);
82 if (w > 0) return 1;
83 }
35 snprintf(buf2, sizeof(buf2), "elm/icon/%s/default", group); 84 snprintf(buf2, sizeof(buf2), "elm/icon/%s/default", group);
36 _els_smart_icon_file_edje_set(o, buf, buf2); 85 file = _elm_theme_group_file_find(buf2);
86 if (!file) return 0;
87 _els_smart_icon_file_edje_set(o, file, buf2);
37 _els_smart_icon_size_get(o, &w, &h); 88 _els_smart_icon_size_get(o, &w, &h);
38 return (w > 0); 89 return (w > 0);
39} 90}
91
92static Eina_Bool
93_cache_free_cb(const Eina_Hash *hash, const void *key, void *data, void *fdata)
94{
95 eina_stringshare_del(data);
96}
97
98int
99_elm_theme_parse(const char *theme)
100{
101 Eina_List *names = NULL;
102 const char *p, *pe;
103
104 p = theme;
105 pe = p;
106 for (;;)
107 {
108 if ((*pe == '/') || (*pe == 0))
109 { // p -> pe == 'name/'
110 if (pe > p)
111 {
112 char *n = malloc(pe - p + 1);
113 if (n)
114 {
115 const char *nn;
116 strncpy(n, p, pe - p);
117 n[pe - p] = 0;
118 nn = eina_stringshare_add(n);
119 if (nn)
120 names = eina_list_append(names, nn);
121 free(n);
122 }
123 }
124 if (*pe == 0) break;
125 p = pe + 1;
126 pe = p;
127 }
128 else
129 pe++;
130 }
131 p = eina_list_data_get(eina_list_last(names));
132 if ((!p) || ((p) && (strcmp(p, "default"))))
133 {
134 p = eina_stringshare_add("default");
135 if (p)
136 names = eina_list_append(names, p);
137 }
138 if (cache)
139 {
140 eina_hash_foreach(cache, _cache_free_cb, NULL);
141 eina_hash_free(cache);
142 cache = NULL;
143 }
144 cache = eina_hash_string_superfast_new(NULL);
145
146 while (themes)
147 {
148 eina_stringshare_del(themes->data);
149 themes = eina_list_remove_list(themes, themes);
150 }
151
152 themes = names;
153 return 1;
154}
diff --git a/src/lib/elm_toolbar.c b/src/lib/elm_toolbar.c
index 828dc6382..1a8d83cf3 100644
--- a/src/lib/elm_toolbar.c
+++ b/src/lib/elm_toolbar.c
@@ -60,7 +60,7 @@ _item_select(Item *it)
60 edje_object_signal_emit(it->base, "elm,state,selected", "elm"); 60 edje_object_signal_emit(it->base, "elm,state,selected", "elm");
61 _item_show(it); 61 _item_show(it);
62 obj2 = it->obj; 62 obj2 = it->obj;
63 if (it->func) it->func(it->data, it->obj, it); 63 if (it->func) it->func((void *)(it->data), it->obj, it);
64 evas_object_smart_callback_call(obj2, "clicked", it); 64 evas_object_smart_callback_call(obj2, "clicked", it);
65} 65}
66 66