[access] elm_access_action(); elm_access_action_cb_set(); added
[framework/uifw/elementary.git] / src / bin / config.c
1 #include <Elementary.h>
2 #ifdef HAVE_CONFIG_H
3 # include "elementary_config.h"
4 #endif
5 #ifndef ELM_LIB_QUICKLAUNCH
6
7 typedef struct _Theme               Theme;
8 typedef struct _Fonts_Data          Fonts_Data;
9 typedef struct _Elm_Text_Class_Data Elm_Text_Class_Data;
10 typedef struct _Elm_Font_Size_Data  Elm_Font_Size_Data;
11
12 struct _Theme
13 {
14    const char *label;
15    const char *name;
16    const char *path;
17    Eina_Bool   in_search_path;
18 };
19
20 static const Eina_List *tsel = NULL;
21 static Eina_List *themes = NULL;
22
23 struct _Elm_Text_Class_Data
24 {
25    const char    *name;
26    const char    *desc;
27    const char    *font;
28    const char    *style;
29    Evas_Font_Size size;
30 };
31
32 struct _Elm_Font_Size_Data
33 {
34    const char    *size_str;
35    Evas_Font_Size size;
36 };
37
38 struct _Fonts_Data
39 {
40    Eina_List  *text_classes;
41
42    Eina_Hash  *font_hash;
43    Eina_List  *font_px_list;
44    Eina_List  *font_scale_list;
45
46    const char *cur_font;
47    const char *cur_style;
48    double      cur_size;
49 };
50
51 #define ELM_LIST_DISABLE(list)                         \
52   do                                                   \
53     {                                                  \
54        const Eina_List *_l = elm_list_items_get(list); \
55        if (_l)                                         \
56          {                                             \
57             elm_list_item_show(eina_list_data_get(_l));\
58             elm_object_disabled_set(list, EINA_TRUE);  \
59          }                                             \
60     }                                                  \
61   while (0)
62
63 #define ELM_LIST_ENABLE(list)                     \
64   do                                              \
65     {                                             \
66        elm_object_disabled_set(list, EINA_FALSE); \
67     }                                             \
68   while (0)
69
70 #define LABEL_FRAME_ADD(label)                                      \
71   do                                                                \
72     {                                                               \
73        pd = elm_frame_add(win);                                     \
74        evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, 0.0); \
75        evas_object_size_hint_align_set(pd, EVAS_HINT_FILL, 0.5);    \
76        elm_object_style_set(pd, "pad_medium");                      \
77        elm_box_pack_end(bx, pd);                                    \
78        evas_object_show(pd);                                        \
79                                                                     \
80        lb = elm_label_add(win);                                     \
81        evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0); \
82        evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, 0.5);    \
83        elm_object_text_set(lb, label);                              \
84        elm_object_content_set(pd, lb);                              \
85        evas_object_show(lb);                                        \
86     }                                                               \
87   while (0)
88
89 static int quiet = 0;
90 static int interactive = 1;
91
92 static const char *theme_set = NULL;
93 static const char *finger_size_set = NULL;
94 static const char *scale_set = NULL;
95 static Fonts_Data fndata = {NULL, NULL, NULL, NULL, NULL, NULL, 0.0};
96
97 static void
98 _font_styles_list_sel(void *data   __UNUSED__,
99                       Evas_Object *obj,
100                       void        *event_info);
101
102 static void
103 config_exit(void *data       __UNUSED__,
104             Evas_Object *obj __UNUSED__,
105             void *event_info __UNUSED__)
106 {
107    Elm_Text_Class_Data *tc_data;
108    Elm_Font_Size_Data *sd;
109
110    EINA_LIST_FREE(fndata.text_classes, tc_data)
111      {
112         eina_stringshare_del(tc_data->name);
113         eina_stringshare_del(tc_data->desc);
114         eina_stringshare_del(tc_data->font);
115         eina_stringshare_del(tc_data->style);
116         free(tc_data);
117      }
118
119    elm_font_available_hash_del(fndata.font_hash);
120    fndata.font_hash = NULL;
121
122    EINA_LIST_FREE(fndata.font_px_list, sd)
123      {
124         eina_stringshare_del(sd->size_str);
125         free(sd);
126      }
127
128    EINA_LIST_FREE(fndata.font_scale_list, sd)
129      {
130         eina_stringshare_del(sd->size_str);
131         free(sd);
132      }
133
134    if (fndata.cur_font) eina_stringshare_del(fndata.cur_font);
135    fndata.cur_font = NULL;
136
137    if (fndata.cur_style) eina_stringshare_del(fndata.cur_style);
138    fndata.cur_style = NULL;
139
140    elm_config_save();
141    elm_exit(); /* exit the program's main loop that runs in elm_run() */
142 }
143
144 static void
145 sb_change(void *data       __UNUSED__,
146           Evas_Object     *obj,
147           void *event_info __UNUSED__)
148 {
149    Eina_Bool val = elm_check_state_get(obj);
150    Eina_Bool sb = elm_config_scroll_bounce_enabled_get();
151
152    if (val == sb) return;
153    elm_config_scroll_bounce_enabled_set(val);
154    elm_config_all_flush();
155
156    /*TODO: enable/disable subordinate sliders (make 'em support it 1st)*/
157 }
158
159 static void
160 bf_round(void *data       __UNUSED__,
161          Evas_Object     *obj,
162          void *event_info __UNUSED__)
163 {
164    double val = elm_slider_value_get(obj);
165    double v;
166
167    v = ((double)((int)(val * 10.0))) / 10.0;
168    if (v != val) elm_slider_value_set(obj, v);
169 }
170
171 static void
172 bf_change(void *data       __UNUSED__,
173           Evas_Object     *obj,
174           void *event_info __UNUSED__)
175 {
176    double bf = elm_config_scroll_bounce_friction_get();
177    double val = elm_slider_value_get(obj);
178
179    if (bf == val) return;
180    elm_config_scroll_bounce_friction_set(val);
181    elm_config_all_flush();
182 }
183
184 static void
185 ps_round(void *data       __UNUSED__,
186          Evas_Object     *obj,
187          void *event_info __UNUSED__)
188 {
189    double val = elm_slider_value_get(obj);
190    double v;
191
192    v = ((double)((int)(val * 10.0))) / 10.0;
193    if (v != val) elm_slider_value_set(obj, v);
194 }
195
196 static void
197 ps_change(void *data       __UNUSED__,
198           Evas_Object     *obj,
199           void *event_info __UNUSED__)
200 {
201    double ps = elm_config_scroll_page_scroll_friction_get();
202    double val = elm_slider_value_get(obj);
203
204    if (ps == val) return;
205    elm_config_scroll_page_scroll_friction_set(val);
206    elm_config_all_flush();
207 }
208
209 static void
210 bis_round(void *data       __UNUSED__,
211           Evas_Object     *obj,
212           void *event_info __UNUSED__)
213 {
214    double val = elm_slider_value_get(obj);
215    double v;
216
217    v = ((double)((int)(val * 10.0))) / 10.0;
218    if (v != val) elm_slider_value_set(obj, v);
219 }
220
221 static void
222 bis_change(void *data       __UNUSED__,
223            Evas_Object     *obj,
224            void *event_info __UNUSED__)
225 {
226    double bis = elm_config_scroll_bring_in_scroll_friction_get();
227    double val = elm_slider_value_get(obj);
228
229    if (bis == val) return;
230    elm_config_scroll_bring_in_scroll_friction_set(val);
231    elm_config_all_flush();
232 }
233
234 static void
235 zf_round(void *data       __UNUSED__,
236          Evas_Object     *obj,
237          void *event_info __UNUSED__)
238 {
239    double val = elm_slider_value_get(obj);
240    double v;
241
242    v = ((double)((int)(val * 10.0))) / 10.0;
243    if (v != val) elm_slider_value_set(obj, v);
244 }
245
246 static void
247 zf_change(void *data       __UNUSED__,
248           Evas_Object     *obj,
249           void *event_info __UNUSED__)
250 {
251    double zf = elm_config_scroll_zoom_friction_get();
252    double val = elm_slider_value_get(obj);
253
254    if (zf == val) return;
255    elm_config_scroll_zoom_friction_set(val);
256    elm_config_all_flush();
257 }
258
259 static void
260 ts_change(void *data       __UNUSED__,
261           Evas_Object     *obj,
262           void *event_info __UNUSED__)
263 {
264    Eina_Bool val = elm_check_state_get(obj);
265    Eina_Bool sb = elm_config_scroll_thumbscroll_enabled_get();
266
267    if (val == sb) return;
268    elm_config_scroll_thumbscroll_enabled_set(val);
269    elm_config_all_flush();
270
271    /*TODO: enable/disable subordinate sliders (make 'em support it 1st)*/
272 }
273
274 static void
275 tst_round(void *data       __UNUSED__,
276           Evas_Object     *obj,
277           void *event_info __UNUSED__)
278 {
279    double val = elm_slider_value_get(obj);
280    double v;
281
282    v = ((double)((int)(val * 10.0))) / 10.0;
283    if (v != val) elm_slider_value_set(obj, v);
284 }
285
286 static void
287 tst_change(void *data       __UNUSED__,
288            Evas_Object     *obj,
289            void *event_info __UNUSED__)
290 {
291    double tst = elm_config_scroll_thumbscroll_threshold_get();
292    double val = elm_slider_value_get(obj);
293
294    if (tst == val) return;
295    elm_config_scroll_thumbscroll_threshold_set(val);
296    elm_config_all_flush();
297 }
298
299 static void
300 tsht_round(void *data       __UNUSED__,
301           Evas_Object     *obj,
302           void *event_info __UNUSED__)
303 {
304    double val = elm_slider_value_get(obj);
305    double v;
306
307    v = ((double)((int)(val * 10.0))) / 10.0;
308    if (v != val) elm_slider_value_set(obj, v);
309 }
310
311 static void
312 tsht_change(void *data       __UNUSED__,
313            Evas_Object     *obj,
314            void *event_info __UNUSED__)
315 {
316    double tst = elm_config_scroll_thumbscroll_hold_threshold_get();
317    double val = elm_slider_value_get(obj);
318
319    if (tst == val) return;
320    elm_config_scroll_thumbscroll_hold_threshold_set(val);
321    elm_config_all_flush();
322 }
323
324 static void
325 tsmt_round(void *data       __UNUSED__,
326            Evas_Object     *obj,
327            void *event_info __UNUSED__)
328 {
329    double val = elm_slider_value_get(obj);
330    double v;
331
332    v = ((double)((int)(val * 10.0))) / 10.0;
333    if (v != val) elm_slider_value_set(obj, v);
334 }
335
336 static void
337 tsmt_change(void *data       __UNUSED__,
338             Evas_Object     *obj,
339             void *event_info __UNUSED__)
340 {
341    double tsmt = elm_config_scroll_thumbscroll_momentum_threshold_get();
342    double val = elm_slider_value_get(obj);
343
344    if (tsmt == val) return;
345    elm_config_scroll_thumbscroll_momentum_threshold_set(val);
346    elm_config_all_flush();
347 }
348
349 static void
350 tsf_round(void *data       __UNUSED__,
351           Evas_Object     *obj,
352           void *event_info __UNUSED__)
353 {
354    double val = elm_slider_value_get(obj);
355    double v;
356
357    v = ((double)((int)(val * 10.0))) / 10.0;
358    if (v != val) elm_slider_value_set(obj, v);
359 }
360
361 static void
362 tsf_change(void *data       __UNUSED__,
363            Evas_Object     *obj,
364            void *event_info __UNUSED__)
365 {
366    double tsf = elm_config_scroll_thumbscroll_friction_get();
367    double val = elm_slider_value_get(obj);
368
369    if (tsf == val) return;
370    elm_config_scroll_thumbscroll_friction_set(val);
371    elm_config_all_flush();
372 }
373
374 static void
375 tsbf_round(void *data       __UNUSED__,
376            Evas_Object     *obj,
377            void *event_info __UNUSED__)
378 {
379    double val = elm_slider_value_get(obj);
380    double v;
381
382    v = ((double)((int)(val * 10.0))) / 10.0;
383    if (v != val) elm_slider_value_set(obj, v);
384 }
385
386 static void
387 tsbf_change(void *data       __UNUSED__,
388             Evas_Object     *obj,
389             void *event_info __UNUSED__)
390 {
391    double tsbf = elm_config_scroll_thumbscroll_border_friction_get();
392    double val = elm_slider_value_get(obj);
393
394    if (tsbf == val) return;
395    elm_config_scroll_thumbscroll_border_friction_set(val);
396    elm_config_all_flush();
397 }
398
399 static void
400 tssf_round(void *data       __UNUSED__,
401            Evas_Object     *obj,
402            void *event_info __UNUSED__)
403 {
404    double val = elm_slider_value_get(obj);
405    double v;
406
407    v = ((double)((int)(val * 20.0))) / 20.0;
408    if (v != val) elm_slider_value_set(obj, v);
409 }
410
411 static void
412 tssf_change(void *data       __UNUSED__,
413             Evas_Object     *obj,
414             void *event_info __UNUSED__)
415 {
416    double tssf = elm_config_scroll_thumbscroll_sensitivity_friction_get();
417    double val = elm_slider_value_get(obj);
418
419    if (tssf == val) return;
420    elm_config_scroll_thumbscroll_sensitivity_friction_set(val);
421    elm_config_all_flush();
422 }
423
424 static void
425 cf_enable(void *data,
426           Evas_Object     *obj,
427           void *event_info __UNUSED__)
428 {
429    Eina_Bool cf = elm_config_cache_flush_enabled_get();
430    Eina_Bool val = elm_check_state_get(obj);
431
432    if (cf == val) return;
433    elm_object_disabled_set((Evas_Object *)data, !val);
434    elm_config_cache_flush_enabled_set(val);
435    elm_config_all_flush();
436 }
437
438 static void
439 cf_round(void *data       __UNUSED__,
440          Evas_Object     *obj,
441          void *event_info __UNUSED__)
442 {
443    double val = elm_slider_value_get(obj);
444    double v;
445
446    v = ((double)((int)(val * 5.0))) / 5.0;
447    if (v != val) elm_slider_value_set(obj, v);
448 }
449
450 static void
451 cf_change(void *data       __UNUSED__,
452           Evas_Object     *obj,
453           void *event_info __UNUSED__)
454 {
455    double cf = elm_config_cache_flush_interval_get();
456    double val = elm_slider_value_get(obj);
457
458    if (cf == val) return;
459    elm_config_cache_flush_interval_set(val);
460    elm_config_all_flush();
461 }
462
463 static void
464 fc_round(void *data       __UNUSED__,
465          Evas_Object     *obj,
466          void *event_info __UNUSED__)
467 {
468    double val = elm_slider_value_get(obj);
469    double v;
470
471    v = ((double)((int)(val * 10.0))) / 10.0;
472    if (v != val) elm_slider_value_set(obj, v);
473 }
474
475 static void
476 fc_change(void *data       __UNUSED__,
477           Evas_Object     *obj,
478           void *event_info __UNUSED__)
479 {
480    double font_cache = elm_config_cache_font_cache_size_get();
481    double val = elm_slider_value_get(obj);
482
483    if (font_cache == val) return;
484    elm_config_cache_font_cache_size_set(val * 1024);
485    elm_config_all_flush();
486 }
487
488 static void
489 ic_round(void *data       __UNUSED__,
490          Evas_Object     *obj,
491          void *event_info __UNUSED__)
492 {
493    double val = elm_slider_value_get(obj);
494    double v;
495
496    v = ((double)((int)(val * 10.0))) / 10.0;
497    if (v != val) elm_slider_value_set(obj, v);
498 }
499
500 static void
501 ic_change(void *data       __UNUSED__,
502           Evas_Object     *obj,
503           void *event_info __UNUSED__)
504 {
505    double image_cache = elm_config_cache_image_cache_size_get();
506    double val = elm_slider_value_get(obj);
507
508    if (image_cache == val) return;
509    elm_config_cache_image_cache_size_set(val * 1024);
510    elm_config_all_flush();
511 }
512
513 static void
514 sc_round(void *data       __UNUSED__,
515          Evas_Object     *obj,
516          void *event_info __UNUSED__)
517 {
518    double val = elm_slider_value_get(obj);
519    double v;
520
521    v = ((double)((int)(val * 10.0))) / 10.0;
522    if (v != val) elm_slider_value_set(obj, v);
523 }
524
525 static void
526 sc_change(void *data       __UNUSED__,
527           Evas_Object     *obj,
528           void *event_info __UNUSED__)
529 {
530    double scale = elm_config_scale_get();
531    double val = elm_slider_value_get(obj);
532
533    if (scale == val) return;
534    elm_config_scale_set(val);
535    elm_config_all_flush();
536 }
537
538 static void
539 fs_round(void *data       __UNUSED__,
540          Evas_Object     *obj,
541          void *event_info __UNUSED__)
542 {
543    double val = elm_slider_value_get(obj);
544    double v;
545
546    v = ((double)((int)(val * 5.0))) / 5.0;
547    if (v != val) elm_slider_value_set(obj, v);
548 }
549
550 static void
551 fs_change(void *data       __UNUSED__,
552           Evas_Object     *obj,
553           void *event_info __UNUSED__)
554 {
555    double fs = elm_config_finger_size_get();
556    double val = elm_slider_value_get(obj);
557
558    if (fs == val) return;
559    elm_config_finger_size_set(val);
560    elm_config_all_flush();
561 }
562
563 static void
564 efc_round(void *data       __UNUSED__,
565           Evas_Object     *obj,
566           void *event_info __UNUSED__)
567 {
568    double val = elm_slider_value_get(obj);
569    double v;
570
571    v = ((double)((int)(val * 5.0))) / 5.0;
572    if (v != val) elm_slider_value_set(obj, v);
573 }
574
575 static void
576 efc_change(void *data       __UNUSED__,
577            Evas_Object     *obj,
578            void *event_info __UNUSED__)
579 {
580    double efc = elm_config_cache_edje_file_cache_size_get();
581    double val = elm_slider_value_get(obj);
582
583    if (efc == val) return;
584    elm_config_cache_edje_file_cache_size_set(val);
585    elm_config_all_flush();
586 }
587
588 static void
589 ecc_round(void *data       __UNUSED__,
590           Evas_Object     *obj,
591           void *event_info __UNUSED__)
592 {
593    double val = elm_slider_value_get(obj);
594    double v;
595
596    v = ((double)((int)(val * 5.0))) / 5.0;
597    if (v != val) elm_slider_value_set(obj, v);
598 }
599
600 static void
601 ecc_change(void *data       __UNUSED__,
602            Evas_Object     *obj,
603            void *event_info __UNUSED__)
604 {
605    double ecc = elm_config_cache_edje_collection_cache_size_get();
606    double val = elm_slider_value_get(obj);
607
608    if (ecc == val) return;
609    elm_config_cache_edje_collection_cache_size_set(val);
610    elm_config_all_flush();
611 }
612
613 static void
614 ac_change(void *data       __UNUSED__,
615           Evas_Object     *obj,
616           void *event_info __UNUSED__)
617 {
618    Eina_Bool val = elm_check_state_get(obj);
619    Eina_Bool ac = elm_config_access_get();
620
621    if (val == ac) return;
622    elm_config_access_set(val);
623    elm_config_all_flush();
624 }
625
626 static void
627 sel_change(void *data       __UNUSED__,
628           Evas_Object     *obj,
629           void *event_info __UNUSED__)
630 {
631    Eina_Bool val = elm_check_state_get(obj);
632    Eina_Bool sel = elm_config_selection_unfocused_clear_get();
633
634    if (val == sel) return;
635    elm_config_selection_unfocused_clear_set(val);
636    elm_config_all_flush();
637    elm_config_save();
638 }
639
640 static void
641 _status_basic(Evas_Object *win,
642               Evas_Object *bx0)
643 {
644    Evas_Object *lb, *fr;
645
646    fr = elm_frame_add(win);
647    evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
648    elm_object_text_set(fr, "Information");
649    elm_box_pack_end(bx0, fr);
650    evas_object_show(fr);
651
652    lb = elm_label_add(win);
653    elm_object_text_set(lb,
654                        "Applying configuration change"
655                        );
656    elm_object_content_set(fr, lb);
657    evas_object_show(lb);
658 }
659
660 static void
661 _status_config(Evas_Object *win,
662                Evas_Object *bx0)
663 {
664    Evas_Object *lb, *pd, *bx, *fr, *sl, *sp;
665
666    fr = elm_frame_add(win);
667    evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
668    evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
669    elm_object_text_set(fr, "Sizing");
670    elm_box_pack_end(bx0, fr);
671    evas_object_show(fr);
672
673    bx = elm_box_add(win);
674    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
675    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.5);
676
677    LABEL_FRAME_ADD("<hilight>Scale</>");
678
679    sl = elm_slider_add(win);
680    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
681    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
682    elm_slider_span_size_set(sl, 120);
683    elm_slider_unit_format_set(sl, "%1.2f");
684    elm_slider_indicator_format_set(sl, "%1.2f");
685    elm_slider_min_max_set(sl, 0.25, 5.0);
686    elm_slider_value_set(sl, elm_config_scale_get());
687    elm_box_pack_end(bx, sl);
688    evas_object_show(sl);
689
690    evas_object_smart_callback_add(sl, "changed", sc_round, NULL);
691    evas_object_smart_callback_add(sl, "delay,changed", sc_change, NULL);
692
693    sp = elm_separator_add(win);
694    elm_separator_horizontal_set(sp, EINA_TRUE);
695    evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0);
696    evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
697    elm_box_pack_end(bx, sp);
698    evas_object_show(sp);
699
700    LABEL_FRAME_ADD("<hilight>Finger Size</><br/>");
701
702    sl = elm_slider_add(win);
703    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
704    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
705    elm_slider_span_size_set(sl, 120);
706    elm_slider_unit_format_set(sl, "%1.0f");
707    elm_slider_indicator_format_set(sl, "%1.0f");
708    elm_slider_min_max_set(sl, 5, 200);
709    elm_slider_value_set(sl, elm_config_finger_size_get());
710    elm_box_pack_end(bx, sl);
711    evas_object_show(sl);
712
713    evas_object_smart_callback_add(sl, "changed", fs_round, NULL);
714    evas_object_smart_callback_add(sl, "delay,changed", fs_change, NULL);
715
716    // FIXME: add theme selector (basic mode and advanced for fallbacks)
717    // FIXME: save config
718    // FIXME: profile selector / creator etc.
719    elm_object_content_set(fr, bx);
720    evas_object_show(bx);
721 }
722
723 static void
724 _flip_to(Evas_Object *win,
725          const char  *name)
726 {
727    Evas_Object *wid, *naviframe;
728    wid = evas_object_data_get(win, name);
729    naviframe = evas_object_data_get(win, "naviframe");
730    elm_naviframe_item_simple_promote(naviframe, wid);
731 }
732
733 static void
734 _cf_sizing(void            *data,
735            Evas_Object *obj __UNUSED__,
736            void *event_info __UNUSED__)
737 {
738    _flip_to(data, "sizing");
739 }
740
741 static void
742 _cf_themes(void            *data,
743            Evas_Object *obj __UNUSED__,
744            void *event_info __UNUSED__)
745 {
746    _flip_to(data, "themes");
747 }
748
749 static void
750 _cf_fonts(void            *data,
751           Evas_Object *obj __UNUSED__,
752           void *event_info __UNUSED__)
753 {
754    _flip_to(data, "fonts");
755 }
756
757 static void
758 _cf_profiles(void            *data,
759              Evas_Object *obj __UNUSED__,
760              void *event_info __UNUSED__)
761 {
762    _flip_to(data, "profiles");
763 }
764
765 static void
766 _cf_scrolling(void            *data,
767               Evas_Object *obj __UNUSED__,
768               void *event_info __UNUSED__)
769 {
770    _flip_to(data, "scrolling");
771 }
772
773 static void
774 _cf_rendering(void            *data,
775               Evas_Object *obj __UNUSED__,
776               void *event_info __UNUSED__)
777 {
778    _flip_to(data, "rendering");
779 }
780
781 static void
782 _cf_caches(void            *data,
783            Evas_Object *obj __UNUSED__,
784            void *event_info __UNUSED__)
785 {
786    _flip_to(data, "caches");
787 }
788
789 static void
790 _cf_access(void            *data,
791            Evas_Object *obj __UNUSED__,
792            void *event_info __UNUSED__)
793 {
794    _flip_to(data, "access");
795 }
796
797 static void
798 _cf_selection(void            *data,
799            Evas_Object *obj __UNUSED__,
800            void *event_info __UNUSED__)
801 {
802    _flip_to(data, "selection");
803 }
804
805 const char *
806 _elm_theme_current_get(const char *theme_search_order)
807 {
808    const char *ret;
809    const char *p;
810
811    if (!theme_search_order)
812      return NULL;
813
814    for (p = theme_search_order;; p++)
815      {
816         if ((*p == ':') || (!*p))
817           {
818              if (p > theme_search_order)
819                {
820                   char *n = malloc(p - theme_search_order + 1);
821                   if (!n)
822                     return NULL;
823
824                   strncpy(n, theme_search_order, p - theme_search_order);
825                   n[p - theme_search_order] = 0;
826                   ret = eina_stringshare_add(n);
827                   free(n);
828                   break;
829                }
830           }
831      }
832
833    return ret;
834 }
835
836 static void
837 _font_overlay_set_all(void            *data,
838                       Evas_Object *obj __UNUSED__,
839                       void *event_info __UNUSED__)
840 {
841    Evas_Object *win, *fclasses;
842    Elm_Text_Class_Data *tc_data, *tc;
843    Elm_Object_Item *list_it;
844    Eina_List *l;
845
846    win = data;
847
848    fclasses = evas_object_data_get(win, "font_classes_list");
849    list_it = elm_list_selected_item_get(fclasses);
850    if (!list_it) return;
851    tc_data = elm_object_item_data_get(list_it);
852
853    EINA_LIST_FOREACH(fndata.text_classes, l, tc)
854      {
855         eina_stringshare_replace(&tc->font, tc_data->font);
856         eina_stringshare_replace(&tc->style, tc_data->style);
857         tc->size = tc_data->size;
858      }
859
860    elm_config_all_flush();
861    elm_config_save();
862 }
863
864 static void
865 _font_overlay_reset(void            *data,
866                     Evas_Object *obj __UNUSED__,
867                     void *event_info __UNUSED__)
868 {
869    Evas_Object *win, *fclasses, *fnames, *fstyles, *fsizes;
870    Elm_Text_Class_Data *tc_data;
871    Elm_Object_Item *list_it;
872
873    win = data;
874
875    fclasses = evas_object_data_get(win, "font_classes_list");
876    list_it = elm_list_selected_item_get(fclasses);
877    if (!list_it) return;
878    tc_data = elm_object_item_data_get(list_it);
879
880    fnames = evas_object_data_get(win, "font_names_list");
881    fstyles = evas_object_data_get(win, "font_styles_list");
882    fsizes = evas_object_data_get(win, "font_sizes_list");
883
884    elm_config_font_overlay_unset(tc_data->name);
885
886    eina_stringshare_replace(&fndata.cur_font, NULL);
887    eina_stringshare_replace(&tc_data->font, NULL);
888    eina_stringshare_replace(&fndata.cur_style, NULL);
889    eina_stringshare_replace(&tc_data->style, NULL);
890    fndata.cur_size = 0.0;
891    tc_data->size = 0.0;
892
893    ELM_LIST_DISABLE(fnames);
894    ELM_LIST_DISABLE(fstyles);
895    ELM_LIST_DISABLE(fsizes);
896
897    elm_config_all_flush();
898    elm_config_save();
899 }
900
901 static void
902 _font_overlay_reset_all(void            *data,
903                         Evas_Object *obj __UNUSED__,
904                         void *event_info __UNUSED__)
905 {
906    Evas_Object *win, *fclasses, *fnames, *fstyles, *fsizes;
907    Elm_Text_Class_Data *tc_data;
908    Elm_Object_Item *list_it;
909    Eina_List *l;
910
911    win = data;
912    eina_stringshare_replace(&fndata.cur_font, NULL);
913    eina_stringshare_replace(&fndata.cur_style, NULL);
914    fndata.cur_size = 0.0;
915
916    EINA_LIST_FOREACH(fndata.text_classes, l, tc_data)
917      {
918         elm_config_font_overlay_unset(tc_data->name);
919
920         eina_stringshare_replace(&tc_data->font, NULL);
921         eina_stringshare_replace(&tc_data->style, NULL);
922         tc_data->size = 0.0;
923      }
924
925    fclasses = evas_object_data_get(win, "font_classes_list");
926    fnames = evas_object_data_get(win, "font_names_list");
927    fstyles = evas_object_data_get(win, "font_styles_list");
928    fsizes = evas_object_data_get(win, "font_sizes_list");
929
930    list_it = elm_list_selected_item_get(fclasses);
931    if (list_it) elm_list_item_selected_set(list_it, EINA_FALSE);
932
933    ELM_LIST_DISABLE(fnames);
934    ELM_LIST_DISABLE(fstyles);
935    ELM_LIST_DISABLE(fsizes);
936
937    elm_config_all_flush();
938    elm_config_save();
939 }
940
941 static void
942 _font_overlay_change(void *data       __UNUSED__,
943                      Evas_Object *obj __UNUSED__,
944                      void *event_info __UNUSED__)
945 {
946    Elm_Text_Class_Data *tc_data;
947    Eina_List *l;
948
949    EINA_LIST_FOREACH(fndata.text_classes, l, tc_data)
950      {
951         if (tc_data->font)
952           {
953              char *name;
954
955              name = elm_font_fontconfig_name_get(tc_data->font,
956                                                  tc_data->style);
957              elm_config_font_overlay_set(tc_data->name, name,
958                                          tc_data->size ? tc_data->size : -100);
959              elm_font_fontconfig_name_free(name);
960           }
961         else
962           elm_config_font_overlay_unset(tc_data->name);
963      }
964
965    elm_config_font_overlay_apply();
966    elm_config_all_flush();
967    elm_config_save();
968
969    /* TODO: apply hinting */
970 }
971
972 static void
973 _config_display_update(Evas_Object *win)
974 {
975    int flush_interval, font_c, image_c, edje_file_c, edje_col_c, ts_threshould, ts_hold_threshold;
976    double scale, s_bounce_friction, ts_momentum_threshold, ts_friction,
977           ts_border_friction, ts_sensitivity_friction, page_friction, bring_in_friction, zoom_friction;
978    const char *curr_theme, *curr_engine;
979    const Eina_List *l_items, *l;
980    Eina_Bool s_bounce, ts;
981    Elm_Object_Item *list_it;
982    Elm_Theme *th;
983    int fs;
984
985    scale = elm_config_scale_get();
986    fs = elm_config_finger_size_get();
987    flush_interval = elm_config_cache_flush_interval_get();
988    font_c = elm_config_cache_font_cache_size_get();
989    image_c = elm_config_cache_image_cache_size_get();
990    edje_file_c = elm_config_cache_edje_file_cache_size_get();
991    edje_col_c = elm_config_cache_edje_collection_cache_size_get();
992
993    s_bounce = elm_config_scroll_bounce_enabled_get();
994    s_bounce_friction = elm_config_scroll_bounce_friction_get();
995    ts = elm_config_scroll_thumbscroll_enabled_get();
996    ts_threshould = elm_config_scroll_thumbscroll_threshold_get();
997    ts_hold_threshold = elm_config_scroll_thumbscroll_hold_threshold_get();
998    ts_momentum_threshold = elm_config_scroll_thumbscroll_momentum_threshold_get();
999    ts_friction = elm_config_scroll_thumbscroll_friction_get();
1000    ts_border_friction = elm_config_scroll_thumbscroll_border_friction_get();
1001    ts_sensitivity_friction = elm_config_scroll_thumbscroll_sensitivity_friction_get();
1002    page_friction = elm_config_scroll_page_scroll_friction_get();
1003    bring_in_friction = elm_config_scroll_bring_in_scroll_friction_get();
1004    zoom_friction = elm_config_scroll_zoom_friction_get();
1005
1006    /* gotta update root windows' atoms */
1007    elm_slider_value_set(evas_object_data_get(win, "scale_slider"), scale);
1008    elm_slider_value_set(evas_object_data_get(win, "fs_slider"), fs);
1009
1010    elm_slider_value_set(evas_object_data_get(win,
1011                                              "cache_flush_interval_slider"),
1012                         flush_interval);
1013    elm_slider_value_set(evas_object_data_get(win, "font_cache_slider"),
1014                         font_c / 1024.0);
1015    elm_slider_value_set(evas_object_data_get(win, "image_cache_slider"),
1016                         image_c / 1024.0);
1017    elm_slider_value_set(evas_object_data_get(win, "edje_file_cache_slider"),
1018                         edje_file_c);
1019    elm_slider_value_set(evas_object_data_get(win,
1020                                              "edje_collection_cache_slider"),
1021                         edje_col_c);
1022
1023    elm_check_state_set(evas_object_data_get(win, "scroll_bounce_check"),
1024                        s_bounce);
1025    elm_slider_value_set(evas_object_data_get(win, "bounce_friction_slider"),
1026                         s_bounce_friction);
1027    elm_check_state_set(evas_object_data_get(win, "thumbscroll_check"), ts);
1028    elm_slider_value_set(evas_object_data_get(win,
1029                                              "thumbscroll_threshold_slider"),
1030                         ts_threshould);
1031    elm_slider_value_set(evas_object_data_get(win,
1032                                              "ts_hold_threshold_slider"),
1033                         ts_hold_threshold);
1034    elm_slider_value_set(evas_object_data_get(win,
1035                                              "ts_momentum_threshold_slider"),
1036                         ts_momentum_threshold);
1037    elm_slider_value_set(evas_object_data_get(win,
1038                                              "thumbscroll_friction_slider"),
1039                         ts_friction);
1040    elm_slider_value_set(evas_object_data_get(win, "ts_border_friction_slider"),
1041                         ts_border_friction);
1042    elm_slider_value_set(evas_object_data_get(win, "ts_sensitivity_friction_slider"),
1043                         ts_sensitivity_friction);
1044    elm_slider_value_set(evas_object_data_get(win,
1045                                              "page_scroll_friction_slider"),
1046                         page_friction);
1047    elm_slider_value_set(evas_object_data_get(win,
1048                                              "bring_in_scroll_friction_slider"),
1049                         bring_in_friction);
1050    elm_slider_value_set(evas_object_data_get(win,
1051                                              "zoom_scroll_friction_slider"),
1052                         zoom_friction);
1053
1054    curr_theme = _elm_theme_current_get(elm_theme_get(NULL));
1055
1056    th = elm_theme_new();
1057    elm_theme_set(th, curr_theme);
1058    elm_object_theme_set(evas_object_data_get(win, "theme_preview"), th);
1059    elm_theme_free(th);
1060    eina_stringshare_del(curr_theme);
1061
1062    curr_engine = elm_config_engine_get();
1063    l_items = elm_list_items_get(evas_object_data_get(win, "engines_list"));
1064    EINA_LIST_FOREACH(l_items, l, list_it)
1065      {
1066         if (!strcmp(elm_object_item_data_get(list_it), curr_engine))
1067           {
1068              elm_list_item_selected_set(list_it, EINA_TRUE);
1069              break;
1070           }
1071      }
1072 }
1073
1074 static void
1075 _profile_change_do(Evas_Object *win,
1076                    const char  *profile)
1077 {
1078    elm_config_profile_set(profile);
1079    elm_config_all_flush();
1080    _config_display_update(win);
1081 }
1082
1083 static Eina_Bool
1084 _config_all_changed(void *data,
1085                     int ev_type __UNUSED__,
1086                     void *ev __UNUSED__)
1087 {
1088    Evas_Object *win = data;
1089    _config_display_update(win);
1090    return ECORE_CALLBACK_PASS_ON;
1091 }
1092
1093 static void
1094 _engine_use(void            *data,
1095             Evas_Object *obj __UNUSED__,
1096             void *event_info __UNUSED__)
1097 {
1098    Evas_Object *li;
1099    const char *selection;
1100
1101    li = data;
1102    selection = elm_object_item_data_get(elm_list_selected_item_get(li));
1103
1104    if (!strcmp(elm_config_engine_get(), selection))
1105      return;
1106
1107    elm_config_engine_set(selection);
1108    elm_config_all_flush();
1109    elm_config_save(); /* make sure new engine has its data dir */
1110 }
1111
1112 static void
1113 _profile_use(void            *data,
1114              Evas_Object *obj __UNUSED__,
1115              void *event_info __UNUSED__)
1116 {
1117    Evas_Object *li;
1118    const char *selection;
1119    const char *profile;
1120
1121    li = data;
1122    selection = elm_object_item_data_get(elm_list_selected_item_get(li));
1123    profile = elm_config_profile_get();
1124
1125    if (!profile)
1126      {
1127         fprintf(stderr, "No profile currently set!\n"); /* FIXME: log domain */
1128         return;
1129      }
1130
1131    if (!strcmp(profile, selection))
1132      return;
1133
1134    elm_config_profile_set(selection); /* just here to update info for getters below */
1135
1136    _profile_change_do(elm_object_top_widget_get(li), selection);
1137    elm_config_all_flush();
1138    elm_config_save(); /* make sure new profile has its data dir */
1139 }
1140
1141 static void
1142 _btn_todo(void *data       __UNUSED__,
1143           Evas_Object *obj __UNUSED__,
1144           void *event_info __UNUSED__)
1145 {
1146    printf("To be done!\n");
1147 }
1148
1149 static void
1150 _profile_reset(void            *data,
1151                Evas_Object *obj __UNUSED__,
1152                void *event_info __UNUSED__)
1153 {
1154    const char *selection, *curr;
1155    const char *pdir;
1156    Evas_Object *li;
1157
1158    li = data;
1159    selection = elm_object_item_data_get(elm_list_selected_item_get(li));
1160    curr = elm_config_profile_get();
1161
1162    elm_config_all_flush();
1163    elm_config_save(); /* dump config into old profile's data dir */
1164
1165    pdir = elm_config_profile_dir_get(selection, EINA_TRUE);
1166    if (!pdir)
1167      return;
1168
1169    ecore_file_recursive_rm(pdir);
1170    elm_config_profile_dir_free(pdir);
1171
1172    elm_config_reload();
1173
1174    _profile_change_do(elm_object_top_widget_get(li), curr);
1175    elm_config_all_flush();
1176    elm_config_save(); /* make sure new profile has its data dir */
1177 }
1178
1179 static void
1180 _theme_use(void *data       __UNUSED__,
1181            Evas_Object *obj __UNUSED__,
1182            void *event_info __UNUSED__)
1183 {
1184    const char *defth;
1185    Elm_Theme *th;
1186    Evas_Object *win = elm_object_top_widget_get(obj);
1187    Evas_Object *sample = evas_object_data_get(win, "theme_preview");
1188
1189    th = elm_object_theme_get(sample);
1190    defth = elm_theme_get(th);
1191    elm_theme_set(NULL, defth);
1192    elm_config_all_flush();
1193    elm_config_save();
1194 }
1195
1196 static void
1197 _theme_sel(void            *data __UNUSED__,
1198            Evas_Object     *obj,
1199            void *event_info __UNUSED__)
1200 {
1201    Evas_Object *win = elm_object_top_widget_get(obj);
1202    Evas_Object *sample = evas_object_data_get(win, "theme_preview");
1203    Elm_Theme *th;
1204    Elm_Object_Item *list_it;
1205    Eina_Strbuf *newth;
1206    Eina_List *l;
1207
1208    if (!sample) return;
1209    tsel = elm_list_selected_items_get(obj);
1210    newth = eina_strbuf_new();
1211    EINA_SAFETY_ON_NULL_RETURN(newth);
1212    th = elm_theme_new();
1213    if (!th)
1214      {
1215         eina_strbuf_free(newth);
1216         return;
1217      }
1218    EINA_LIST_REVERSE_FOREACH((Eina_List*)tsel, l, list_it)
1219      {
1220         Theme *t = elm_object_item_data_get(list_it);
1221         eina_strbuf_append_printf(newth, "%s:", t->name);
1222         if ((!l->prev) && strcmp(t->name, "default"))
1223           /* ensure default theme is always there for fallback */
1224           eina_strbuf_append(newth, "default");
1225      }
1226    elm_theme_set(th, eina_strbuf_string_get(newth));
1227    eina_strbuf_free(newth);
1228    elm_object_theme_set(sample, th);
1229    elm_theme_free(th);
1230 }
1231
1232 /*static void
1233    _theme_browse(void *data, Evas_Object *obj, void *event_info)
1234    {
1235    printf("not implemented\n");
1236    }*/
1237
1238 static void
1239 _status_config_sizing(Evas_Object *win,
1240                       Evas_Object *naviframe)
1241 {
1242    Evas_Object *lb, *pd, *bx, *sl, *sp;
1243
1244    bx = elm_box_add(win);
1245    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
1246    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.5);
1247
1248    LABEL_FRAME_ADD("<hilight>Scale</>");
1249
1250    sl = elm_slider_add(win);
1251    evas_object_data_set(win, "scale_slider", sl);
1252    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
1253    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
1254    elm_slider_span_size_set(sl, 120);
1255    elm_slider_unit_format_set(sl, "%1.2f");
1256    elm_slider_indicator_format_set(sl, "%1.2f");
1257    elm_slider_min_max_set(sl, 0.25, 5.0);
1258    elm_slider_value_set(sl, elm_config_scale_get());
1259    elm_box_pack_end(bx, sl);
1260    evas_object_show(sl);
1261
1262    evas_object_smart_callback_add(sl, "changed", sc_round, NULL);
1263    evas_object_smart_callback_add(sl, "delay,changed", sc_change, NULL);
1264
1265    sp = elm_separator_add(win);
1266    elm_separator_horizontal_set(sp, EINA_TRUE);
1267    evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0);
1268    evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
1269    elm_box_pack_end(bx, sp);
1270    evas_object_show(sp);
1271
1272    LABEL_FRAME_ADD("<hilight>Finger Size</><br/>");
1273
1274    sl = elm_slider_add(win);
1275    evas_object_data_set(win, "fs_slider", sl);
1276    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
1277    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
1278    elm_slider_span_size_set(sl, 120);
1279    elm_slider_unit_format_set(sl, "%1.0f");
1280    elm_slider_indicator_format_set(sl, "%1.0f");
1281    elm_slider_min_max_set(sl, 5, 200);
1282    elm_slider_value_set(sl, elm_config_finger_size_get());
1283    elm_box_pack_end(bx, sl);
1284    evas_object_show(sl);
1285
1286    evas_object_smart_callback_add(sl, "changed", fs_round, NULL);
1287    evas_object_smart_callback_add(sl, "delay,changed", fs_change, NULL);
1288
1289    evas_object_data_set(win, "sizing", bx);
1290
1291    elm_naviframe_item_simple_push(naviframe, bx);
1292 }
1293
1294 static void
1295 _status_config_access(Evas_Object *win,
1296                       Evas_Object *naviframe)
1297 {
1298    Evas_Object *bx, *ck;
1299
1300    bx = elm_box_add(win);
1301    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
1302    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.5);
1303
1304    ck = elm_check_add(win);
1305    elm_object_tooltip_text_set(ck, "Set access mode");
1306    elm_object_text_set(ck, "Enable Access Mode");
1307    evas_object_data_set(win, "access_check", ck);
1308    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, 0.0);
1309    evas_object_size_hint_align_set(ck, EVAS_HINT_FILL, 0.5);
1310    elm_check_state_set(ck, elm_config_access_get());
1311    elm_box_pack_end(bx, ck);
1312    evas_object_show(ck);
1313
1314    evas_object_smart_callback_add(ck, "changed", ac_change, NULL);
1315
1316    evas_object_data_set(win, "access", bx);
1317
1318    elm_naviframe_item_simple_push(naviframe, bx);
1319 }
1320
1321 static void
1322 _status_config_selection(Evas_Object *win,
1323                       Evas_Object *naviframe)
1324 {
1325    Evas_Object *bx, *ck;
1326
1327    bx = elm_box_add(win);
1328    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
1329    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.5);
1330
1331    ck = elm_check_add(win);
1332    elm_object_tooltip_text_set(ck, "Set selection mode");
1333    elm_object_text_set(ck, "Enable clear selection when unfocus");
1334    evas_object_data_set(win, "selection_check", ck);
1335    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, 0.0);
1336    evas_object_size_hint_align_set(ck, EVAS_HINT_FILL, 0.5);
1337    elm_check_state_set(ck, elm_config_selection_unfocused_clear_get());
1338    elm_box_pack_end(bx, ck);
1339    evas_object_show(ck);
1340
1341    evas_object_smart_callback_add(ck, "changed", sel_change, NULL);
1342
1343    evas_object_data_set(win, "selection", bx);
1344
1345    elm_naviframe_item_simple_push(naviframe, bx);
1346 }
1347
1348 static Evas_Object *
1349 _sample_theme_new(Evas_Object *win)
1350 {
1351    Evas_Object *base, *bg, *bt, *ck, *rd, *rdg, *sl, *fr, *li, *rc, *sp;
1352
1353    base = elm_table_add(win);
1354    evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1355    evas_object_size_hint_align_set(base, EVAS_HINT_FILL, EVAS_HINT_FILL);
1356
1357    bg = elm_bg_add(win);
1358    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1359    evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
1360    elm_table_pack(base, bg, 0, 0, 2, 5);
1361    evas_object_show(bg);
1362
1363    bt = elm_button_add(win);
1364    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1365    elm_object_text_set(bt, "Button");
1366    elm_table_pack(base, bt, 0, 0, 1, 1);
1367    evas_object_show(bt);
1368
1369    ck = elm_check_add(win);
1370    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, 0.0);
1371    elm_object_text_set(ck, "Check");
1372    elm_table_pack(base, ck, 0, 1, 1, 1);
1373    evas_object_show(ck);
1374
1375    rd = elm_radio_add(win);
1376    evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, 0.0);
1377    elm_radio_state_value_set(rd, 0);
1378    elm_object_text_set(rd, "Radio 1");
1379    elm_table_pack(base, rd, 1, 0, 1, 1);
1380    evas_object_show(rd);
1381    rdg = rd;
1382
1383    rd = elm_radio_add(win);
1384    evas_object_size_hint_weight_set(rd, EVAS_HINT_EXPAND, 0.0);
1385    elm_radio_state_value_set(rd, 1);
1386    elm_object_text_set(rd, "Radio 2");
1387    elm_radio_group_add(rd, rdg);
1388    elm_table_pack(base, rd, 1, 1, 1, 1);
1389    evas_object_show(rd);
1390
1391    sp = elm_separator_add(win);
1392    elm_separator_horizontal_set(sp, EINA_TRUE);
1393    evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0);
1394    evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
1395    elm_table_pack(base, sp, 0, 2, 2, 1);
1396    evas_object_show(sp);
1397
1398    sl = elm_slider_add(win);
1399    elm_object_text_set(sl, "Slider");
1400    elm_slider_span_size_set(sl, 120);
1401    elm_slider_min_max_set(sl, 1, 10);
1402    elm_slider_value_set(sl, 4);
1403    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
1404    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, EVAS_HINT_FILL);
1405    elm_table_pack(base, sl, 0, 3, 2, 1);
1406    evas_object_show(sl);
1407
1408    fr = elm_frame_add(win);
1409    elm_object_text_set(fr, "Frame");
1410    elm_table_pack(base, fr, 0, 4, 2, 1);
1411    evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1412    evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
1413    evas_object_show(fr);
1414
1415    li = elm_list_add(win);
1416    evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1417    evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
1418    elm_object_content_set(fr, li);
1419    evas_object_show(li);
1420
1421    elm_list_item_append(li, "List Item 1", NULL, NULL, NULL, NULL);
1422    elm_list_item_append(li, "Second Item", NULL, NULL, NULL, NULL);
1423    elm_list_item_append(li, "Third Item", NULL, NULL, NULL, NULL);
1424    elm_list_go(li);
1425
1426    rc = evas_object_rectangle_add(evas_object_evas_get(win));
1427    evas_object_size_hint_weight_set(rc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1428    evas_object_size_hint_min_set(rc, 160, 120);
1429    elm_table_pack(base, rc, 0, 4, 2, 1);
1430
1431    return base;
1432 }
1433
1434 static void
1435 _status_config_themes(Evas_Object *win,
1436                       Evas_Object *naviframe)
1437 {
1438    Evas_Object *tb, *rc, *sc, *sp, *li, *pd, *fr, *bt, *sample;
1439    Eina_List *list, *l;
1440    char *th, *s, *ext;
1441    Elm_Theme *d;
1442    Elm_Object_Item *list_it, *def_it = NULL;
1443    const char *theme_name, *sep[20];
1444    unsigned int x;
1445
1446    tb = elm_table_add(win);
1447    evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1448    evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
1449
1450    rc = evas_object_rectangle_add(evas_object_evas_get(win));
1451    evas_object_size_hint_weight_set(rc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1452    evas_object_size_hint_min_set(rc, 0, 130);
1453    elm_table_pack(tb, rc, 0, 0, 1, 1);
1454
1455    rc = evas_object_rectangle_add(evas_object_evas_get(win));
1456    evas_object_size_hint_weight_set(rc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1457    evas_object_size_hint_min_set(rc, 0, 200);
1458    elm_table_pack(tb, rc, 0, 1, 1, 1);
1459
1460    /////////////////////////////////////////////
1461
1462    pd = elm_frame_add(win);
1463    elm_object_style_set(pd, "pad_medium");
1464    evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1465    evas_object_size_hint_align_set(pd, EVAS_HINT_FILL, EVAS_HINT_FILL);
1466    elm_table_pack(tb, pd, 0, 0, 1, 1);
1467    evas_object_show(pd);
1468
1469    li = elm_list_add(win);
1470    elm_list_multi_select_set(li, EINA_TRUE);
1471    evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1472    evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
1473    elm_object_content_set(pd, li);
1474    evas_object_show(li);
1475
1476    list = elm_theme_name_available_list_new();
1477    d = elm_theme_default_get();
1478    theme_name = elm_theme_get(d);
1479    for (x = 1, sep[0] = theme_name; x < sizeof(sep) / sizeof(sep[0]); x++)
1480      {
1481         sep[x] = strchr(sep[x - 1] + 1, ':');
1482         if (!sep[x]) break;
1483      }
1484    EINA_LIST_FOREACH(list, l, th)
1485      {
1486         Theme *t;
1487         int y;
1488
1489         t = calloc(1, sizeof(Theme));
1490         t->name = eina_stringshare_add(th);
1491         s = elm_theme_list_item_path_get(th, &(t->in_search_path));
1492         if (s)
1493           {
1494              t->path = eina_stringshare_add(s);
1495              free(s);
1496           }
1497         if (t->in_search_path)
1498           {
1499              s = strdup(th);
1500              if (s)
1501                {
1502                   s[0] = toupper(s[0]);
1503                   t->label = eina_stringshare_add(s);
1504                   free(s);
1505                }
1506              else
1507                t->label = eina_stringshare_add(s);
1508           }
1509         else
1510           {
1511              s = strdup(ecore_file_file_get(th));
1512              if (s)
1513                {
1514                   s[0] = toupper(s[0]);
1515                   ext = strrchr(s, '.');
1516                   if (ext) *ext = 0;
1517                   t->label = eina_stringshare_add(s);
1518                   free(s);
1519                }
1520              else
1521                t->label = eina_stringshare_add(s);
1522           }
1523         themes = eina_list_append(themes, t);
1524         list_it = elm_list_item_append(li, t->label, NULL, NULL, NULL, t);
1525         if (!strcmp(t->name, "default")) def_it = list_it;
1526         for (y = x - 1 /* ignore default e theme */; y > 0; y--)
1527           {
1528              const char *start = (sep[y - 1][0] == ':') ? sep[y - 1] + 1 : sep[y - 1];
1529              unsigned int len = (unsigned int)(sep[y] - start);
1530              if (strncmp(start , t->name, len) || (strlen(t->name) != len)) continue;
1531
1532              if (!elm_list_item_selected_get(list_it))
1533                elm_list_item_selected_set(list_it, EINA_TRUE);
1534              break;
1535           }
1536      }
1537    if (!elm_list_selected_items_get(li))
1538      elm_list_item_selected_set(def_it, EINA_TRUE);
1539    evas_object_smart_callback_add(li, "selected", _theme_sel, NULL);
1540    evas_object_smart_callback_add(li, "unselected", _theme_sel, NULL);
1541    elm_theme_name_available_list_free(list);
1542
1543    elm_list_go(li);
1544
1545    pd = elm_frame_add(win);
1546    elm_object_style_set(pd, "pad_medium");
1547    evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1548    evas_object_size_hint_align_set(pd, 0.9, 0.9);
1549    elm_table_pack(tb, pd, 0, 0, 1, 1);
1550    evas_object_show(pd);
1551
1552    /* FIXME: not implemented yet
1553       bt = elm_button_add(win);
1554       evas_object_smart_callback_add(bt, "clicked", _theme_browse, win);
1555       elm_object_text_set(bt, "Browse...");
1556       evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1557       evas_object_size_hint_align_set(bt, 0.9, 0.9);
1558       elm_object_content_set(pd, bt);
1559       evas_object_show(bt);
1560     */
1561    pd = elm_frame_add(win);
1562    elm_object_style_set(pd, "pad_medium");
1563    evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, 0.0);
1564    evas_object_size_hint_align_set(pd, EVAS_HINT_FILL, EVAS_HINT_FILL);
1565    elm_table_pack(tb, pd, 0, 1, 1, 1);
1566    evas_object_show(pd);
1567
1568    fr = elm_frame_add(win);
1569    elm_object_text_set(fr, "Preview");
1570    evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1571    evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
1572    elm_object_content_set(pd, fr);
1573    evas_object_show(fr);
1574
1575    sc = elm_scroller_add(win);
1576    elm_scroller_bounce_set(sc, EINA_FALSE, EINA_FALSE);
1577    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1578    evas_object_size_hint_align_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL);
1579    elm_object_content_set(fr, sc);
1580    evas_object_show(sc);
1581
1582    sample = _sample_theme_new(win);
1583    elm_object_content_set(sc, sample);
1584    evas_object_show(sample);
1585    evas_object_data_set(win, "theme_preview", sample);
1586
1587    /////////////////////////////////////////////
1588    sp = elm_separator_add(win);
1589    elm_separator_horizontal_set(sp, EINA_TRUE);
1590    evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0);
1591    evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
1592    elm_table_pack(tb, sp, 0, 2, 1, 1);
1593    evas_object_show(sp);
1594
1595    pd = elm_frame_add(win);
1596    elm_object_style_set(pd, "pad_medium");
1597    evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, 0.0);
1598    evas_object_size_hint_align_set(pd, 0.5, 0.5);
1599    elm_table_pack(tb, pd, 0, 3, 1, 1);
1600    evas_object_show(pd);
1601
1602    bt = elm_button_add(win);
1603    evas_object_smart_callback_add(bt, "clicked", _theme_use, win);
1604    elm_object_text_set(bt, "Use Theme");
1605    evas_object_size_hint_weight_set(bt, EVAS_HINT_EXPAND, 0.0);
1606    evas_object_size_hint_align_set(bt, 0.5, 0.5);
1607    elm_object_content_set(pd, bt);
1608    evas_object_show(bt);
1609
1610    evas_object_data_set(win, "themes", tb);
1611    elm_naviframe_item_simple_push(naviframe, tb);
1612 }
1613
1614 static void
1615 _font_preview_update(Evas_Object *win)
1616 {
1617    Evas_Font_Size sz;
1618    char *name;
1619
1620    if (!fndata.cur_font)
1621      return;
1622
1623    name = elm_font_fontconfig_name_get(fndata.cur_font, fndata.cur_style);
1624    sz = fndata.cur_size;
1625
1626    if (sz < 0)
1627      sz = (-sz * 10) / 100;
1628    if (sz == 0)
1629      sz = 10;
1630
1631    edje_object_text_class_set(evas_object_data_get(win, "font_preview"),
1632                               "font_preview", name, sz);
1633
1634    elm_font_fontconfig_name_free(name);
1635 }
1636
1637 static void
1638 _font_classes_list_sel(void *data   __UNUSED__,
1639                        Evas_Object *obj,
1640                        void        *event_info)
1641 {
1642    const Eina_List *f_names_items, *l;
1643    Elm_Text_Class_Data *tc_data;
1644    Evas_Object *f_names_list;
1645    Elm_Object_Item *list_it;
1646
1647    tc_data = elm_object_item_data_get(event_info);
1648
1649    f_names_list = evas_object_data_get(elm_object_top_widget_get(obj),
1650                                        "font_names_list");
1651    ELM_LIST_ENABLE(f_names_list);
1652
1653    f_names_items = elm_list_items_get(f_names_list);
1654
1655    EINA_LIST_FOREACH(f_names_items, l, list_it)
1656      {
1657         const char *s;
1658
1659         s = elm_object_item_text_get(list_it);
1660
1661         if (tc_data->font && !strcmp(s, tc_data->font))
1662           {
1663              elm_list_item_selected_set(list_it, EINA_TRUE);
1664              elm_list_item_show(list_it);
1665              break;
1666           }
1667      }
1668 }
1669
1670 static void
1671 _font_names_list_sel(void *data   __UNUSED__,
1672                      Evas_Object *obj,
1673                      void        *event_info)
1674 {
1675    Evas_Object *style_list, *cls_list, *win;
1676    const char *style, *sel_font;
1677    Elm_Text_Class_Data *tc_data;
1678    Elm_Object_Item *list_it, *fc_list_it;
1679    Elm_Font_Properties *efp;
1680    const Eina_List *l;
1681
1682    list_it = event_info;
1683    sel_font = elm_object_item_text_get(list_it);
1684
1685    win = elm_object_top_widget_get(obj);
1686    style_list = evas_object_data_get(win, "font_styles_list");
1687    cls_list = evas_object_data_get(win, "font_classes_list");
1688
1689    fc_list_it = elm_list_selected_item_get(cls_list);
1690    if (!fc_list_it) return;  /* should not happen, fonts list disabled in
1691                          * this case */
1692
1693    eina_stringshare_replace(&fndata.cur_font, sel_font);
1694
1695    tc_data = elm_object_item_data_get(fc_list_it);
1696    if (tc_data->font) eina_stringshare_del(tc_data->font);
1697    if (fndata.cur_font) tc_data->font = eina_stringshare_ref(fndata.cur_font);
1698
1699    /* load styles list */
1700    efp = eina_hash_find(fndata.font_hash, sel_font);
1701
1702    ELM_LIST_ENABLE(style_list);
1703    elm_list_clear(style_list);
1704
1705    evas_event_freeze(evas_object_evas_get(style_list));
1706    edje_freeze();
1707
1708    list_it = NULL;
1709
1710    EINA_LIST_FOREACH(efp->styles, l, style)
1711      {
1712         Elm_Object_Item *i;
1713
1714         i = elm_list_item_append(style_list, style, NULL, NULL,
1715                                  _font_styles_list_sel, NULL);
1716
1717         if (tc_data->style && (!strcmp(style, tc_data->style)))
1718           list_it = i;
1719      }
1720
1721    elm_list_go(style_list);
1722
1723    edje_thaw();
1724    evas_event_thaw(evas_object_evas_get(style_list));
1725
1726    if (list_it)
1727      elm_list_item_selected_set(list_it, EINA_TRUE);
1728
1729    _font_preview_update(win);
1730 }
1731
1732 static void
1733 _font_styles_list_sel(void *data   __UNUSED__,
1734                       Evas_Object *obj,
1735                       void        *event_info)
1736 {
1737    Evas_Object *fc_list, *fs_list, *win;
1738    Elm_Text_Class_Data *tc_data;
1739    const Eina_List *l;
1740    Elm_Object_Item *list_it;
1741
1742    win = elm_object_top_widget_get(obj);
1743    fc_list = evas_object_data_get(win, "font_classes_list");
1744    fs_list = evas_object_data_get(win, "font_sizes_list");
1745
1746    list_it = elm_list_selected_item_get(fc_list);
1747    if (!list_it) return;  /* should not happen */
1748
1749    eina_stringshare_replace(&fndata.cur_style,
1750                             elm_object_item_text_get(event_info));
1751    ELM_LIST_ENABLE(fs_list);
1752
1753    tc_data = elm_object_item_data_get(list_it);
1754    eina_stringshare_del(tc_data->style);
1755    tc_data->style = eina_stringshare_ref(fndata.cur_style);
1756
1757    evas_event_freeze(evas_object_evas_get(fs_list));
1758    edje_freeze();
1759
1760    EINA_LIST_FOREACH(elm_list_items_get(fs_list), l, list_it)
1761      {
1762         Elm_Font_Size_Data *sdata;
1763
1764         sdata = elm_object_item_data_get(list_it);
1765         elm_list_item_selected_set(l->data, EINA_FALSE);
1766
1767         if (tc_data->size == sdata->size)
1768           {
1769              elm_list_item_selected_set(list_it, EINA_TRUE);
1770              elm_list_item_show(list_it);
1771              break;
1772           }
1773      }
1774
1775    edje_thaw();
1776    evas_event_thaw(evas_object_evas_get(fs_list));
1777
1778    _font_preview_update(win);
1779 }
1780
1781 static void
1782 _font_sizes_list_sel(void *data       __UNUSED__,
1783                      Evas_Object *obj __UNUSED__,
1784                      void *event_info __UNUSED__)
1785 {
1786    Elm_Text_Class_Data *tc_data;
1787    Evas_Object *fc_list, *win;
1788    Elm_Font_Size_Data *sd;
1789    Elm_Object_Item *list_it;
1790
1791    win = elm_object_top_widget_get(obj);
1792    fc_list = evas_object_data_get(win, "font_classes_list");
1793
1794    list_it = elm_list_selected_item_get(fc_list);
1795    if (!list_it) return;  /* should not happen */
1796
1797    sd = elm_object_item_data_get(event_info);
1798    fndata.cur_size = sd->size;
1799
1800    tc_data = elm_object_item_data_get(list_it);
1801    tc_data->size = fndata.cur_size;
1802
1803    _font_preview_update(win);
1804 }
1805
1806 static void
1807 _fstyle_list_unselect_cb(void *data       __UNUSED__,
1808                          Evas_Object     *obj,
1809                          void *event_info __UNUSED__)
1810 {
1811    Evas_Object *sizes_list, *win;
1812
1813    if (elm_list_selected_item_get(obj)) return;
1814
1815    win = elm_object_top_widget_get(obj);
1816
1817    sizes_list = evas_object_data_get(win, "font_sizes_list");
1818    ELM_LIST_DISABLE(sizes_list);
1819 }
1820
1821 static void
1822 _fc_list_unselect_cb(void *data       __UNUSED__,
1823                      Evas_Object     *obj,
1824                      void *event_info __UNUSED__)
1825 {
1826    Evas_Object *font_names_list, *styles_list, *sizes_list, *win;
1827
1828    if (elm_list_selected_item_get(obj)) return;
1829
1830    win = elm_object_top_widget_get(obj);
1831
1832    font_names_list = evas_object_data_get(win, "font_names_list");
1833    ELM_LIST_DISABLE(font_names_list);
1834
1835    styles_list = evas_object_data_get(win, "font_styles_list");
1836    ELM_LIST_DISABLE(styles_list);
1837
1838    sizes_list = evas_object_data_get(win, "font_sizes_list");
1839    ELM_LIST_DISABLE(sizes_list);
1840 }
1841
1842 static void
1843 _font_classes_list_load(Evas_Object *li)
1844 {
1845    Elm_Text_Class_Data *tc_data;
1846    Eina_List *l;
1847    Evas *evas;
1848
1849    evas = evas_object_evas_get(li);
1850    evas_event_freeze(evas);
1851    edje_freeze();
1852
1853    EINA_LIST_FOREACH(fndata.text_classes, l, tc_data)
1854      elm_list_item_append(li, tc_data->desc, NULL, NULL,
1855                           _font_classes_list_sel, tc_data);
1856
1857    evas_object_smart_callback_add(li, "unselected", _fc_list_unselect_cb,
1858                                   NULL);
1859
1860    elm_list_go(li);
1861    edje_thaw();
1862    evas_event_thaw(evas);
1863 }
1864
1865 static void
1866 _fonts_data_fill(Evas *evas)
1867 {
1868    const Eina_List *fo_list, *l;
1869    Eina_List *text_classes;
1870    Elm_Text_Class_Data *tc_data;
1871    Elm_Font_Size_Data *sd;
1872    Elm_Font_Overlay *efo;
1873    Eina_List *evas_fonts;
1874    Elm_Text_Class *etc;
1875    int i;
1876
1877    evas_fonts = evas_font_available_list(evas);
1878    fndata.font_hash = elm_font_available_hash_add(evas_fonts);
1879    evas_font_available_list_free(evas, evas_fonts);
1880
1881    text_classes = elm_config_text_classes_list_get();
1882    fo_list = elm_config_font_overlay_list_get();
1883
1884    EINA_LIST_FOREACH(text_classes, l, etc)
1885      {
1886         const Eina_List *ll;
1887
1888         tc_data = calloc(1, sizeof(*tc_data));
1889         if (!tc_data) continue;
1890
1891         tc_data->name = eina_stringshare_add(etc->name);
1892         tc_data->desc = eina_stringshare_add(etc->desc);
1893
1894         EINA_LIST_FOREACH(fo_list, ll, efo)
1895           {
1896              if (strcmp(tc_data->name, efo->text_class))
1897                continue;
1898
1899              if (efo->font)
1900                {
1901                   Elm_Font_Properties *efp;
1902
1903                   efp = elm_font_properties_get(efo->font);
1904                   if (efp)
1905                     {
1906                        tc_data->font = eina_stringshare_add(efp->name);
1907                        /* we're sure we recorded with only 1 style selected */
1908                        tc_data->style = eina_stringshare_add(efp->styles->data);
1909                        elm_font_properties_free(efp);
1910                     }
1911                }
1912              tc_data->size = efo->size;
1913           }
1914
1915         fndata.text_classes = eina_list_append(fndata.text_classes, tc_data);
1916      }
1917
1918    elm_config_text_classes_list_free(text_classes);
1919
1920    /* FIXME: hinting later */
1921    /* fndata.hinting = e_config->font_hinting; */
1922
1923    sd = calloc(1, sizeof(Elm_Font_Size_Data));
1924    sd->size_str = eina_stringshare_add("Tiny");
1925    sd->size = -50;
1926    fndata.font_scale_list = eina_list_append(fndata.font_scale_list, sd);
1927
1928    sd = calloc(1, sizeof(Elm_Font_Size_Data));
1929    sd->size_str = eina_stringshare_add("Small");
1930    sd->size = -80;
1931    fndata.font_scale_list = eina_list_append(fndata.font_scale_list, sd);
1932
1933    sd = calloc(1, sizeof(Elm_Font_Size_Data));
1934    sd->size_str = eina_stringshare_add("Normal");
1935    sd->size = -100;
1936    fndata.font_scale_list = eina_list_append(fndata.font_scale_list, sd);
1937
1938    sd = calloc(1, sizeof(Elm_Font_Size_Data));
1939    sd->size_str = eina_stringshare_add("Big");
1940    sd->size = -150;
1941    fndata.font_scale_list = eina_list_append(fndata.font_scale_list, sd);
1942
1943    sd = calloc(1, sizeof(Elm_Font_Size_Data));
1944    sd->size_str = eina_stringshare_add("Really Big");
1945    sd->size = -190;
1946    fndata.font_scale_list = eina_list_append(fndata.font_scale_list, sd);
1947
1948    sd = calloc(1, sizeof(Elm_Font_Size_Data));
1949    sd->size_str = eina_stringshare_add("Huge");
1950    sd->size = -250;
1951    fndata.font_scale_list = eina_list_append(fndata.font_scale_list, sd);
1952
1953    for (i = 5; i < 51; i++)
1954      {
1955         char str[16];
1956
1957         str[0] = 0;
1958         snprintf(str, sizeof(str), "%d pixels", i);
1959
1960         sd = calloc(1, sizeof(Elm_Font_Size_Data));
1961         sd->size_str = eina_stringshare_add(str);
1962         sd->size = i;
1963         fndata.font_px_list = eina_list_append(fndata.font_px_list, sd);
1964      }
1965 }
1966
1967 static int
1968 _font_sort_cb(const void *data1,
1969               const void *data2)
1970 {
1971    if (!data1) return 1;
1972    if (!data2) return -1;
1973    return strcmp(data1, data2);
1974 }
1975
1976 static void
1977 _font_sizes_list_load(Evas_Object *size_list)
1978 {
1979    Elm_Font_Size_Data *size_data;
1980    Eina_List *l;
1981    Evas *evas;
1982
1983    evas = evas_object_evas_get(size_list);
1984    evas_event_freeze(evas);
1985    edje_freeze();
1986
1987    EINA_LIST_FOREACH(fndata.font_scale_list, l, size_data)
1988      elm_list_item_append(size_list, size_data->size_str, NULL, NULL,
1989                           _font_sizes_list_sel, size_data);
1990
1991    EINA_LIST_FOREACH(fndata.font_px_list, l, size_data)
1992      elm_list_item_append(size_list, size_data->size_str, NULL, NULL,
1993                           _font_sizes_list_sel, size_data);
1994
1995    elm_list_go(size_list);
1996    edje_thaw();
1997    evas_event_thaw(evas);
1998 }
1999
2000 static void
2001 _fnames_list_unselect_cb(void *data       __UNUSED__,
2002                          Evas_Object     *obj,
2003                          void *event_info __UNUSED__)
2004 {
2005    Evas_Object *styles_list, *sizes_list, *win;
2006
2007    if (elm_list_selected_item_get(obj)) return;
2008
2009    win = elm_object_top_widget_get(obj);
2010
2011    styles_list = evas_object_data_get(win, "font_styles_list");
2012    ELM_LIST_DISABLE(styles_list);
2013
2014    sizes_list = evas_object_data_get(win, "font_sizes_list");
2015    ELM_LIST_DISABLE(sizes_list);
2016 }
2017
2018 static Eina_Bool
2019 _font_list_fill(const Eina_Hash *hash __UNUSED__,
2020                 const void *key       __UNUSED__,
2021                 void                 *data,
2022                 void                 *fdata)
2023 {
2024    Elm_Font_Properties *efp;
2025    Eina_List **flist;
2026
2027    flist = fdata;
2028    efp = data;
2029
2030    *flist = eina_list_append(*flist, efp->name);
2031
2032    return EINA_TRUE;
2033 }
2034
2035 static void
2036 _font_names_list_load(Evas_Object *flist)
2037 {
2038    Eina_List *l, *names_list = NULL;
2039    const char *font;
2040    Evas *evas;
2041
2042    evas = evas_object_evas_get(flist);
2043    evas_event_freeze(evas);
2044    edje_freeze();
2045
2046    eina_hash_foreach(fndata.font_hash, _font_list_fill, &names_list);
2047    names_list = eina_list_sort(names_list, eina_list_count(names_list),
2048                                _font_sort_cb);
2049
2050    EINA_LIST_FOREACH(names_list, l, font)
2051      elm_list_item_append(flist, font, NULL, NULL, _font_names_list_sel, NULL);
2052
2053    EINA_LIST_FREE(names_list, font) ;
2054
2055    evas_object_smart_callback_add(flist, "unselected",
2056                                   _fnames_list_unselect_cb, NULL);
2057
2058    elm_list_go(flist);
2059
2060    edje_thaw();
2061    evas_event_thaw(evas);
2062 }
2063
2064 static void
2065 _status_config_fonts(Evas_Object *win,
2066                      Evas_Object *naviframe)
2067 {
2068    Evas_Object *base, *fr, *li, *rc, *preview, *sp, *pd, *bt, *bx;
2069    char buf[PATH_MAX];
2070
2071    _fonts_data_fill(evas_object_evas_get(win));
2072
2073    base = elm_table_add(win);
2074    evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2075    evas_object_size_hint_align_set(base, EVAS_HINT_FILL, EVAS_HINT_FILL);
2076
2077    /* yeah, dummy rectangles are ugly as hell, but no good way yet of
2078       fixing sizes */
2079    rc = evas_object_rectangle_add(evas_object_evas_get(win));
2080    evas_object_size_hint_weight_set(rc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2081    evas_object_size_hint_align_set(rc, EVAS_HINT_FILL, EVAS_HINT_FILL);
2082    evas_object_size_hint_min_set(rc, 70, 170);
2083    elm_table_pack(base, rc, 1, 0, 1, 1);
2084
2085    fr = elm_frame_add(win);
2086    elm_object_text_set(fr, "Font Class");
2087    elm_table_pack(base, fr, 0, 0, 1, 2);
2088    evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2089    evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
2090    evas_object_show(fr);
2091
2092    /* FIXME: no multiselection for this list, for now */
2093    li = elm_list_add(win);
2094    evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2095    evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
2096    elm_object_content_set(fr, li);
2097    evas_object_show(li);
2098
2099    evas_object_data_set(win, "font_classes_list", li);
2100    _font_classes_list_load(li);
2101
2102    fr = elm_frame_add(win);
2103    elm_object_text_set(fr, "Font");
2104    elm_table_pack(base, fr, 1, 0, 1, 2);
2105    evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2106    evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
2107    evas_object_show(fr);
2108
2109    li = elm_list_add(win);
2110    evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2111    evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
2112    elm_object_content_set(fr, li);
2113    evas_object_show(li);
2114
2115    evas_object_data_set(win, "font_names_list", li);
2116    _font_names_list_load(li);
2117    ELM_LIST_DISABLE(li);
2118
2119    rc = evas_object_rectangle_add(evas_object_evas_get(win));
2120    evas_object_size_hint_weight_set(rc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2121    evas_object_size_hint_align_set(rc, EVAS_HINT_FILL, EVAS_HINT_FILL);
2122    evas_object_size_hint_min_set(rc, 70, 130);
2123    elm_table_pack(base, rc, 1, 2, 1, 1);
2124
2125    fr = elm_frame_add(win);
2126    elm_object_text_set(fr, "Style");
2127    elm_table_pack(base, fr, 0, 2, 1, 1);
2128    evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2129    evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
2130    evas_object_show(fr);
2131    ELM_LIST_DISABLE(li);
2132
2133    li = elm_list_add(win);
2134    evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2135    evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
2136    elm_object_content_set(fr, li);
2137    evas_object_show(li);
2138
2139    evas_object_data_set(win, "font_styles_list", li);
2140    evas_object_smart_callback_add(li, "unselected", _fstyle_list_unselect_cb,
2141                                   NULL);
2142
2143    fr = elm_frame_add(win);
2144    elm_object_text_set(fr, "Size");
2145    elm_table_pack(base, fr, 1, 2, 1, 1);
2146    evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2147    evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
2148    evas_object_show(fr);
2149
2150    li = elm_list_add(win);
2151    evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2152    evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
2153    elm_object_content_set(fr, li);
2154    evas_object_show(li);
2155
2156    evas_object_data_set(win, "font_sizes_list", li);
2157    _font_sizes_list_load(li);
2158    ELM_LIST_DISABLE(li);
2159
2160    bx = elm_box_add(win);
2161    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2162    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
2163    elm_table_pack(base, bx, 0, 3, 2, 1);
2164    evas_object_show(bx);
2165
2166    /* FIXME: what to do here? dedicated widget? some new entry API set? */
2167    snprintf(buf, sizeof(buf), "%s/objects/font_preview.edj", elm_app_data_dir_get());
2168    preview = elm_layout_add(win);
2169    elm_layout_file_set(preview, buf, "font_preview");
2170    elm_object_part_text_set(preview, "elm.text", "Preview Text â€” æˆ‘真的会写中文");
2171    evas_object_size_hint_weight_set(preview, EVAS_HINT_EXPAND, 0.0);
2172    evas_object_size_hint_align_set(preview, EVAS_HINT_FILL, EVAS_HINT_FILL);
2173    evas_object_show(preview);
2174
2175    elm_box_pack_end(bx, preview);
2176    evas_object_data_set(win, "font_preview", elm_layout_edje_get(preview));
2177
2178    /////////////////////////////////////////////
2179    sp = elm_separator_add(win);
2180    elm_separator_horizontal_set(sp, EINA_TRUE);
2181    evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0);
2182    evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
2183    elm_table_pack(base, sp, 0, 4, 2, 1);
2184    evas_object_show(sp);
2185
2186    pd = elm_frame_add(win);
2187    elm_object_style_set(pd, "pad_medium");
2188    evas_object_size_hint_weight_set(pd, EVAS_HINT_EXPAND, 0.0);
2189    evas_object_size_hint_align_set(pd, 0.5, 0.5);
2190    elm_table_pack(base, pd, 0, 5, 2, 1);
2191    evas_object_show(pd);
2192
2193    bx = elm_box_add(win);
2194    elm_box_horizontal_set(bx, EINA_TRUE);
2195    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2196    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
2197    evas_object_show(bx);
2198
2199    bt = elm_button_add(win);
2200    evas_object_smart_callback_add(bt, "clicked", _font_overlay_set_all, win);
2201    elm_object_text_set(bt, "Set to All");
2202    evas_object_size_hint_weight_set(bt, 0.0, 0.0);
2203    evas_object_size_hint_align_set(bt, 0.5, 0.5);
2204    elm_box_pack_end(bx, bt);
2205    evas_object_show(bt);
2206
2207    bt = elm_button_add(win);
2208    evas_object_smart_callback_add(bt, "clicked", _font_overlay_reset, win);
2209    elm_object_text_set(bt, "Reset");
2210    evas_object_size_hint_weight_set(bt, 0.0, 0.0);
2211    evas_object_size_hint_align_set(bt, 0.5, 0.5);
2212    elm_box_pack_end(bx, bt);
2213    evas_object_show(bt);
2214
2215    bt = elm_button_add(win);
2216    evas_object_smart_callback_add(bt, "clicked", _font_overlay_reset_all, win);
2217    elm_object_text_set(bt, "Reset All");
2218    evas_object_size_hint_weight_set(bt, 0.0, 0.0);
2219    evas_object_size_hint_align_set(bt, 0.5, 0.5);
2220    elm_box_pack_end(bx, bt);
2221    evas_object_show(bt);
2222
2223    bt = elm_button_add(win);
2224    evas_object_smart_callback_add(bt, "clicked", _font_overlay_change, win);
2225    elm_object_text_set(bt, "Apply");
2226    evas_object_size_hint_weight_set(bt, 0.0, 0.0);
2227    evas_object_size_hint_align_set(bt, 0.5, 0.5);
2228    elm_box_pack_end(bx, bt);
2229    evas_object_show(bt);
2230
2231    elm_object_content_set(pd, bx);
2232
2233    evas_object_data_set(win, "fonts", base);
2234
2235    elm_naviframe_item_simple_push(naviframe, base);
2236 }
2237
2238 static void
2239 _engines_list_item_del_cb(void            *data,
2240                           Evas_Object *obj __UNUSED__,
2241                           void *event_info __UNUSED__)
2242 {
2243    free(data);
2244 }
2245
2246 static void
2247 _profiles_list_item_del_cb(void            *data,
2248                            Evas_Object *obj __UNUSED__,
2249                            void *event_info __UNUSED__)
2250 {
2251    free(data);
2252 }
2253
2254 static void
2255 _profiles_list_selected_cb(void            *data,
2256                            Evas_Object     *obj,
2257                            void *event_info __UNUSED__)
2258 {
2259    const char *cur_profile = NULL;
2260    const char *sel_profile, *pdir;
2261    const char *prof_name;
2262    char buf[PATH_MAX];
2263    Evas_Object *en;
2264 #ifdef ELM_EFREET
2265    Efreet_Desktop *desk = NULL;
2266 #endif
2267
2268    sel_profile = data;
2269    if (!sel_profile)
2270      return;
2271
2272    cur_profile = elm_config_profile_get();
2273
2274    pdir = elm_config_profile_dir_get(sel_profile, EINA_TRUE);
2275    if (!pdir) pdir = elm_config_profile_dir_get(sel_profile, EINA_FALSE);
2276 #ifdef ELM_EFREET
2277    snprintf(buf, sizeof(buf), "%s/profile.desktop", pdir);
2278    desk = efreet_desktop_new(buf);
2279    if ((desk) && (desk->name)) prof_name = desk->name;
2280    else
2281      {
2282         if (desk) efreet_desktop_free(desk);
2283         pdir = elm_config_profile_dir_get(sel_profile, EINA_FALSE);
2284         snprintf(buf, sizeof(buf), "%s/profile.desktop", pdir);
2285         desk = efreet_desktop_new(buf);
2286         if ((desk) && (desk->name)) prof_name = desk->name;
2287         else prof_name = cur_profile;
2288      }
2289 #endif
2290    prof_name = cur_profile;
2291
2292    if (!pdir)
2293      elm_object_disabled_set(evas_object_data_get(obj, "prof_reset_btn"),
2294                              EINA_TRUE);
2295    else
2296      {
2297         elm_object_disabled_set(evas_object_data_get(obj, "prof_del_btn"),
2298                                 EINA_TRUE);
2299         elm_object_disabled_set(evas_object_data_get(obj, "prof_reset_btn"),
2300                                 EINA_FALSE);
2301         elm_object_disabled_set(evas_object_data_get(obj, "prof_use_btn"),
2302                                 EINA_FALSE);
2303         elm_config_profile_dir_free(pdir);
2304      }
2305
2306    snprintf(buf, sizeof(buf), "<hilight>Selected profile: %s</><br/>",
2307             prof_name);
2308    elm_object_text_set(evas_object_data_get(obj, "prof_name_lbl"), buf);
2309
2310    en = evas_object_data_get(obj, "prof_desc_entry");
2311 #ifdef ELM_EFREET
2312    if (desk) elm_object_text_set(en, desk->comment);
2313    else
2314 #endif
2315    elm_object_text_set(en, "Unknown");
2316
2317 #ifdef ELM_EFREET
2318    if (desk) efreet_desktop_free(desk);
2319 #endif
2320 }
2321
2322 static void
2323 _profiles_list_fill(Evas_Object *l_widget,
2324                     Eina_List   *p_names)
2325 {
2326    const char *cur_profile = NULL;
2327    const char *profile;
2328    void *sel_it = NULL;
2329    Eina_List *l;
2330
2331    if (!p_names)
2332      return;
2333
2334    elm_list_clear(l_widget);
2335
2336    cur_profile = elm_config_profile_get();
2337
2338    EINA_LIST_FOREACH(p_names, l, profile)
2339      {
2340 #ifdef ELM_EFREET
2341         Efreet_Desktop *desk = NULL;
2342 #endif
2343         const char *label, *ext, *pdir;
2344         char buf[PATH_MAX];
2345         Elm_Object_Item *list_it;
2346         Evas_Object *ic;
2347
2348         pdir = elm_config_profile_dir_get(profile, EINA_TRUE);
2349         if (!pdir) pdir = elm_config_profile_dir_get(profile, EINA_FALSE);
2350         label = profile;
2351
2352 #ifdef ELM_EFREET
2353         snprintf(buf, sizeof(buf), "%s/profile.desktop", pdir);
2354         desk = efreet_desktop_new(buf);
2355         if ((desk) && (desk->name)) label = desk->name;
2356         else
2357           {
2358              if (desk) efreet_desktop_free(desk);
2359              pdir = elm_config_profile_dir_get(profile, EINA_FALSE);
2360              snprintf(buf, sizeof(buf), "%s/profile.desktop", pdir);
2361              desk = efreet_desktop_new(buf);
2362              if ((desk) && (desk->name)) label = desk->name;
2363              else label = profile;
2364           }
2365 #endif
2366
2367         buf[0] = 0;
2368         if (pdir) snprintf(buf, sizeof(buf), "%s/icon.edj", pdir);
2369 #ifdef ELM_EFREET
2370         if ((desk) && (desk->icon) && (pdir))
2371           snprintf(buf, sizeof(buf), "%s/%s", pdir, desk->icon);
2372 #endif
2373         ic = elm_icon_add(l_widget);
2374         ext = strrchr(buf, '.');
2375         if (ext)
2376           {
2377              if (!strcmp(ext, ".edj")) elm_image_file_set(ic, buf, "icon");
2378              else elm_image_file_set(ic, buf, NULL);
2379           }
2380
2381         evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL,
2382                                          1, 1);
2383         evas_object_show(ic);
2384
2385         list_it = elm_list_item_append(l_widget, label, ic, NULL,
2386                                        _profiles_list_selected_cb,
2387                                        strdup(profile));
2388         elm_object_item_del_cb_set(list_it, _profiles_list_item_del_cb);
2389         if (cur_profile && !strcmp(profile, cur_profile))
2390           sel_it = list_it;
2391
2392         elm_config_profile_dir_free(pdir);
2393
2394 #ifdef ELM_EFREET
2395         if (desk) efreet_desktop_free(desk);
2396 #endif
2397      }
2398
2399    if (sel_it) elm_list_item_selected_set(sel_it, EINA_TRUE);
2400    elm_list_go(l_widget);
2401 }
2402
2403 static void
2404 _profiles_list_unselect_cb(void *data       __UNUSED__,
2405                            Evas_Object     *obj,
2406                            void *event_info __UNUSED__)
2407 {
2408    if (elm_list_selected_item_get(obj)) return;
2409    elm_object_disabled_set(evas_object_data_get(obj, "prof_del_btn"),
2410                            EINA_TRUE);
2411    elm_object_disabled_set(evas_object_data_get(obj, "prof_reset_btn"),
2412                            EINA_TRUE);
2413    elm_object_disabled_set(evas_object_data_get(obj, "prof_use_btn"),
2414                            EINA_TRUE);
2415 }
2416
2417 static void
2418 _status_config_profiles(Evas_Object *win,
2419                         Evas_Object *naviframe)
2420 {
2421    Evas_Object *li, *bx, *fr_bx1, *fr_bx2, *btn_bx, *fr, *lb, *en, *sp, *pd,
2422    *bt;
2423    Eina_List *profs;
2424    Evas *evas;
2425
2426    bx = elm_box_add(win);
2427    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2428    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
2429
2430    fr_bx1 = elm_box_add(win);
2431    evas_object_size_hint_weight_set(fr_bx1, EVAS_HINT_EXPAND,
2432                                     EVAS_HINT_EXPAND);
2433    evas_object_size_hint_align_set(fr_bx1, EVAS_HINT_FILL, EVAS_HINT_FILL);
2434    elm_box_homogeneous_set(fr_bx1, EINA_TRUE);
2435    evas_object_show(fr_bx1);
2436
2437    fr_bx2 = elm_box_add(win);
2438    evas_object_size_hint_weight_set(fr_bx2, EVAS_HINT_EXPAND,
2439                                     EVAS_HINT_EXPAND);
2440    evas_object_size_hint_align_set(fr_bx2, EVAS_HINT_FILL, EVAS_HINT_FILL);
2441    evas_object_show(fr_bx2);
2442
2443    fr = elm_frame_add(win);
2444    elm_object_text_set(fr, "Available Profiles");
2445    evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2446    evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
2447    elm_object_content_set(fr, fr_bx1);
2448    elm_box_pack_end(bx, fr);
2449    evas_object_show(fr);
2450
2451    li = elm_list_add(win);
2452    evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2453    evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
2454    evas_object_smart_callback_add(li, "unselected", _profiles_list_unselect_cb,
2455                                   NULL);
2456
2457    profs = elm_config_profile_list_get();
2458
2459    evas_object_show(li);
2460    elm_box_pack_end(fr_bx2, li);
2461
2462    lb = elm_label_add(win);
2463    evas_object_size_hint_weight_set(lb, EVAS_HINT_EXPAND, 0.0);
2464    evas_object_size_hint_align_set(lb, EVAS_HINT_FILL, 0.5);
2465
2466    evas_object_show(lb);
2467
2468    en = elm_entry_add(win);
2469    elm_entry_scrollable_set(en, EINA_TRUE);
2470    elm_entry_editable_set(en, EINA_FALSE);
2471    evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2472    evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL);
2473    evas_object_show(en);
2474
2475    evas_object_data_set(li, "prof_name_lbl", lb);
2476    evas_object_data_set(li, "prof_desc_entry", en);
2477
2478    elm_box_pack_end(fr_bx2, lb);
2479    elm_box_pack_end(fr_bx1, fr_bx2);
2480    elm_box_pack_end(fr_bx1, en);
2481
2482    /////////////////////////////////////////////
2483    sp = elm_separator_add(win);
2484    elm_separator_horizontal_set(sp, EINA_TRUE);
2485    evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0);
2486    evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
2487    elm_box_pack_end(bx, sp);
2488    evas_object_show(sp);
2489
2490    pd = elm_frame_add(win);
2491    elm_object_style_set(pd, "pad_medium");
2492    evas_object_size_hint_weight_set(pd, 0.0, 0.0);
2493    evas_object_size_hint_align_set(pd, 0.5, 0.5);
2494    elm_box_pack_end(bx, pd);
2495    evas_object_show(pd);
2496
2497    btn_bx = elm_box_add(win);
2498    elm_box_horizontal_set(btn_bx, EINA_TRUE);
2499    evas_object_size_hint_weight_set(btn_bx, EVAS_HINT_EXPAND,
2500                                     EVAS_HINT_EXPAND);
2501    evas_object_size_hint_align_set(btn_bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
2502    evas_object_show(btn_bx);
2503
2504    bt = elm_button_add(win);
2505    evas_object_smart_callback_add(bt, "clicked", _profile_use, li);
2506    elm_object_text_set(bt, "Use");
2507    evas_object_size_hint_weight_set(bt, 0.0, 0.0);
2508    evas_object_size_hint_align_set(bt, 0.5, 0.5);
2509    elm_box_pack_end(btn_bx, bt);
2510    evas_object_show(bt);
2511
2512    evas_object_data_set(li, "prof_use_btn", bt);
2513
2514    bt = elm_button_add(win);
2515    evas_object_smart_callback_add(bt, "clicked", _btn_todo, NULL); /* TODO */
2516    elm_object_text_set(bt, "Delete");
2517    evas_object_size_hint_weight_set(bt, 0.0, 0.0);
2518    evas_object_size_hint_align_set(bt, 0.5, 0.5);
2519    elm_box_pack_end(btn_bx, bt);
2520    evas_object_show(bt);
2521
2522    evas_object_data_set(li, "prof_del_btn", bt);
2523
2524    bt = elm_button_add(win);
2525    evas_object_smart_callback_add(bt, "clicked", _profile_reset, li);
2526    elm_object_text_set(bt, "Reset");
2527    evas_object_size_hint_weight_set(bt, 0.0, 0.0);
2528    evas_object_size_hint_align_set(bt, 0.5, 0.5);
2529    elm_box_pack_end(btn_bx, bt);
2530    evas_object_show(bt);
2531
2532    evas_object_data_set(li, "prof_reset_btn", bt);
2533
2534    bt = elm_button_add(win);
2535    evas_object_smart_callback_add(bt, "clicked", _btn_todo, NULL); /* TODO */
2536    elm_object_text_set(bt, "Add new");
2537    evas_object_size_hint_weight_set(bt, 0.0, 0.0);
2538    evas_object_size_hint_align_set(bt, 0.5, 0.5);
2539    elm_box_pack_end(btn_bx, bt);
2540    evas_object_show(bt);
2541
2542    elm_object_content_set(pd, btn_bx);
2543
2544    evas = evas_object_evas_get(li);
2545    evas_event_freeze(evas);
2546    edje_freeze();
2547
2548    _profiles_list_fill(li, profs);
2549
2550    elm_config_profile_list_free(profs);
2551
2552    edje_thaw();
2553    evas_event_thaw(evas);
2554
2555    evas_object_data_set(win, "profiles", bx);
2556    elm_naviframe_item_simple_push(naviframe, bx);
2557 }
2558
2559 static void
2560 _status_config_scrolling(Evas_Object *win,
2561                          Evas_Object *naviframe)
2562 {
2563    Evas_Object *lb, *pd, *bx, *sl, *sp, *ck, *sc;
2564
2565    bx = elm_box_add(win);
2566    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
2567    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.5);
2568
2569    sc = elm_scroller_add(win);
2570    evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2571    evas_object_size_hint_align_set(sc, EVAS_HINT_FILL, EVAS_HINT_FILL);
2572    elm_scroller_bounce_set(sc, EINA_FALSE, EINA_TRUE);
2573    evas_object_show(sc);
2574    elm_object_content_set(sc, bx);
2575
2576    ck = elm_check_add(win);
2577    elm_object_tooltip_text_set(ck, "Set whether scrollers should bounce<br/>"
2578                                    "when they reach their viewport's edge<br/>"
2579                                    "during a scroll");
2580    elm_object_text_set(ck, "Enable scroll bounce");
2581    evas_object_data_set(win, "scroll_bounce_check", ck);
2582    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, 0.0);
2583    evas_object_size_hint_align_set(ck, EVAS_HINT_FILL, 0.5);
2584    elm_check_state_set(ck, elm_config_scroll_bounce_enabled_get());
2585    elm_box_pack_end(bx, ck);
2586    evas_object_show(ck);
2587
2588    evas_object_smart_callback_add(ck, "changed", sb_change, NULL);
2589
2590    LABEL_FRAME_ADD("<hilight>Scroll bounce friction</>");
2591
2592    sl = elm_slider_add(win);
2593    elm_object_tooltip_text_set(sl, "This is the amount of inertia a <br/>"
2594                                    "scroller will impose at bounce animations");
2595    evas_object_data_set(win, "bounce_friction_slider", sl);
2596    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
2597    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
2598    elm_slider_span_size_set(sl, 120);
2599    elm_slider_unit_format_set(sl, "%1.2f");
2600    elm_slider_indicator_format_set(sl, "%1.2f");
2601    elm_slider_min_max_set(sl, 0.0, 4.0);
2602    elm_slider_value_set(sl, elm_config_scroll_bounce_friction_get());
2603    elm_box_pack_end(bx, sl);
2604    evas_object_show(sl);
2605
2606    evas_object_smart_callback_add(sl, "changed", bf_round, NULL);
2607    evas_object_smart_callback_add(sl, "delay,changed", bf_change, NULL);
2608
2609    sp = elm_separator_add(win);
2610    elm_separator_horizontal_set(sp, EINA_TRUE);
2611    evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0);
2612    evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
2613    elm_box_pack_end(bx, sp);
2614    evas_object_show(sp);
2615
2616    ck = elm_check_add(win);
2617    elm_object_tooltip_text_set(ck, "Set whether scrollers should be<br/>"
2618                                    "draggable from any point in their views");
2619    elm_object_text_set(ck, "Enable thumb scroll");
2620    evas_object_data_set(win, "thumbscroll_check", ck);
2621    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, 0.0);
2622    evas_object_size_hint_align_set(ck, EVAS_HINT_FILL, 0.5);
2623    elm_check_state_set(ck, elm_config_scroll_thumbscroll_enabled_get());
2624    elm_box_pack_end(bx, ck);
2625    evas_object_show(ck);
2626
2627    evas_object_smart_callback_add(ck, "changed", ts_change, NULL);
2628
2629    LABEL_FRAME_ADD("<hilight>Thumb scroll threshold</>");
2630
2631    sl = elm_slider_add(win);
2632    elm_object_tooltip_text_set(sl, "This is the number of pixels one should<br/>"
2633                                    "travel while dragging a scroller's view<br/>"
2634                                    "to actually trigger scrolling");
2635    evas_object_data_set(win, "thumbscroll_threshold_slider", sl);
2636    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
2637    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
2638    elm_slider_span_size_set(sl, 120);
2639    elm_slider_unit_format_set(sl, "%1.0f pixels");
2640    elm_slider_indicator_format_set(sl, "%1.0f");
2641    elm_slider_min_max_set(sl, 8.0, 50.0);
2642    elm_slider_value_set(sl, elm_config_scroll_thumbscroll_threshold_get());
2643    elm_box_pack_end(bx, sl);
2644    evas_object_show(sl);
2645
2646    evas_object_smart_callback_add(sl, "changed", tst_round, NULL);
2647    evas_object_smart_callback_add(sl, "delay,changed", tst_change, NULL);
2648
2649    LABEL_FRAME_ADD("<hilight>Thumb scroll hold threshold</>");
2650
2651    sl = elm_slider_add(win);
2652    elm_object_tooltip_text_set(sl, "This is the number of pixels the range<br/>"
2653                                    "which can be scrolled, while the scroller<br/>"
2654                                    "is holed");
2655    evas_object_data_set(win, "thumbscroll_hold_threshold_slider", sl);
2656    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
2657    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
2658    elm_slider_span_size_set(sl, 120);
2659    elm_slider_unit_format_set(sl, "%1.0f pixels");
2660    elm_slider_indicator_format_set(sl, "%1.0f");
2661    elm_slider_min_max_set(sl, 4.0, 500.0);
2662    elm_slider_value_set(sl, elm_config_scroll_thumbscroll_threshold_get());
2663    elm_box_pack_end(bx, sl);
2664    evas_object_show(sl);
2665
2666    evas_object_smart_callback_add(sl, "changed", tsht_round, NULL);
2667    evas_object_smart_callback_add(sl, "delay,changed", tsht_change, NULL);
2668
2669    LABEL_FRAME_ADD("<hilight>Thumb scroll momentum threshold</>");
2670
2671    sl = elm_slider_add(win);
2672    elm_object_tooltip_text_set(sl, "This is the minimum speed of mouse <br/>"
2673                                    "cursor movement which will trigger<br/>"
2674                                    "list self scrolling animation after a<br/>"
2675                                    "mouse up event (pixels/second)");
2676    evas_object_data_set(win, "ts_momentum_threshold_slider", sl);
2677    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
2678    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
2679    elm_slider_span_size_set(sl, 120);
2680    elm_slider_unit_format_set(sl, "%1.0f pixels/s");
2681    elm_slider_indicator_format_set(sl, "%1.0f");
2682    elm_slider_min_max_set(sl, 10.0, 200.0);
2683    elm_slider_value_set(sl, elm_config_scroll_thumbscroll_momentum_threshold_get());
2684    elm_box_pack_end(bx, sl);
2685    evas_object_show(sl);
2686
2687    evas_object_smart_callback_add(sl, "changed", tsmt_round, NULL);
2688    evas_object_smart_callback_add(sl, "delay,changed", tsmt_change,
2689                                   NULL);
2690
2691    LABEL_FRAME_ADD("<hilight>Thumb scroll friction</>");
2692
2693    sl = elm_slider_add(win);
2694    elm_object_tooltip_text_set(sl, "This is the amount of inertia a<br/>"
2695                                    "scroller will impose at self scrolling<br/>"
2696                                    "animations");
2697    evas_object_data_set(win, "thumbscroll_friction_slider", sl);
2698    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
2699    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
2700    elm_slider_span_size_set(sl, 120);
2701    elm_slider_unit_format_set(sl, "%1.1f");
2702    elm_slider_indicator_format_set(sl, "%1.1f");
2703    elm_slider_min_max_set(sl, 0.0, 15.0);
2704    elm_slider_value_set(sl, elm_config_scroll_thumbscroll_friction_get());
2705    elm_box_pack_end(bx, sl);
2706    evas_object_show(sl);
2707
2708    evas_object_smart_callback_add(sl, "changed", tsf_round, NULL);
2709    evas_object_smart_callback_add(sl, "delay,changed", tsf_change, NULL);
2710
2711    LABEL_FRAME_ADD("<hilight>Thumb scroll border friction</>");
2712
2713    sl = elm_slider_add(win);
2714    elm_object_tooltip_text_set(sl, "This is the amount of lag between your<br/>"
2715                                    "actual mouse cursor dragging movement<br/>"
2716                                    "and a scroller's view movement itself,<br/>"
2717                                    "while pushing it into bounce state<br/>"
2718                                    "manually");
2719    evas_object_data_set(win, "ts_border_friction_slider", sl);
2720    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
2721    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
2722    elm_slider_span_size_set(sl, 120);
2723    elm_slider_unit_format_set(sl, "%1.2f");
2724    elm_slider_indicator_format_set(sl, "%1.2f");
2725    elm_slider_min_max_set(sl, 0.0, 1.0);
2726    elm_slider_value_set(sl, elm_config_scroll_thumbscroll_border_friction_get());
2727    elm_box_pack_end(bx, sl);
2728    evas_object_show(sl);
2729
2730    evas_object_smart_callback_add(sl, "changed", tsbf_round, NULL);
2731    evas_object_smart_callback_add(sl, "delay,changed", tsbf_change, NULL);
2732
2733    LABEL_FRAME_ADD("<hilight>Thumb scroll sensitivity friction</>");
2734
2735    sl = elm_slider_add(win);
2736    elm_object_tooltip_text_set(sl, "This is the sensitivity amount which<br/>"
2737                                    "is be multiplied by the length of mouse<br/>"
2738                                    "dragging.");
2739    evas_object_data_set(win, "ts_sensitivity_friction_slider", sl);
2740    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
2741    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
2742    elm_slider_span_size_set(sl, 120);
2743    elm_slider_unit_format_set(sl, "%1.2f");
2744    elm_slider_indicator_format_set(sl, "%1.2f");
2745    elm_slider_min_max_set(sl, 0.1, 1.0);
2746    elm_slider_value_set(sl, elm_config_scroll_thumbscroll_sensitivity_friction_get());
2747    elm_box_pack_end(bx, sl);
2748    evas_object_show(sl);
2749
2750    evas_object_smart_callback_add(sl, "changed", tssf_round, NULL);
2751    evas_object_smart_callback_add(sl, "delay,changed", tssf_change, NULL);
2752
2753    sp = elm_separator_add(win);
2754    elm_separator_horizontal_set(sp, EINA_TRUE);
2755    evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0);
2756    evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
2757    elm_box_pack_end(bx, sp);
2758    evas_object_show(sp);
2759
2760    LABEL_FRAME_ADD("<hilight>Page scroll friction</>");
2761
2762    sl = elm_slider_add(win);
2763    elm_object_tooltip_text_set(sl, "This is the amount of inertia a<br/>"
2764                                    "paged scroller will impose at<br/>"
2765                                    "page fitting animations");
2766    evas_object_data_set(win, "page_scroll_friction_slider", sl);
2767    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
2768    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
2769    elm_slider_span_size_set(sl, 120);
2770    elm_slider_unit_format_set(sl, "%1.1f");
2771    elm_slider_indicator_format_set(sl, "%1.1f");
2772    elm_slider_min_max_set(sl, 0.0, 5.0);
2773    elm_slider_value_set(sl, elm_config_scroll_page_scroll_friction_get());
2774    elm_box_pack_end(bx, sl);
2775    evas_object_show(sl);
2776
2777    evas_object_smart_callback_add(sl, "changed", ps_round, NULL);
2778    evas_object_smart_callback_add(sl, "delay,changed", ps_change, NULL);
2779
2780    LABEL_FRAME_ADD("<hilight>Bring in scroll friction</>");
2781
2782    sl = elm_slider_add(win);
2783    elm_object_tooltip_text_set(sl, "This is the amount of inertia a<br/>"
2784                                    "scroller will impose at region bring<br/>"
2785                                    "animations");
2786    evas_object_data_set(win, "bring_in_scroll_friction_slider", sl);
2787    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
2788    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
2789    elm_slider_span_size_set(sl, 120);
2790    elm_slider_unit_format_set(sl, "%1.1f");
2791    elm_slider_indicator_format_set(sl, "%1.1f");
2792    elm_slider_min_max_set(sl, 0.0, 5.0);
2793    elm_slider_value_set(sl, elm_config_scroll_bring_in_scroll_friction_get());
2794    elm_box_pack_end(bx, sl);
2795    evas_object_show(sl);
2796
2797    evas_object_smart_callback_add(sl, "changed", bis_round, NULL);
2798    evas_object_smart_callback_add(sl, "delay,changed", bis_change, NULL);
2799
2800    LABEL_FRAME_ADD("<hilight>Zoom scroll friction</>");
2801
2802    sl = elm_slider_add(win);
2803    elm_object_tooltip_text_set(sl, "This is the amount of inertia<br/>"
2804                                    "scrollers will impose at animations<br/>"
2805                                    "triggered by Elementary widgets'<br/>"
2806                                    "zooming API");
2807    evas_object_data_set(win, "zoom_scroll_friction_slider", sl);
2808    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
2809    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
2810    elm_slider_span_size_set(sl, 120);
2811    elm_slider_unit_format_set(sl, "%1.1f");
2812    elm_slider_indicator_format_set(sl, "%1.1f");
2813    elm_slider_min_max_set(sl, 0.0, 5.0);
2814    elm_slider_value_set(sl, elm_config_scroll_zoom_friction_get());
2815    elm_box_pack_end(bx, sl);
2816    evas_object_show(sl);
2817
2818    evas_object_smart_callback_add(sl, "changed", zf_round, NULL);
2819    evas_object_smart_callback_add(sl, "delay,changed", zf_change, NULL);
2820
2821    evas_object_data_set(win, "scrolling", sc);
2822
2823    elm_naviframe_item_simple_push(naviframe, sc);
2824 }
2825
2826 static char *
2827 _engine_name_prettify(const char *engine)
2828 {
2829    char *ret, *ptr;
2830
2831    ret = strdup(engine);
2832    ret[0] -= 0x20;
2833
2834    while ((ptr = strpbrk(ret, "_")))
2835      {
2836         *ptr = ' ';
2837      }
2838
2839    return ret;
2840 }
2841
2842 /* FIXME! ideally, we would trim elm_config.c's _elm_engines list at
2843    build time, making a getter for is as in ecore-evas. */
2844 static Eina_Bool
2845 _elm_engine_supported(const char *engine)
2846 {
2847    const char *engines[] = {
2848       "software_x11",
2849       "fb",
2850       "directfb",
2851       "software_16_x11",
2852       "software_8_x11",
2853       "xrender_x11",
2854       "opengl_x11",
2855       "software_gdi",
2856       "software_16_wince_gdi",
2857       "sdl",
2858       "software_16_sdl",
2859       "opengl_sdl",
2860       "ews",
2861       "opengl_cocoa",
2862       "psl1ght",
2863       "wayland_shm",
2864       "wayland_egl",
2865       NULL
2866    };
2867
2868    unsigned int i;
2869
2870    for (i = 0; engines[i]; i++)
2871      {
2872 #define ENGINE_COMPARE(name) (!strcmp(engines[i], name))
2873         if (ENGINE_COMPARE(engine))
2874           return EINA_TRUE;
2875 #undef ENGINE_COMPARE
2876      }
2877
2878    return EINA_FALSE;
2879 }
2880
2881 static void
2882 _engines_list_fill(Evas_Object *l_widget,
2883                    Eina_List   *e_names)
2884 {
2885    const char *engine, *cur_engine;
2886    void *sel_it = NULL;
2887    Eina_List *l;
2888
2889    if (!e_names)
2890      return;
2891
2892    cur_engine = elm_config_engine_get();
2893
2894    EINA_LIST_FOREACH(e_names, l, engine)
2895      {
2896         const char *label;
2897         Elm_Object_Item *list_it;
2898
2899         if (!_elm_engine_supported(engine))
2900           continue;
2901
2902         label = _engine_name_prettify(engine);
2903
2904         list_it = elm_list_item_append(l_widget, label, NULL, NULL, NULL,
2905                                   strdup(engine));
2906         elm_object_item_del_cb_set(list_it, _engines_list_item_del_cb);
2907         free((void *)label);
2908
2909         if (!strcmp(cur_engine, engine))
2910           sel_it = list_it;
2911      }
2912
2913    if (sel_it) elm_list_item_selected_set(sel_it, EINA_TRUE);
2914    elm_list_go(l_widget);
2915 }
2916
2917 static void
2918 _status_config_rendering(Evas_Object *win,
2919                          Evas_Object *naviframe)
2920 {
2921    Evas_Object *li, *bx, *fr, *sp, *pd, *bt;
2922    Eina_List *engines;
2923
2924    bx = elm_box_add(win);
2925    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2926    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
2927
2928    fr = elm_frame_add(win);
2929    elm_object_text_set(fr, "Available Engines");
2930    evas_object_size_hint_weight_set(fr, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2931    evas_object_size_hint_align_set(fr, EVAS_HINT_FILL, EVAS_HINT_FILL);
2932    elm_box_pack_end(bx, fr);
2933    evas_object_show(fr);
2934
2935    li = elm_list_add(win);
2936    elm_object_content_set(fr, li);
2937    evas_object_size_hint_weight_set(li, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
2938    evas_object_size_hint_align_set(li, EVAS_HINT_FILL, EVAS_HINT_FILL);
2939
2940    engines = ecore_evas_engines_get();
2941    _engines_list_fill(li, engines);
2942    ecore_evas_engines_free(engines);
2943
2944    evas_object_show(li);
2945    evas_object_data_set(win, "engines_list", li);
2946
2947    /////////////////////////////////////////////
2948    sp = elm_separator_add(win);
2949    elm_separator_horizontal_set(sp, EINA_TRUE);
2950    evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0);
2951    evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
2952    elm_box_pack_end(bx, sp);
2953    evas_object_show(sp);
2954
2955    pd = elm_frame_add(win);
2956    elm_object_style_set(pd, "pad_medium");
2957    evas_object_size_hint_weight_set(pd, 0.0, 0.0);
2958    evas_object_size_hint_align_set(pd, 0.5, 0.5);
2959    elm_box_pack_end(bx, pd);
2960    evas_object_show(pd);
2961
2962    bt = elm_button_add(win);
2963    evas_object_smart_callback_add(bt, "clicked", _engine_use, li);
2964    elm_object_text_set(bt, "Use Engine");
2965    evas_object_size_hint_weight_set(bt, 0.0, 0.0);
2966    evas_object_size_hint_align_set(bt, 0.5, 0.5);
2967    elm_object_content_set(pd, bt);
2968    evas_object_show(bt);
2969
2970    evas_object_data_set(win, "rendering", bx);
2971    elm_naviframe_item_simple_push(naviframe, bx);
2972 }
2973
2974 static void
2975 _status_config_caches(Evas_Object *win,
2976                       Evas_Object *naviframe)
2977 {
2978    Evas_Object *lb, *pd, *bx, *sl, *sp, *ck;
2979
2980    bx = elm_box_add(win);
2981    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
2982    evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, 0.5);
2983
2984    LABEL_FRAME_ADD("<hilight>Cache Flush Interval (8 ticks per second)</>");
2985
2986    sl = elm_slider_add(win);
2987    evas_object_data_set(win, "cache_flush_interval_slider", sl);
2988    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
2989    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
2990    elm_slider_span_size_set(sl, 120);
2991    elm_slider_unit_format_set(sl, "%1.0f ticks");
2992    elm_slider_indicator_format_set(sl, "%1.0f");
2993    elm_slider_min_max_set(sl, 8.0, 4096.0);
2994    elm_slider_value_set(sl, elm_config_cache_flush_interval_get());
2995    elm_object_disabled_set(sl, !elm_config_cache_flush_enabled_get());
2996
2997    ck = elm_check_add(win);
2998    evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, 0.0);
2999    evas_object_size_hint_align_set(ck, EVAS_HINT_FILL, 0.5);
3000    elm_object_text_set(ck, "Enable Flushing");
3001    elm_check_state_set(ck, elm_config_cache_flush_enabled_get());
3002    evas_object_smart_callback_add(ck, "changed", cf_enable, sl);
3003    elm_box_pack_end(bx, ck);
3004    evas_object_show(ck);
3005
3006    elm_box_pack_end(bx, sl);
3007    evas_object_show(sl);
3008
3009    evas_object_smart_callback_add(sl, "changed", cf_round, NULL);
3010    evas_object_smart_callback_add(sl, "delay,changed", cf_change, NULL);
3011
3012    sp = elm_separator_add(win);
3013    elm_separator_horizontal_set(sp, EINA_TRUE);
3014    evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0);
3015    evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
3016    elm_box_pack_end(bx, sp);
3017    evas_object_show(sp);
3018
3019    LABEL_FRAME_ADD("<hilight>Font Cache Size</>");
3020
3021    sl = elm_slider_add(win);
3022    evas_object_data_set(win, "font_cache_slider", sl);
3023    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
3024    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
3025    elm_slider_span_size_set(sl, 120);
3026    elm_slider_unit_format_set(sl, "%1.1f MB");
3027    elm_slider_indicator_format_set(sl, "%1.1f");
3028    elm_slider_min_max_set(sl, 0.0, 4.0);
3029    elm_slider_value_set(sl, (double)elm_config_cache_font_cache_size_get() / 1024.0);
3030    elm_box_pack_end(bx, sl);
3031    evas_object_show(sl);
3032
3033    evas_object_smart_callback_add(sl, "changed", fc_round, NULL);
3034    evas_object_smart_callback_add(sl, "delay,changed", fc_change, NULL);
3035
3036    sp = elm_separator_add(win);
3037    elm_separator_horizontal_set(sp, EINA_TRUE);
3038    evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0);
3039    evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
3040    elm_box_pack_end(bx, sp);
3041    evas_object_show(sp);
3042
3043    LABEL_FRAME_ADD("<hilight>Image Cache Size</>");
3044
3045    sl = elm_slider_add(win);
3046    evas_object_data_set(win, "image_cache_slider", sl);
3047    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
3048    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
3049    elm_slider_span_size_set(sl, 120);
3050    elm_slider_unit_format_set(sl, "%1.0f MB");
3051    elm_slider_indicator_format_set(sl, "%1.0f");
3052    elm_slider_min_max_set(sl, 0, 32);
3053    elm_slider_value_set(sl, (double)elm_config_cache_image_cache_size_get() / 1024.0);
3054    elm_box_pack_end(bx, sl);
3055    evas_object_show(sl);
3056
3057    evas_object_smart_callback_add(sl, "changed", ic_round, NULL);
3058    evas_object_smart_callback_add(sl, "delay,changed", ic_change, NULL);
3059
3060    sp = elm_separator_add(win);
3061    elm_separator_horizontal_set(sp, EINA_TRUE);
3062    evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0);
3063    evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
3064    elm_box_pack_end(bx, sp);
3065    evas_object_show(sp);
3066
3067    LABEL_FRAME_ADD("<hilight>Number of Edje Files to Cache</>");
3068
3069    sl = elm_slider_add(win);
3070    evas_object_data_set(win, "edje_file_cache_slider", sl);
3071    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
3072    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
3073    elm_slider_span_size_set(sl, 120);
3074    elm_slider_unit_format_set(sl, "%1.0f files");
3075    elm_slider_indicator_format_set(sl, "%1.0f");
3076    elm_slider_min_max_set(sl, 0, 32);
3077    elm_slider_value_set(sl, elm_config_cache_edje_file_cache_size_get());
3078    elm_box_pack_end(bx, sl);
3079    evas_object_show(sl);
3080
3081    evas_object_smart_callback_add(sl, "changed", efc_round, NULL);
3082    evas_object_smart_callback_add(sl, "delay,changed", efc_change, NULL);
3083
3084    sp = elm_separator_add(win);
3085    elm_separator_horizontal_set(sp, EINA_TRUE);
3086    evas_object_size_hint_weight_set(sp, EVAS_HINT_EXPAND, 0.0);
3087    evas_object_size_hint_align_set(sp, EVAS_HINT_FILL, 0.5);
3088    elm_box_pack_end(bx, sp);
3089    evas_object_show(sp);
3090
3091    LABEL_FRAME_ADD("<hilight>Number of Edje Collections to Cache</>");
3092
3093    sl = elm_slider_add(win);
3094    evas_object_data_set(win, "edje_collection_cache_slider", sl);
3095    evas_object_size_hint_weight_set(sl, EVAS_HINT_EXPAND, 0.0);
3096    evas_object_size_hint_align_set(sl, EVAS_HINT_FILL, 0.5);
3097    elm_slider_span_size_set(sl, 120);
3098    elm_slider_unit_format_set(sl, "%1.0f collections");
3099    elm_slider_indicator_format_set(sl, "%1.0f");
3100    elm_slider_min_max_set(sl, 0, 128);
3101    elm_slider_value_set(sl, elm_config_cache_edje_collection_cache_size_get());
3102    elm_box_pack_end(bx, sl);
3103    evas_object_show(sl);
3104
3105    evas_object_smart_callback_add(sl, "changed", ecc_round, NULL);
3106    evas_object_smart_callback_add(sl, "delay,changed", ecc_change, NULL);
3107
3108    evas_object_data_set(win, "caches", bx);
3109
3110    elm_naviframe_item_simple_push(naviframe, bx);
3111 }
3112
3113 static void
3114 _status_config_full(Evas_Object *win,
3115                     Evas_Object *bx0)
3116 {
3117    Evas_Object *tb, *naviframe;
3118    Elm_Object_Item *tb_sizing, *tb_it;
3119
3120    tb = elm_toolbar_add(win);
3121    elm_toolbar_select_mode_set(tb, ELM_OBJECT_SELECT_MODE_ALWAYS);
3122    elm_toolbar_menu_parent_set(tb, win);
3123    elm_toolbar_homogeneous_set(tb, EINA_FALSE);
3124    evas_object_size_hint_weight_set(tb, EVAS_HINT_EXPAND, 0.0);
3125    evas_object_size_hint_align_set(tb, EVAS_HINT_FILL, EVAS_HINT_FILL);
3126
3127    tb_sizing = elm_toolbar_item_append(tb, "zoom-fit-best", "Sizing",
3128                                     _cf_sizing, win);
3129    elm_toolbar_item_priority_set(tb_sizing, 100);
3130
3131    tb_it = elm_toolbar_item_append(tb, "preferences-desktop-theme", "Theme",
3132                                 _cf_themes, win);
3133    elm_toolbar_item_priority_set(tb_it, 90);
3134
3135    elm_toolbar_item_append(tb, "preferences-desktop-font", "Fonts",
3136                            _cf_fonts, win);
3137
3138    tb_it = elm_toolbar_item_append(tb, "system-users", "Profiles",
3139                                 _cf_profiles, win);
3140    elm_toolbar_item_priority_set(tb_it, 90);
3141
3142    elm_toolbar_item_append(tb, "system-run", "Scrolling", _cf_scrolling, win);
3143    elm_toolbar_item_append(tb, "video-display", "Rendering",
3144                            _cf_rendering, win);
3145    elm_toolbar_item_append(tb, "appointment-new", "Caches", _cf_caches, win);
3146    elm_toolbar_item_append(tb, "stock_spellcheck", "Access", _cf_access, win);
3147    elm_toolbar_item_append(tb, "clear-selection-check", "Selection", _cf_selection, win);
3148
3149    elm_box_pack_end(bx0, tb);
3150    evas_object_show(tb);
3151
3152    naviframe = elm_naviframe_add(win);
3153    evas_object_size_hint_align_set(naviframe, EVAS_HINT_FILL, EVAS_HINT_FILL);
3154    evas_object_size_hint_weight_set(naviframe, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3155    evas_object_data_set(win, "naviframe", naviframe);
3156
3157    _status_config_themes(win, naviframe);
3158    _status_config_fonts(win, naviframe);
3159    _status_config_profiles(win, naviframe);
3160    _status_config_rendering(win, naviframe);
3161    _status_config_scrolling(win, naviframe);
3162    _status_config_caches(win, naviframe);
3163    _status_config_access(win, naviframe);
3164    _status_config_selection(win, naviframe);
3165    _status_config_sizing(win, naviframe); // Note: call this at the end.
3166
3167    // FIXME uncomment after flip style fix, please
3168    //elm_object_style_set(naviframe, "flip");
3169    elm_toolbar_item_selected_set(tb_sizing, EINA_TRUE);
3170    elm_box_pack_end(bx0, naviframe);
3171    evas_object_show(naviframe);
3172 }
3173
3174 static void
3175 win_create(void)
3176 {
3177    Evas_Object *win, *bx0;
3178
3179    win = elm_win_util_standard_add("main", "Elementary Config");
3180    ecore_event_handler_add(ELM_EVENT_CONFIG_ALL_CHANGED, _config_all_changed,
3181                            win);
3182    evas_object_smart_callback_add(win, "delete,request", config_exit, NULL);
3183
3184    bx0 = elm_box_add(win);
3185    evas_object_size_hint_weight_set(bx0, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
3186    elm_win_resize_object_add(win, bx0);
3187    evas_object_show(bx0);
3188
3189    if (!interactive) _status_basic(win, bx0);
3190    else if (0)
3191      _status_config(win, bx0);
3192    else _status_config_full(win, bx0);
3193
3194    evas_object_resize(win, 320, 480);
3195    evas_object_show(win);
3196 }
3197
3198 static Eina_Bool
3199 _exit_timer(void *data __UNUSED__)
3200 {
3201    elm_exit();
3202    return ECORE_CALLBACK_CANCEL;
3203 }
3204
3205 /* this is your elementary main function - it MUST be called IMMEDIATELY
3206  * after elm_init() and MUST be passed argc and argv, and MUST be called
3207  * elm_main and not be static - must be a visible symbol with EAPI infront */
3208 EAPI_MAIN int
3209 elm_main(int    argc,
3210          char **argv)
3211 {
3212    int i;
3213
3214    elm_app_info_set(elm_main, "elementary", "images/logo.png");
3215    elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
3216    elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
3217
3218    for (i = 1; i < argc; i++)
3219      {
3220         if (!strcmp(argv[i], "-h"))
3221           {
3222              printf("Usage:\n"
3223                     "  -h                This help\n"
3224                     "  -q                Quiet mode (dont show window)\n"
3225                     "  -t THEME          Set theme to THEME (ELM_THEME spec)\n"
3226                     "  -f SIZE           Set finger size to SIZE pixels\n"
3227                     "  -s SCALE          Set scale factor to SCALE\n"
3228                     );
3229           }
3230         else if (!strcmp(argv[i], "-q"))
3231           {
3232              quiet = 1;
3233              interactive = 0;
3234           }
3235         else if ((!strcmp(argv[i], "-t")) && (i < argc - 1))
3236           {
3237              i++;
3238              theme_set = argv[i];
3239              interactive = 0;
3240           }
3241         else if ((!strcmp(argv[i], "-f")) && (i < argc - 1))
3242           {
3243              i++;
3244              finger_size_set = argv[i];
3245              interactive = 0;
3246           }
3247         else if ((!strcmp(argv[i], "-s")) && (i < argc - 1))
3248           {
3249              i++;
3250              scale_set = argv[i];
3251              interactive = 0;
3252           }
3253      }
3254    /* put here any init code specific to this app like parsing args, etc. */
3255    if (!quiet)
3256      {
3257 #ifdef ELM_EFREET
3258         elm_need_efreet();
3259 #endif
3260         win_create(); /* create main window */
3261         if (!interactive)
3262           ecore_timer_add(2.0, _exit_timer, NULL);
3263      }
3264    if (!interactive)
3265      {
3266         if (theme_set) elm_theme_set(NULL, theme_set);
3267         if (finger_size_set) elm_config_finger_size_set(atoi(finger_size_set));
3268         if (scale_set)  elm_config_scale_set(atof(scale_set));
3269
3270         elm_config_all_flush();
3271
3272         if (quiet) elm_exit();
3273      }
3274    elm_run(); /* and run the program now and handle all events, etc. */
3275    /* if the mainloop that elm_run() runs exists, we exit the app */
3276    elm_shutdown(); /* clean up and shut down */
3277    /* exit code */
3278    return 0;
3279 }
3280
3281 #endif
3282 /* All emelentary apps should use this. Put it right after elm_main() */
3283 ELM_MAIN()