2 # include "elementary_config.h"
9 #include <Elementary.h>
12 EAPI int ELM_EVENT_CONFIG_ALL_CHANGED = 0;
14 Elm_Config *_elm_config = NULL;
15 char *_elm_profile = NULL;
16 static Eet_Data_Descriptor *_config_edd = NULL;
17 static Eet_Data_Descriptor *_config_font_overlay_edd = NULL;
18 const char *_elm_preferred_engine = NULL;
20 static Ecore_Poller *_elm_cache_flush_poller = NULL;
22 const char *_elm_engines[] = {
31 "software_16_wince_gdi",
44 /* whenever you want to add a new text class support into Elementary,
45 declare it both here and in the (default) theme */
46 static const Elm_Text_Class _elm_text_classes[] = {
47 {"button", "Button Labels"},
48 {"label", "Text Labels"},
49 {"entry", "Text Entries"},
50 {"title_bar", "Title Bar"},
51 {"list_item", "List Items"},
52 {"grid_item", "Grid Items"},
53 {"toolbar_item", "Toolbar Items"},
54 {"menu_item", "Menu Items"},
58 static void _desc_init(void);
59 static void _desc_shutdown(void);
60 static void _profile_fetch_from_conf(void);
61 static void _config_free(void);
62 static void _config_apply(void);
63 static Elm_Config *_config_user_load(void);
64 static Elm_Config *_config_system_load(void);
65 static void _config_load(void);
66 static void _config_update(void);
67 static void _env_get(void);
68 static size_t _elm_data_dir_snprintf(char *dst,
72 static size_t _elm_user_dir_snprintf(char *dst,
77 #define ELM_CONFIG_VAL(edd, type, member, dtype) \
78 EET_DATA_DESCRIPTOR_ADD_BASIC(edd, type, #member, member, dtype)
79 #define ELM_CONFIG_LIST(edd, type, member, eddtype) \
80 EET_DATA_DESCRIPTOR_ADD_LIST(edd, type, #member, member, eddtype)
82 #ifdef HAVE_ELEMENTARY_X
83 static Ecore_Event_Handler *_prop_change_handler = NULL;
84 static Ecore_Timer *_prop_all_update_timer = NULL;
85 static Ecore_Timer *_prop_change_delay_timer = NULL;
86 static Ecore_X_Window _root_1st = 0;
88 static Ecore_X_Atom _atom[ATOM_COUNT];
89 static Ecore_X_Atom _atom_config = 0;
90 static const char *_atom_names[ATOM_COUNT] =
95 #define ATOM_E_PROFILE 0
96 #define ATOM_E_CONFIG 1
98 static Eina_Bool _prop_all_update_cb(void *data __UNUSED__);
99 static Eina_Bool _prop_config_get(void);
100 static void _prop_config_set(void);
101 static Eina_Bool _prop_change(void *data __UNUSED__,
102 int ev_type __UNUSED__,
106 _prop_all_update_cb(void *data __UNUSED__)
109 ecore_x_window_prop_string_set(_root_1st, _atom[ATOM_E_PROFILE],
111 _prop_all_update_timer = NULL;
116 _prop_config_get(void)
121 unsigned char *data = NULL;
122 Elm_Config *config_data;
124 snprintf(buf, sizeof(buf), "ELM_CONFIG_%s", _elm_profile);
125 atom = ecore_x_atom_get(buf);
127 if (!ecore_x_window_prop_property_get(_root_1st,
128 atom, _atom[ATOM_E_CONFIG],
131 if (!ecore_x_window_prop_property_get(_root_1st,
132 _atom[ATOM_E_CONFIG],
133 _atom[ATOM_E_CONFIG],
137 _atom_config = _atom[ATOM_E_CONFIG];
146 config_data = eet_data_descriptor_decode(_config_edd, data, size);
148 if (!config_data) return EINA_FALSE;
150 /* What do we do on version mismatch when someone changes the
151 * config in the rootwindow? */
152 /* Most obvious case, new version and we are still linked to
153 * whatever was there before, we just ignore until user restarts us */
154 if (config_data->config_version > ELM_CONFIG_VERSION)
156 /* What in the case the version is older? Do we even support those
157 * cases or we only check for equality above? */
160 _elm_config = config_data;
162 _elm_config_font_overlay_apply();
165 ecore_event_add(ELM_EVENT_CONFIG_ALL_CHANGED, NULL, NULL, NULL);
170 _prop_config_set(void)
172 unsigned char *config_data = NULL;
175 config_data = eet_data_descriptor_encode(_config_edd, _elm_config, &size);
181 snprintf(buf, sizeof(buf), "ELM_CONFIG_%s", _elm_profile);
182 atom = ecore_x_atom_get(buf);
185 ecore_x_window_prop_property_set(_root_1st, _atom_config,
186 _atom[ATOM_E_CONFIG], 8,
193 _prop_change_delay_cb(void *data __UNUSED__)
197 s = ecore_x_window_prop_string_get(_root_1st, _atom[ATOM_E_PROFILE]);
200 if (_elm_profile) free(_elm_profile);
204 _prop_change_delay_timer = NULL;
209 _prop_change(void *data __UNUSED__,
210 int ev_type __UNUSED__,
213 Ecore_X_Event_Window_Property *event = ev;
215 if (event->win == _root_1st)
217 if (event->atom == _atom[ATOM_E_PROFILE])
219 if (_prop_change_delay_timer) ecore_timer_del(_prop_change_delay_timer);
220 _prop_change_delay_timer = ecore_timer_add(0.1, _prop_change_delay_cb, NULL);
222 else if (((_atom_config > 0) && (event->atom == _atom_config)) ||
223 (event->atom == _atom[ATOM_E_CONFIG]))
225 if (_prop_change_delay_timer) ecore_timer_del(_prop_change_delay_timer);
226 _prop_change_delay_timer = ecore_timer_add(0.1, _prop_change_delay_cb, NULL);
229 return ECORE_CALLBACK_PASS_ON;
237 Eet_Data_Descriptor_Class eddc;
239 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Config);
240 eddc.func.str_direct_alloc = NULL;
241 eddc.func.str_direct_free = NULL;
243 _config_edd = eet_data_descriptor_file_new(&eddc);
246 printf("EEEK! eet_data_descriptor_file_new() failed\n");
250 memset(&eddc, 0, sizeof(eddc)); /* just in case... */
251 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Font_Overlay);
252 eddc.func.str_direct_alloc = NULL;
253 eddc.func.str_direct_free = NULL;
255 _config_font_overlay_edd = eet_data_descriptor_stream_new(&eddc);
256 if (!_config_font_overlay_edd)
258 printf("EEEK! eet_data_descriptor_stream_new() failed\n");
259 eet_data_descriptor_free(_config_edd);
262 #define T_INT EET_T_INT
263 #define T_DOUBLE EET_T_DOUBLE
264 #define T_STRING EET_T_STRING
265 #define T_UCHAR EET_T_UCHAR
267 #define T Elm_Font_Overlay
268 #define D _config_font_overlay_edd
269 ELM_CONFIG_VAL(D, T, text_class, EET_T_STRING);
270 ELM_CONFIG_VAL(D, T, font, EET_T_STRING);
271 ELM_CONFIG_VAL(D, T, size, EET_T_INT);
276 #define D _config_edd
277 ELM_CONFIG_VAL(D, T, config_version, T_INT);
278 ELM_CONFIG_VAL(D, T, engine, T_STRING);
279 ELM_CONFIG_VAL(D, T, vsync, T_UCHAR);
280 ELM_CONFIG_VAL(D, T, thumbscroll_enable, T_UCHAR);
281 ELM_CONFIG_VAL(D, T, thumbscroll_threshold, T_INT);
282 ELM_CONFIG_VAL(D, T, thumbscroll_momentum_threshold, T_DOUBLE);
283 ELM_CONFIG_VAL(D, T, thumbscroll_friction, T_DOUBLE);
284 ELM_CONFIG_VAL(D, T, thumbscroll_bounce_friction, T_DOUBLE);
285 ELM_CONFIG_VAL(D, T, thumbscroll_border_friction, T_DOUBLE);
286 ELM_CONFIG_VAL(D, T, thumbscroll_sensitivity_friction, T_DOUBLE);
287 ELM_CONFIG_VAL(D, T, page_scroll_friction, T_DOUBLE);
288 ELM_CONFIG_VAL(D, T, bring_in_scroll_friction, T_DOUBLE);
289 ELM_CONFIG_VAL(D, T, zoom_friction, T_DOUBLE);
290 ELM_CONFIG_VAL(D, T, thumbscroll_bounce_enable, T_UCHAR);
291 ELM_CONFIG_VAL(D, T, scroll_smooth_amount, T_DOUBLE);
292 ELM_CONFIG_VAL(D, T, scroll_smooth_history_weight, T_DOUBLE);
293 ELM_CONFIG_VAL(D, T, scroll_smooth_future_time, T_DOUBLE);
294 ELM_CONFIG_VAL(D, T, scroll_smooth_time_window, T_DOUBLE);
295 ELM_CONFIG_VAL(D, T, scale, T_DOUBLE);
296 ELM_CONFIG_VAL(D, T, bgpixmap, T_INT);
297 ELM_CONFIG_VAL(D, T, compositing, T_INT);
298 /* EET_DATA_DESCRIPTOR_ADD_LIST(D, T, "font_dirs", font_dirs, sub_edd); */
299 ELM_CONFIG_LIST(D, T, font_overlays, _config_font_overlay_edd);
300 ELM_CONFIG_VAL(D, T, font_hinting, T_INT);
301 ELM_CONFIG_VAL(D, T, cache_flush_poll_interval, T_INT);
302 ELM_CONFIG_VAL(D, T, cache_flush_enable, T_UCHAR);
303 ELM_CONFIG_VAL(D, T, image_cache, T_INT);
304 ELM_CONFIG_VAL(D, T, font_cache, T_INT);
305 ELM_CONFIG_VAL(D, T, edje_cache, T_INT);
306 ELM_CONFIG_VAL(D, T, edje_collection_cache, T_INT);
307 ELM_CONFIG_VAL(D, T, finger_size, T_INT);
308 ELM_CONFIG_VAL(D, T, fps, T_DOUBLE);
309 ELM_CONFIG_VAL(D, T, theme, T_STRING);
310 ELM_CONFIG_VAL(D, T, modules, T_STRING);
311 ELM_CONFIG_VAL(D, T, tooltip_delay, T_DOUBLE);
312 ELM_CONFIG_VAL(D, T, cursor_engine_only, T_UCHAR);
313 ELM_CONFIG_VAL(D, T, focus_highlight_enable, T_UCHAR);
314 ELM_CONFIG_VAL(D, T, focus_highlight_animate, T_UCHAR);
315 ELM_CONFIG_VAL(D, T, toolbar_shrink_mode, T_INT);
316 ELM_CONFIG_VAL(D, T, fileselector_expand_enable, T_UCHAR);
317 ELM_CONFIG_VAL(D, T, inwin_dialogs_enable, T_UCHAR);
318 ELM_CONFIG_VAL(D, T, icon_size, T_INT);
319 ELM_CONFIG_VAL(D, T, longpress_timeout, T_DOUBLE);
320 ELM_CONFIG_VAL(D, T, effect_enable, T_UCHAR);
321 ELM_CONFIG_VAL(D, T, desktop_entry, T_UCHAR);
322 ELM_CONFIG_VAL(D, T, password_show_last, T_UCHAR);
323 ELM_CONFIG_VAL(D, T, password_show_last_timeout, T_DOUBLE);
324 ELM_CONFIG_VAL(D, T, glayer_zoom_finger_enable, T_UCHAR);
325 ELM_CONFIG_VAL(D, T, glayer_zoom_finger_factor, T_DOUBLE);
326 ELM_CONFIG_VAL(D, T, glayer_zoom_wheel_factor, T_DOUBLE);
327 ELM_CONFIG_VAL(D, T, glayer_zoom_distance_tolerance, T_DOUBLE);
328 ELM_CONFIG_VAL(D, T, glayer_rotate_finger_enable, T_UCHAR);
329 ELM_CONFIG_VAL(D, T, glayer_rotate_angular_tolerance, T_DOUBLE);
330 ELM_CONFIG_VAL(D, T, glayer_line_min_length, T_DOUBLE);
331 ELM_CONFIG_VAL(D, T, glayer_line_distance_tolerance, T_DOUBLE);
332 ELM_CONFIG_VAL(D, T, glayer_line_angular_tolerance, T_DOUBLE);
333 ELM_CONFIG_VAL(D, T, glayer_flick_time_limit_ms, T_INT);
334 ELM_CONFIG_VAL(D, T, glayer_long_tap_start_timeout, T_DOUBLE);
335 ELM_CONFIG_VAL(D, T, access_mode, T_INT);
336 ELM_CONFIG_VAL(D, T, glayer_continues_enable, T_UCHAR);
337 ELM_CONFIG_VAL(D, T, week_start, T_INT);
338 ELM_CONFIG_VAL(D, T, weekend_start, T_INT);
339 ELM_CONFIG_VAL(D, T, weekend_len, T_INT);
353 eet_data_descriptor_free(_config_edd);
357 if (_config_font_overlay_edd)
359 eet_data_descriptor_free(_config_font_overlay_edd);
360 _config_font_overlay_edd = NULL;
365 _sort_files_cb(const void *f1,
368 return strcmp(f1, f2);
372 _elm_config_current_profile_get(void)
378 _elm_data_dir_snprintf(char *dst,
383 size_t data_dir_len, off;
386 data_dir_len = eina_strlcpy(dst, _elm_data_dir, size);
388 off = data_dir_len + 1;
393 dst[data_dir_len] = '/';
395 off = off + vsnprintf(dst + off, size - off, fmt, ap);
403 _elm_user_dir_snprintf(char *dst,
409 size_t user_dir_len, off;
413 home = evil_homedir_get();
415 home = getenv("HOME");
420 user_dir_len = eina_str_join_len(dst, size, '/', home, strlen(home),
421 ELEMENTARY_BASE_DIR, sizeof(ELEMENTARY_BASE_DIR) - 1);
423 off = user_dir_len + 1;
428 dst[user_dir_len] = '/';
430 off = off + vsnprintf(dst + off, size - off, fmt, ap);
438 _elm_config_profile_dir_get(const char *prof,
446 _elm_user_dir_snprintf(buf, sizeof(buf), "config/%s", prof);
448 if (ecore_file_is_dir(buf))
454 snprintf(buf, sizeof(buf), "%s/config/%s", _elm_data_dir, prof);
456 if (ecore_file_is_dir(buf))
463 _elm_config_font_overlays_list(void)
465 return _elm_config->font_overlays;
469 _elm_config_font_overlay_set(const char *text_class,
473 Elm_Font_Overlay *efd;
476 EINA_LIST_FOREACH(_elm_config->font_overlays, l, efd)
478 if (strcmp(efd->text_class, text_class))
481 if (efd->font) eina_stringshare_del(efd->font);
482 efd->font = eina_stringshare_add(font);
484 _elm_config->font_overlays =
485 eina_list_promote_list(_elm_config->font_overlays, l);
489 /* the text class doesn't exist */
490 efd = calloc(1, sizeof(Elm_Font_Overlay));
491 efd->text_class = eina_stringshare_add(text_class);
492 efd->font = eina_stringshare_add(font);
495 _elm_config->font_overlays = eina_list_prepend(_elm_config->font_overlays,
500 _elm_config_font_overlay_remove(const char *text_class)
502 Elm_Font_Overlay *efd;
505 EINA_LIST_FOREACH(_elm_config->font_overlays, l, efd)
507 if (strcmp(efd->text_class, text_class))
510 _elm_config->font_overlays =
511 eina_list_remove_list(_elm_config->font_overlays, l);
512 if (efd->text_class) eina_stringshare_del(efd->text_class);
513 if (efd->font) eina_stringshare_del(efd->font);
521 _elm_config_font_overlay_apply(void)
523 Elm_Font_Overlay *efd;
527 for (i = 0; _elm_text_classes[i].desc; i++)
528 edje_text_class_del(_elm_text_classes[i].name);
530 EINA_LIST_FOREACH(_elm_config->font_overlays, l, efd)
531 edje_text_class_set(efd->text_class, efd->font, efd->size);
535 _elm_config_text_classes_get(void)
537 Eina_List *ret = NULL;
540 for (i = 0; _elm_text_classes[i].desc; i++)
543 tc = malloc(sizeof(*tc));
546 *tc = _elm_text_classes[i];
548 ret = eina_list_append(ret, tc);
555 _elm_config_text_classes_free(Eina_List *l)
559 EINA_LIST_FREE(l, tc)
564 _elm_config_profiles_list(void)
566 Eina_File_Direct_Info *info;
567 Eina_List *flist = NULL;
568 Eina_Iterator *file_it;
573 len = _elm_user_dir_snprintf(buf, sizeof(buf), "config");
575 file_it = eina_file_direct_ls(buf);
582 len = sizeof(buf) - len;
584 EINA_ITERATOR_FOREACH(file_it, info)
588 if (eina_file_statat(eina_iterator_container_get(file_it), info, &st))
593 if (info->name_length >= len)
596 if (info->type == EINA_FILE_DIR)
599 eina_list_sorted_insert(flist, _sort_files_cb,
600 eina_stringshare_add(info->path +
605 eina_iterator_free(file_it);
608 len = eina_str_join_len(buf, sizeof(buf), '/', _elm_data_dir,
609 strlen(_elm_data_dir), "config",
610 sizeof("config") - 1);
612 file_it = eina_file_direct_ls(buf);
619 len = sizeof(buf) - len;
620 EINA_ITERATOR_FOREACH(file_it, info)
622 if (info->name_length >= len)
632 EINA_LIST_FOREACH(flist, l, tmp)
633 if (!strcmp(info->path + info->name_start, tmp))
638 eina_list_sorted_insert(flist, _sort_files_cb,
639 eina_stringshare_add(info->path +
648 eina_iterator_free(file_it);
652 EINA_LIST_FREE(flist, dir)
653 eina_stringshare_del(dir);
659 _profile_fetch_from_conf(void)
661 char buf[PATH_MAX], *p, *s;
665 _elm_profile = strdup("default");
667 // if env var - use profile without question
668 s = getenv("ELM_PROFILE");
672 _elm_profile = strdup(s);
677 _elm_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
678 ef = eet_open(buf, EET_FILE_MODE_READ);
681 p = eet_read(ef, "config", &len);
685 _elm_profile = malloc(len + 1);
686 memcpy(_elm_profile, p, len);
687 _elm_profile[len] = 0;
696 _elm_data_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
697 ef = eet_open(buf, EET_FILE_MODE_READ);
700 p = eet_read(ef, "config", &len);
704 _elm_profile = malloc(len + 1);
705 memcpy(_elm_profile, p, len);
706 _elm_profile[len] = 0;
716 Elm_Font_Overlay *fo;
719 if (!_elm_config) return;
720 EINA_LIST_FREE(_elm_config->font_dirs, fontdir)
722 eina_stringshare_del(fontdir);
724 if (_elm_config->engine) eina_stringshare_del(_elm_config->engine);
725 EINA_LIST_FREE(_elm_config->font_overlays, fo)
727 if (fo->text_class) eina_stringshare_del(fo->text_class);
728 if (fo->font) eina_stringshare_del(fo->font);
731 if (_elm_config->theme) eina_stringshare_del(_elm_config->theme);
732 if (_elm_config->modules) eina_stringshare_del(_elm_config->modules);
740 _elm_theme_parse(NULL, _elm_config->theme);
741 ecore_animator_frametime_set(1.0 / _elm_config->fps);
745 _config_sub_apply(void)
747 edje_frametime_set(1.0 / _elm_config->fps);
748 edje_scale_set(_elm_config->scale);
749 edje_password_show_last_set(_elm_config->password_show_last);
750 edje_password_show_last_timeout_set(_elm_config->password_show_last_timeout);
751 if (_elm_config->modules) _elm_module_parse(_elm_config->modules);
755 _elm_cache_flush_cb(void *data __UNUSED__)
757 elm_cache_all_flush();
758 return ECORE_CALLBACK_RENEW;
761 /* kind of abusing this call right now -- shared between all of those
762 * properties -- but they are not meant to be called that periodically
770 elm_cache_all_flush();
772 EINA_LIST_FOREACH(_elm_win_list, l, win)
774 Evas *e = evas_object_evas_get(win);
775 evas_image_cache_set(e, _elm_config->image_cache * 1024);
776 evas_font_cache_set(e, _elm_config->font_cache * 1024);
778 edje_file_cache_set(_elm_config->edje_cache);
779 edje_collection_cache_set(_elm_config->edje_collection_cache);
781 if (_elm_cache_flush_poller)
783 ecore_poller_del(_elm_cache_flush_poller);
784 _elm_cache_flush_poller = NULL;
786 if (_elm_config->cache_flush_enable)
788 if (_elm_config->cache_flush_poll_interval > 0)
790 _elm_cache_flush_poller =
791 ecore_poller_add(ECORE_POLLER_CORE,
792 _elm_config->cache_flush_poll_interval,
793 _elm_cache_flush_cb, NULL);
799 _config_user_load(void)
801 Elm_Config *cfg = NULL;
805 _elm_user_dir_snprintf(buf, sizeof(buf), "config/%s/base.cfg",
808 ef = eet_open(buf, EET_FILE_MODE_READ);
811 cfg = eet_data_read(ef, _config_edd, "config");
818 _config_system_load(void)
820 Elm_Config *cfg = NULL;
824 _elm_data_dir_snprintf(buf, sizeof(buf), "config/%s/base.cfg",
827 ef = eet_open(buf, EET_FILE_MODE_READ);
830 cfg = eet_data_read(ef, _config_edd, "config");
839 _elm_config = _config_user_load();
842 if (_elm_config->config_version < ELM_CONFIG_VERSION)
847 /* no user config, fallback for system. No need to check version for
848 * this one, if it's not the right one, someone screwed up at the time
849 * of installing it */
850 _elm_config = _config_system_load();
851 if (_elm_config) return;
852 /* FIXME: config load could have failed because of a non-existent
853 * profile. Fallback to default before moving on */
855 // config load fail - defaults
856 // why are these here? well if they are, it means you can make a gui
857 // config recovery app i guess...
858 _elm_config = ELM_NEW(Elm_Config);
859 _elm_config->config_version = ELM_CONFIG_VERSION;
860 _elm_config->engine = eina_stringshare_add("software_x11");
861 _elm_config->vsync = 0;
862 _elm_config->thumbscroll_enable = EINA_TRUE;
863 _elm_config->thumbscroll_threshold = 24;
864 _elm_config->thumbscroll_momentum_threshold = 100.0;
865 _elm_config->thumbscroll_friction = 1.0;
866 _elm_config->thumbscroll_bounce_friction = 0.5;
867 _elm_config->thumbscroll_bounce_enable = EINA_TRUE;
868 _elm_config->page_scroll_friction = 0.5;
869 _elm_config->bring_in_scroll_friction = 0.5;
870 _elm_config->zoom_friction = 0.5;
871 _elm_config->thumbscroll_border_friction = 0.5;
872 _elm_config->thumbscroll_sensitivity_friction = 0.25; // magic number! just trial and error shows this makes it behave "nicer" and not run off at high speed all the time
873 _elm_config->scroll_smooth_amount = 1.0;
874 _elm_config->scroll_smooth_history_weight = 0.3;
875 _elm_config->scroll_smooth_future_time = 0.0;
876 _elm_config->scroll_smooth_time_window = 0.2;
877 _elm_config->scale = 1.0;
878 _elm_config->bgpixmap = 0;
879 _elm_config->compositing = 1;
880 _elm_config->font_hinting = 2;
881 _elm_config->cache_flush_poll_interval = 512;
882 _elm_config->cache_flush_enable = EINA_TRUE;
883 _elm_config->font_dirs = NULL;
884 _elm_config->image_cache = 4096;
885 _elm_config->font_cache = 512;
886 _elm_config->edje_cache = 32;
887 _elm_config->edje_collection_cache = 64;
888 _elm_config->finger_size = 40;
889 _elm_config->fps = 60.0;
890 _elm_config->theme = eina_stringshare_add("default");
891 _elm_config->modules = NULL;
892 _elm_config->tooltip_delay = 1.0;
893 _elm_config->cursor_engine_only = EINA_TRUE;
894 _elm_config->focus_highlight_enable = EINA_FALSE;
895 _elm_config->focus_highlight_animate = EINA_TRUE;
896 _elm_config->toolbar_shrink_mode = 2;
897 _elm_config->fileselector_expand_enable = EINA_FALSE;
898 _elm_config->inwin_dialogs_enable = EINA_FALSE;
899 _elm_config->icon_size = 32;
900 _elm_config->longpress_timeout = 1.0;
901 _elm_config->effect_enable = EINA_TRUE;
902 _elm_config->desktop_entry = EINA_FALSE;
903 _elm_config->is_mirrored = EINA_FALSE; /* Read sys value in env_get() */
904 _elm_config->password_show_last = EINA_FALSE;
905 _elm_config->password_show_last_timeout = 2.0;
906 _elm_config->glayer_zoom_finger_enable = EINA_TRUE;
907 _elm_config->glayer_zoom_finger_factor = 1.0;
908 _elm_config->glayer_zoom_wheel_factor = 0.05;
909 _elm_config->glayer_zoom_distance_tolerance = 1.0; /* 1 times elm_finger_size_get() */
910 _elm_config->glayer_rotate_finger_enable = EINA_TRUE;
911 _elm_config->glayer_rotate_angular_tolerance = 2.0; /* 2 DEG */
912 _elm_config->glayer_line_min_length = 1.0; /* 1 times elm_finger_size_get() */
913 _elm_config->glayer_line_distance_tolerance = 3.0; /* 3 times elm_finger_size_get() */
914 _elm_config->glayer_line_angular_tolerance = 20.0; /* 20 DEG */
915 _elm_config->glayer_flick_time_limit_ms = 120; /* ms to finish flick */
916 _elm_config->glayer_long_tap_start_timeout = 1.2; /* 1.2 second to start long-tap */
917 _elm_config->glayer_continues_enable = EINA_TRUE; /* Continue gestures default */
918 _elm_config->week_start = 1; /* monday */
919 _elm_config->weekend_start = 6; /* saturday */
920 _elm_config->weekend_len = 2;
924 _elm_config_eet_close_error_get(Eet_File *ef,
928 const char *erstr = NULL;
933 case EET_ERROR_WRITE_ERROR:
934 erstr = "An error occurred while saving Elementary's "
935 "settings to disk. The error could not be "
936 "deterimined. The file where the error occurred was: "
937 "%s. This file has been deleted to avoid corrupt data.";
940 case EET_ERROR_WRITE_ERROR_FILE_TOO_BIG:
941 erstr = "Elementary's settings files are too big "
942 "for the file system they are being saved to. "
943 "This error is very strange as the files should "
944 "be extremely small. Please check the settings "
945 "for your home directory. "
946 "The file where the error occurred was: %s ."
947 "This file has been deleted to avoid corrupt data.";
950 case EET_ERROR_WRITE_ERROR_IO_ERROR:
951 erstr = "An output error occurred when writing the settings "
952 "files for Elementary. Your disk is having troubles "
953 "and possibly needs replacement. "
954 "The file where the error occurred was: %s ."
955 "This file has been deleted to avoid corrupt data.";
958 case EET_ERROR_WRITE_ERROR_OUT_OF_SPACE:
959 erstr = "Elementary cannot write its settings file "
960 "because it ran out of space to write the file. "
961 "You have either run out of disk space or have "
962 "gone over your quota limit. "
963 "The file where the error occurred was: %s ."
964 "This file has been deleted to avoid corrupt data.";
967 case EET_ERROR_WRITE_ERROR_FILE_CLOSED:
968 erstr = "Elementary unexpectedly had the settings file "
969 "it was writing closed on it. This is very unusual. "
970 "The file where the error occurred was: %s "
971 "This file has been deleted to avoid corrupt data.";
979 /* delete any partially-written file */
980 ecore_file_unlink(file);
981 return strdup(erstr);
988 _elm_config_profile_save(void)
990 char buf[4096], buf2[4096];
996 len = _elm_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
997 if (len + 1 >= sizeof(buf))
1000 len = _elm_user_dir_snprintf(buf2, sizeof(buf2), "config/profile.cfg.tmp");
1001 if (len + 1 >= sizeof(buf2))
1004 ef = eet_open(buf2, EET_FILE_MODE_WRITE);
1008 ok = eet_write(ef, "config", _elm_profile, strlen(_elm_profile), 0);
1012 err = _elm_config_eet_close_error_get(ef, buf2);
1020 ret = ecore_file_mv(buf2, buf);
1023 ERR("Error saving Elementary's configuration file");
1027 ecore_file_unlink(buf2);
1031 ecore_file_unlink(buf2);
1036 _elm_config_save(void)
1038 char buf[4096], buf2[4096];
1044 len = _elm_user_dir_snprintf(buf, sizeof(buf), "config/%s", _elm_profile);
1045 if (len + 1 >= sizeof(buf))
1048 ok = ecore_file_mkpath(buf);
1051 ERR("Problem accessing Elementary's user configuration directory: %s",
1056 if (!_elm_config_profile_save())
1062 if (len + sizeof("base.cfg") >= sizeof(buf) - len)
1065 memcpy(buf + len, "base.cfg", sizeof("base.cfg"));
1066 len += sizeof("base.cfg") - 1;
1068 if (len + sizeof(".tmp") >= sizeof(buf))
1071 memcpy(buf2, buf, len);
1072 memcpy(buf2 + len, ".tmp", sizeof(".tmp"));
1074 ef = eet_open(buf2, EET_FILE_MODE_WRITE);
1078 ok = eet_data_write(ef, _config_edd, "config", _elm_config, 1);
1082 err = _elm_config_eet_close_error_get(ef, buf2);
1090 ret = ecore_file_mv(buf2, buf);
1093 ERR("Error saving Elementary's configuration file");
1097 ecore_file_unlink(buf2);
1101 ecore_file_unlink(buf2);
1106 _config_update(void)
1110 tcfg = _config_system_load();
1113 /* weird profile or something? We should probably fill
1114 * with hardcoded defaults, or get from default previx */
1117 #define IFCFG(v) if ((_elm_config->config_version & 0xffff) < (v)) {
1118 #define IFCFGELSE } else {
1120 #define COPYVAL(x) do {_elm_config->x = tcfg->x; } while(0)
1121 #define COPYPTR(x) do {_elm_config->x = tcfg->x; tcfg->x = NULL; } while(0)
1122 #define COPYSTR(x) COPYPTR(x)
1124 /* we also need to update for property changes in the root window
1125 * if needed, but that will be dependent on new properties added
1126 * with each version */
1129 COPYVAL(longpress_timeout);
1139 /* after updating user config, we must save */
1148 s = getenv("ELM_ENGINE");
1151 if ((!strcasecmp(s, "x11")) ||
1152 (!strcasecmp(s, "x")) ||
1153 (!strcasecmp(s, "software-x11")) ||
1154 (!strcasecmp(s, "software_x11")))
1155 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_X11);
1156 else if ((!strcasecmp(s, "opengl")) ||
1157 (!strcasecmp(s, "gl")) ||
1158 (!strcasecmp(s, "opengl-x11")) ||
1159 (!strcasecmp(s, "opengl_x11")))
1160 eina_stringshare_replace(&_elm_config->engine, ELM_OPENGL_X11);
1161 else if ((!strcasecmp(s, "x11-8")) ||
1162 (!strcasecmp(s, "x8")) ||
1163 (!strcasecmp(s, "software-8-x11")) ||
1164 (!strcasecmp(s, "software_8_x11")))
1165 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_8_X11);
1166 else if ((!strcasecmp(s, "x11-16")) ||
1167 (!strcasecmp(s, "x16")) ||
1168 (!strcasecmp(s, "software-16-x11")) ||
1169 (!strcasecmp(s, "software_16_x11")))
1170 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_16_X11);
1172 else if ((!strcasecmp(s, "xrender")) ||
1173 (!strcasecmp(s, "xr")) ||
1174 (!strcasecmp(s, "xrender-x11")) ||
1175 (!strcasecmp(s, "xrender_x11")))
1176 eina_stringshare_replace(&_elm_config->engine, ELM_XRENDER_X11);
1178 else if ((!strcasecmp(s, "fb")) ||
1179 (!strcasecmp(s, "software-fb")) ||
1180 (!strcasecmp(s, "software_fb")))
1181 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_FB);
1182 else if ((!strcasecmp(s, "directfb")) ||
1183 (!strcasecmp(s, "dfb")))
1184 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_DIRECTFB);
1185 else if ((!strcasecmp(s, "psl1ght")))
1186 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_PSL1GHT);
1187 else if ((!strcasecmp(s, "sdl")) ||
1188 (!strcasecmp(s, "software-sdl")) ||
1189 (!strcasecmp(s, "software_sdl")))
1190 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_SDL);
1191 else if ((!strcasecmp(s, "sdl-16")) ||
1192 (!strcasecmp(s, "software-16-sdl")) ||
1193 (!strcasecmp(s, "software_16_sdl")))
1194 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_16_SDL);
1195 else if ((!strcasecmp(s, "opengl-sdl")) ||
1196 (!strcasecmp(s, "opengl_sdl")) ||
1197 (!strcasecmp(s, "gl-sdl")) ||
1198 (!strcasecmp(s, "gl_sdl")))
1199 eina_stringshare_replace(&_elm_config->engine, ELM_OPENGL_SDL);
1200 else if ((!strcasecmp(s, "opengl-cocoa")) ||
1201 (!strcasecmp(s, "opengl_cocoa")) ||
1202 (!strcasecmp(s, "gl-cocoa")) ||
1203 (!strcasecmp(s, "gl_cocoa")))
1204 eina_stringshare_replace(&_elm_config->engine, ELM_OPENGL_COCOA);
1205 else if ((!strcasecmp(s, "gdi")) ||
1206 (!strcasecmp(s, "software-gdi")) ||
1207 (!strcasecmp(s, "software_gdi")))
1208 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_WIN32);
1209 else if ((!strcasecmp(s, "wince-gdi")) ||
1210 (!strcasecmp(s, "software-16-wince-gdi")) ||
1211 (!strcasecmp(s, "software_16_wince_gdi")))
1212 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_16_WINCE);
1213 else if (!strcasecmp(s, "buffer"))
1214 eina_stringshare_replace(&_elm_config->engine, ELM_BUFFER);
1215 else if ((!strncmp(s, "shot:", 5)))
1216 eina_stringshare_replace(&_elm_config->engine, s);
1217 else if ((!strcasecmp(s, "ews")))
1218 eina_stringshare_replace(&_elm_config->engine, ELM_EWS);
1219 else if ((!strcasecmp(s, "wayland_shm")))
1220 eina_stringshare_replace(&_elm_config->engine, ELM_WAYLAND_SHM);
1221 else if ((!strcasecmp(s, "wayland_egl")))
1222 eina_stringshare_replace(&_elm_config->engine, ELM_WAYLAND_EGL);
1224 ERR("Unknown engine '%s'.", s);
1227 s = getenv("ELM_VSYNC");
1228 if (s) _elm_config->vsync = !!atoi(s);
1230 s = getenv("ELM_THUMBSCROLL_ENABLE");
1231 if (s) _elm_config->thumbscroll_enable = !!atoi(s);
1232 s = getenv("ELM_THUMBSCROLL_THRESHOLD");
1233 if (s) _elm_config->thumbscroll_threshold = atoi(s);
1234 // FIXME: floatformat locale issues here 1.0 vs 1,0 - should just be 1.0
1235 s = getenv("ELM_THUMBSCROLL_MOMENTUM_THRESHOLD");
1236 if (s) _elm_config->thumbscroll_momentum_threshold = atof(s);
1237 s = getenv("ELM_THUMBSCROLL_FRICTION");
1238 if (s) _elm_config->thumbscroll_friction = atof(s);
1239 s = getenv("ELM_THUMBSCROLL_BOUNCE_ENABLE");
1240 if (s) _elm_config->thumbscroll_bounce_enable = !!atoi(s);
1241 s = getenv("ELM_THUMBSCROLL_BOUNCE_FRICTION");
1242 if (s) _elm_config->thumbscroll_bounce_friction = atof(s);
1243 s = getenv("ELM_PAGE_SCROLL_FRICTION");
1244 if (s) _elm_config->page_scroll_friction = atof(s);
1245 s = getenv("ELM_BRING_IN_SCROLL_FRICTION");
1246 if (s) _elm_config->bring_in_scroll_friction = atof(s);
1247 s = getenv("ELM_ZOOM_FRICTION");
1248 if (s) _elm_config->zoom_friction = atof(s);
1249 s = getenv("ELM_THUMBSCROLL_BORDER_FRICTION");
1259 _elm_config->thumbscroll_border_friction = friction;
1261 s = getenv("ELM_THUMBSCROLL_SENSITIVITY_FRICTION");
1271 _elm_config->thumbscroll_sensitivity_friction = friction;
1273 s = getenv("ELM_SCROLL_SMOOTH_AMOUNT");
1274 if (s) _elm_config->scroll_smooth_amount = atof(s);
1275 s = getenv("ELM_SCROLL_SMOOTH_HISTORY_WEIGHT");
1276 if (s) _elm_config->scroll_smooth_history_weight = atof(s);
1277 s = getenv("ELM_SCROLL_SMOOTH_FUTURE_TIME");
1278 if (s) _elm_config->scroll_smooth_future_time = atof(s);
1279 s = getenv("ELM_SCROLL_SMOOTH_TIME_WINDOW");
1280 if (s) _elm_config->scroll_smooth_time_window = atof(s);
1281 s = getenv("ELM_THEME");
1282 if (s) eina_stringshare_replace(&_elm_config->theme, s);
1284 s = getenv("ELM_FONT_HINTING");
1287 if (!strcasecmp(s, "none")) _elm_config->font_hinting = 0;
1288 else if (!strcasecmp(s, "auto"))
1289 _elm_config->font_hinting = 1;
1290 else if (!strcasecmp(s, "bytecode"))
1291 _elm_config->font_hinting = 2;
1294 s = getenv("ELM_FONT_PATH");
1300 EINA_LIST_FREE(_elm_config->font_dirs, p)
1302 eina_stringshare_del(p);
1305 buf2 = alloca(strlen(s) + 1);
1310 if ((*p == ':') || (*p == 0))
1315 strncpy(buf2, pp, len);
1317 _elm_config->font_dirs =
1318 eina_list_append(_elm_config->font_dirs,
1319 eina_stringshare_add(buf2));
1332 s = getenv("ELM_IMAGE_CACHE");
1333 if (s) _elm_config->image_cache = atoi(s);
1335 s = getenv("ELM_FONT_CACHE");
1336 if (s) _elm_config->font_cache = atoi(s);
1338 s = getenv("ELM_SCALE");
1339 if (s) _elm_config->scale = atof(s);
1341 s = getenv("ELM_FINGER_SIZE");
1342 if (s) _elm_config->finger_size = atoi(s);
1344 s = getenv("ELM_PASSWORD_SHOW_LAST");
1345 if (s) _elm_config->password_show_last = !!atoi(s);
1347 s = getenv("ELM_PASSWORD_SHOW_LAST_TIMEOUT");
1350 double pw_show_last_timeout = atof(s);
1351 if (pw_show_last_timeout >= 0.0)
1352 _elm_config->password_show_last_timeout = pw_show_last_timeout;
1355 s = getenv("ELM_FPS");
1356 if (s) _elm_config->fps = atof(s);
1357 if (_elm_config->fps < 1.0) _elm_config->fps = 1.0;
1359 s = getenv("ELM_MODULES");
1360 if (s) eina_stringshare_replace(&_elm_config->modules, s);
1362 /* Get RTL orientation from system */
1363 setlocale(LC_ALL, "");
1364 bindtextdomain(PACKAGE, LOCALE_DIR);
1365 _elm_config->is_mirrored = !strcmp(E_("default:LTR"), "default:RTL");
1367 s = getenv("ELM_TOOLTIP_DELAY");
1370 double delay = atof(s);
1372 _elm_config->tooltip_delay = delay;
1375 s = getenv("ELM_CURSOR_ENGINE_ONLY");
1376 if (s) _elm_config->cursor_engine_only = !!atoi(s);
1378 s = getenv("ELM_FOCUS_HIGHLIGHT_ENABLE");
1379 if (s) _elm_config->focus_highlight_enable = !!atoi(s);
1381 s = getenv("ELM_FOCUS_HIGHLIGHT_ANIMATE");
1382 if (s) _elm_config->focus_highlight_animate = !!atoi(s);
1384 s = getenv("ELM_TOOLBAR_SHRINK_MODE");
1385 if (s) _elm_config->toolbar_shrink_mode = atoi(s);
1387 s = getenv("ELM_FILESELECTOR_EXPAND_ENABLE");
1388 if (s) _elm_config->fileselector_expand_enable = !!atoi(s);
1390 s = getenv("ELM_INWIN_DIALOGS_ENABLE");
1391 if (s) _elm_config->inwin_dialogs_enable = !!atoi(s);
1393 s = getenv("ELM_ICON_SIZE");
1394 if (s) _elm_config->icon_size = atoi(s);
1396 s = getenv("ELM_LONGPRESS_TIMEOUT");
1397 if (s) _elm_config->longpress_timeout = atof(s);
1398 if (_elm_config->longpress_timeout < 0.0)
1399 _elm_config->longpress_timeout = 0.0;
1401 s = getenv("ELM_EFFECT_ENABLE");
1402 if (s) _elm_config->effect_enable = !!atoi(s);
1404 s = getenv("ELM_DESKTOP_ENTRY");
1405 if (s) _elm_config->desktop_entry = !!atoi(s);
1406 s = getenv("ELM_ACCESS_MODE");
1407 if (s) _elm_config->access_mode = ELM_ACCESS_MODE_ON;
1411 elm_config_mirrored_get(void)
1413 return _elm_config->is_mirrored;
1417 elm_config_mirrored_set(Eina_Bool mirrored)
1419 _elm_config->is_mirrored = mirrored;
1424 elm_config_cursor_engine_only_get(void)
1426 return _elm_config->cursor_engine_only;
1430 elm_config_cursor_engine_only_set(Eina_Bool engine_only)
1432 engine_only = !!engine_only;
1433 _elm_config->cursor_engine_only = engine_only;
1436 EINA_DEPRECATED EAPI double
1437 elm_tooltip_delay_get(void)
1439 return elm_config_tooltip_delay_get();
1442 EINA_DEPRECATED EAPI Eina_Bool
1443 elm_tooltip_delay_set(double delay)
1445 elm_config_tooltip_delay_set(delay);
1450 elm_config_tooltip_delay_get(void)
1452 return _elm_config->tooltip_delay;
1456 elm_config_tooltip_delay_set(double delay)
1458 if (delay < 0.0) return;
1459 _elm_config->tooltip_delay = delay;
1463 elm_config_scale_get(void)
1465 return _elm_config->scale;
1469 elm_config_scale_set(double scale)
1471 if (_elm_config->scale == scale) return;
1472 _elm_config->scale = scale;
1477 elm_config_password_show_last_get(void)
1479 return _elm_config->password_show_last;
1483 elm_config_password_show_last_set(Eina_Bool password_show_last)
1485 if (_elm_config->password_show_last == password_show_last) return;
1486 _elm_config->password_show_last = password_show_last;
1487 edje_password_show_last_set(_elm_config->password_show_last);
1491 elm_config_password_show_last_timeout_get(void)
1493 return _elm_config->password_show_last_timeout;
1497 elm_config_password_show_last_timeout_set(double password_show_last_timeout)
1499 if (_elm_config->password_show_last_timeout == password_show_last_timeout) return;
1500 _elm_config->password_show_last_timeout = password_show_last_timeout;
1501 edje_password_show_last_timeout_set(_elm_config->password_show_last_timeout);
1505 elm_config_save(void)
1507 return _elm_config_save();
1511 elm_config_reload(void)
1513 _elm_config_reload();
1517 elm_config_profile_get(void)
1519 return _elm_config_current_profile_get();
1523 elm_config_profile_dir_get(const char *profile,
1526 return _elm_config_profile_dir_get(profile, is_user);
1530 elm_config_profile_dir_free(const char *p_dir)
1532 free((void *)p_dir);
1536 elm_config_profile_list_get(void)
1538 return _elm_config_profiles_list();
1542 elm_config_profile_list_free(Eina_List *l)
1546 EINA_LIST_FREE(l, dir)
1547 eina_stringshare_del(dir);
1551 elm_config_profile_set(const char *profile)
1553 EINA_SAFETY_ON_NULL_RETURN(profile);
1554 _elm_config_profile_set(profile);
1558 elm_config_engine_get(void)
1560 return _elm_config->engine;
1564 elm_config_engine_set(const char *engine)
1566 EINA_SAFETY_ON_NULL_RETURN(engine);
1568 _elm_config_engine_set(engine);
1572 elm_config_text_classes_list_get(void)
1574 return _elm_config_text_classes_get();
1578 elm_config_text_classes_list_free(Eina_List *list)
1580 _elm_config_text_classes_free(list);
1583 EAPI const Eina_List *
1584 elm_config_font_overlay_list_get(void)
1586 return _elm_config_font_overlays_list();
1590 elm_config_font_overlay_set(const char *text_class,
1592 Evas_Font_Size size)
1594 EINA_SAFETY_ON_NULL_RETURN(text_class);
1595 _elm_config_font_overlay_set(text_class, font, size);
1599 elm_config_font_overlay_unset(const char *text_class)
1601 EINA_SAFETY_ON_NULL_RETURN(text_class);
1602 _elm_config_font_overlay_remove(text_class);
1606 elm_config_font_overlay_apply(void)
1608 _elm_config_font_overlay_apply();
1612 elm_config_finger_size_get(void)
1614 return _elm_config->finger_size;
1618 elm_config_finger_size_set(Evas_Coord size)
1620 if (_elm_config->finger_size == size) return;
1621 _elm_config->finger_size = size;
1626 elm_config_cache_flush_interval_get(void)
1628 return _elm_config->cache_flush_poll_interval;
1632 elm_config_cache_flush_interval_set(int size)
1634 if (_elm_config->cache_flush_poll_interval == size) return;
1635 _elm_config->cache_flush_poll_interval = size;
1641 elm_config_cache_flush_enabled_get(void)
1643 return _elm_config->cache_flush_enable;
1647 elm_config_cache_flush_enabled_set(Eina_Bool enabled)
1649 enabled = !!enabled;
1650 if (_elm_config->cache_flush_enable == enabled) return;
1651 _elm_config->cache_flush_enable = enabled;
1656 EINA_DEPRECATED EAPI int
1657 elm_font_cache_get(void)
1659 return elm_config_cache_font_cache_size_get();
1663 elm_config_cache_font_cache_size_get(void)
1665 return _elm_config->font_cache;
1668 EINA_DEPRECATED EAPI void
1669 elm_font_cache_set(int size)
1671 elm_config_cache_font_cache_size_set(size);
1675 elm_config_cache_font_cache_size_set(int size)
1677 if (_elm_config->font_cache == size) return;
1678 _elm_config->font_cache = size;
1683 EINA_DEPRECATED EAPI int
1684 elm_image_cache_get(void)
1686 return elm_config_cache_image_cache_size_get();
1690 elm_config_cache_image_cache_size_get(void)
1692 return _elm_config->image_cache;
1695 EINA_DEPRECATED EAPI void
1696 elm_image_cache_set(int size)
1698 elm_config_cache_image_cache_size_set(size);
1702 elm_config_cache_image_cache_size_set(int size)
1704 if (_elm_config->image_cache == size) return;
1705 _elm_config->image_cache = size;
1710 EINA_DEPRECATED EAPI int
1711 elm_edje_file_cache_get(void)
1713 return elm_config_cache_edje_file_cache_size_get();
1717 elm_config_cache_edje_file_cache_size_get()
1719 return _elm_config->edje_cache;
1722 EINA_DEPRECATED EAPI void
1723 elm_edje_file_cache_set(int size)
1725 elm_config_cache_edje_file_cache_size_set(size);
1729 elm_config_cache_edje_file_cache_size_set(int size)
1731 if (_elm_config->edje_cache == size) return;
1732 _elm_config->edje_cache = size;
1737 EINA_DEPRECATED EAPI int
1738 elm_edje_collection_cache_get(void)
1740 return elm_config_cache_edje_collection_cache_size_get();
1744 elm_config_cache_edje_collection_cache_size_get(void)
1746 return _elm_config->edje_collection_cache;
1749 EINA_DEPRECATED EAPI void
1750 elm_edje_collection_cache_set(int size)
1752 elm_config_cache_edje_collection_cache_size_set(size);
1756 elm_config_cache_edje_collection_cache_size_set(int size)
1758 if (_elm_config->edje_collection_cache == size) return;
1759 _elm_config->edje_collection_cache = size;
1765 elm_config_focus_highlight_enabled_get(void)
1767 return _elm_config->focus_highlight_enable;
1771 elm_config_focus_highlight_enabled_set(Eina_Bool enable)
1773 _elm_config->focus_highlight_enable = !!enable;
1777 elm_config_focus_highlight_animate_get(void)
1779 return _elm_config->focus_highlight_animate;
1783 elm_config_focus_highlight_animate_set(Eina_Bool animate)
1785 _elm_config->focus_highlight_animate = !!animate;
1789 elm_config_scroll_bounce_enabled_get(void)
1791 return _elm_config->thumbscroll_bounce_enable;
1795 elm_config_scroll_bounce_enabled_set(Eina_Bool enabled)
1797 _elm_config->thumbscroll_bounce_enable = enabled;
1801 elm_config_scroll_bounce_friction_get(void)
1803 return _elm_config->thumbscroll_bounce_friction;
1807 elm_config_scroll_bounce_friction_set(double friction)
1809 _elm_config->thumbscroll_bounce_friction = friction;
1813 elm_config_scroll_page_scroll_friction_get(void)
1815 return _elm_config->page_scroll_friction;
1819 elm_config_scroll_page_scroll_friction_set(double friction)
1821 _elm_config->page_scroll_friction = friction;
1825 elm_config_scroll_bring_in_scroll_friction_get(void)
1827 return _elm_config->bring_in_scroll_friction;
1831 elm_config_scroll_bring_in_scroll_friction_set(double friction)
1833 _elm_config->bring_in_scroll_friction = friction;
1837 elm_config_scroll_zoom_friction_get(void)
1839 return _elm_config->zoom_friction;
1843 elm_config_scroll_zoom_friction_set(double friction)
1845 _elm_config->zoom_friction = friction;
1849 elm_config_scroll_thumbscroll_enabled_get(void)
1851 return _elm_config->thumbscroll_enable;
1855 elm_config_scroll_thumbscroll_enabled_set(Eina_Bool enabled)
1857 _elm_config->thumbscroll_enable = enabled;
1861 elm_config_scroll_thumbscroll_threshold_get(void)
1863 return _elm_config->thumbscroll_threshold;
1867 elm_config_scroll_thumbscroll_threshold_set(unsigned int threshold)
1869 _elm_config->thumbscroll_threshold = threshold;
1873 elm_config_scroll_thumbscroll_momentum_threshold_get(void)
1875 return _elm_config->thumbscroll_momentum_threshold;
1879 elm_config_scroll_thumbscroll_momentum_threshold_set(double threshold)
1881 _elm_config->thumbscroll_momentum_threshold = threshold;
1885 elm_config_scroll_thumbscroll_friction_get(void)
1887 return _elm_config->thumbscroll_friction;
1891 elm_config_scroll_thumbscroll_friction_set(double friction)
1893 _elm_config->thumbscroll_friction = friction;
1897 elm_config_scroll_thumbscroll_border_friction_get(void)
1899 return _elm_config->thumbscroll_border_friction;
1903 elm_config_scroll_thumbscroll_border_friction_set(double friction)
1905 if (friction < 0.0) friction = 0.0;
1906 if (friction > 1.0) friction = 1.0;
1907 _elm_config->thumbscroll_friction = friction;
1911 elm_config_scroll_thumbscroll_sensitivity_friction_get(void)
1913 return _elm_config->thumbscroll_sensitivity_friction;
1917 elm_config_scroll_thumbscroll_sensitivity_friction_set(double friction)
1919 if (friction < 0.1) friction = 0.1;
1920 if (friction > 1.0) friction = 1.0;
1921 _elm_config->thumbscroll_friction = friction;
1925 elm_config_longpress_timeout_set(double longpress_timeout)
1927 _elm_config->longpress_timeout = longpress_timeout;
1931 elm_config_longpress_timeout_get(void)
1933 return _elm_config->longpress_timeout;
1937 elm_config_all_flush(void)
1939 #ifdef HAVE_ELEMENTARY_X
1940 if (_prop_all_update_timer) ecore_timer_del(_prop_all_update_timer);
1941 _prop_all_update_timer = ecore_timer_add(0.1, _prop_all_update_cb, NULL);
1949 const char *cur_dom = textdomain(NULL);
1950 const char *trans_comment = gettext("");
1951 const char *msg_locale = setlocale(LC_MESSAGES, NULL);
1953 /* Same concept as what glib does:
1954 * We shouldn't translate if there are no translations for the
1955 * application in the current locale + domain. (Unless locale is
1956 * en_/C where translating only parts of the interface make some
1959 _elm_config->translate = !(strcmp (cur_dom, "messages") &&
1960 !*trans_comment && strncmp (msg_locale, "en_", 3) &&
1961 strcmp (msg_locale, "C"));
1966 _elm_config_init(void)
1968 if (!ELM_EVENT_CONFIG_ALL_CHANGED)
1969 ELM_EVENT_CONFIG_ALL_CHANGED = ecore_event_type_new();
1971 _profile_fetch_from_conf();
1973 if (_elm_preferred_engine) eina_stringshare_del(_elm_preferred_engine);
1974 if (_elm_config->engine)
1975 _elm_preferred_engine = eina_stringshare_add(_elm_config->engine);
1977 _elm_preferred_engine = NULL;
1978 _translation_init();
1981 _elm_config_font_overlay_apply();
1986 _elm_config_sub_shutdown(void)
1988 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
1989 if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
1990 ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
1991 ENGINE_COMPARE(ELM_XRENDER_X11) ||
1992 ENGINE_COMPARE(ELM_OPENGL_X11) ||
1993 ENGINE_COMPARE(ELM_OPENGL_COCOA))
1994 #undef ENGINE_COMPARE
1996 #ifdef HAVE_ELEMENTARY_X
1997 ecore_x_disconnect();
2003 _elm_config_sub_init(void)
2005 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2006 if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
2007 ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
2008 ENGINE_COMPARE(ELM_XRENDER_X11) ||
2009 ENGINE_COMPARE(ELM_OPENGL_X11) ||
2010 ENGINE_COMPARE(ELM_OPENGL_COCOA))
2011 #undef ENGINE_COMPARE
2013 #ifdef HAVE_ELEMENTARY_X
2014 if (!ecore_x_init(NULL))
2016 ERR("Cannot connect to X11 display. check $DISPLAY variable");
2019 _root_1st = ecore_x_window_root_first_get();
2021 if (!ecore_x_screen_is_composited(0))
2022 _elm_config->compositing = 0;
2024 ecore_x_atoms_get(_atom_names, ATOM_COUNT, _atom);
2025 ecore_x_event_mask_set(_root_1st,
2026 ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
2027 _prop_change_handler = ecore_event_handler_add
2028 (ECORE_X_EVENT_WINDOW_PROPERTY, _prop_change, NULL);
2029 if (!getenv("ELM_PROFILE"))
2033 s = ecore_x_window_prop_string_get(_root_1st,
2034 _atom[ATOM_E_PROFILE]);
2041 if (strcmp(_elm_profile, s)) changed = 1;
2045 if (changed) _prop_config_get();
2050 _config_sub_apply();
2054 _elm_config_reload(void)
2059 _elm_config_font_overlay_apply();
2065 _elm_config_engine_set(const char *engine)
2067 if (_elm_config->engine && strcmp(_elm_config->engine, engine))
2068 eina_stringshare_del(_elm_config->engine);
2070 _elm_config->engine = eina_stringshare_add(engine);
2074 elm_config_preferred_engine_get(void)
2076 return _elm_preferred_engine;
2080 elm_config_preferred_engine_set(const char *engine)
2083 eina_stringshare_replace(&(_elm_preferred_engine), engine);
2086 if (_elm_preferred_engine) eina_stringshare_del(_elm_preferred_engine);
2087 _elm_preferred_engine = eina_stringshare_add(_elm_config->engine);
2092 _elm_config_profile_set(const char *profile)
2094 Eina_Bool changed = EINA_FALSE;
2098 if (strcmp(_elm_profile, profile))
2103 _elm_profile = strdup(profile);
2110 _elm_config_font_overlay_apply();
2117 _elm_config_shutdown(void)
2119 #ifdef HAVE_ELEMENTARY_X
2120 if (_prop_all_update_timer)
2122 ecore_timer_del(_prop_all_update_timer);
2123 _prop_all_update_timer = NULL;
2124 _prop_all_update_cb(NULL);
2126 if (_prop_change_delay_timer) ecore_timer_del(_prop_change_delay_timer);
2127 _prop_change_delay_timer = NULL;
2130 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2131 if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
2132 ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
2133 ENGINE_COMPARE(ELM_XRENDER_X11) ||
2134 ENGINE_COMPARE(ELM_OPENGL_X11))
2135 #undef ENGINE_COMPARE
2137 #ifdef HAVE_ELEMENTARY_X
2138 ecore_event_handler_del(_prop_change_handler);
2139 _prop_change_handler = NULL;
2143 if (_elm_preferred_engine)
2145 eina_stringshare_del(_elm_preferred_engine);
2146 _elm_preferred_engine = NULL;
2151 _elm_profile = NULL;