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 static Eet_Data_Descriptor *_config_color_edd = NULL;
19 static Eet_Data_Descriptor *_config_color_palette_edd = NULL;
20 const char *_elm_preferred_engine = NULL;
22 static Ecore_Poller *_elm_cache_flush_poller = NULL;
24 const char *_elm_engines[] = {
33 "software_16_wince_gdi",
46 /* whenever you want to add a new text class support into Elementary,
47 declare it both here and in the (default) theme */
48 static const Elm_Text_Class _elm_text_classes[] = {
49 {"button", "Button Labels"},
50 {"label", "Text Labels"},
51 {"entry", "Text Entries"},
52 {"title_bar", "Title Bar"},
53 {"list_item", "List Items"},
54 {"grid_item", "Grid Items"},
55 {"toolbar_item", "Toolbar Items"},
56 {"menu_item", "Menu Items"},
60 static void _desc_init(void);
61 static void _desc_shutdown(void);
62 static void _profile_fetch_from_conf(void);
63 static void _config_free(void);
64 static void _config_apply(void);
65 static Elm_Config *_config_user_load(void);
66 static Elm_Config *_config_system_load(void);
67 static void _config_load(void);
68 static void _config_update(void);
69 static void _env_get(void);
70 static size_t _elm_data_dir_snprintf(char *dst,
74 static size_t _elm_user_dir_snprintf(char *dst,
79 #define ELM_CONFIG_VAL(edd, type, member, dtype) \
80 EET_DATA_DESCRIPTOR_ADD_BASIC(edd, type, #member, member, dtype)
81 #define ELM_CONFIG_LIST(edd, type, member, eddtype) \
82 EET_DATA_DESCRIPTOR_ADD_LIST(edd, type, #member, member, eddtype)
84 #ifdef HAVE_ELEMENTARY_X
85 static Ecore_Event_Handler *_prop_change_handler = NULL;
86 static Ecore_Timer *_prop_all_update_timer = NULL;
87 static Ecore_Timer *_prop_change_delay_timer = NULL;
88 static Ecore_X_Window _root_1st = 0;
90 static Ecore_X_Atom _atom[ATOM_COUNT];
91 static Ecore_X_Atom _atom_config = 0;
92 static const char *_atom_names[ATOM_COUNT] =
97 #define ATOM_E_PROFILE 0
98 #define ATOM_E_CONFIG 1
100 static Eina_Bool _prop_all_update_cb(void *data __UNUSED__);
101 static Eina_Bool _prop_config_get(void);
102 static void _prop_config_set(void);
103 static Eina_Bool _prop_change(void *data __UNUSED__,
104 int ev_type __UNUSED__,
108 _prop_all_update_cb(void *data __UNUSED__)
111 ecore_x_window_prop_string_set(_root_1st, _atom[ATOM_E_PROFILE],
113 _prop_all_update_timer = NULL;
118 _prop_config_get(void)
123 unsigned char *data = NULL;
124 Elm_Config *config_data;
126 snprintf(buf, sizeof(buf), "ELM_CONFIG_%s", _elm_profile);
127 atom = ecore_x_atom_get(buf);
129 if (!ecore_x_window_prop_property_get(_root_1st,
130 atom, _atom[ATOM_E_CONFIG],
133 if (!ecore_x_window_prop_property_get(_root_1st,
134 _atom[ATOM_E_CONFIG],
135 _atom[ATOM_E_CONFIG],
139 _atom_config = _atom[ATOM_E_CONFIG];
148 config_data = eet_data_descriptor_decode(_config_edd, data, size);
150 if (!config_data) return EINA_FALSE;
152 /* What do we do on version mismatch when someone changes the
153 * config in the rootwindow? */
154 /* Most obvious case, new version and we are still linked to
155 * whatever was there before, we just ignore until user restarts us */
156 if (config_data->config_version > ELM_CONFIG_VERSION)
158 /* What in the case the version is older? Do we even support those
159 * cases or we only check for equality above? */
162 _elm_config = config_data;
164 _elm_config_font_overlay_apply();
167 ecore_event_add(ELM_EVENT_CONFIG_ALL_CHANGED, NULL, NULL, NULL);
172 _prop_config_set(void)
174 unsigned char *config_data = NULL;
177 config_data = eet_data_descriptor_encode(_config_edd, _elm_config, &size);
183 snprintf(buf, sizeof(buf), "ELM_CONFIG_%s", _elm_profile);
184 atom = ecore_x_atom_get(buf);
187 ecore_x_window_prop_property_set(_root_1st, _atom_config,
188 _atom[ATOM_E_CONFIG], 8,
195 _prop_change_delay_cb(void *data __UNUSED__)
199 s = ecore_x_window_prop_string_get(_root_1st, _atom[ATOM_E_PROFILE]);
202 if (_elm_profile) free(_elm_profile);
206 _prop_change_delay_timer = NULL;
211 _prop_change(void *data __UNUSED__,
212 int ev_type __UNUSED__,
215 Ecore_X_Event_Window_Property *event = ev;
217 if (event->win == _root_1st)
219 if (event->atom == _atom[ATOM_E_PROFILE])
221 if (_prop_change_delay_timer) ecore_timer_del(_prop_change_delay_timer);
222 _prop_change_delay_timer = ecore_timer_add(0.1, _prop_change_delay_cb, NULL);
224 else if (((_atom_config > 0) && (event->atom == _atom_config)) ||
225 (event->atom == _atom[ATOM_E_CONFIG]))
227 if (_prop_change_delay_timer) ecore_timer_del(_prop_change_delay_timer);
228 _prop_change_delay_timer = ecore_timer_add(0.1, _prop_change_delay_cb, NULL);
231 return ECORE_CALLBACK_PASS_ON;
239 Eet_Data_Descriptor_Class eddc;
241 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Config);
242 eddc.func.str_direct_alloc = NULL;
243 eddc.func.str_direct_free = NULL;
245 _config_edd = eet_data_descriptor_file_new(&eddc);
248 printf("EEEK! eet_data_descriptor_file_new() failed\n");
252 memset(&eddc, 0, sizeof(eddc)); /* just in case... */
253 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Font_Overlay);
254 eddc.func.str_direct_alloc = NULL;
255 eddc.func.str_direct_free = NULL;
257 _config_font_overlay_edd = eet_data_descriptor_stream_new(&eddc);
258 if (!_config_font_overlay_edd)
260 printf("EEEK! eet_data_descriptor_stream_new() failed\n");
261 eet_data_descriptor_free(_config_edd);
265 memset(&eddc, 0, sizeof(eddc)); /* just in case... */
266 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Color_RGBA);
267 eddc.func.str_direct_alloc = NULL;
268 eddc.func.str_direct_free = NULL;
270 _config_color_edd = eet_data_descriptor_stream_new(&eddc);
271 if (!_config_color_edd)
273 printf("EEEK! eet_data_descriptor_stream_new() failed\n");
274 eet_data_descriptor_free(_config_edd);
278 memset(&eddc, 0, sizeof(eddc)); /* just in case... */
279 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Custom_Palette);
280 eddc.func.str_direct_alloc = NULL;
281 eddc.func.str_direct_free = NULL;
283 _config_color_palette_edd = eet_data_descriptor_stream_new(&eddc);
284 if (!_config_color_palette_edd)
286 printf("EEEK! eet_data_descriptor_stream_new() failed\n");
287 eet_data_descriptor_free(_config_edd);
291 #define T_INT EET_T_INT
292 #define T_DOUBLE EET_T_DOUBLE
293 #define T_STRING EET_T_STRING
294 #define T_UCHAR EET_T_UCHAR
296 #define T Elm_Font_Overlay
297 #define D _config_font_overlay_edd
298 ELM_CONFIG_VAL(D, T, text_class, EET_T_STRING);
299 ELM_CONFIG_VAL(D, T, font, EET_T_STRING);
300 ELM_CONFIG_VAL(D, T, size, EET_T_INT);
304 #define T Elm_Color_RGBA
305 #define D _config_color_edd
306 ELM_CONFIG_VAL(D, T, r, EET_T_UINT);
307 ELM_CONFIG_VAL(D, T, g, EET_T_UINT);
308 ELM_CONFIG_VAL(D, T, b, EET_T_UINT);
309 ELM_CONFIG_VAL(D, T, a, EET_T_UINT);
313 #define T Elm_Custom_Palette
314 #define D _config_color_palette_edd
315 ELM_CONFIG_VAL(D, T, palette_name, EET_T_STRING);
316 ELM_CONFIG_LIST(D, T, color_list, _config_color_edd);
321 #define D _config_edd
322 ELM_CONFIG_VAL(D, T, config_version, T_INT);
323 ELM_CONFIG_VAL(D, T, engine, T_STRING);
324 ELM_CONFIG_VAL(D, T, vsync, T_UCHAR);
325 ELM_CONFIG_VAL(D, T, thumbscroll_enable, T_UCHAR);
326 ELM_CONFIG_VAL(D, T, thumbscroll_threshold, T_INT);
327 ELM_CONFIG_VAL(D, T, thumbscroll_momentum_threshold, T_DOUBLE);
328 ELM_CONFIG_VAL(D, T, thumbscroll_friction, T_DOUBLE);
329 ELM_CONFIG_VAL(D, T, thumbscroll_bounce_friction, T_DOUBLE);
330 ELM_CONFIG_VAL(D, T, thumbscroll_border_friction, T_DOUBLE);
331 ELM_CONFIG_VAL(D, T, thumbscroll_sensitivity_friction, T_DOUBLE);
332 ELM_CONFIG_VAL(D, T, page_scroll_friction, T_DOUBLE);
333 ELM_CONFIG_VAL(D, T, bring_in_scroll_friction, T_DOUBLE);
334 ELM_CONFIG_VAL(D, T, zoom_friction, T_DOUBLE);
335 ELM_CONFIG_VAL(D, T, thumbscroll_bounce_enable, T_UCHAR);
336 ELM_CONFIG_VAL(D, T, scroll_smooth_time_interval, T_DOUBLE);
337 ELM_CONFIG_VAL(D, T, scroll_smooth_amount, T_DOUBLE);
338 ELM_CONFIG_VAL(D, T, scroll_smooth_history_weight, T_DOUBLE);
339 ELM_CONFIG_VAL(D, T, scroll_smooth_future_time, T_DOUBLE);
340 ELM_CONFIG_VAL(D, T, scroll_smooth_time_window, T_DOUBLE);
341 ELM_CONFIG_VAL(D, T, scale, T_DOUBLE);
342 ELM_CONFIG_VAL(D, T, bgpixmap, T_INT);
343 ELM_CONFIG_VAL(D, T, compositing, T_INT);
344 /* EET_DATA_DESCRIPTOR_ADD_LIST(D, T, "font_dirs", font_dirs, sub_edd); */
345 ELM_CONFIG_LIST(D, T, font_overlays, _config_font_overlay_edd);
346 ELM_CONFIG_VAL(D, T, font_hinting, T_INT);
347 ELM_CONFIG_VAL(D, T, cache_flush_poll_interval, T_INT);
348 ELM_CONFIG_VAL(D, T, cache_flush_enable, T_UCHAR);
349 ELM_CONFIG_VAL(D, T, image_cache, T_INT);
350 ELM_CONFIG_VAL(D, T, font_cache, T_INT);
351 ELM_CONFIG_VAL(D, T, edje_cache, T_INT);
352 ELM_CONFIG_VAL(D, T, edje_collection_cache, T_INT);
353 ELM_CONFIG_VAL(D, T, finger_size, T_INT);
354 ELM_CONFIG_VAL(D, T, fps, T_DOUBLE);
355 ELM_CONFIG_VAL(D, T, theme, T_STRING);
356 ELM_CONFIG_VAL(D, T, modules, T_STRING);
357 ELM_CONFIG_VAL(D, T, tooltip_delay, T_DOUBLE);
358 ELM_CONFIG_VAL(D, T, cursor_engine_only, T_UCHAR);
359 ELM_CONFIG_VAL(D, T, focus_highlight_enable, T_UCHAR);
360 ELM_CONFIG_VAL(D, T, focus_highlight_animate, T_UCHAR);
361 ELM_CONFIG_VAL(D, T, toolbar_shrink_mode, T_INT);
362 ELM_CONFIG_VAL(D, T, fileselector_expand_enable, T_UCHAR);
363 ELM_CONFIG_VAL(D, T, inwin_dialogs_enable, T_UCHAR);
364 ELM_CONFIG_VAL(D, T, icon_size, T_INT);
365 ELM_CONFIG_VAL(D, T, longpress_timeout, T_DOUBLE);
366 ELM_CONFIG_VAL(D, T, effect_enable, T_UCHAR);
367 ELM_CONFIG_VAL(D, T, desktop_entry, T_UCHAR);
368 ELM_CONFIG_VAL(D, T, password_show_last, T_UCHAR);
369 ELM_CONFIG_VAL(D, T, password_show_last_timeout, T_DOUBLE);
370 ELM_CONFIG_VAL(D, T, glayer_zoom_finger_enable, T_UCHAR);
371 ELM_CONFIG_VAL(D, T, glayer_zoom_finger_factor, T_DOUBLE);
372 ELM_CONFIG_VAL(D, T, glayer_zoom_wheel_factor, T_DOUBLE);
373 ELM_CONFIG_VAL(D, T, glayer_zoom_distance_tolerance, T_DOUBLE);
374 ELM_CONFIG_VAL(D, T, glayer_rotate_finger_enable, T_UCHAR);
375 ELM_CONFIG_VAL(D, T, glayer_rotate_angular_tolerance, T_DOUBLE);
376 ELM_CONFIG_VAL(D, T, glayer_line_min_length, T_DOUBLE);
377 ELM_CONFIG_VAL(D, T, glayer_line_distance_tolerance, T_DOUBLE);
378 ELM_CONFIG_VAL(D, T, glayer_line_angular_tolerance, T_DOUBLE);
379 ELM_CONFIG_VAL(D, T, glayer_flick_time_limit_ms, T_INT);
380 ELM_CONFIG_VAL(D, T, glayer_long_tap_start_timeout, T_DOUBLE);
381 ELM_CONFIG_VAL(D, T, access_mode, T_INT);
382 ELM_CONFIG_VAL(D, T, glayer_continues_enable, T_UCHAR);
383 ELM_CONFIG_VAL(D, T, week_start, T_INT);
384 ELM_CONFIG_VAL(D, T, weekend_start, T_INT);
385 ELM_CONFIG_VAL(D, T, weekend_len, T_INT);
386 ELM_CONFIG_VAL(D, T, year_min, T_INT);
387 ELM_CONFIG_VAL(D, T, year_max, T_INT);
388 ELM_CONFIG_LIST(D, T, color_palette, _config_color_palette_edd);
402 eet_data_descriptor_free(_config_edd);
406 if (_config_font_overlay_edd)
408 eet_data_descriptor_free(_config_font_overlay_edd);
409 _config_font_overlay_edd = NULL;
412 if (_config_color_edd)
414 eet_data_descriptor_free(_config_color_edd);
415 _config_color_edd = NULL;
418 if (_config_color_palette_edd)
420 eet_data_descriptor_free(_config_color_palette_edd);
421 _config_color_palette_edd = NULL;
426 _sort_files_cb(const void *f1,
429 return strcmp(f1, f2);
433 _elm_config_current_profile_get(void)
439 _elm_data_dir_snprintf(char *dst,
444 size_t data_dir_len, off;
447 data_dir_len = eina_strlcpy(dst, _elm_data_dir, size);
449 off = data_dir_len + 1;
454 dst[data_dir_len] = '/';
456 off = off + vsnprintf(dst + off, size - off, fmt, ap);
464 _elm_user_dir_snprintf(char *dst,
470 size_t user_dir_len, off;
474 home = evil_homedir_get();
476 home = getenv("HOME");
481 user_dir_len = eina_str_join_len(dst, size, '/', home, strlen(home),
482 ELEMENTARY_BASE_DIR, sizeof(ELEMENTARY_BASE_DIR) - 1);
484 off = user_dir_len + 1;
489 dst[user_dir_len] = '/';
491 off = off + vsnprintf(dst + off, size - off, fmt, ap);
499 _elm_config_profile_dir_get(const char *prof,
507 _elm_user_dir_snprintf(buf, sizeof(buf), "config/%s", prof);
509 if (ecore_file_is_dir(buf))
515 snprintf(buf, sizeof(buf), "%s/config/%s", _elm_data_dir, prof);
517 if (ecore_file_is_dir(buf))
524 _elm_config_font_overlays_list(void)
526 return _elm_config->font_overlays;
530 _elm_config_font_overlay_set(const char *text_class,
534 Elm_Font_Overlay *efd;
537 EINA_LIST_FOREACH(_elm_config->font_overlays, l, efd)
539 if (strcmp(efd->text_class, text_class))
542 if (efd->font) eina_stringshare_del(efd->font);
543 efd->font = eina_stringshare_add(font);
545 _elm_config->font_overlays =
546 eina_list_promote_list(_elm_config->font_overlays, l);
550 /* the text class doesn't exist */
551 efd = calloc(1, sizeof(Elm_Font_Overlay));
552 efd->text_class = eina_stringshare_add(text_class);
553 efd->font = eina_stringshare_add(font);
556 _elm_config->font_overlays = eina_list_prepend(_elm_config->font_overlays,
561 _elm_config_font_overlay_remove(const char *text_class)
563 Elm_Font_Overlay *efd;
566 EINA_LIST_FOREACH(_elm_config->font_overlays, l, efd)
568 if (strcmp(efd->text_class, text_class))
571 _elm_config->font_overlays =
572 eina_list_remove_list(_elm_config->font_overlays, l);
573 if (efd->text_class) eina_stringshare_del(efd->text_class);
574 if (efd->font) eina_stringshare_del(efd->font);
582 _elm_config_font_overlay_apply(void)
584 Elm_Font_Overlay *efd;
588 for (i = 0; _elm_text_classes[i].desc; i++)
589 edje_text_class_del(_elm_text_classes[i].name);
591 EINA_LIST_FOREACH(_elm_config->font_overlays, l, efd)
592 edje_text_class_set(efd->text_class, efd->font, efd->size);
596 _elm_config_text_classes_get(void)
598 Eina_List *ret = NULL;
601 for (i = 0; _elm_text_classes[i].desc; i++)
604 tc = malloc(sizeof(*tc));
607 *tc = _elm_text_classes[i];
609 ret = eina_list_append(ret, tc);
616 _elm_config_text_classes_free(Eina_List *l)
620 EINA_LIST_FREE(l, tc)
625 _elm_config_color_list_get(const char *palette_name)
628 Elm_Custom_Palette *cpalette;
629 EINA_LIST_FOREACH(_elm_config->color_palette, plist, cpalette)
631 if (strcmp(cpalette->palette_name, palette_name))
633 return cpalette->color_list;
639 _elm_config_color_set(const char *palette_name,
646 Elm_Custom_Palette *cpalette;
647 Elm_Color_RGBA *color;
648 EINA_LIST_FOREACH(_elm_config->color_palette, plist, cpalette)
650 if (strcmp(cpalette->palette_name, palette_name))
653 color = calloc(1, sizeof(Elm_Color_RGBA));
658 cpalette->color_list = eina_list_prepend(cpalette->color_list,
664 _elm_config_colors_free(const char *palette_name)
667 Elm_Custom_Palette *cpalette;
668 Elm_Color_RGBA *color;
669 EINA_LIST_FOREACH(_elm_config->color_palette, plist, cpalette)
671 if (strcmp(cpalette->palette_name, palette_name))
674 EINA_LIST_FREE(cpalette->color_list, color)
682 _elm_config_profiles_list(void)
684 Eina_File_Direct_Info *info;
685 Eina_List *flist = NULL;
686 Eina_Iterator *file_it;
691 len = _elm_user_dir_snprintf(buf, sizeof(buf), "config");
693 file_it = eina_file_stat_ls(buf);
700 len = sizeof(buf) - len;
702 EINA_ITERATOR_FOREACH(file_it, info)
704 if (info->name_length >= len)
707 if (info->type == EINA_FILE_DIR)
710 eina_list_sorted_insert(flist, _sort_files_cb,
711 eina_stringshare_add(info->path +
716 eina_iterator_free(file_it);
719 len = eina_str_join_len(buf, sizeof(buf), '/', _elm_data_dir,
720 strlen(_elm_data_dir), "config",
721 sizeof("config") - 1);
723 file_it = eina_file_direct_ls(buf);
730 len = sizeof(buf) - len;
731 EINA_ITERATOR_FOREACH(file_it, info)
733 if (info->name_length >= len)
743 EINA_LIST_FOREACH(flist, l, tmp)
744 if (!strcmp(info->path + info->name_start, tmp))
749 eina_list_sorted_insert(flist, _sort_files_cb,
750 eina_stringshare_add(info->path +
759 eina_iterator_free(file_it);
763 EINA_LIST_FREE(flist, dir)
764 eina_stringshare_del(dir);
770 _profile_fetch_from_conf(void)
772 char buf[PATH_MAX], *p, *s;
776 _elm_profile = strdup("default");
778 // if env var - use profile without question
779 s = getenv("ELM_PROFILE");
783 _elm_profile = strdup(s);
788 _elm_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
789 ef = eet_open(buf, EET_FILE_MODE_READ);
792 p = eet_read(ef, "config", &len);
796 _elm_profile = malloc(len + 1);
797 memcpy(_elm_profile, p, len);
798 _elm_profile[len] = 0;
807 _elm_data_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
808 ef = eet_open(buf, EET_FILE_MODE_READ);
811 p = eet_read(ef, "config", &len);
815 _elm_profile = malloc(len + 1);
816 memcpy(_elm_profile, p, len);
817 _elm_profile[len] = 0;
827 Elm_Font_Overlay *fo;
829 Elm_Custom_Palette *palette;
830 Elm_Color_RGBA *color;
832 if (!_elm_config) return;
833 EINA_LIST_FREE(_elm_config->font_dirs, fontdir)
835 eina_stringshare_del(fontdir);
837 if (_elm_config->engine) eina_stringshare_del(_elm_config->engine);
838 EINA_LIST_FREE(_elm_config->font_overlays, fo)
840 if (fo->text_class) eina_stringshare_del(fo->text_class);
841 if (fo->font) eina_stringshare_del(fo->font);
844 EINA_LIST_FREE(_elm_config->color_palette, palette)
846 if (palette->palette_name) eina_stringshare_del(palette->palette_name);
847 EINA_LIST_FREE(palette->color_list, color) free(color);
850 if (_elm_config->theme) eina_stringshare_del(_elm_config->theme);
851 if (_elm_config->modules) eina_stringshare_del(_elm_config->modules);
859 _elm_theme_parse(NULL, _elm_config->theme);
860 ecore_animator_frametime_set(1.0 / _elm_config->fps);
864 _config_sub_apply(void)
866 edje_frametime_set(1.0 / _elm_config->fps);
867 edje_scale_set(_elm_config->scale);
868 edje_password_show_last_set(_elm_config->password_show_last);
869 edje_password_show_last_timeout_set(_elm_config->password_show_last_timeout);
870 if (_elm_config->modules) _elm_module_parse(_elm_config->modules);
874 _elm_cache_flush_cb(void *data __UNUSED__)
876 elm_cache_all_flush();
877 return ECORE_CALLBACK_RENEW;
880 /* kind of abusing this call right now -- shared between all of those
881 * properties -- but they are not meant to be called that periodically
889 elm_cache_all_flush();
891 EINA_LIST_FOREACH(_elm_win_list, l, win)
893 Evas *e = evas_object_evas_get(win);
894 evas_image_cache_set(e, _elm_config->image_cache * 1024);
895 evas_font_cache_set(e, _elm_config->font_cache * 1024);
897 edje_file_cache_set(_elm_config->edje_cache);
898 edje_collection_cache_set(_elm_config->edje_collection_cache);
900 if (_elm_cache_flush_poller)
902 ecore_poller_del(_elm_cache_flush_poller);
903 _elm_cache_flush_poller = NULL;
905 if (_elm_config->cache_flush_enable)
907 if (_elm_config->cache_flush_poll_interval > 0)
909 _elm_cache_flush_poller =
910 ecore_poller_add(ECORE_POLLER_CORE,
911 _elm_config->cache_flush_poll_interval,
912 _elm_cache_flush_cb, NULL);
918 _config_user_load(void)
920 Elm_Config *cfg = NULL;
924 _elm_user_dir_snprintf(buf, sizeof(buf), "config/%s/base.cfg",
927 ef = eet_open(buf, EET_FILE_MODE_READ);
930 cfg = eet_data_read(ef, _config_edd, "config");
937 _config_system_load(void)
939 Elm_Config *cfg = NULL;
943 _elm_data_dir_snprintf(buf, sizeof(buf), "config/%s/base.cfg",
946 ef = eet_open(buf, EET_FILE_MODE_READ);
949 cfg = eet_data_read(ef, _config_edd, "config");
958 _elm_config = _config_user_load();
961 if (_elm_config->config_version < ELM_CONFIG_VERSION)
966 /* no user config, fallback for system. No need to check version for
967 * this one, if it's not the right one, someone screwed up at the time
968 * of installing it */
969 _elm_config = _config_system_load();
970 if (_elm_config) return;
971 /* FIXME: config load could have failed because of a non-existent
972 * profile. Fallback to default before moving on */
974 // config load fail - defaults
975 // why are these here? well if they are, it means you can make a gui
976 // config recovery app i guess...
977 _elm_config = ELM_NEW(Elm_Config);
978 _elm_config->config_version = ELM_CONFIG_VERSION;
979 _elm_config->engine = eina_stringshare_add("software_x11");
980 _elm_config->vsync = 0;
981 _elm_config->thumbscroll_enable = EINA_TRUE;
982 _elm_config->thumbscroll_threshold = 24;
983 _elm_config->thumbscroll_momentum_threshold = 100.0;
984 _elm_config->thumbscroll_friction = 1.0;
985 _elm_config->thumbscroll_bounce_friction = 0.5;
986 _elm_config->thumbscroll_bounce_enable = EINA_TRUE;
987 _elm_config->page_scroll_friction = 0.5;
988 _elm_config->bring_in_scroll_friction = 0.5;
989 _elm_config->zoom_friction = 0.5;
990 _elm_config->thumbscroll_border_friction = 0.5;
991 _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
992 _elm_config->scroll_smooth_time_interval = 0.008;
993 _elm_config->scroll_smooth_amount = 1.0;
994 _elm_config->scroll_smooth_history_weight = 0.3;
995 _elm_config->scroll_smooth_future_time = 0.0;
996 _elm_config->scroll_smooth_time_window = 0.2;
997 _elm_config->scale = 1.0;
998 _elm_config->bgpixmap = 0;
999 _elm_config->compositing = 1;
1000 _elm_config->font_hinting = 2;
1001 _elm_config->cache_flush_poll_interval = 512;
1002 _elm_config->cache_flush_enable = EINA_TRUE;
1003 _elm_config->font_dirs = NULL;
1004 _elm_config->image_cache = 4096;
1005 _elm_config->font_cache = 512;
1006 _elm_config->edje_cache = 32;
1007 _elm_config->edje_collection_cache = 64;
1008 _elm_config->finger_size = 40;
1009 _elm_config->fps = 60.0;
1010 _elm_config->theme = eina_stringshare_add("default");
1011 _elm_config->modules = NULL;
1012 _elm_config->tooltip_delay = 1.0;
1013 _elm_config->cursor_engine_only = EINA_TRUE;
1014 _elm_config->focus_highlight_enable = EINA_FALSE;
1015 _elm_config->focus_highlight_animate = EINA_TRUE;
1016 _elm_config->toolbar_shrink_mode = 2;
1017 _elm_config->fileselector_expand_enable = EINA_FALSE;
1018 _elm_config->inwin_dialogs_enable = EINA_FALSE;
1019 _elm_config->icon_size = 32;
1020 _elm_config->longpress_timeout = 1.0;
1021 _elm_config->effect_enable = EINA_TRUE;
1022 _elm_config->desktop_entry = EINA_FALSE;
1023 _elm_config->is_mirrored = EINA_FALSE; /* Read sys value in env_get() */
1024 _elm_config->password_show_last = EINA_FALSE;
1025 _elm_config->password_show_last_timeout = 2.0;
1026 _elm_config->glayer_zoom_finger_enable = EINA_TRUE;
1027 _elm_config->glayer_zoom_finger_factor = 1.0;
1028 _elm_config->glayer_zoom_wheel_factor = 0.05;
1029 _elm_config->glayer_zoom_distance_tolerance = 1.0; /* 1 times elm_finger_size_get() */
1030 _elm_config->glayer_rotate_finger_enable = EINA_TRUE;
1031 _elm_config->glayer_rotate_angular_tolerance = 2.0; /* 2 DEG */
1032 _elm_config->glayer_line_min_length = 1.0; /* 1 times elm_finger_size_get() */
1033 _elm_config->glayer_line_distance_tolerance = 3.0; /* 3 times elm_finger_size_get() */
1034 _elm_config->glayer_line_angular_tolerance = 20.0; /* 20 DEG */
1035 _elm_config->glayer_flick_time_limit_ms = 120; /* ms to finish flick */
1036 _elm_config->glayer_long_tap_start_timeout = 1.2; /* 1.2 second to start long-tap */
1037 _elm_config->glayer_continues_enable = EINA_TRUE; /* Continue gestures default */
1038 _elm_config->week_start = 1; /* monday */
1039 _elm_config->weekend_start = 6; /* saturday */
1040 _elm_config->weekend_len = 2;
1041 _elm_config->year_min = 2;
1042 _elm_config->year_max = 137;
1043 _elm_config->color_palette = NULL;
1047 _elm_config_eet_close_error_get(Eet_File *ef,
1051 const char *erstr = NULL;
1053 err = eet_close(ef);
1056 case EET_ERROR_WRITE_ERROR:
1057 erstr = "An error occurred while saving Elementary's "
1058 "settings to disk. The error could not be "
1059 "deterimined. The file where the error occurred was: "
1060 "%s. This file has been deleted to avoid corrupt data.";
1063 case EET_ERROR_WRITE_ERROR_FILE_TOO_BIG:
1064 erstr = "Elementary's settings files are too big "
1065 "for the file system they are being saved to. "
1066 "This error is very strange as the files should "
1067 "be extremely small. Please check the settings "
1068 "for your home directory. "
1069 "The file where the error occurred was: %s ."
1070 "This file has been deleted to avoid corrupt data.";
1073 case EET_ERROR_WRITE_ERROR_IO_ERROR:
1074 erstr = "An output error occurred when writing the settings "
1075 "files for Elementary. Your disk is having troubles "
1076 "and possibly needs replacement. "
1077 "The file where the error occurred was: %s ."
1078 "This file has been deleted to avoid corrupt data.";
1081 case EET_ERROR_WRITE_ERROR_OUT_OF_SPACE:
1082 erstr = "Elementary cannot write its settings file "
1083 "because it ran out of space to write the file. "
1084 "You have either run out of disk space or have "
1085 "gone over your quota limit. "
1086 "The file where the error occurred was: %s ."
1087 "This file has been deleted to avoid corrupt data.";
1090 case EET_ERROR_WRITE_ERROR_FILE_CLOSED:
1091 erstr = "Elementary unexpectedly had the settings file "
1092 "it was writing closed on it. This is very unusual. "
1093 "The file where the error occurred was: %s "
1094 "This file has been deleted to avoid corrupt data.";
1102 /* delete any partially-written file */
1103 ecore_file_unlink(file);
1104 return strdup(erstr);
1111 _elm_config_profile_save(void)
1113 char buf[4096], buf2[4096];
1119 len = _elm_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
1120 if (len + 1 >= sizeof(buf))
1123 len = _elm_user_dir_snprintf(buf2, sizeof(buf2), "config/profile.cfg.tmp");
1124 if (len + 1 >= sizeof(buf2))
1127 ef = eet_open(buf2, EET_FILE_MODE_WRITE);
1131 ok = eet_write(ef, "config", _elm_profile, strlen(_elm_profile), 0);
1135 err = _elm_config_eet_close_error_get(ef, buf2);
1143 ret = ecore_file_mv(buf2, buf);
1146 ERR("Error saving Elementary's configuration file");
1150 ecore_file_unlink(buf2);
1154 ecore_file_unlink(buf2);
1159 _elm_config_save(void)
1161 char buf[4096], buf2[4096];
1167 len = _elm_user_dir_snprintf(buf, sizeof(buf), "config/%s", _elm_profile);
1168 if (len + 1 >= sizeof(buf))
1171 ok = ecore_file_mkpath(buf);
1174 ERR("Problem accessing Elementary's user configuration directory: %s",
1179 if (!_elm_config_profile_save())
1185 if (len + sizeof("base.cfg") >= sizeof(buf) - len)
1188 memcpy(buf + len, "base.cfg", sizeof("base.cfg"));
1189 len += sizeof("base.cfg") - 1;
1191 if (len + sizeof(".tmp") >= sizeof(buf))
1194 memcpy(buf2, buf, len);
1195 memcpy(buf2 + len, ".tmp", sizeof(".tmp"));
1197 ef = eet_open(buf2, EET_FILE_MODE_WRITE);
1201 ok = eet_data_write(ef, _config_edd, "config", _elm_config, 1);
1205 err = _elm_config_eet_close_error_get(ef, buf2);
1213 ret = ecore_file_mv(buf2, buf);
1216 ERR("Error saving Elementary's configuration file");
1220 ecore_file_unlink(buf2);
1224 ecore_file_unlink(buf2);
1229 _config_update(void)
1233 tcfg = _config_system_load();
1236 /* weird profile or something? We should probably fill
1237 * with hardcoded defaults, or get from default previx */
1240 #define IFCFG(v) if ((_elm_config->config_version & 0xffff) < (v)) {
1241 #define IFCFGELSE } else {
1243 #define COPYVAL(x) do {_elm_config->x = tcfg->x; } while (0)
1244 #define COPYPTR(x) do {_elm_config->x = tcfg->x; tcfg->x = NULL; } while (0)
1245 #define COPYSTR(x) COPYPTR(x)
1247 /* we also need to update for property changes in the root window
1248 * if needed, but that will be dependent on new properties added
1249 * with each version */
1252 COPYVAL(longpress_timeout);
1262 /* after updating user config, we must save */
1271 s = getenv("ELM_ENGINE");
1274 if ((!strcasecmp(s, "x11")) ||
1275 (!strcasecmp(s, "x")) ||
1276 (!strcasecmp(s, "software-x11")) ||
1277 (!strcasecmp(s, "software_x11")))
1278 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_X11);
1279 else if ((!strcasecmp(s, "opengl")) ||
1280 (!strcasecmp(s, "gl")) ||
1281 (!strcasecmp(s, "opengl-x11")) ||
1282 (!strcasecmp(s, "opengl_x11")))
1283 eina_stringshare_replace(&_elm_config->engine, ELM_OPENGL_X11);
1284 else if ((!strcasecmp(s, "x11-8")) ||
1285 (!strcasecmp(s, "x8")) ||
1286 (!strcasecmp(s, "software-8-x11")) ||
1287 (!strcasecmp(s, "software_8_x11")))
1288 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_8_X11);
1289 else if ((!strcasecmp(s, "x11-16")) ||
1290 (!strcasecmp(s, "x16")) ||
1291 (!strcasecmp(s, "software-16-x11")) ||
1292 (!strcasecmp(s, "software_16_x11")))
1293 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_16_X11);
1295 else if ((!strcasecmp(s, "xrender")) ||
1296 (!strcasecmp(s, "xr")) ||
1297 (!strcasecmp(s, "xrender-x11")) ||
1298 (!strcasecmp(s, "xrender_x11")))
1299 eina_stringshare_replace(&_elm_config->engine, ELM_XRENDER_X11);
1301 else if ((!strcasecmp(s, "fb")) ||
1302 (!strcasecmp(s, "software-fb")) ||
1303 (!strcasecmp(s, "software_fb")))
1304 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_FB);
1305 else if ((!strcasecmp(s, "directfb")) ||
1306 (!strcasecmp(s, "dfb")))
1307 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_DIRECTFB);
1308 else if ((!strcasecmp(s, "psl1ght")))
1309 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_PSL1GHT);
1310 else if ((!strcasecmp(s, "sdl")) ||
1311 (!strcasecmp(s, "software-sdl")) ||
1312 (!strcasecmp(s, "software_sdl")))
1313 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_SDL);
1314 else if ((!strcasecmp(s, "sdl-16")) ||
1315 (!strcasecmp(s, "software-16-sdl")) ||
1316 (!strcasecmp(s, "software_16_sdl")))
1317 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_16_SDL);
1318 else if ((!strcasecmp(s, "opengl-sdl")) ||
1319 (!strcasecmp(s, "opengl_sdl")) ||
1320 (!strcasecmp(s, "gl-sdl")) ||
1321 (!strcasecmp(s, "gl_sdl")))
1322 eina_stringshare_replace(&_elm_config->engine, ELM_OPENGL_SDL);
1323 else if ((!strcasecmp(s, "opengl-cocoa")) ||
1324 (!strcasecmp(s, "opengl_cocoa")) ||
1325 (!strcasecmp(s, "gl-cocoa")) ||
1326 (!strcasecmp(s, "gl_cocoa")))
1327 eina_stringshare_replace(&_elm_config->engine, ELM_OPENGL_COCOA);
1328 else if ((!strcasecmp(s, "gdi")) ||
1329 (!strcasecmp(s, "software-gdi")) ||
1330 (!strcasecmp(s, "software_gdi")))
1331 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_WIN32);
1332 else if ((!strcasecmp(s, "wince-gdi")) ||
1333 (!strcasecmp(s, "software-16-wince-gdi")) ||
1334 (!strcasecmp(s, "software_16_wince_gdi")))
1335 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_16_WINCE);
1336 else if (!strcasecmp(s, "buffer"))
1337 eina_stringshare_replace(&_elm_config->engine, ELM_BUFFER);
1338 else if ((!strncmp(s, "shot:", 5)))
1339 eina_stringshare_replace(&_elm_config->engine, s);
1340 else if ((!strcasecmp(s, "ews")))
1341 eina_stringshare_replace(&_elm_config->engine, ELM_EWS);
1342 else if ((!strcasecmp(s, "wayland_shm")))
1343 eina_stringshare_replace(&_elm_config->engine, ELM_WAYLAND_SHM);
1344 else if ((!strcasecmp(s, "wayland_egl")))
1345 eina_stringshare_replace(&_elm_config->engine, ELM_WAYLAND_EGL);
1347 ERR("Unknown engine '%s'.", s);
1350 s = getenv("ELM_VSYNC");
1351 if (s) _elm_config->vsync = !!atoi(s);
1353 s = getenv("ELM_THUMBSCROLL_ENABLE");
1354 if (s) _elm_config->thumbscroll_enable = !!atoi(s);
1355 s = getenv("ELM_THUMBSCROLL_THRESHOLD");
1356 if (s) _elm_config->thumbscroll_threshold = atoi(s);
1357 // FIXME: floatformat locale issues here 1.0 vs 1,0 - should just be 1.0
1358 s = getenv("ELM_THUMBSCROLL_MOMENTUM_THRESHOLD");
1359 if (s) _elm_config->thumbscroll_momentum_threshold = _elm_atof(s);
1360 s = getenv("ELM_THUMBSCROLL_FRICTION");
1361 if (s) _elm_config->thumbscroll_friction = _elm_atof(s);
1362 s = getenv("ELM_THUMBSCROLL_BOUNCE_ENABLE");
1363 if (s) _elm_config->thumbscroll_bounce_enable = !!atoi(s);
1364 s = getenv("ELM_THUMBSCROLL_BOUNCE_FRICTION");
1365 if (s) _elm_config->thumbscroll_bounce_friction = _elm_atof(s);
1366 s = getenv("ELM_PAGE_SCROLL_FRICTION");
1367 if (s) _elm_config->page_scroll_friction = _elm_atof(s);
1368 s = getenv("ELM_BRING_IN_SCROLL_FRICTION");
1369 if (s) _elm_config->bring_in_scroll_friction = _elm_atof(s);
1370 s = getenv("ELM_ZOOM_FRICTION");
1371 if (s) _elm_config->zoom_friction = _elm_atof(s);
1372 s = getenv("ELM_THUMBSCROLL_BORDER_FRICTION");
1375 friction = _elm_atof(s);
1382 _elm_config->thumbscroll_border_friction = friction;
1384 s = getenv("ELM_THUMBSCROLL_SENSITIVITY_FRICTION");
1387 friction = _elm_atof(s);
1394 _elm_config->thumbscroll_sensitivity_friction = friction;
1396 s = getenv("ELM_SCROLL_SMOOTH_TIME_INTERVAL");
1397 if (s) _elm_config->scroll_smooth_time_interval = atof(s);
1398 s = getenv("ELM_SCROLL_SMOOTH_AMOUNT");
1399 if (s) _elm_config->scroll_smooth_amount = _elm_atof(s);
1400 s = getenv("ELM_SCROLL_SMOOTH_HISTORY_WEIGHT");
1401 if (s) _elm_config->scroll_smooth_history_weight = _elm_atof(s);
1402 s = getenv("ELM_SCROLL_SMOOTH_FUTURE_TIME");
1403 if (s) _elm_config->scroll_smooth_future_time = _elm_atof(s);
1404 s = getenv("ELM_SCROLL_SMOOTH_TIME_WINDOW");
1405 if (s) _elm_config->scroll_smooth_time_window = _elm_atof(s);
1406 s = getenv("ELM_THEME");
1407 if (s) eina_stringshare_replace(&_elm_config->theme, s);
1409 s = getenv("ELM_FONT_HINTING");
1412 if (!strcasecmp(s, "none")) _elm_config->font_hinting = 0;
1413 else if (!strcasecmp(s, "auto"))
1414 _elm_config->font_hinting = 1;
1415 else if (!strcasecmp(s, "bytecode"))
1416 _elm_config->font_hinting = 2;
1419 s = getenv("ELM_FONT_PATH");
1425 EINA_LIST_FREE(_elm_config->font_dirs, p)
1427 eina_stringshare_del(p);
1430 buf2 = alloca(strlen(s) + 1);
1435 if ((*p == ':') || (*p == 0))
1440 strncpy(buf2, pp, len);
1442 _elm_config->font_dirs =
1443 eina_list_append(_elm_config->font_dirs,
1444 eina_stringshare_add(buf2));
1457 s = getenv("ELM_IMAGE_CACHE");
1458 if (s) _elm_config->image_cache = atoi(s);
1460 s = getenv("ELM_FONT_CACHE");
1461 if (s) _elm_config->font_cache = atoi(s);
1463 s = getenv("ELM_SCALE");
1464 if (s) _elm_config->scale = _elm_atof(s);
1466 s = getenv("ELM_FINGER_SIZE");
1467 if (s) _elm_config->finger_size = atoi(s);
1469 s = getenv("ELM_PASSWORD_SHOW_LAST");
1470 if (s) _elm_config->password_show_last = !!atoi(s);
1472 s = getenv("ELM_PASSWORD_SHOW_LAST_TIMEOUT");
1475 double pw_show_last_timeout = _elm_atof(s);
1476 if (pw_show_last_timeout >= 0.0)
1477 _elm_config->password_show_last_timeout = pw_show_last_timeout;
1480 s = getenv("ELM_FPS");
1481 if (s) _elm_config->fps = _elm_atof(s);
1482 if (_elm_config->fps < 1.0) _elm_config->fps = 1.0;
1484 s = getenv("ELM_MODULES");
1485 if (s) eina_stringshare_replace(&_elm_config->modules, s);
1487 /* Get RTL orientation from system */
1488 setlocale(LC_ALL, "");
1489 bindtextdomain(PACKAGE, LOCALE_DIR);
1490 _elm_config->is_mirrored = !strcmp(E_("default:LTR"), "default:RTL");
1492 s = getenv("ELM_TOOLTIP_DELAY");
1495 double delay = _elm_atof(s);
1497 _elm_config->tooltip_delay = delay;
1500 s = getenv("ELM_CURSOR_ENGINE_ONLY");
1501 if (s) _elm_config->cursor_engine_only = !!atoi(s);
1503 s = getenv("ELM_FOCUS_HIGHLIGHT_ENABLE");
1504 if (s) _elm_config->focus_highlight_enable = !!atoi(s);
1506 s = getenv("ELM_FOCUS_HIGHLIGHT_ANIMATE");
1507 if (s) _elm_config->focus_highlight_animate = !!atoi(s);
1509 s = getenv("ELM_TOOLBAR_SHRINK_MODE");
1510 if (s) _elm_config->toolbar_shrink_mode = atoi(s);
1512 s = getenv("ELM_FILESELECTOR_EXPAND_ENABLE");
1513 if (s) _elm_config->fileselector_expand_enable = !!atoi(s);
1515 s = getenv("ELM_INWIN_DIALOGS_ENABLE");
1516 if (s) _elm_config->inwin_dialogs_enable = !!atoi(s);
1518 s = getenv("ELM_ICON_SIZE");
1519 if (s) _elm_config->icon_size = atoi(s);
1521 s = getenv("ELM_LONGPRESS_TIMEOUT");
1522 if (s) _elm_config->longpress_timeout = _elm_atof(s);
1523 if (_elm_config->longpress_timeout < 0.0)
1524 _elm_config->longpress_timeout = 0.0;
1526 s = getenv("ELM_EFFECT_ENABLE");
1527 if (s) _elm_config->effect_enable = !!atoi(s);
1529 s = getenv("ELM_DESKTOP_ENTRY");
1530 if (s) _elm_config->desktop_entry = !!atoi(s);
1531 s = getenv("ELM_ACCESS_MODE");
1532 if (s) _elm_config->access_mode = ELM_ACCESS_MODE_ON;
1536 elm_config_mirrored_get(void)
1538 return _elm_config->is_mirrored;
1542 elm_config_mirrored_set(Eina_Bool mirrored)
1544 _elm_config->is_mirrored = mirrored;
1549 elm_config_cursor_engine_only_get(void)
1551 return _elm_config->cursor_engine_only;
1555 elm_config_cursor_engine_only_set(Eina_Bool engine_only)
1557 engine_only = !!engine_only;
1558 _elm_config->cursor_engine_only = engine_only;
1562 elm_config_tooltip_delay_get(void)
1564 return _elm_config->tooltip_delay;
1568 elm_config_tooltip_delay_set(double delay)
1570 if (delay < 0.0) return;
1571 _elm_config->tooltip_delay = delay;
1577 return elm_config_scale_get();
1581 elm_config_scale_get(void)
1583 return _elm_config->scale;
1587 elm_scale_set(double scale)
1589 elm_config_scale_set(scale);
1593 elm_config_scale_set(double scale)
1595 if (_elm_config->scale == scale) return;
1596 _elm_config->scale = scale;
1601 elm_config_password_show_last_get(void)
1603 return _elm_config->password_show_last;
1607 elm_config_password_show_last_set(Eina_Bool password_show_last)
1609 if (_elm_config->password_show_last == password_show_last) return;
1610 _elm_config->password_show_last = password_show_last;
1611 edje_password_show_last_set(_elm_config->password_show_last);
1615 elm_config_password_show_last_timeout_get(void)
1617 return _elm_config->password_show_last_timeout;
1621 elm_config_password_show_last_timeout_set(double password_show_last_timeout)
1623 if (_elm_config->password_show_last_timeout == password_show_last_timeout) return;
1624 _elm_config->password_show_last_timeout = password_show_last_timeout;
1625 edje_password_show_last_timeout_set(_elm_config->password_show_last_timeout);
1629 elm_config_save(void)
1631 return _elm_config_save();
1635 elm_config_reload(void)
1637 _elm_config_reload();
1641 elm_config_profile_get(void)
1643 return _elm_config_current_profile_get();
1647 elm_config_profile_dir_get(const char *profile,
1650 return _elm_config_profile_dir_get(profile, is_user);
1654 elm_config_profile_dir_free(const char *p_dir)
1656 free((void *)p_dir);
1660 elm_config_profile_list_get(void)
1662 return _elm_config_profiles_list();
1666 elm_config_profile_list_free(Eina_List *l)
1670 EINA_LIST_FREE(l, dir)
1671 eina_stringshare_del(dir);
1675 elm_config_profile_set(const char *profile)
1677 EINA_SAFETY_ON_NULL_RETURN(profile);
1678 _elm_config_profile_set(profile);
1682 elm_config_profile_exists(const char *profile)
1684 EINA_SAFETY_ON_NULL_RETURN_VAL(profile, EINA_FALSE);
1685 return _elm_config_profile_exists(profile);
1689 elm_config_engine_get(void)
1691 return _elm_config->engine;
1695 elm_config_engine_set(const char *engine)
1697 EINA_SAFETY_ON_NULL_RETURN(engine);
1699 _elm_config_engine_set(engine);
1703 elm_config_text_classes_list_get(void)
1705 return _elm_config_text_classes_get();
1709 elm_config_text_classes_list_free(Eina_List *list)
1711 _elm_config_text_classes_free(list);
1714 EAPI const Eina_List *
1715 elm_config_font_overlay_list_get(void)
1717 return _elm_config_font_overlays_list();
1721 elm_config_font_overlay_set(const char *text_class,
1723 Evas_Font_Size size)
1725 EINA_SAFETY_ON_NULL_RETURN(text_class);
1726 _elm_config_font_overlay_set(text_class, font, size);
1730 elm_config_font_overlay_unset(const char *text_class)
1732 EINA_SAFETY_ON_NULL_RETURN(text_class);
1733 _elm_config_font_overlay_remove(text_class);
1737 elm_config_font_overlay_apply(void)
1739 _elm_config_font_overlay_apply();
1742 // WRAPPER:: will be removed soon.
1744 elm_finger_size_get(void)
1746 return elm_config_finger_size_get();
1750 elm_config_finger_size_get(void)
1752 return _elm_config->finger_size;
1755 // WRAPPER:: will be removed soon.
1757 elm_finger_size_set(Evas_Coord size)
1759 elm_config_finger_size_set(size);
1763 elm_config_finger_size_set(Evas_Coord size)
1765 if (_elm_config->finger_size == size) return;
1766 _elm_config->finger_size = size;
1771 elm_config_cache_flush_interval_get(void)
1773 return _elm_config->cache_flush_poll_interval;
1777 elm_config_cache_flush_interval_set(int size)
1779 if (_elm_config->cache_flush_poll_interval == size) return;
1780 _elm_config->cache_flush_poll_interval = size;
1786 elm_config_cache_flush_enabled_get(void)
1788 return _elm_config->cache_flush_enable;
1792 elm_config_cache_flush_enabled_set(Eina_Bool enabled)
1794 enabled = !!enabled;
1795 if (_elm_config->cache_flush_enable == enabled) return;
1796 _elm_config->cache_flush_enable = enabled;
1802 elm_config_cache_font_cache_size_get(void)
1804 return _elm_config->font_cache;
1808 elm_config_cache_font_cache_size_set(int size)
1810 if (_elm_config->font_cache == size) return;
1811 _elm_config->font_cache = size;
1817 elm_config_cache_image_cache_size_get(void)
1819 return _elm_config->image_cache;
1823 elm_config_cache_image_cache_size_set(int size)
1825 if (_elm_config->image_cache == size) return;
1826 _elm_config->image_cache = size;
1832 elm_config_cache_edje_file_cache_size_get()
1834 return _elm_config->edje_cache;
1838 elm_config_cache_edje_file_cache_size_set(int size)
1840 if (_elm_config->edje_cache == size) return;
1841 _elm_config->edje_cache = size;
1847 elm_config_cache_edje_collection_cache_size_get(void)
1849 return _elm_config->edje_collection_cache;
1853 elm_config_cache_edje_collection_cache_size_set(int size)
1855 if (_elm_config->edje_collection_cache == size) return;
1856 _elm_config->edje_collection_cache = size;
1862 elm_config_focus_highlight_enabled_get(void)
1864 return _elm_config->focus_highlight_enable;
1868 elm_config_focus_highlight_enabled_set(Eina_Bool enable)
1870 _elm_config->focus_highlight_enable = !!enable;
1874 elm_config_focus_highlight_animate_get(void)
1876 return _elm_config->focus_highlight_animate;
1880 elm_config_focus_highlight_animate_set(Eina_Bool animate)
1882 _elm_config->focus_highlight_animate = !!animate;
1886 elm_config_scroll_bounce_enabled_get(void)
1888 return _elm_config->thumbscroll_bounce_enable;
1892 elm_config_scroll_bounce_enabled_set(Eina_Bool enabled)
1894 _elm_config->thumbscroll_bounce_enable = enabled;
1898 elm_config_scroll_bounce_friction_get(void)
1900 return _elm_config->thumbscroll_bounce_friction;
1904 elm_config_scroll_bounce_friction_set(double friction)
1906 _elm_config->thumbscroll_bounce_friction = friction;
1910 elm_config_scroll_page_scroll_friction_get(void)
1912 return _elm_config->page_scroll_friction;
1916 elm_config_scroll_page_scroll_friction_set(double friction)
1918 _elm_config->page_scroll_friction = friction;
1922 elm_config_scroll_bring_in_scroll_friction_get(void)
1924 return _elm_config->bring_in_scroll_friction;
1928 elm_config_scroll_bring_in_scroll_friction_set(double friction)
1930 _elm_config->bring_in_scroll_friction = friction;
1934 elm_config_scroll_zoom_friction_get(void)
1936 return _elm_config->zoom_friction;
1940 elm_config_scroll_zoom_friction_set(double friction)
1942 _elm_config->zoom_friction = friction;
1946 elm_config_scroll_thumbscroll_enabled_get(void)
1948 return _elm_config->thumbscroll_enable;
1952 elm_config_scroll_thumbscroll_enabled_set(Eina_Bool enabled)
1954 _elm_config->thumbscroll_enable = enabled;
1958 elm_config_scroll_thumbscroll_threshold_get(void)
1960 return _elm_config->thumbscroll_threshold;
1964 elm_config_scroll_thumbscroll_threshold_set(unsigned int threshold)
1966 _elm_config->thumbscroll_threshold = threshold;
1970 elm_config_scroll_thumbscroll_momentum_threshold_get(void)
1972 return _elm_config->thumbscroll_momentum_threshold;
1976 elm_config_scroll_thumbscroll_momentum_threshold_set(double threshold)
1978 _elm_config->thumbscroll_momentum_threshold = threshold;
1982 elm_config_scroll_thumbscroll_friction_get(void)
1984 return _elm_config->thumbscroll_friction;
1988 elm_config_scroll_thumbscroll_friction_set(double friction)
1990 _elm_config->thumbscroll_friction = friction;
1994 elm_config_scroll_thumbscroll_border_friction_get(void)
1996 return _elm_config->thumbscroll_border_friction;
2000 elm_config_scroll_thumbscroll_border_friction_set(double friction)
2002 if (friction < 0.0) friction = 0.0;
2003 if (friction > 1.0) friction = 1.0;
2004 _elm_config->thumbscroll_border_friction = friction;
2008 elm_config_scroll_thumbscroll_sensitivity_friction_get(void)
2010 return _elm_config->thumbscroll_sensitivity_friction;
2014 elm_config_scroll_thumbscroll_sensitivity_friction_set(double friction)
2016 if (friction < 0.1) friction = 0.1;
2017 if (friction > 1.0) friction = 1.0;
2018 _elm_config->thumbscroll_sensitivity_friction = friction;
2022 elm_config_longpress_timeout_set(double longpress_timeout)
2024 _elm_config->longpress_timeout = longpress_timeout;
2028 elm_config_longpress_timeout_get(void)
2030 return _elm_config->longpress_timeout;
2034 elm_config_all_flush(void)
2036 #ifdef HAVE_ELEMENTARY_X
2037 if (_prop_all_update_timer) ecore_timer_del(_prop_all_update_timer);
2038 _prop_all_update_timer = ecore_timer_add(0.1, _prop_all_update_cb, NULL);
2046 const char *cur_dom = textdomain(NULL);
2047 const char *trans_comment = gettext("");
2048 const char *msg_locale = setlocale(LC_MESSAGES, NULL);
2050 /* Same concept as what glib does:
2051 * We shouldn't translate if there are no translations for the
2052 * application in the current locale + domain. (Unless locale is
2053 * en_/C where translating only parts of the interface make some
2056 _elm_config->translate = !(strcmp (cur_dom, "messages") &&
2057 !*trans_comment && strncmp (msg_locale, "en_", 3) &&
2058 strcmp (msg_locale, "C"));
2063 _elm_config_init(void)
2065 if (!ELM_EVENT_CONFIG_ALL_CHANGED)
2066 ELM_EVENT_CONFIG_ALL_CHANGED = ecore_event_type_new();
2068 _profile_fetch_from_conf();
2071 if (_elm_preferred_engine) eina_stringshare_del(_elm_preferred_engine);
2072 if (_elm_config->engine)
2073 _elm_preferred_engine = eina_stringshare_add(_elm_config->engine);
2075 _elm_preferred_engine = NULL;
2076 _translation_init();
2078 _elm_config_font_overlay_apply();
2083 _elm_config_sub_shutdown(void)
2085 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2086 if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
2087 ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
2088 ENGINE_COMPARE(ELM_XRENDER_X11) ||
2089 ENGINE_COMPARE(ELM_OPENGL_X11) ||
2090 ENGINE_COMPARE(ELM_OPENGL_COCOA))
2091 #undef ENGINE_COMPARE
2093 #ifdef HAVE_ELEMENTARY_X
2100 _elm_config_sub_init(void)
2102 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2103 if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
2104 ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
2105 ENGINE_COMPARE(ELM_XRENDER_X11) ||
2106 ENGINE_COMPARE(ELM_OPENGL_X11) ||
2107 ENGINE_COMPARE(ELM_OPENGL_COCOA))
2108 #undef ENGINE_COMPARE
2110 #ifdef HAVE_ELEMENTARY_X
2111 if (!ecore_x_init(NULL))
2113 ERR("Cannot connect to X11 display. check $DISPLAY variable");
2116 _root_1st = ecore_x_window_root_first_get();
2118 if (!ecore_x_screen_is_composited(0))
2119 _elm_config->compositing = 0;
2121 ecore_x_atoms_get(_atom_names, ATOM_COUNT, _atom);
2122 ecore_x_event_mask_set(_root_1st,
2123 ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
2124 _prop_change_handler = ecore_event_handler_add
2125 (ECORE_X_EVENT_WINDOW_PROPERTY, _prop_change, NULL);
2126 if (!getenv("ELM_PROFILE"))
2130 s = ecore_x_window_prop_string_get(_root_1st,
2131 _atom[ATOM_E_PROFILE]);
2138 if (strcmp(_elm_profile, s)) changed = 1;
2142 if (changed) _prop_config_get();
2147 _config_sub_apply();
2151 _elm_config_reload(void)
2156 _elm_config_font_overlay_apply();
2162 _elm_config_engine_set(const char *engine)
2164 if (_elm_config->engine && strcmp(_elm_config->engine, engine))
2165 eina_stringshare_del(_elm_config->engine);
2167 _elm_config->engine = eina_stringshare_add(engine);
2171 elm_config_preferred_engine_get(void)
2173 return _elm_preferred_engine;
2177 elm_config_preferred_engine_set(const char *engine)
2180 eina_stringshare_replace(&(_elm_preferred_engine), engine);
2183 if (_elm_preferred_engine) eina_stringshare_del(_elm_preferred_engine);
2184 _elm_preferred_engine = eina_stringshare_add(_elm_config->engine);
2189 _elm_config_profile_set(const char *profile)
2191 Eina_Bool changed = EINA_FALSE;
2195 if (strcmp(_elm_profile, profile))
2200 _elm_profile = strdup(profile);
2207 _elm_config_font_overlay_apply();
2214 _elm_config_profile_exists(const char *profile)
2216 Eina_List *profs = _elm_config_profiles_list();
2218 const char *p, *dir;
2219 Eina_Bool res = EINA_FALSE;
2221 EINA_LIST_FOREACH(profs, l, p)
2223 if (!strcmp(profile, p))
2230 EINA_LIST_FREE(profs, dir)
2231 eina_stringshare_del(dir);
2237 _elm_config_shutdown(void)
2239 #ifdef HAVE_ELEMENTARY_X
2240 if (_prop_all_update_timer)
2242 ecore_timer_del(_prop_all_update_timer);
2243 _prop_all_update_timer = NULL;
2244 _prop_all_update_cb(NULL);
2246 if (_prop_change_delay_timer) ecore_timer_del(_prop_change_delay_timer);
2247 _prop_change_delay_timer = NULL;
2250 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2251 if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
2252 ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
2253 ENGINE_COMPARE(ELM_XRENDER_X11) ||
2254 ENGINE_COMPARE(ELM_OPENGL_X11))
2255 #undef ENGINE_COMPARE
2257 #ifdef HAVE_ELEMENTARY_X
2258 ecore_event_handler_del(_prop_change_handler);
2259 _prop_change_handler = NULL;
2263 if (_elm_preferred_engine)
2265 eina_stringshare_del(_elm_preferred_engine);
2266 _elm_preferred_engine = NULL;
2271 _elm_profile = NULL;