2 # include "elementary_config.h"
9 #include <Elementary.h>
13 Elm_Config *_elm_config = NULL;
14 char *_elm_profile = NULL;
15 static Eet_Data_Descriptor *_config_edd = NULL;
16 static Eet_Data_Descriptor *_config_font_overlay_edd = NULL;
18 static Ecore_Poller *_elm_cache_flush_poller = NULL;
20 const char *_elm_engines[] = {
29 "software_16_wince_gdi",
36 /* whenever you want to add a new text class support into Elementary,
37 declare it both here and in the (default) theme */
38 static const Elm_Text_Class _elm_text_classes[] = {
39 {"button", "Button Labels"},
40 {"label", "Text Labels"},
41 {"entry", "Text Entries"},
42 {"title_bar", "Title Bar"},
43 {"list_item", "List Items"},
44 {"grid_item", "Grid Items"},
45 {"toolbar_item", "Toolbar Items"},
46 {"menu_item", "Menu Items"},
50 static void _desc_init(void);
51 static void _desc_shutdown(void);
52 static void _profile_fetch_from_conf(void);
53 static void _config_free(void);
54 static void _config_apply(void);
55 static Elm_Config *_config_user_load(void);
56 static Elm_Config *_config_system_load(void);
57 static void _config_load(void);
58 static void _config_update(void);
59 static void _env_get(void);
60 static size_t _elm_data_dir_snprintf(char *dst,
64 static size_t _elm_user_dir_snprintf(char *dst,
69 #define ELM_CONFIG_VAL(edd, type, member, dtype) \
70 EET_DATA_DESCRIPTOR_ADD_BASIC(edd, type, #member, member, dtype)
71 #define ELM_CONFIG_LIST(edd, type, member, eddtype) \
72 EET_DATA_DESCRIPTOR_ADD_LIST(edd, type, #member, member, eddtype)
74 #ifdef HAVE_ELEMENTARY_X
75 static Ecore_Event_Handler *_prop_change_handler = NULL;
76 static Ecore_X_Window _root_1st = 0;
78 static Ecore_X_Atom _atom[ATOM_COUNT];
79 static Ecore_X_Atom _atom_config = 0;
80 static const char *_atom_names[ATOM_COUNT] =
82 "ENLIGHTENMENT_SCALE",
83 "ENLIGHTENMENT_FINGER_SIZE",
84 "ENLIGHTENMENT_THEME",
85 "ENLIGHTENMENT_PROFILE",
86 "ENLIGHTENMENT_FONT_OVERLAY",
87 "ENLIGHTENMENT_CACHE_FLUSH_INTERVAL",
88 "ENLIGHTENMENT_CACHE_FLUSH_ENABLE",
89 "ENLIGHTENMENT_FONT_CACHE",
90 "ENLIGHTENMENT_IMAGE_CACHE",
91 "ENLIGHTENMENT_EDJE_FILE_CACHE",
92 "ENLIGHTENMENT_EDJE_COLLECTION_CACHE",
93 "ENLIGHTENMENT_THUMBSCROLL_BOUNCE_ENABLE",
94 "ENLIGHTENMENT_THUMBSCROLL_BOUNCE_FRICTION",
95 "ENLIGHTENMENT_THUMBSCROLL_ENABLE",
96 "ENLIGHTENMENT_THUMBSCROLL_THRESHOLD",
97 "ENLIGHTENMENT_THUMBSCROLL_MOMENTUM_THRESHOLD",
98 "ENLIGHTENMENT_THUMBSCROLL_FRICTION",
99 "ENLIGHTENMENT_THUMBSCROLL_BORDER_FRICTION",
100 "ENLIGHTENMENT_THUMBSCROLL_PAGE_SCROLL_FRICTION",
101 "ENLIGHTENMENT_THUMBSCROLL_BRING_IN_SCROLL_FRICTION",
102 "ENLIGHTENMENT_THUMBSCROLL_ZOOM_FRICTION",
103 "ENLIGHTENMENT_INPUT_PANEL",
104 "ENLIGHTENMENT_AUTOCAPITAL_ALLOW",
105 "ENLIGHTENMENT_AUTOPERIOD_ALLOW",
106 "ENLIGHTENMENT_CONFIG"
108 #define ATOM_E_SCALE 0
109 #define ATOM_E_FINGER_SIZE 1
110 #define ATOM_E_THEME 2
111 #define ATOM_E_PROFILE 3
112 #define ATOM_E_FONT_OVERLAY 4
113 #define ATOM_E_CACHE_FLUSH_INTERVAL 5
114 #define ATOM_E_CACHE_FLUSH_ENABLE 6
115 #define ATOM_E_FONT_CACHE 7
116 #define ATOM_E_IMAGE_CACHE 8
117 #define ATOM_E_EDJE_FILE_CACHE 9
118 #define ATOM_E_EDJE_COLLECTION_CACHE 10
119 #define ATOM_E_THUMBSCROLL_BOUNCE_ENABLE 11
120 #define ATOM_E_THUMBSCROLL_BOUNCE_FRICTION 12
121 #define ATOM_E_THUMBSCROLL_ENABLE 13
122 #define ATOM_E_THUMBSCROLL_THRESHOLD 14
123 #define ATOM_E_THUMBSCROLL_MOMENTUM_THRESHOLD 15
124 #define ATOM_E_THUMBSCROLL_FRICTION 16
125 #define ATOM_E_THUMBSCROLL_BORDER_FRICTION 17
126 #define ATOM_E_THUMBSCROLL_PAGE_SCROLL_FRICTION 18
127 #define ATOM_E_THUMBSCROLL_BRING_IN_SCROLL_FRICTION 19
128 #define ATOM_E_THUMBSCROLL_ZOOM_FRICTION 20
129 #define ATOM_E_CONFIG 21
130 #define ATOM_E_INPUT_PANEL 22
131 #define ATOM_E_AUTOCAPITAL_ALLOW 23
132 #define ATOM_E_AUTOPERIOD_ALLOW 24
134 static Eina_Bool _prop_config_get(void);
135 static Eina_Bool _prop_change(void *data __UNUSED__,
136 int ev_type __UNUSED__,
140 _prop_config_get(void)
145 unsigned char *data = NULL;
146 Elm_Config *config_data;
148 snprintf(buf, sizeof(buf), "ENLIGHTENMENT_CONFIG_%s", _elm_profile);
149 atom = ecore_x_atom_get(buf);
151 if (!ecore_x_window_prop_property_get(_root_1st,
152 atom, _atom[ATOM_E_CONFIG],
155 if (!ecore_x_window_prop_property_get(_root_1st,
156 _atom[ATOM_E_CONFIG],
157 _atom[ATOM_E_CONFIG],
161 _atom_config = _atom[ATOM_E_CONFIG];
170 config_data = eet_data_descriptor_decode(_config_edd, data, size);
172 if (!config_data) return EINA_FALSE;
174 /* What do we do on version mismatch when someone changes the
175 * config in the rootwindow? */
176 /* Most obvious case, new version and we are still linked to
177 * whatever was there before, we just ignore until user restarts us */
178 if (config_data->config_version > ELM_CONFIG_VERSION)
180 /* What in the case the version is older? Do we even support those
181 * cases or we only check for equality above? */
184 _elm_config = config_data;
186 _elm_config_font_overlay_apply();
193 _prop_change(void *data __UNUSED__,
194 int ev_type __UNUSED__,
197 Ecore_X_Event_Window_Property *event = ev;
199 if (event->win == _root_1st)
201 if (event->atom == _atom[ATOM_E_SCALE])
203 unsigned int val = 1000;
205 if (ecore_x_window_prop_card32_get(event->win,
211 pscale = _elm_config->scale;
212 if (val > 0) _elm_config->scale = (double)val / 1000.0;
213 if (pscale != _elm_config->scale)
220 else if (event->atom == _atom[ATOM_E_FINGER_SIZE])
222 unsigned int val = 1000;
224 if (ecore_x_window_prop_card32_get(event->win,
230 pfinger_size = _elm_config->finger_size;
231 _elm_config->finger_size = val;
232 if (pfinger_size != _elm_config->finger_size)
239 else if (event->atom == _atom[ATOM_E_THEME])
243 val = ecore_x_window_prop_string_get(event->win,
245 eina_stringshare_replace(&_elm_config->theme, val);
248 _elm_theme_parse(NULL, val);
254 else if (event->atom == _atom[ATOM_E_PROFILE])
258 val = ecore_x_window_prop_string_get(event->win,
266 if (strcmp(_elm_profile, val)) changed = 1;
272 if (!_prop_config_get())
277 _elm_config_font_overlay_apply();
283 else if (event->atom == _atom[ATOM_E_FONT_OVERLAY])
285 unsigned int val = 1000;
287 if (ecore_x_window_prop_card32_get(event->win,
294 _elm_config_font_overlay_apply();
298 else if (event->atom == _atom[ATOM_E_CACHE_FLUSH_INTERVAL])
300 unsigned int val = 1000;
302 if (ecore_x_window_prop_card32_get(event->win,
306 int cache_flush_interval;
308 cache_flush_interval = _elm_config->cache_flush_poll_interval;
309 _elm_config->cache_flush_poll_interval = val;
310 if (cache_flush_interval !=
311 _elm_config->cache_flush_poll_interval)
315 else if (event->atom == _atom[ATOM_E_CACHE_FLUSH_ENABLE])
317 unsigned int val = 1000;
319 if (ecore_x_window_prop_card32_get(event->win,
323 _elm_config->cache_flush_enable = !!val;
327 else if (event->atom == _atom[ATOM_E_FONT_CACHE])
329 unsigned int val = 1000;
331 if (ecore_x_window_prop_card32_get(event->win,
337 font_cache = _elm_config->font_cache;
338 _elm_config->font_cache = val;
339 if (font_cache != _elm_config->font_cache)
343 else if (event->atom == _atom[ATOM_E_IMAGE_CACHE])
345 unsigned int val = 1000;
347 if (ecore_x_window_prop_card32_get(event->win,
353 image_cache = _elm_config->image_cache;
354 _elm_config->image_cache = val;
355 if (image_cache != _elm_config->image_cache)
359 else if (event->atom == _atom[ATOM_E_EDJE_FILE_CACHE])
361 unsigned int val = 1000;
363 if (ecore_x_window_prop_card32_get(event->win,
369 edje_file_cache = _elm_config->edje_cache;
370 _elm_config->edje_cache = val;
371 if (edje_file_cache != _elm_config->edje_cache)
375 else if (event->atom == _atom[ATOM_E_EDJE_COLLECTION_CACHE])
377 unsigned int val = 1000;
379 if (ecore_x_window_prop_card32_get(event->win,
383 int edje_collection_cache;
385 edje_collection_cache = _elm_config->edje_collection_cache;
386 _elm_config->edje_collection_cache = val;
387 if (edje_collection_cache !=
388 _elm_config->edje_collection_cache)
392 else if (event->atom == _atom[ATOM_E_THUMBSCROLL_BOUNCE_ENABLE])
394 unsigned int val = 1000;
396 if (ecore_x_window_prop_card32_get(event->win,
400 _elm_config->thumbscroll_bounce_enable = !!val;
403 else if (event->atom == _atom[ATOM_E_THUMBSCROLL_BOUNCE_FRICTION])
405 unsigned int val = 1000;
407 if (ecore_x_window_prop_card32_get(event->win,
412 _elm_config->thumbscroll_bounce_friction =
413 (double)val / 1000.0;
416 else if (event->atom == _atom[ATOM_E_THUMBSCROLL_ENABLE])
418 unsigned int val = 1000;
420 if (ecore_x_window_prop_card32_get(event->win,
424 _elm_config->thumbscroll_enable = !!val;
427 else if (event->atom == _atom[ATOM_E_THUMBSCROLL_THRESHOLD])
429 unsigned int val = 1000;
431 if (ecore_x_window_prop_card32_get(event->win,
435 if (val > 0) _elm_config->thumbscroll_threshold = val;
438 else if (event->atom == _atom[ATOM_E_THUMBSCROLL_MOMENTUM_THRESHOLD])
440 unsigned int val = 1000;
442 if (ecore_x_window_prop_card32_get(event->win,
446 _elm_config->thumbscroll_momentum_threshold =
447 (double)val / 1000.0;
450 else if (event->atom == _atom[ATOM_E_THUMBSCROLL_FRICTION])
452 unsigned int val = 1000;
454 if (ecore_x_window_prop_card32_get(event->win,
458 _elm_config->thumbscroll_friction = (double)val / 1000.0;
461 else if (event->atom == _atom[ATOM_E_THUMBSCROLL_BORDER_FRICTION])
463 unsigned int val = 1000;
465 if (ecore_x_window_prop_card32_get(event->win,
469 _elm_config->thumbscroll_border_friction =
470 (double)val / 1000.0;
473 else if (event->atom == _atom[ATOM_E_THUMBSCROLL_PAGE_SCROLL_FRICTION])
475 unsigned int val = 1000;
477 if (ecore_x_window_prop_card32_get(event->win,
481 _elm_config->page_scroll_friction =
482 (double)val / 1000.0;
485 else if (event->atom ==
486 _atom[ATOM_E_THUMBSCROLL_BRING_IN_SCROLL_FRICTION])
488 unsigned int val = 1000;
490 if (ecore_x_window_prop_card32_get(event->win,
494 _elm_config->bring_in_scroll_friction =
495 (double)val / 1000.0;
498 else if (event->atom ==
499 _atom[ATOM_E_THUMBSCROLL_ZOOM_FRICTION])
501 unsigned int val = 1000;
503 if (ecore_x_window_prop_card32_get(event->win,
507 _elm_config->zoom_friction = (double)val / 1000.0;
510 else if (event->atom == _atom[ATOM_E_INPUT_PANEL])
512 unsigned int val = 0;
514 if (ecore_x_window_prop_card32_get(event->win,
518 int input_panel_enable;
520 input_panel_enable = _elm_config->input_panel_enable;
521 _elm_config->input_panel_enable = val;
522 if (input_panel_enable != _elm_config->input_panel_enable)
524 edje_input_panel_enabled_set(_elm_config->input_panel_enable);
528 else if (event->atom == _atom[ATOM_E_AUTOCAPITAL_ALLOW])
530 unsigned int val = 0;
532 if (ecore_x_window_prop_card32_get(event->win,
536 int autocapital_allow;
538 autocapital_allow = _elm_config->autocapital_allow;
539 _elm_config->autocapital_allow = val;
540 if (autocapital_allow != _elm_config->autocapital_allow)
542 edje_autocapitalization_allow_set(_elm_config->autocapital_allow);
546 else if (event->atom == _atom[ATOM_E_AUTOPERIOD_ALLOW])
548 unsigned int val = 0;
550 if (ecore_x_window_prop_card32_get(event->win,
554 int autoperiod_allow;
556 autoperiod_allow = _elm_config->autoperiod_allow;
557 _elm_config->autoperiod_allow = val;
558 if (autoperiod_allow != _elm_config->autoperiod_allow)
560 edje_autoperiod_allow_set(_elm_config->autoperiod_allow);
564 else if (((_atom_config > 0) && (event->atom == _atom_config)) ||
565 (event->atom == _atom[ATOM_E_CONFIG]))
570 return ECORE_CALLBACK_PASS_ON;
578 Eet_Data_Descriptor_Class eddc;
580 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Config);
581 eddc.func.str_direct_alloc = NULL;
582 eddc.func.str_direct_free = NULL;
584 _config_edd = eet_data_descriptor_file_new(&eddc);
587 printf("EEEK! eet_data_descriptor_file_new() failed\n");
591 memset(&eddc, 0, sizeof(eddc)); /* just in case... */
592 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Font_Overlay);
593 eddc.func.str_direct_alloc = NULL;
594 eddc.func.str_direct_free = NULL;
596 _config_font_overlay_edd = eet_data_descriptor_stream_new(&eddc);
597 if (!_config_font_overlay_edd)
599 printf("EEEK! eet_data_descriptor_stream_new() failed\n");
600 eet_data_descriptor_free(_config_edd);
603 #define T_INT EET_T_INT
604 #define T_DOUBLE EET_T_DOUBLE
605 #define T_STRING EET_T_STRING
606 #define T_UCHAR EET_T_UCHAR
608 #define T Elm_Font_Overlay
609 #define D _config_font_overlay_edd
610 ELM_CONFIG_VAL(D, T, text_class, EET_T_STRING);
611 ELM_CONFIG_VAL(D, T, font, EET_T_STRING);
612 ELM_CONFIG_VAL(D, T, size, EET_T_INT);
617 #define D _config_edd
618 ELM_CONFIG_VAL(D, T, config_version, T_INT);
619 ELM_CONFIG_VAL(D, T, engine, T_STRING);
620 ELM_CONFIG_VAL(D, T, vsync, T_UCHAR);
621 ELM_CONFIG_VAL(D, T, thumbscroll_enable, T_UCHAR);
622 ELM_CONFIG_VAL(D, T, thumbscroll_threshold, T_INT);
623 ELM_CONFIG_VAL(D, T, thumbscroll_momentum_threshold, T_DOUBLE);
624 ELM_CONFIG_VAL(D, T, thumbscroll_friction, T_DOUBLE);
625 ELM_CONFIG_VAL(D, T, thumbscroll_bounce_friction, T_DOUBLE);
626 ELM_CONFIG_VAL(D, T, thumbscroll_border_friction, T_DOUBLE);
627 ELM_CONFIG_VAL(D, T, page_scroll_friction, T_DOUBLE);
628 ELM_CONFIG_VAL(D, T, bring_in_scroll_friction, T_DOUBLE);
629 ELM_CONFIG_VAL(D, T, zoom_friction, T_DOUBLE);
630 ELM_CONFIG_VAL(D, T, thumbscroll_bounce_enable, T_UCHAR);
631 ELM_CONFIG_VAL(D, T, scroll_smooth_time_interval, T_DOUBLE);
632 ELM_CONFIG_VAL(D, T, scroll_smooth_amount, T_DOUBLE);
633 ELM_CONFIG_VAL(D, T, scroll_smooth_history_weight, T_DOUBLE);
634 ELM_CONFIG_VAL(D, T, scroll_smooth_future_time, T_DOUBLE);
635 ELM_CONFIG_VAL(D, T, scroll_smooth_time_window, T_DOUBLE);
636 ELM_CONFIG_VAL(D, T, scale, T_DOUBLE);
637 ELM_CONFIG_VAL(D, T, bgpixmap, T_INT);
638 ELM_CONFIG_VAL(D, T, compositing, T_INT);
639 /* EET_DATA_DESCRIPTOR_ADD_LIST(D, T, "font_dirs", font_dirs, sub_edd); */
640 ELM_CONFIG_LIST(D, T, font_overlays, _config_font_overlay_edd);
641 ELM_CONFIG_VAL(D, T, font_hinting, T_INT);
642 ELM_CONFIG_VAL(D, T, cache_flush_poll_interval, T_INT);
643 ELM_CONFIG_VAL(D, T, cache_flush_enable, T_UCHAR);
644 ELM_CONFIG_VAL(D, T, image_cache, T_INT);
645 ELM_CONFIG_VAL(D, T, font_cache, T_INT);
646 ELM_CONFIG_VAL(D, T, edje_cache, T_INT);
647 ELM_CONFIG_VAL(D, T, edje_collection_cache, T_INT);
648 ELM_CONFIG_VAL(D, T, finger_size, T_INT);
649 ELM_CONFIG_VAL(D, T, fps, T_DOUBLE);
650 ELM_CONFIG_VAL(D, T, theme, T_STRING);
651 ELM_CONFIG_VAL(D, T, modules, T_STRING);
652 ELM_CONFIG_VAL(D, T, tooltip_delay, T_DOUBLE);
653 ELM_CONFIG_VAL(D, T, cursor_engine_only, T_UCHAR);
654 ELM_CONFIG_VAL(D, T, focus_highlight_enable, T_UCHAR);
655 ELM_CONFIG_VAL(D, T, focus_highlight_animate, T_UCHAR);
656 ELM_CONFIG_VAL(D, T, toolbar_shrink_mode, T_INT);
657 ELM_CONFIG_VAL(D, T, fileselector_expand_enable, T_UCHAR);
658 ELM_CONFIG_VAL(D, T, inwin_dialogs_enable, T_UCHAR);
659 ELM_CONFIG_VAL(D, T, icon_size, T_INT);
660 ELM_CONFIG_VAL(D, T, longpress_timeout, T_DOUBLE);
661 ELM_CONFIG_VAL(D, T, effect_enable, T_UCHAR);
662 ELM_CONFIG_VAL(D, T, desktop_entry, T_UCHAR);
663 ELM_CONFIG_VAL(D, T, input_panel_enable, T_INT);
664 ELM_CONFIG_VAL(D, T, password_show_last, T_UCHAR);
665 ELM_CONFIG_VAL(D, T, password_show_last_timeout, T_DOUBLE);
679 eet_data_descriptor_free(_config_edd);
683 if (_config_font_overlay_edd)
685 eet_data_descriptor_free(_config_font_overlay_edd);
686 _config_font_overlay_edd = NULL;
691 _sort_files_cb(const void *f1,
694 return strcmp(f1, f2);
698 _elm_config_current_profile_get(void)
704 _elm_data_dir_snprintf(char *dst,
709 size_t data_dir_len, off;
712 data_dir_len = eina_strlcpy(dst, _elm_data_dir, size);
714 off = data_dir_len + 1;
719 dst[data_dir_len] = '/';
721 off = off + vsnprintf(dst + off, size - off, fmt, ap);
729 _elm_user_dir_snprintf(char *dst,
735 size_t user_dir_len, off;
739 home = evil_homedir_get();
741 home = getenv("HOME");
746 user_dir_len = eina_str_join_len(dst, size, '/', home, strlen(home),
747 ".elementary", sizeof(".elementary") - 1);
749 off = user_dir_len + 1;
754 dst[user_dir_len] = '/';
756 off = off + vsnprintf(dst + off, size - off, fmt, ap);
764 _elm_config_profile_dir_get(const char *prof,
772 _elm_user_dir_snprintf(buf, sizeof(buf), "config/%s", prof);
774 if (ecore_file_is_dir(buf))
780 snprintf(buf, sizeof(buf), "%s/config/%s", _elm_data_dir, prof);
782 if (ecore_file_is_dir(buf))
789 _elm_config_font_overlays_list(void)
791 return _elm_config->font_overlays;
795 _elm_config_font_overlay_set(const char *text_class,
799 Elm_Font_Overlay *efd;
802 EINA_LIST_FOREACH(_elm_config->font_overlays, l, efd)
804 if (strcmp(efd->text_class, text_class))
807 if (efd->font) eina_stringshare_del(efd->font);
808 efd->font = eina_stringshare_add(font);
810 _elm_config->font_overlays =
811 eina_list_promote_list(_elm_config->font_overlays, l);
815 /* the text class doesn't exist */
816 efd = calloc(1, sizeof(Elm_Font_Overlay));
817 efd->text_class = eina_stringshare_add(text_class);
818 efd->font = eina_stringshare_add(font);
821 _elm_config->font_overlays = eina_list_prepend(_elm_config->font_overlays,
826 _elm_config_font_overlay_remove(const char *text_class)
828 Elm_Font_Overlay *efd;
831 EINA_LIST_FOREACH(_elm_config->font_overlays, l, efd)
833 if (strcmp(efd->text_class, text_class))
836 _elm_config->font_overlays =
837 eina_list_remove_list(_elm_config->font_overlays, l);
838 if (efd->text_class) eina_stringshare_del(efd->text_class);
839 if (efd->font) eina_stringshare_del(efd->font);
847 _elm_config_font_overlay_apply(void)
849 Elm_Font_Overlay *efd;
853 for (i = 0; _elm_text_classes[i].desc; i++)
854 edje_text_class_del(_elm_text_classes[i].name);
856 EINA_LIST_FOREACH(_elm_config->font_overlays, l, efd)
857 edje_text_class_set(efd->text_class, efd->font, efd->size);
861 _elm_config_text_classes_get(void)
863 Eina_List *ret = NULL;
866 for (i = 0; _elm_text_classes[i].desc; i++)
869 tc = malloc(sizeof(*tc));
871 *tc = _elm_text_classes[i];
873 ret = eina_list_append(ret, tc);
880 _elm_config_text_classes_free(Eina_List *l)
884 EINA_LIST_FREE(l, tc)
889 _elm_config_profiles_list(void)
891 const Eina_File_Direct_Info *info;
892 Eina_List *flist = NULL;
893 Eina_Iterator *file_it;
898 len = _elm_user_dir_snprintf(buf, sizeof(buf), "config");
900 file_it = eina_file_direct_ls(buf);
907 len = sizeof(buf) - len;
909 EINA_ITERATOR_FOREACH(file_it, info)
911 if (info->name_length >= len)
914 if (info->type == EINA_FILE_DIR)
917 eina_list_sorted_insert(flist, _sort_files_cb,
918 eina_stringshare_add(info->path +
923 eina_iterator_free(file_it);
926 len = eina_str_join_len(buf, sizeof(buf), '/', _elm_data_dir,
927 strlen(_elm_data_dir), "config",
928 sizeof("config") - 1);
930 file_it = eina_file_direct_ls(buf);
937 len = sizeof(buf) - len;
938 EINA_ITERATOR_FOREACH(file_it, info)
940 if (info->name_length >= len)
950 EINA_LIST_FOREACH(flist, l, tmp)
951 if (!strcmp(info->path + info->name_start, tmp))
956 eina_list_sorted_insert(flist, _sort_files_cb,
957 eina_stringshare_add(info->path +
968 eina_iterator_free(file_it);
971 EINA_LIST_FREE(flist, dir)
972 eina_stringshare_del(dir);
978 _profile_fetch_from_conf(void)
980 char buf[PATH_MAX], *p, *s;
984 _elm_profile = strdup("default");
986 // if env var - use profile without question
987 s = getenv("ELM_PROFILE");
991 _elm_profile = strdup(s);
996 _elm_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
997 ef = eet_open(buf, EET_FILE_MODE_READ);
1000 p = eet_read(ef, "config", &len);
1004 _elm_profile = malloc(len + 1);
1005 memcpy(_elm_profile, p, len);
1006 _elm_profile[len] = 0;
1015 _elm_data_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
1016 ef = eet_open(buf, EET_FILE_MODE_READ);
1019 p = eet_read(ef, "config", &len);
1023 _elm_profile = malloc(len + 1);
1024 memcpy(_elm_profile, p, len);
1025 _elm_profile[len] = 0;
1035 Elm_Font_Overlay *fo;
1036 const char *fontdir;
1038 if (!_elm_config) return;
1039 EINA_LIST_FREE(_elm_config->font_dirs, fontdir)
1041 eina_stringshare_del(fontdir);
1043 if (_elm_config->engine) eina_stringshare_del(_elm_config->engine);
1044 EINA_LIST_FREE(_elm_config->font_overlays, fo)
1046 if (fo->text_class) eina_stringshare_del(fo->text_class);
1047 if (fo->font) eina_stringshare_del(fo->font);
1050 if (_elm_config->theme) eina_stringshare_del(_elm_config->theme);
1051 if (_elm_config->modules) eina_stringshare_del(_elm_config->modules);
1059 _elm_theme_parse(NULL, _elm_config->theme);
1060 ecore_animator_frametime_set(1.0 / _elm_config->fps);
1064 _config_sub_apply(void)
1066 edje_frametime_set(1.0 / _elm_config->fps);
1067 edje_scale_set(_elm_config->scale);
1068 edje_password_show_last_set(_elm_config->password_show_last);
1069 edje_password_show_last_timeout_set(_elm_config->password_show_last_timeout);
1070 if (_elm_config->modules) _elm_module_parse(_elm_config->modules);
1071 edje_input_panel_enabled_set(_elm_config->input_panel_enable);
1072 edje_autocapitalization_allow_set(_elm_config->autocapital_allow);
1073 edje_autoperiod_allow_set(_elm_config->autoperiod_allow);
1074 edje_password_show_last_set(_elm_config->password_show_last);
1075 edje_password_show_last_timeout_set(_elm_config->password_show_last_timeout);
1076 if (_elm_config->modules) _elm_module_parse(_elm_config->modules);
1080 _elm_cache_flush_cb(void *data __UNUSED__)
1083 return ECORE_CALLBACK_RENEW;
1086 /* kind of abusing this call right now -- shared between all of those
1087 * properties -- but they are not meant to be called that periodically
1097 EINA_LIST_FOREACH(_elm_win_list, l, win)
1099 Evas *e = evas_object_evas_get(win);
1100 evas_image_cache_set(e, _elm_config->image_cache * 1024);
1101 evas_font_cache_set(e, _elm_config->font_cache * 1024);
1103 edje_file_cache_set(_elm_config->edje_cache);
1104 edje_collection_cache_set(_elm_config->edje_collection_cache);
1106 if (_elm_cache_flush_poller)
1108 ecore_poller_del(_elm_cache_flush_poller);
1109 _elm_cache_flush_poller = NULL;
1111 if (_elm_config->cache_flush_enable)
1113 if (_elm_config->cache_flush_poll_interval > 0)
1115 _elm_cache_flush_poller =
1116 ecore_poller_add(ECORE_POLLER_CORE,
1117 _elm_config->cache_flush_poll_interval,
1118 _elm_cache_flush_cb, NULL);
1124 _config_user_load(void)
1126 Elm_Config *cfg = NULL;
1130 _elm_user_dir_snprintf(buf, sizeof(buf), "config/%s/base.cfg",
1133 ef = eet_open(buf, EET_FILE_MODE_READ);
1136 cfg = eet_data_read(ef, _config_edd, "config");
1143 _config_system_load(void)
1145 Elm_Config *cfg = NULL;
1149 _elm_data_dir_snprintf(buf, sizeof(buf), "config/%s/base.cfg",
1152 ef = eet_open(buf, EET_FILE_MODE_READ);
1155 cfg = eet_data_read(ef, _config_edd, "config");
1164 _elm_config = _config_user_load();
1167 if (_elm_config->config_version < ELM_CONFIG_VERSION)
1172 /* no user config, fallback for system. No need to check version for
1173 * this one, if it's not the right one, someone screwed up at the time
1174 * of installing it */
1175 _elm_config = _config_system_load();
1176 if (_elm_config) return;
1177 /* FIXME: config load could have failed because of a non-existent
1178 * profile. Fallback to default before moving on */
1180 // config load fail - defaults
1181 /* XXX: do these make sense? Only if it's valid to install the lib
1182 * without the config, but do we want that? */
1183 _elm_config = ELM_NEW(Elm_Config);
1184 _elm_config->config_version = ELM_CONFIG_VERSION;
1185 _elm_config->engine = eina_stringshare_add("software_x11");
1186 _elm_config->vsync = 0;
1187 _elm_config->thumbscroll_enable = EINA_TRUE;
1188 _elm_config->thumbscroll_threshold = 24;
1189 _elm_config->thumbscroll_momentum_threshold = 100.0;
1190 _elm_config->thumbscroll_friction = 1.0;
1191 _elm_config->thumbscroll_bounce_friction = 0.5;
1192 _elm_config->thumbscroll_bounce_enable = EINA_TRUE;
1193 _elm_config->page_scroll_friction = 0.5;
1194 _elm_config->bring_in_scroll_friction = 0.5;
1195 _elm_config->zoom_friction = 0.5;
1196 _elm_config->thumbscroll_border_friction = 0.5;
1197 _elm_config->scroll_smooth_time_interval = 0.008;
1198 _elm_config->scroll_smooth_amount = 1.0;
1199 _elm_config->scroll_smooth_history_weight = 0.3;
1200 _elm_config->scroll_smooth_future_time = 0.0;
1201 _elm_config->scroll_smooth_time_window = 0.2;
1202 _elm_config->scale = 1.0;
1203 _elm_config->bgpixmap = 0;
1204 _elm_config->compositing = 1;
1205 _elm_config->font_hinting = 2;
1206 _elm_config->cache_flush_poll_interval = 512;
1207 _elm_config->cache_flush_enable = EINA_TRUE;
1208 _elm_config->font_dirs = NULL;
1209 _elm_config->image_cache = 4096;
1210 _elm_config->font_cache = 512;
1211 _elm_config->edje_cache = 32;
1212 _elm_config->edje_collection_cache = 64;
1213 _elm_config->finger_size = 40;
1214 _elm_config->fps = 60.0;
1215 _elm_config->theme = eina_stringshare_add("default");
1216 _elm_config->modules = NULL;
1217 _elm_config->tooltip_delay = 1.0;
1218 _elm_config->cursor_engine_only = EINA_TRUE;
1219 _elm_config->focus_highlight_enable = EINA_FALSE;
1220 _elm_config->focus_highlight_animate = EINA_TRUE;
1221 _elm_config->toolbar_shrink_mode = 2;
1222 _elm_config->fileselector_expand_enable = EINA_FALSE;
1223 _elm_config->inwin_dialogs_enable = EINA_FALSE;
1224 _elm_config->icon_size = 32;
1225 _elm_config->longpress_timeout = 1.0;
1226 _elm_config->effect_enable = EINA_TRUE;
1227 _elm_config->desktop_entry = EINA_FALSE;
1228 _elm_config->is_mirrored = EINA_FALSE; /* Read sys value in env_get() */
1229 _elm_config->password_show_last = EINA_FALSE;
1230 _elm_config->password_show_last_timeout = 2.0;
1234 _elm_config_eet_close_error_get(Eet_File *ef,
1238 const char *erstr = NULL;
1240 err = eet_close(ef);
1243 case EET_ERROR_WRITE_ERROR:
1244 erstr = "An error occurred while saving Elementary's "
1245 "settings to disk. The error could not be "
1246 "deterimined. The file where the error occurred was: "
1247 "%s. This file has been deleted to avoid corrupt data.";
1250 case EET_ERROR_WRITE_ERROR_FILE_TOO_BIG:
1251 erstr = "Elementary's settings files are too big "
1252 "for the file system they are being saved to. "
1253 "This error is very strange as the files should "
1254 "be extremely small. Please check the settings "
1255 "for your home directory. "
1256 "The file where the error occurred was: %s ."
1257 "This file has been deleted to avoid corrupt data.";
1260 case EET_ERROR_WRITE_ERROR_IO_ERROR:
1261 erstr = "An output error occurred when writing the settings "
1262 "files for Elementary. Your disk is having troubles "
1263 "and possibly needs replacement. "
1264 "The file where the error occurred was: %s ."
1265 "This file has been deleted to avoid corrupt data.";
1268 case EET_ERROR_WRITE_ERROR_OUT_OF_SPACE:
1269 erstr = "Elementary cannot write its settings file "
1270 "because it ran out of space to write the file. "
1271 "You have either run out of disk space or have "
1272 "gone over your quota limit. "
1273 "The file where the error occurred was: %s ."
1274 "This file has been deleted to avoid corrupt data.";
1277 case EET_ERROR_WRITE_ERROR_FILE_CLOSED:
1278 erstr = "Elementary unexpectedly had the settings file "
1279 "it was writing closed on it. This is very unusual. "
1280 "The file where the error occurred was: %s "
1281 "This file has been deleted to avoid corrupt data.";
1289 /* delete any partially-written file */
1290 ecore_file_unlink(file);
1291 return strdup(erstr);
1298 _elm_config_profile_save(void)
1300 char buf[4096], buf2[4096];
1306 len = _elm_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
1307 if (len + 1 >= sizeof(buf))
1310 len = _elm_user_dir_snprintf(buf2, sizeof(buf2), "config/profile.cfg.tmp");
1311 if (len + 1 >= sizeof(buf2))
1314 ef = eet_open(buf2, EET_FILE_MODE_WRITE);
1318 ok = eet_write(ef, "config", _elm_profile, strlen(_elm_profile), 0);
1322 err = _elm_config_eet_close_error_get(ef, buf2);
1330 ret = ecore_file_mv(buf2, buf);
1333 ERR("Error saving Elementary's configuration file");
1337 ecore_file_unlink(buf2);
1341 ecore_file_unlink(buf2);
1346 _elm_config_save(void)
1348 char buf[4096], buf2[4096];
1354 len = _elm_user_dir_snprintf(buf, sizeof(buf), "config/%s", _elm_profile);
1355 if (len + 1 >= sizeof(buf))
1358 ok = ecore_file_mkpath(buf);
1361 ERR("Problem acessing Elementary's user configuration directory: %s",
1366 if (!_elm_config_profile_save())
1372 if (len + sizeof("base.cfg") >= sizeof(buf) - len)
1375 memcpy(buf + len, "base.cfg", sizeof("base.cfg"));
1376 len += sizeof("base.cfg") - 1;
1378 if (len + sizeof(".tmp") >= sizeof(buf))
1381 memcpy(buf2, buf, len);
1382 memcpy(buf2 + len, ".tmp", sizeof(".tmp"));
1384 ef = eet_open(buf2, EET_FILE_MODE_WRITE);
1388 ok = eet_data_write(ef, _config_edd, "config", _elm_config, 1);
1392 err = _elm_config_eet_close_error_get(ef, buf2);
1400 ret = ecore_file_mv(buf2, buf);
1403 ERR("Error saving Elementary's configuration file");
1407 ecore_file_unlink(buf2);
1411 ecore_file_unlink(buf2);
1416 _config_update(void)
1420 tcfg = _config_system_load();
1423 /* weird profile or something? We should probably fill
1424 * with hardcoded defaults, or get from default previx */
1427 #define IFCFG(v) if ((_elm_config->config_version & 0xffff) < (v)) {
1428 #define IFCFGELSE } else {
1430 #define COPYVAL(x) do {_elm_config->x = tcfg->x; } while(0)
1431 #define COPYPTR(x) do {_elm_config->x = tcfg->x; tcfg->x = NULL; } while(0)
1432 #define COPYSTR(x) COPYPTR(x)
1434 /* we also need to update for property changes in the root window
1435 * if needed, but that will be dependent on new properties added
1436 * with each version */
1439 COPYVAL(longpress_timeout);
1449 /* after updating user config, we must save */
1458 s = getenv("ELM_ENGINE");
1461 if ((!strcasecmp(s, "x11")) ||
1462 (!strcasecmp(s, "x")) ||
1463 (!strcasecmp(s, "software-x11")) ||
1464 (!strcasecmp(s, "software_x11")))
1465 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_X11);
1466 else if ((!strcasecmp(s, "opengl")) ||
1467 (!strcasecmp(s, "gl")) ||
1468 (!strcasecmp(s, "opengl-x11")) ||
1469 (!strcasecmp(s, "opengl_x11")))
1470 eina_stringshare_replace(&_elm_config->engine, ELM_OPENGL_X11);
1471 else if ((!strcasecmp(s, "x11-8")) ||
1472 (!strcasecmp(s, "x8")) ||
1473 (!strcasecmp(s, "software-8-x11")) ||
1474 (!strcasecmp(s, "software_8_x11")))
1475 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_8_X11);
1476 else if ((!strcasecmp(s, "x11-16")) ||
1477 (!strcasecmp(s, "x16")) ||
1478 (!strcasecmp(s, "software-16-x11")) ||
1479 (!strcasecmp(s, "software_16_x11")))
1480 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_16_X11);
1482 else if ((!strcasecmp(s, "xrender")) ||
1483 (!strcasecmp(s, "xr")) ||
1484 (!strcasecmp(s, "xrender-x11")) ||
1485 (!strcasecmp(s, "xrender_x11")))
1486 eina_stringshare_replace(&_elm_config->engine, ELM_XRENDER_X11);
1488 else if ((!strcasecmp(s, "fb")) ||
1489 (!strcasecmp(s, "software-fb")) ||
1490 (!strcasecmp(s, "software_fb")))
1491 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_FB);
1492 else if ((!strcasecmp(s, "directfb")) ||
1493 (!strcasecmp(s, "dfb")))
1494 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_DIRECTFB);
1495 else if ((!strcasecmp(s, "sdl")) ||
1496 (!strcasecmp(s, "software-sdl")) ||
1497 (!strcasecmp(s, "software_sdl")))
1498 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_SDL);
1499 else if ((!strcasecmp(s, "sdl-16")) ||
1500 (!strcasecmp(s, "software-16-sdl")) ||
1501 (!strcasecmp(s, "software_16_sdl")))
1502 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_16_SDL);
1503 else if ((!strcasecmp(s, "opengl-sdl")) ||
1504 (!strcasecmp(s, "opengl_sdl")) ||
1505 (!strcasecmp(s, "gl-sdl")) ||
1506 (!strcasecmp(s, "gl_sdl")))
1507 eina_stringshare_replace(&_elm_config->engine, ELM_OPENGL_SDL);
1508 else if ((!strcasecmp(s, "gdi")) ||
1509 (!strcasecmp(s, "software-gdi")) ||
1510 (!strcasecmp(s, "software_gdi")))
1511 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_WIN32);
1512 else if ((!strcasecmp(s, "wince-gdi")) ||
1513 (!strcasecmp(s, "software-16-wince-gdi")) ||
1514 (!strcasecmp(s, "software_16_wince_gdi")))
1515 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_16_WINCE);
1516 else if ((!strncmp(s, "shot:", 5)))
1517 eina_stringshare_replace(&_elm_config->engine, s);
1520 s = getenv("ELM_VSYNC");
1521 if (s) _elm_config->vsync = !!atoi(s);
1523 s = getenv("ELM_THUMBSCROLL_ENABLE");
1524 if (s) _elm_config->thumbscroll_enable = !!atoi(s);
1525 s = getenv("ELM_THUMBSCROLL_THRESHOLD");
1526 if (s) _elm_config->thumbscroll_threshold = atoi(s);
1527 // FIXME: floatformat locale issues here 1.0 vs 1,0 - should just be 1.0
1528 s = getenv("ELM_THUMBSCROLL_MOMENTUM_THRESHOLD");
1529 if (s) _elm_config->thumbscroll_momentum_threshold = atof(s);
1530 s = getenv("ELM_THUMBSCROLL_FRICTION");
1531 if (s) _elm_config->thumbscroll_friction = atof(s);
1532 s = getenv("ELM_THUMBSCROLL_BOUNCE_ENABLE");
1533 if (s) _elm_config->thumbscroll_bounce_enable = !!atoi(s);
1534 s = getenv("ELM_THUMBSCROLL_BOUNCE_FRICTION");
1535 if (s) _elm_config->thumbscroll_bounce_friction = atof(s);
1536 s = getenv("ELM_PAGE_SCROLL_FRICTION");
1537 if (s) _elm_config->page_scroll_friction = atof(s);
1538 s = getenv("ELM_BRING_IN_SCROLL_FRICTION");
1539 if (s) _elm_config->bring_in_scroll_friction = atof(s);
1540 s = getenv("ELM_ZOOM_FRICTION");
1541 if (s) _elm_config->zoom_friction = atof(s);
1542 s = getenv("ELM_THUMBSCROLL_BORDER_FRICTION");
1552 _elm_config->thumbscroll_border_friction = friction;
1554 s = getenv("ELM_SCROLL_SMOOTH_TIME_INTERVAL");
1555 if (s) _elm_config->scroll_smooth_time_interval = atof(s);
1556 s = getenv("ELM_SCROLL_SMOOTH_AMOUNT");
1557 if (s) _elm_config->scroll_smooth_amount = atof(s);
1558 s = getenv("ELM_SCROLL_SMOOTH_HISTORY_WEIGHT");
1559 if (s) _elm_config->scroll_smooth_history_weight = atof(s);
1560 s = getenv("ELM_SCROLL_SMOOTH_FUTURE_TIME");
1561 if (s) _elm_config->scroll_smooth_future_time = atof(s);
1562 s = getenv("ELM_SCROLL_SMOOTH_TIME_WINDOW");
1563 if (s) _elm_config->scroll_smooth_time_window = atof(s);
1564 s = getenv("ELM_THEME");
1565 if (s) eina_stringshare_replace(&_elm_config->theme, s);
1567 s = getenv("ELM_FONT_HINTING");
1570 if (!strcasecmp(s, "none")) _elm_config->font_hinting = 0;
1571 else if (!strcasecmp(s, "auto"))
1572 _elm_config->font_hinting = 1;
1573 else if (!strcasecmp(s, "bytecode"))
1574 _elm_config->font_hinting = 2;
1577 s = getenv("ELM_FONT_PATH");
1583 EINA_LIST_FREE(_elm_config->font_dirs, p)
1585 eina_stringshare_del(p);
1588 buf2 = alloca(strlen(s) + 1);
1593 if ((*p == ':') || (*p == 0))
1598 strncpy(buf2, pp, len);
1600 _elm_config->font_dirs =
1601 eina_list_append(_elm_config->font_dirs,
1602 eina_stringshare_add(buf2));
1615 s = getenv("ELM_IMAGE_CACHE");
1616 if (s) _elm_config->image_cache = atoi(s);
1618 s = getenv("ELM_FONT_CACHE");
1619 if (s) _elm_config->font_cache = atoi(s);
1621 s = getenv("ELM_SCALE");
1622 if (s) _elm_config->scale = atof(s);
1624 _elm_config->finger_size =
1625 (double)_elm_config->finger_size * _elm_config->scale;
1626 s = getenv("ELM_FINGER_SIZE");
1627 if (s) _elm_config->finger_size = atoi(s);
1629 s = getenv("ELM_PASSWORD_SHOW_LAST");
1630 if (s) _elm_config->password_show_last = !!atoi(s);
1632 s = getenv("ELM_PASSWORD_SHOW_LAST_TIMEOUT");
1635 double pw_show_last_timeout = atof(s);
1636 if (pw_show_last_timeout >= 0.0)
1637 _elm_config->password_show_last_timeout = pw_show_last_timeout;
1640 s = getenv("ELM_FPS");
1641 if (s) _elm_config->fps = atof(s);
1642 if (_elm_config->fps < 1.0) _elm_config->fps = 1.0;
1644 s = getenv("ELM_MODULES");
1645 if (s) eina_stringshare_replace(&_elm_config->modules, s);
1647 /* Get RTL orientation from system */
1648 setlocale(LC_ALL, "");
1649 bindtextdomain(PACKAGE, LOCALE_DIR);
1650 _elm_config->is_mirrored = !strcmp(E_("default:LTR"), "default:RTL");
1652 s = getenv("ELM_TOOLTIP_DELAY");
1655 double delay = atof(s);
1657 _elm_config->tooltip_delay = delay;
1660 s = getenv("ELM_CURSOR_ENGINE_ONLY");
1661 if (s) _elm_config->cursor_engine_only = !!atoi(s);
1663 s = getenv("ELM_FOCUS_HIGHLIGHT_ENABLE");
1664 if (s) _elm_config->focus_highlight_enable = !!atoi(s);
1666 s = getenv("ELM_FOCUS_HIGHLIGHT_ANIMATE");
1667 if (s) _elm_config->focus_highlight_animate = !!atoi(s);
1669 s = getenv("ELM_TOOLBAR_SHRINK_MODE");
1670 if (s) _elm_config->toolbar_shrink_mode = atoi(s);
1672 s = getenv("ELM_FILESELECTOR_EXPAND_ENABLE");
1673 if (s) _elm_config->fileselector_expand_enable = !!atoi(s);
1675 s = getenv("ELM_INWIN_DIALOGS_ENABLE");
1676 if (s) _elm_config->inwin_dialogs_enable = !!atoi(s);
1678 s = getenv("ELM_ICON_SIZE");
1679 if (s) _elm_config->icon_size = atoi(s);
1681 s = getenv("ELM_INPUT_PANEL");
1682 if (s) _elm_config->input_panel_enable = atoi(s);
1684 s = getenv("ELM_LONGPRESS_TIMEOUT");
1685 if (s) _elm_config->longpress_timeout = atof(s);
1686 if (_elm_config->longpress_timeout < 0.0)
1687 _elm_config->longpress_timeout = 0.0;
1689 s = getenv("ELM_EFFECT_ENABLE");
1690 if (s) _elm_config->effect_enable = !!atoi(s);
1692 s = getenv("ELM_DESKTOP_ENTRY");
1693 if (s) _elm_config->desktop_entry = !!atoi(s);
1697 * Get the system mirrored mode. This determines the default mirrored mode
1700 * @return EINA_TRUE if mirrored is set, EINA_FALSE otherwise
1703 elm_mirrored_get(void)
1705 return _elm_config->is_mirrored;
1709 * Set the system mirrored mode. This determines the default mirrored mode
1712 * @param mirrored EINA_TRUE to set mirrored mode, EINA_FALSE to unset it.
1715 elm_mirrored_set(Eina_Bool mirrored)
1717 _elm_config->is_mirrored = mirrored;
1722 _elm_config_init(void)
1725 _profile_fetch_from_conf();
1727 // NOTE: Do not merge upstream code. Just leave it.
1730 // _elm_config_font_overlay_apply();
1735 _elm_config_sub_init(void)
1737 // NOTE: Do not merge upstream code. Just leave it.
1740 _elm_config_font_overlay_apply();
1743 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
1744 if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
1745 ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
1746 ENGINE_COMPARE(ELM_XRENDER_X11) ||
1747 ENGINE_COMPARE(ELM_OPENGL_X11))
1748 #undef ENGINE_COMPARE
1750 #ifdef HAVE_ELEMENTARY_X
1751 unsigned int val = 1000;
1753 if (!ecore_x_init(NULL))
1755 ERR("Cannot connect to X11 display. check $DISPLAY variable");
1758 _root_1st = ecore_x_window_root_first_get();
1760 if (!ecore_x_screen_is_composited(0))
1761 _elm_config->compositing = 0;
1763 ecore_x_atoms_get(_atom_names, ATOM_COUNT, _atom);
1764 ecore_x_event_mask_set(_root_1st,
1765 ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
1766 _prop_change_handler = ecore_event_handler_add
1767 (ECORE_X_EVENT_WINDOW_PROPERTY, _prop_change, NULL);
1768 if (!getenv("ELM_SCALE"))
1770 if (ecore_x_window_prop_card32_get(_root_1st,
1771 _atom[ATOM_E_SCALE],
1776 _elm_config->scale = (double)val / 1000.0;
1777 // FIXME: hack until e export finger size too
1778 if (!getenv("ELM_FINGER_SIZE"))
1780 _elm_config->finger_size = 40.0 * _elm_config->scale;
1782 edje_scale_set(_elm_config->scale);
1786 if (!getenv("ELM_FINGER_SIZE"))
1788 if (ecore_x_window_prop_card32_get(_root_1st,
1789 _atom[ATOM_E_FINGER_SIZE],
1794 _elm_config->finger_size = val;
1798 if (!getenv("ELM_THEME"))
1802 s = ecore_x_window_prop_string_get(_root_1st,
1803 _atom[ATOM_E_THEME]);
1806 eina_stringshare_replace(&_elm_config->theme, s);
1807 _elm_theme_parse(NULL, s);
1811 if (!getenv("ELM_PROFILE"))
1815 s = ecore_x_window_prop_string_get(_root_1st,
1816 _atom[ATOM_E_PROFILE]);
1823 if (strcmp(_elm_profile, s)) changed = 1;
1827 if (changed) _prop_config_get();
1830 if (!getenv("ELM_INPUT_PANEL"))
1832 if (ecore_x_window_prop_card32_get(_root_1st,
1833 _atom[ATOM_E_INPUT_PANEL],
1838 _elm_config->input_panel_enable = val;
1839 edje_input_panel_enabled_set(_elm_config->input_panel_enable);
1843 if (ecore_x_window_prop_card32_get(_root_1st,
1844 _atom[ATOM_E_AUTOCAPITAL_ALLOW],
1849 _elm_config->autocapital_allow = val;
1850 edje_autocapitalization_allow_set(_elm_config->autocapital_allow);
1853 if (ecore_x_window_prop_card32_get(_root_1st,
1854 _atom[ATOM_E_AUTOPERIOD_ALLOW],
1859 _elm_config->autoperiod_allow = val;
1860 edje_autoperiod_allow_set(_elm_config->autoperiod_allow);
1865 _config_sub_apply();
1869 _elm_config_reload(void)
1874 _elm_config_font_overlay_apply();
1880 _elm_config_engine_set(const char *engine)
1882 if (_elm_config->engine && strcmp(_elm_config->engine, engine))
1883 eina_stringshare_del(_elm_config->engine);
1885 _elm_config->engine = eina_stringshare_add(engine);
1889 _elm_config_profile_set(const char *profile)
1891 Eina_Bool changed = EINA_FALSE;
1895 if (strcmp(_elm_profile, profile))
1900 _elm_profile = strdup(profile);
1907 _elm_config_font_overlay_apply();
1914 _elm_config_shutdown(void)
1916 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
1917 if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
1918 ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
1919 ENGINE_COMPARE(ELM_XRENDER_X11) ||
1920 ENGINE_COMPARE(ELM_OPENGL_X11))
1921 #undef ENGINE_COMPARE
1923 #ifdef HAVE_ELEMENTARY_X
1924 ecore_event_handler_del(_prop_change_handler);
1925 _prop_change_handler = NULL;
1932 _elm_profile = NULL;