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[] = {
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;
165 _elm_config_font_overlay_apply();
168 ecore_event_add(ELM_EVENT_CONFIG_ALL_CHANGED, NULL, NULL, NULL);
173 _prop_config_set(void)
175 unsigned char *config_data = NULL;
178 config_data = eet_data_descriptor_encode(_config_edd, _elm_config, &size);
184 snprintf(buf, sizeof(buf), "ELM_CONFIG_%s", _elm_profile);
185 atom = ecore_x_atom_get(buf);
188 ecore_x_window_prop_property_set(_root_1st, _atom_config,
189 _atom[ATOM_E_CONFIG], 8,
196 _prop_change_delay_cb(void *data __UNUSED__)
200 if (!getenv("ELM_PROFILE"))
202 s = ecore_x_window_prop_string_get(_root_1st, _atom[ATOM_E_PROFILE]);
205 if (_elm_profile) free(_elm_profile);
210 _prop_change_delay_timer = NULL;
215 _prop_change(void *data __UNUSED__,
216 int ev_type __UNUSED__,
219 Ecore_X_Event_Window_Property *event = ev;
221 if (event->win == _root_1st)
223 if (event->atom == _atom[ATOM_E_PROFILE])
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);
228 else if (((_atom_config > 0) && (event->atom == _atom_config)) ||
229 (event->atom == _atom[ATOM_E_CONFIG]))
231 if (_prop_change_delay_timer) ecore_timer_del(_prop_change_delay_timer);
232 _prop_change_delay_timer = ecore_timer_add(0.1, _prop_change_delay_cb, NULL);
235 return ECORE_CALLBACK_PASS_ON;
243 Eet_Data_Descriptor_Class eddc;
245 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Config);
246 eddc.func.str_direct_alloc = NULL;
247 eddc.func.str_direct_free = NULL;
249 _config_edd = eet_data_descriptor_file_new(&eddc);
252 printf("EEEK! eet_data_descriptor_file_new() failed\n");
256 memset(&eddc, 0, sizeof(eddc)); /* just in case... */
257 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Font_Overlay);
258 eddc.func.str_direct_alloc = NULL;
259 eddc.func.str_direct_free = NULL;
261 _config_font_overlay_edd = eet_data_descriptor_stream_new(&eddc);
262 if (!_config_font_overlay_edd)
264 printf("EEEK! eet_data_descriptor_stream_new() failed\n");
265 eet_data_descriptor_free(_config_edd);
269 memset(&eddc, 0, sizeof(eddc)); /* just in case... */
270 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Color_RGBA);
271 eddc.func.str_direct_alloc = NULL;
272 eddc.func.str_direct_free = NULL;
274 _config_color_edd = eet_data_descriptor_stream_new(&eddc);
275 if (!_config_color_edd)
277 printf("EEEK! eet_data_descriptor_stream_new() failed\n");
278 eet_data_descriptor_free(_config_edd);
282 memset(&eddc, 0, sizeof(eddc)); /* just in case... */
283 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Custom_Palette);
284 eddc.func.str_direct_alloc = NULL;
285 eddc.func.str_direct_free = NULL;
287 _config_color_palette_edd = eet_data_descriptor_stream_new(&eddc);
288 if (!_config_color_palette_edd)
290 printf("EEEK! eet_data_descriptor_stream_new() failed\n");
291 eet_data_descriptor_free(_config_edd);
295 #define T_INT EET_T_INT
296 #define T_DOUBLE EET_T_DOUBLE
297 #define T_STRING EET_T_STRING
298 #define T_UCHAR EET_T_UCHAR
300 #define T Elm_Font_Overlay
301 #define D _config_font_overlay_edd
302 ELM_CONFIG_VAL(D, T, text_class, EET_T_STRING);
303 ELM_CONFIG_VAL(D, T, font, EET_T_STRING);
304 ELM_CONFIG_VAL(D, T, size, EET_T_INT);
308 #define T Elm_Color_RGBA
309 #define D _config_color_edd
310 ELM_CONFIG_VAL(D, T, r, EET_T_UINT);
311 ELM_CONFIG_VAL(D, T, g, EET_T_UINT);
312 ELM_CONFIG_VAL(D, T, b, EET_T_UINT);
313 ELM_CONFIG_VAL(D, T, a, EET_T_UINT);
317 #define T Elm_Custom_Palette
318 #define D _config_color_palette_edd
319 ELM_CONFIG_VAL(D, T, palette_name, EET_T_STRING);
320 ELM_CONFIG_LIST(D, T, color_list, _config_color_edd);
325 #define D _config_edd
326 ELM_CONFIG_VAL(D, T, config_version, T_INT);
327 ELM_CONFIG_VAL(D, T, engine, T_STRING);
328 ELM_CONFIG_VAL(D, T, vsync, T_UCHAR);
329 ELM_CONFIG_VAL(D, T, thumbscroll_enable, T_UCHAR);
330 ELM_CONFIG_VAL(D, T, thumbscroll_threshold, T_INT);
331 ELM_CONFIG_VAL(D, T, thumbscroll_hold_threshold, T_INT);
332 ELM_CONFIG_VAL(D, T, thumbscroll_momentum_threshold, T_DOUBLE);
333 ELM_CONFIG_VAL(D, T, thumbscroll_friction, T_DOUBLE);
334 ELM_CONFIG_VAL(D, T, thumbscroll_bounce_friction, T_DOUBLE);
335 ELM_CONFIG_VAL(D, T, thumbscroll_border_friction, T_DOUBLE);
336 ELM_CONFIG_VAL(D, T, thumbscroll_sensitivity_friction, T_DOUBLE);
337 ELM_CONFIG_VAL(D, T, page_scroll_friction, T_DOUBLE);
338 ELM_CONFIG_VAL(D, T, bring_in_scroll_friction, T_DOUBLE);
339 ELM_CONFIG_VAL(D, T, zoom_friction, T_DOUBLE);
340 ELM_CONFIG_VAL(D, T, thumbscroll_bounce_enable, T_UCHAR);
341 ELM_CONFIG_VAL(D, T, scroll_smooth_time_interval, T_DOUBLE);
342 ELM_CONFIG_VAL(D, T, scroll_smooth_amount, T_DOUBLE);
343 ELM_CONFIG_VAL(D, T, scroll_smooth_history_weight, T_DOUBLE);
344 ELM_CONFIG_VAL(D, T, scroll_smooth_future_time, T_DOUBLE);
345 ELM_CONFIG_VAL(D, T, scroll_smooth_time_window, T_DOUBLE);
346 ELM_CONFIG_VAL(D, T, scale, T_DOUBLE);
347 ELM_CONFIG_VAL(D, T, bgpixmap, T_INT);
348 ELM_CONFIG_VAL(D, T, compositing, T_INT);
349 /* EET_DATA_DESCRIPTOR_ADD_LIST(D, T, "font_dirs", font_dirs, sub_edd); */
350 ELM_CONFIG_LIST(D, T, font_overlays, _config_font_overlay_edd);
351 ELM_CONFIG_VAL(D, T, font_hinting, T_INT);
352 ELM_CONFIG_VAL(D, T, cache_flush_poll_interval, T_INT);
353 ELM_CONFIG_VAL(D, T, cache_flush_enable, T_UCHAR);
354 ELM_CONFIG_VAL(D, T, image_cache, T_INT);
355 ELM_CONFIG_VAL(D, T, font_cache, T_INT);
356 ELM_CONFIG_VAL(D, T, edje_cache, T_INT);
357 ELM_CONFIG_VAL(D, T, edje_collection_cache, T_INT);
358 ELM_CONFIG_VAL(D, T, finger_size, T_INT);
359 ELM_CONFIG_VAL(D, T, fps, T_DOUBLE);
360 ELM_CONFIG_VAL(D, T, theme, T_STRING);
361 ELM_CONFIG_VAL(D, T, modules, T_STRING);
362 ELM_CONFIG_VAL(D, T, tooltip_delay, T_DOUBLE);
363 ELM_CONFIG_VAL(D, T, cursor_engine_only, T_UCHAR);
364 ELM_CONFIG_VAL(D, T, focus_highlight_enable, T_UCHAR);
365 ELM_CONFIG_VAL(D, T, focus_highlight_animate, T_UCHAR);
366 ELM_CONFIG_VAL(D, T, toolbar_shrink_mode, T_INT);
367 ELM_CONFIG_VAL(D, T, fileselector_expand_enable, T_UCHAR);
368 ELM_CONFIG_VAL(D, T, inwin_dialogs_enable, T_UCHAR);
369 ELM_CONFIG_VAL(D, T, icon_size, T_INT);
370 ELM_CONFIG_VAL(D, T, longpress_timeout, T_DOUBLE);
371 ELM_CONFIG_VAL(D, T, effect_enable, T_UCHAR);
372 ELM_CONFIG_VAL(D, T, desktop_entry, T_UCHAR);
373 ELM_CONFIG_VAL(D, T, password_show_last, T_UCHAR);
374 ELM_CONFIG_VAL(D, T, password_show_last_timeout, T_DOUBLE);
375 ELM_CONFIG_VAL(D, T, glayer_zoom_finger_enable, T_UCHAR);
376 ELM_CONFIG_VAL(D, T, glayer_zoom_finger_factor, T_DOUBLE);
377 ELM_CONFIG_VAL(D, T, glayer_zoom_wheel_factor, T_DOUBLE);
378 ELM_CONFIG_VAL(D, T, glayer_zoom_distance_tolerance, T_DOUBLE);
379 ELM_CONFIG_VAL(D, T, glayer_rotate_finger_enable, T_UCHAR);
380 ELM_CONFIG_VAL(D, T, glayer_rotate_angular_tolerance, T_DOUBLE);
381 ELM_CONFIG_VAL(D, T, glayer_line_min_length, T_DOUBLE);
382 ELM_CONFIG_VAL(D, T, glayer_line_distance_tolerance, T_DOUBLE);
383 ELM_CONFIG_VAL(D, T, glayer_line_angular_tolerance, T_DOUBLE);
384 ELM_CONFIG_VAL(D, T, glayer_flick_time_limit_ms, T_INT);
385 ELM_CONFIG_VAL(D, T, glayer_long_tap_start_timeout, T_DOUBLE);
386 ELM_CONFIG_VAL(D, T, glayer_double_tap_timeout, T_DOUBLE);
387 ELM_CONFIG_VAL(D, T, access_mode, T_UCHAR);
388 ELM_CONFIG_VAL(D, T, selection_clear_enable, T_UCHAR);
389 ELM_CONFIG_VAL(D, T, glayer_continues_enable, T_UCHAR);
390 ELM_CONFIG_VAL(D, T, week_start, T_INT);
391 ELM_CONFIG_VAL(D, T, weekend_start, T_INT);
392 ELM_CONFIG_VAL(D, T, weekend_len, T_INT);
393 ELM_CONFIG_VAL(D, T, year_min, T_INT);
394 ELM_CONFIG_VAL(D, T, year_max, T_INT);
395 ELM_CONFIG_LIST(D, T, color_palette, _config_color_palette_edd);
396 ELM_CONFIG_VAL(D, T, softcursor_mode, T_UCHAR);
397 ELM_CONFIG_VAL(D, T, auto_norender_withdrawn, T_UCHAR);
398 ELM_CONFIG_VAL(D, T, auto_norender_iconified_same_as_withdrawn, T_UCHAR);
399 ELM_CONFIG_VAL(D, T, auto_flush_withdrawn, T_UCHAR);
400 ELM_CONFIG_VAL(D, T, auto_dump_withdrawn, T_UCHAR);
401 ELM_CONFIG_VAL(D, T, auto_throttle, T_UCHAR);
402 ELM_CONFIG_VAL(D, T, auto_throttle_amount, T_DOUBLE);
403 ELM_CONFIG_VAL(D, T, indicator_service_0, T_STRING);
404 ELM_CONFIG_VAL(D, T, indicator_service_90, T_STRING);
405 ELM_CONFIG_VAL(D, T, indicator_service_180, T_STRING);
406 ELM_CONFIG_VAL(D, T, indicator_service_270, T_STRING);
420 eet_data_descriptor_free(_config_edd);
424 if (_config_font_overlay_edd)
426 eet_data_descriptor_free(_config_font_overlay_edd);
427 _config_font_overlay_edd = NULL;
430 if (_config_color_edd)
432 eet_data_descriptor_free(_config_color_edd);
433 _config_color_edd = NULL;
436 if (_config_color_palette_edd)
438 eet_data_descriptor_free(_config_color_palette_edd);
439 _config_color_palette_edd = NULL;
444 _sort_files_cb(const void *f1,
447 return strcmp(f1, f2);
451 _elm_config_current_profile_get(void)
457 _elm_data_dir_snprintf(char *dst,
462 size_t data_dir_len, off;
465 data_dir_len = eina_strlcpy(dst, _elm_data_dir, size);
467 off = data_dir_len + 1;
472 dst[data_dir_len] = '/';
474 off = off + vsnprintf(dst + off, size - off, fmt, ap);
482 _elm_user_dir_snprintf(char *dst,
488 size_t user_dir_len, off;
492 home = evil_homedir_get();
494 home = getenv("HOME");
499 user_dir_len = eina_str_join_len(dst, size, '/', home, strlen(home),
500 ELEMENTARY_BASE_DIR, sizeof(ELEMENTARY_BASE_DIR) - 1);
502 off = user_dir_len + 1;
507 dst[user_dir_len] = '/';
509 off = off + vsnprintf(dst + off, size - off, fmt, ap);
517 _elm_config_profile_dir_get(const char *prof,
525 _elm_user_dir_snprintf(buf, sizeof(buf), "config/%s", prof);
527 if (ecore_file_is_dir(buf))
533 snprintf(buf, sizeof(buf), "%s/config/%s", _elm_data_dir, prof);
535 if (ecore_file_is_dir(buf))
542 _elm_config_font_overlays_list(void)
544 return _elm_config->font_overlays;
547 Eina_Bool _elm_config_access_get(void)
549 return _elm_config->access_mode;
552 void _elm_config_access_set(Eina_Bool is_access)
554 is_access = !!is_access;
555 if (_elm_config->access_mode == is_access) return;
556 _elm_config->access_mode = is_access;
557 _elm_win_access(is_access);
559 if (!is_access) _elm_access_shutdown();
562 Eina_Bool _elm_config_selection_unfocused_clear_get(void)
564 return _elm_config->selection_clear_enable;
567 void _elm_config_selection_unfocused_clear_set(Eina_Bool enabled)
570 if (_elm_config->selection_clear_enable == enabled) return;
571 _elm_config->selection_clear_enable = enabled;
575 _elm_config_font_overlay_set(const char *text_class,
579 Elm_Font_Overlay *efd;
582 EINA_LIST_FOREACH(_elm_config->font_overlays, l, efd)
584 if (strcmp(efd->text_class, text_class))
587 if (efd->font) eina_stringshare_del(efd->font);
588 efd->font = eina_stringshare_add(font);
590 _elm_config->font_overlays =
591 eina_list_promote_list(_elm_config->font_overlays, l);
595 /* the text class doesn't exist */
596 efd = calloc(1, sizeof(Elm_Font_Overlay));
597 efd->text_class = eina_stringshare_add(text_class);
598 efd->font = eina_stringshare_add(font);
601 _elm_config->font_overlays = eina_list_prepend(_elm_config->font_overlays,
606 _elm_config_font_overlay_remove(const char *text_class)
608 Elm_Font_Overlay *efd;
611 EINA_LIST_FOREACH(_elm_config->font_overlays, l, efd)
613 if (strcmp(efd->text_class, text_class))
616 _elm_config->font_overlays =
617 eina_list_remove_list(_elm_config->font_overlays, l);
618 if (efd->text_class) eina_stringshare_del(efd->text_class);
619 if (efd->font) eina_stringshare_del(efd->font);
627 _elm_config_font_overlay_apply(void)
629 Elm_Font_Overlay *efd;
633 for (i = 0; _elm_text_classes[i].desc; i++)
634 edje_text_class_del(_elm_text_classes[i].name);
636 EINA_LIST_FOREACH(_elm_config->font_overlays, l, efd)
637 edje_text_class_set(efd->text_class, efd->font, efd->size);
641 _elm_config_text_classes_get(void)
643 Eina_List *ret = NULL;
646 for (i = 0; _elm_text_classes[i].desc; i++)
649 tc = malloc(sizeof(*tc));
652 *tc = _elm_text_classes[i];
654 ret = eina_list_append(ret, tc);
661 _elm_config_text_classes_free(Eina_List *l)
665 EINA_LIST_FREE(l, tc)
670 _elm_config_color_list_get(const char *palette_name)
673 Elm_Custom_Palette *cpalette;
674 EINA_LIST_FOREACH(_elm_config->color_palette, plist, cpalette)
676 if (strcmp(cpalette->palette_name, palette_name))
678 return cpalette->color_list;
684 _elm_config_color_set(const char *palette_name,
691 Elm_Custom_Palette *cpalette;
692 Elm_Color_RGBA *color;
693 EINA_LIST_FOREACH(_elm_config->color_palette, plist, cpalette)
695 if (strcmp(cpalette->palette_name, palette_name))
698 color = calloc(1, sizeof(Elm_Color_RGBA));
703 cpalette->color_list = eina_list_prepend(cpalette->color_list,
709 _elm_config_colors_free(const char *palette_name)
712 Elm_Custom_Palette *cpalette;
713 Elm_Color_RGBA *color;
714 EINA_LIST_FOREACH(_elm_config->color_palette, plist, cpalette)
716 if (strcmp(cpalette->palette_name, palette_name))
719 EINA_LIST_FREE(cpalette->color_list, color)
727 _elm_config_profiles_list(void)
729 Eina_File_Direct_Info *info;
730 Eina_List *flist = NULL;
731 Eina_Iterator *file_it;
736 len = _elm_user_dir_snprintf(buf, sizeof(buf), "config");
738 file_it = eina_file_stat_ls(buf);
745 len = sizeof(buf) - len;
747 EINA_ITERATOR_FOREACH(file_it, info)
749 if (info->name_length >= len)
752 if (info->type == EINA_FILE_DIR)
755 eina_list_sorted_insert(flist, _sort_files_cb,
756 eina_stringshare_add(info->path +
761 eina_iterator_free(file_it);
764 len = eina_str_join_len(buf, sizeof(buf), '/', _elm_data_dir,
765 strlen(_elm_data_dir), "config",
766 sizeof("config") - 1);
768 file_it = eina_file_direct_ls(buf);
775 len = sizeof(buf) - len;
776 EINA_ITERATOR_FOREACH(file_it, info)
778 if (info->name_length >= len)
788 EINA_LIST_FOREACH(flist, l, tmp)
789 if (!strcmp(info->path + info->name_start, tmp))
794 eina_list_sorted_insert(flist, _sort_files_cb,
795 eina_stringshare_add(info->path +
804 eina_iterator_free(file_it);
808 EINA_LIST_FREE(flist, dir)
809 eina_stringshare_del(dir);
815 _profile_fetch_from_conf(void)
817 char buf[PATH_MAX], *p, *s;
821 _elm_profile = strdup("default");
823 // if env var - use profile without question
824 s = getenv("ELM_PROFILE");
828 _elm_profile = strdup(s);
833 _elm_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
834 ef = eet_open(buf, EET_FILE_MODE_READ);
837 p = eet_read(ef, "config", &len);
841 _elm_profile = malloc(len + 1);
842 memcpy(_elm_profile, p, len);
843 _elm_profile[len] = 0;
852 _elm_data_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
853 ef = eet_open(buf, EET_FILE_MODE_READ);
856 p = eet_read(ef, "config", &len);
860 _elm_profile = malloc(len + 1);
861 memcpy(_elm_profile, p, len);
862 _elm_profile[len] = 0;
872 Elm_Font_Overlay *fo;
874 Elm_Custom_Palette *palette;
875 Elm_Color_RGBA *color;
877 if (!_elm_config) return;
878 EINA_LIST_FREE(_elm_config->font_dirs, fontdir)
880 eina_stringshare_del(fontdir);
882 if (_elm_config->engine) eina_stringshare_del(_elm_config->engine);
883 EINA_LIST_FREE(_elm_config->font_overlays, fo)
885 if (fo->text_class) eina_stringshare_del(fo->text_class);
886 if (fo->font) eina_stringshare_del(fo->font);
889 EINA_LIST_FREE(_elm_config->color_palette, palette)
891 if (palette->palette_name) eina_stringshare_del(palette->palette_name);
892 EINA_LIST_FREE(palette->color_list, color) free(color);
895 if (_elm_config->theme) eina_stringshare_del(_elm_config->theme);
896 if (_elm_config->modules) eina_stringshare_del(_elm_config->modules);
904 _elm_theme_parse(NULL, _elm_config->theme);
905 ecore_animator_frametime_set(1.0 / _elm_config->fps);
909 _config_sub_apply(void)
911 edje_frametime_set(1.0 / _elm_config->fps);
912 edje_scale_set(_elm_config->scale);
913 edje_password_show_last_set(_elm_config->password_show_last);
914 edje_password_show_last_timeout_set(_elm_config->password_show_last_timeout);
915 if (_elm_config->modules) _elm_module_parse(_elm_config->modules);
919 _elm_cache_flush_cb(void *data __UNUSED__)
921 elm_cache_all_flush();
922 return ECORE_CALLBACK_RENEW;
925 /* kind of abusing this call right now -- shared between all of those
926 * properties -- but they are not meant to be called that periodically
934 elm_cache_all_flush();
936 EINA_LIST_FOREACH(_elm_win_list, l, win)
938 Evas *e = evas_object_evas_get(win);
939 evas_image_cache_set(e, _elm_config->image_cache * 1024);
940 evas_font_cache_set(e, _elm_config->font_cache * 1024);
942 edje_file_cache_set(_elm_config->edje_cache);
943 edje_collection_cache_set(_elm_config->edje_collection_cache);
945 if (_elm_cache_flush_poller)
947 ecore_poller_del(_elm_cache_flush_poller);
948 _elm_cache_flush_poller = NULL;
950 if (_elm_config->cache_flush_enable)
952 if (_elm_config->cache_flush_poll_interval > 0)
954 _elm_cache_flush_poller =
955 ecore_poller_add(ECORE_POLLER_CORE,
956 _elm_config->cache_flush_poll_interval,
957 _elm_cache_flush_cb, NULL);
963 _config_user_load(void)
965 Elm_Config *cfg = NULL;
969 _elm_user_dir_snprintf(buf, sizeof(buf), "config/%s/base.cfg",
972 ef = eet_open(buf, EET_FILE_MODE_READ);
975 cfg = eet_data_read(ef, _config_edd, "config");
982 _config_system_load(void)
984 Elm_Config *cfg = NULL;
988 _elm_data_dir_snprintf(buf, sizeof(buf), "config/%s/base.cfg",
991 ef = eet_open(buf, EET_FILE_MODE_READ);
994 cfg = eet_data_read(ef, _config_edd, "config");
1003 _elm_config = _config_user_load();
1006 if (_elm_config->config_version < ELM_CONFIG_VERSION)
1011 /* no user config, fallback for system. No need to check version for
1012 * this one, if it's not the right one, someone screwed up at the time
1013 * of installing it */
1014 _elm_config = _config_system_load();
1015 if (_elm_config) return;
1016 /* FIXME: config load could have failed because of a non-existent
1017 * profile. Fallback to default before moving on */
1019 // config load fail - defaults
1020 // why are these here? well if they are, it means you can make a gui
1021 // config recovery app i guess...
1022 _elm_config = ELM_NEW(Elm_Config);
1023 _elm_config->config_version = ELM_CONFIG_VERSION;
1024 _elm_config->engine = eina_stringshare_add("software_x11");
1025 _elm_config->vsync = 0;
1026 _elm_config->thumbscroll_enable = EINA_TRUE;
1027 _elm_config->thumbscroll_threshold = 24;
1028 _elm_config->thumbscroll_hold_threshold = 24;
1029 _elm_config->thumbscroll_momentum_threshold = 100.0;
1030 _elm_config->thumbscroll_friction = 1.0;
1031 _elm_config->thumbscroll_bounce_friction = 0.5;
1032 _elm_config->thumbscroll_bounce_enable = EINA_TRUE;
1033 _elm_config->page_scroll_friction = 0.5;
1034 _elm_config->bring_in_scroll_friction = 0.5;
1035 _elm_config->zoom_friction = 0.5;
1036 _elm_config->thumbscroll_border_friction = 0.5;
1037 _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
1038 _elm_config->scroll_smooth_time_interval = 0.008;
1039 _elm_config->scroll_smooth_amount = 1.0;
1040 _elm_config->scroll_smooth_history_weight = 0.3;
1041 _elm_config->scroll_smooth_future_time = 0.0;
1042 _elm_config->scroll_smooth_time_window = 0.2;
1043 _elm_config->scale = 1.0;
1044 _elm_config->bgpixmap = 0;
1045 _elm_config->compositing = 1;
1046 _elm_config->font_hinting = 2;
1047 _elm_config->cache_flush_poll_interval = 512;
1048 _elm_config->cache_flush_enable = EINA_TRUE;
1049 _elm_config->font_dirs = NULL;
1050 _elm_config->image_cache = 4096;
1051 _elm_config->font_cache = 512;
1052 _elm_config->edje_cache = 32;
1053 _elm_config->edje_collection_cache = 64;
1054 _elm_config->finger_size = 40;
1055 _elm_config->fps = 60.0;
1056 _elm_config->theme = eina_stringshare_add("default");
1057 _elm_config->modules = NULL;
1058 _elm_config->tooltip_delay = 1.0;
1059 _elm_config->cursor_engine_only = EINA_TRUE;
1060 _elm_config->focus_highlight_enable = EINA_FALSE;
1061 _elm_config->focus_highlight_animate = EINA_TRUE;
1062 _elm_config->toolbar_shrink_mode = 2;
1063 _elm_config->fileselector_expand_enable = EINA_FALSE;
1064 _elm_config->inwin_dialogs_enable = EINA_FALSE;
1065 _elm_config->icon_size = 32;
1066 _elm_config->longpress_timeout = 1.0;
1067 _elm_config->effect_enable = EINA_TRUE;
1068 _elm_config->desktop_entry = EINA_FALSE;
1069 _elm_config->is_mirrored = EINA_FALSE; /* Read sys value in env_get() */
1070 _elm_config->password_show_last = EINA_FALSE;
1071 _elm_config->password_show_last_timeout = 2.0;
1072 _elm_config->glayer_zoom_finger_enable = EINA_TRUE;
1073 _elm_config->glayer_zoom_finger_factor = 1.0;
1074 _elm_config->glayer_zoom_wheel_factor = 0.05;
1075 _elm_config->glayer_zoom_distance_tolerance = 1.0; /* 1 times elm_finger_size_get() */
1076 _elm_config->glayer_rotate_finger_enable = EINA_TRUE;
1077 _elm_config->glayer_rotate_angular_tolerance = 2.0; /* 2 DEG */
1078 _elm_config->glayer_line_min_length = 1.0; /* 1 times elm_finger_size_get() */
1079 _elm_config->glayer_line_distance_tolerance = 3.0; /* 3 times elm_finger_size_get() */
1080 _elm_config->glayer_line_angular_tolerance = 20.0; /* 20 DEG */
1081 _elm_config->glayer_flick_time_limit_ms = 120; /* ms to finish flick */
1082 _elm_config->glayer_long_tap_start_timeout = 1.2; /* 1.2 second to start long-tap */
1083 _elm_config->glayer_double_tap_timeout = 0.25; /* 0.25 seconds between 2 mouse downs of a tap. */
1084 _elm_config->glayer_continues_enable = EINA_TRUE; /* Continue gestures default */
1085 _elm_config->access_mode = ELM_ACCESS_MODE_OFF;
1086 _elm_config->selection_clear_enable = EINA_TRUE;
1087 _elm_config->week_start = 1; /* monday */
1088 _elm_config->weekend_start = 6; /* saturday */
1089 _elm_config->weekend_len = 2;
1090 _elm_config->year_min = 2;
1091 _elm_config->year_max = 137;
1092 _elm_config->softcursor_mode = 0; /* 0 = auto, 1 = on, 2 = off */
1093 _elm_config->color_palette = NULL;
1094 _elm_config->auto_norender_withdrawn = 0;
1095 _elm_config->auto_norender_iconified_same_as_withdrawn = 1;
1096 _elm_config->auto_flush_withdrawn = 0;
1097 _elm_config->auto_dump_withdrawn = 0;
1098 _elm_config->auto_throttle = 0;
1099 _elm_config->auto_throttle_amount = 0.1;
1100 _elm_config->indicator_service_0 = eina_stringshare_add("elm_indicator_portrait");
1101 _elm_config->indicator_service_90 = eina_stringshare_add("elm_indicator_landscape");
1102 _elm_config->indicator_service_180 = eina_stringshare_add("elm_indicator_portrait");
1103 _elm_config->indicator_service_270 = eina_stringshare_add("elm_indicator_landscape");
1107 _elm_config_eet_close_error_get(Eet_File *ef,
1111 const char *erstr = NULL;
1113 err = eet_close(ef);
1116 case EET_ERROR_WRITE_ERROR:
1117 erstr = "An error occurred while saving Elementary's "
1118 "settings to disk. The error could not be "
1119 "deterimined. The file where the error occurred was: "
1120 "%s. This file has been deleted to avoid corrupt data.";
1123 case EET_ERROR_WRITE_ERROR_FILE_TOO_BIG:
1124 erstr = "Elementary's settings files are too big "
1125 "for the file system they are being saved to. "
1126 "This error is very strange as the files should "
1127 "be extremely small. Please check the settings "
1128 "for your home directory. "
1129 "The file where the error occurred was: %s ."
1130 "This file has been deleted to avoid corrupt data.";
1133 case EET_ERROR_WRITE_ERROR_IO_ERROR:
1134 erstr = "An output error occurred when writing the settings "
1135 "files for Elementary. Your disk is having troubles "
1136 "and possibly needs replacement. "
1137 "The file where the error occurred was: %s ."
1138 "This file has been deleted to avoid corrupt data.";
1141 case EET_ERROR_WRITE_ERROR_OUT_OF_SPACE:
1142 erstr = "Elementary cannot write its settings file "
1143 "because it ran out of space to write the file. "
1144 "You have either run out of disk space or have "
1145 "gone over your quota limit. "
1146 "The file where the error occurred was: %s ."
1147 "This file has been deleted to avoid corrupt data.";
1150 case EET_ERROR_WRITE_ERROR_FILE_CLOSED:
1151 erstr = "Elementary unexpectedly had the settings file "
1152 "it was writing closed on it. This is very unusual. "
1153 "The file where the error occurred was: %s "
1154 "This file has been deleted to avoid corrupt data.";
1162 /* delete any partially-written file */
1163 ecore_file_unlink(file);
1164 return strdup(erstr);
1171 _elm_config_profile_save(void)
1173 char buf[4096], buf2[4096];
1179 len = _elm_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
1180 if (len + 1 >= sizeof(buf))
1183 len = _elm_user_dir_snprintf(buf2, sizeof(buf2), "config/profile.cfg.tmp");
1184 if (len + 1 >= sizeof(buf2))
1187 ef = eet_open(buf2, EET_FILE_MODE_WRITE);
1191 ok = eet_write(ef, "config", _elm_profile, strlen(_elm_profile), 0);
1195 err = _elm_config_eet_close_error_get(ef, buf2);
1203 ret = ecore_file_mv(buf2, buf);
1206 ERR("Error saving Elementary's configuration profile file");
1210 ecore_file_unlink(buf2);
1214 ecore_file_unlink(buf2);
1219 _elm_config_save(void)
1221 char buf[4096], buf2[4096];
1227 len = _elm_user_dir_snprintf(buf, sizeof(buf), "config/%s", _elm_profile);
1228 if (len + 1 >= sizeof(buf))
1231 ok = ecore_file_mkpath(buf);
1234 ERR("Problem accessing Elementary's user configuration directory: %s",
1239 if (!_elm_config_profile_save())
1245 if (len + sizeof("base.cfg") >= sizeof(buf) - len)
1248 memcpy(buf + len, "base.cfg", sizeof("base.cfg"));
1249 len += sizeof("base.cfg") - 1;
1251 if (len + sizeof(".tmp") >= sizeof(buf))
1254 memcpy(buf2, buf, len);
1255 memcpy(buf2 + len, ".tmp", sizeof(".tmp"));
1257 ef = eet_open(buf2, EET_FILE_MODE_WRITE);
1261 ok = eet_data_write(ef, _config_edd, "config", _elm_config, 1);
1265 err = _elm_config_eet_close_error_get(ef, buf2);
1273 ret = ecore_file_mv(buf2, buf);
1276 ERR("Error saving Elementary's configuration file");
1280 ecore_file_unlink(buf2);
1284 ecore_file_unlink(buf2);
1289 _config_update(void)
1293 tcfg = _config_system_load();
1296 /* weird profile or something? We should probably fill
1297 * with hardcoded defaults, or get from default previx */
1300 #define IFCFG(v) if ((_elm_config->config_version & 0xffff) < (v)) {
1301 #define IFCFGELSE } else {
1303 #define COPYVAL(x) do {_elm_config->x = tcfg->x; } while (0)
1304 #define COPYPTR(x) do {_elm_config->x = tcfg->x; tcfg->x = NULL; } while (0)
1305 #define COPYSTR(x) COPYPTR(x)
1307 /* we also need to update for property changes in the root window
1308 * if needed, but that will be dependent on new properties added
1309 * with each version */
1312 COPYVAL(longpress_timeout);
1322 /* after updating user config, we must save */
1331 s = getenv("ELM_ENGINE");
1334 if ((!strcasecmp(s, "x11")) ||
1335 (!strcasecmp(s, "x")) ||
1336 (!strcasecmp(s, "software-x11")) ||
1337 (!strcasecmp(s, "software_x11")))
1338 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_X11);
1339 else if ((!strcasecmp(s, "opengl")) ||
1340 (!strcasecmp(s, "gl")) ||
1341 (!strcasecmp(s, "opengl-x11")) ||
1342 (!strcasecmp(s, "opengl_x11")))
1343 eina_stringshare_replace(&_elm_config->engine, ELM_OPENGL_X11);
1344 else if ((!strcasecmp(s, "x11-8")) ||
1345 (!strcasecmp(s, "x8")) ||
1346 (!strcasecmp(s, "software-8-x11")) ||
1347 (!strcasecmp(s, "software_8_x11")))
1348 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_8_X11);
1349 else if ((!strcasecmp(s, "x11-16")) ||
1350 (!strcasecmp(s, "x16")) ||
1351 (!strcasecmp(s, "software-16-x11")) ||
1352 (!strcasecmp(s, "software_16_x11")))
1353 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_16_X11);
1355 else if ((!strcasecmp(s, "xrender")) ||
1356 (!strcasecmp(s, "xr")) ||
1357 (!strcasecmp(s, "xrender-x11")) ||
1358 (!strcasecmp(s, "xrender_x11")))
1359 eina_stringshare_replace(&_elm_config->engine, ELM_XRENDER_X11);
1361 else if ((!strcasecmp(s, "fb")) ||
1362 (!strcasecmp(s, "software-fb")) ||
1363 (!strcasecmp(s, "software_fb")))
1364 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_FB);
1365 else if ((!strcasecmp(s, "directfb")) ||
1366 (!strcasecmp(s, "dfb")))
1367 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_DIRECTFB);
1368 else if ((!strcasecmp(s, "psl1ght")))
1369 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_PSL1GHT);
1370 else if ((!strcasecmp(s, "sdl")) ||
1371 (!strcasecmp(s, "software-sdl")) ||
1372 (!strcasecmp(s, "software_sdl")))
1373 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_SDL);
1374 else if ((!strcasecmp(s, "sdl-16")) ||
1375 (!strcasecmp(s, "software-16-sdl")) ||
1376 (!strcasecmp(s, "software_16_sdl")))
1377 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_16_SDL);
1378 else if ((!strcasecmp(s, "opengl-sdl")) ||
1379 (!strcasecmp(s, "opengl_sdl")) ||
1380 (!strcasecmp(s, "gl-sdl")) ||
1381 (!strcasecmp(s, "gl_sdl")))
1382 eina_stringshare_replace(&_elm_config->engine, ELM_OPENGL_SDL);
1383 else if ((!strcasecmp(s, "opengl-cocoa")) ||
1384 (!strcasecmp(s, "opengl_cocoa")) ||
1385 (!strcasecmp(s, "gl-cocoa")) ||
1386 (!strcasecmp(s, "gl_cocoa")))
1387 eina_stringshare_replace(&_elm_config->engine, ELM_OPENGL_COCOA);
1388 else if ((!strcasecmp(s, "gdi")) ||
1389 (!strcasecmp(s, "software-gdi")) ||
1390 (!strcasecmp(s, "software_gdi")))
1391 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_WIN32);
1392 else if ((!strcasecmp(s, "wince-gdi")) ||
1393 (!strcasecmp(s, "software-16-wince-gdi")) ||
1394 (!strcasecmp(s, "software_16_wince_gdi")))
1395 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_16_WINCE);
1396 else if (!strcasecmp(s, "buffer"))
1397 eina_stringshare_replace(&_elm_config->engine, ELM_BUFFER);
1398 else if ((!strncmp(s, "shot:", 5)))
1399 eina_stringshare_replace(&_elm_config->engine, s);
1400 else if ((!strcasecmp(s, "ews")))
1401 eina_stringshare_replace(&_elm_config->engine, ELM_EWS);
1402 else if ((!strcasecmp(s, "wayland_shm")))
1403 eina_stringshare_replace(&_elm_config->engine, ELM_WAYLAND_SHM);
1404 else if ((!strcasecmp(s, "wayland_egl")))
1405 eina_stringshare_replace(&_elm_config->engine, ELM_WAYLAND_EGL);
1407 ERR("Unknown engine '%s'.", s);
1410 s = getenv("ELM_VSYNC");
1411 if (s) _elm_config->vsync = !!atoi(s);
1413 s = getenv("ELM_THUMBSCROLL_ENABLE");
1414 if (s) _elm_config->thumbscroll_enable = !!atoi(s);
1415 s = getenv("ELM_THUMBSCROLL_THRESHOLD");
1416 if (s) _elm_config->thumbscroll_threshold = atoi(s);
1417 s = getenv("ELM_THUMBSCROLL_HOLD_THRESHOLD");
1418 if (s) _elm_config->thumbscroll_hold_threshold = atoi(s);
1419 // FIXME: floatformat locale issues here 1.0 vs 1,0 - should just be 1.0
1420 s = getenv("ELM_THUMBSCROLL_MOMENTUM_THRESHOLD");
1421 if (s) _elm_config->thumbscroll_momentum_threshold = _elm_atof(s);
1422 s = getenv("ELM_THUMBSCROLL_FRICTION");
1423 if (s) _elm_config->thumbscroll_friction = _elm_atof(s);
1424 s = getenv("ELM_THUMBSCROLL_BOUNCE_ENABLE");
1425 if (s) _elm_config->thumbscroll_bounce_enable = !!atoi(s);
1426 s = getenv("ELM_THUMBSCROLL_BOUNCE_FRICTION");
1427 if (s) _elm_config->thumbscroll_bounce_friction = _elm_atof(s);
1428 s = getenv("ELM_PAGE_SCROLL_FRICTION");
1429 if (s) _elm_config->page_scroll_friction = _elm_atof(s);
1430 s = getenv("ELM_BRING_IN_SCROLL_FRICTION");
1431 if (s) _elm_config->bring_in_scroll_friction = _elm_atof(s);
1432 s = getenv("ELM_ZOOM_FRICTION");
1433 if (s) _elm_config->zoom_friction = _elm_atof(s);
1434 s = getenv("ELM_THUMBSCROLL_BORDER_FRICTION");
1437 friction = _elm_atof(s);
1444 _elm_config->thumbscroll_border_friction = friction;
1446 s = getenv("ELM_THUMBSCROLL_SENSITIVITY_FRICTION");
1449 friction = _elm_atof(s);
1456 _elm_config->thumbscroll_sensitivity_friction = friction;
1458 s = getenv("ELM_SCROLL_SMOOTH_TIME_INTERVAL");
1459 if (s) _elm_config->scroll_smooth_time_interval = atof(s);
1460 s = getenv("ELM_SCROLL_SMOOTH_AMOUNT");
1461 if (s) _elm_config->scroll_smooth_amount = _elm_atof(s);
1462 s = getenv("ELM_SCROLL_SMOOTH_HISTORY_WEIGHT");
1463 if (s) _elm_config->scroll_smooth_history_weight = _elm_atof(s);
1464 s = getenv("ELM_SCROLL_SMOOTH_FUTURE_TIME");
1465 if (s) _elm_config->scroll_smooth_future_time = _elm_atof(s);
1466 s = getenv("ELM_SCROLL_SMOOTH_TIME_WINDOW");
1467 if (s) _elm_config->scroll_smooth_time_window = _elm_atof(s);
1468 s = getenv("ELM_THEME");
1469 if (s) eina_stringshare_replace(&_elm_config->theme, s);
1471 s = getenv("ELM_FONT_HINTING");
1474 if (!strcasecmp(s, "none")) _elm_config->font_hinting = 0;
1475 else if (!strcasecmp(s, "auto"))
1476 _elm_config->font_hinting = 1;
1477 else if (!strcasecmp(s, "bytecode"))
1478 _elm_config->font_hinting = 2;
1481 s = getenv("ELM_FONT_PATH");
1487 EINA_LIST_FREE(_elm_config->font_dirs, p)
1489 eina_stringshare_del(p);
1492 buf2 = alloca(strlen(s) + 1);
1497 if ((*p == ':') || (*p == 0))
1502 strncpy(buf2, pp, len);
1504 _elm_config->font_dirs =
1505 eina_list_append(_elm_config->font_dirs,
1506 eina_stringshare_add(buf2));
1519 s = getenv("ELM_IMAGE_CACHE");
1520 if (s) _elm_config->image_cache = atoi(s);
1522 s = getenv("ELM_FONT_CACHE");
1523 if (s) _elm_config->font_cache = atoi(s);
1525 s = getenv("ELM_SCALE");
1526 if (s) _elm_config->scale = _elm_atof(s);
1528 s = getenv("ELM_FINGER_SIZE");
1529 if (s) _elm_config->finger_size = atoi(s);
1531 s = getenv("ELM_PASSWORD_SHOW_LAST");
1532 if (s) _elm_config->password_show_last = !!atoi(s);
1534 s = getenv("ELM_PASSWORD_SHOW_LAST_TIMEOUT");
1537 double pw_show_last_timeout = _elm_atof(s);
1538 if (pw_show_last_timeout >= 0.0)
1539 _elm_config->password_show_last_timeout = pw_show_last_timeout;
1542 s = getenv("ELM_FPS");
1543 if (s) _elm_config->fps = _elm_atof(s);
1544 if (_elm_config->fps < 1.0) _elm_config->fps = 1.0;
1546 s = getenv("ELM_MODULES");
1547 if (s) eina_stringshare_replace(&_elm_config->modules, s);
1549 s = getenv("ELM_TOOLTIP_DELAY");
1552 double delay = _elm_atof(s);
1554 _elm_config->tooltip_delay = delay;
1557 s = getenv("ELM_CURSOR_ENGINE_ONLY");
1558 if (s) _elm_config->cursor_engine_only = !!atoi(s);
1560 s = getenv("ELM_FOCUS_HIGHLIGHT_ENABLE");
1561 if (s) _elm_config->focus_highlight_enable = !!atoi(s);
1563 s = getenv("ELM_FOCUS_HIGHLIGHT_ANIMATE");
1564 if (s) _elm_config->focus_highlight_animate = !!atoi(s);
1566 s = getenv("ELM_TOOLBAR_SHRINK_MODE");
1567 if (s) _elm_config->toolbar_shrink_mode = atoi(s);
1569 s = getenv("ELM_FILESELECTOR_EXPAND_ENABLE");
1570 if (s) _elm_config->fileselector_expand_enable = !!atoi(s);
1572 s = getenv("ELM_INWIN_DIALOGS_ENABLE");
1573 if (s) _elm_config->inwin_dialogs_enable = !!atoi(s);
1575 s = getenv("ELM_ICON_SIZE");
1576 if (s) _elm_config->icon_size = atoi(s);
1578 s = getenv("ELM_LONGPRESS_TIMEOUT");
1579 if (s) _elm_config->longpress_timeout = _elm_atof(s);
1580 if (_elm_config->longpress_timeout < 0.0)
1581 _elm_config->longpress_timeout = 0.0;
1583 s = getenv("ELM_EFFECT_ENABLE");
1584 if (s) _elm_config->effect_enable = !!atoi(s);
1586 s = getenv("ELM_DESKTOP_ENTRY");
1587 if (s) _elm_config->desktop_entry = !!atoi(s);
1588 s = getenv("ELM_ACCESS_MODE");
1589 if (s) _elm_config->access_mode = ELM_ACCESS_MODE_ON;
1591 s = getenv("ELM_SELECTION_CLEAR_ENABLE");
1592 if (s) _elm_config->selection_clear_enable = !!atoi(s);
1594 s = getenv("ELM_AUTO_THROTTLE");
1595 if (s) _elm_config->auto_throttle = EINA_TRUE;
1596 s = getenv("ELM_AUTO_THROTTLE_AMOUNT");
1597 if (s) _elm_config->auto_throttle_amount = _elm_atof(s);
1598 s = getenv("ELM_AUTO_NORENDER_WITHDRAWN");
1599 if (s) _elm_config->auto_norender_withdrawn = EINA_TRUE;
1600 s = getenv("ELM_AUTO_NORENDER_ICONIFIED_SAME_AS_WITHDRAWN");
1601 if (s) _elm_config->auto_norender_iconified_same_as_withdrawn = EINA_TRUE;
1602 s = getenv("ELM_AUTO_FLUSH_WITHDRAWN");
1603 if (s) _elm_config->auto_flush_withdrawn = EINA_TRUE;
1604 s = getenv("ELM_AUTO_DUMP_WIDTHDRAWN");
1605 if (s) _elm_config->auto_dump_withdrawn = EINA_TRUE;
1607 s = getenv("ELM_INDICATOR_SERVICE_0");
1608 if (s) eina_stringshare_replace(&_elm_config->indicator_service_0, s);
1609 s = getenv("ELM_INDICATOR_SERVICE_90");
1610 if (s) eina_stringshare_replace(&_elm_config->indicator_service_90, s);
1611 s = getenv("ELM_INDICATOR_SERVICE_180");
1612 if (s) eina_stringshare_replace(&_elm_config->indicator_service_180, s);
1613 s = getenv("ELM_INDICATOR_SERVICE_270");
1614 if (s) eina_stringshare_replace(&_elm_config->indicator_service_270, s);
1618 elm_config_mirrored_get(void)
1620 return _elm_config->is_mirrored;
1624 elm_config_mirrored_set(Eina_Bool mirrored)
1626 mirrored = !!mirrored;
1627 if (_elm_config->is_mirrored == mirrored) return;
1628 _elm_config->is_mirrored = mirrored;
1633 elm_config_cursor_engine_only_get(void)
1635 return _elm_config->cursor_engine_only;
1639 elm_config_cursor_engine_only_set(Eina_Bool engine_only)
1641 engine_only = !!engine_only;
1642 _elm_config->cursor_engine_only = engine_only;
1646 elm_config_tooltip_delay_get(void)
1648 return _elm_config->tooltip_delay;
1652 elm_config_tooltip_delay_set(double delay)
1654 if (delay < 0.0) return;
1655 _elm_config->tooltip_delay = delay;
1661 return elm_config_scale_get();
1665 elm_config_scale_get(void)
1667 return _elm_config->scale;
1671 elm_scale_set(double scale)
1673 elm_config_scale_set(scale);
1677 elm_config_scale_set(double scale)
1679 if (scale < 0.0) return;
1680 if (_elm_config->scale == scale) return;
1681 _elm_config->scale = scale;
1686 elm_config_password_show_last_get(void)
1688 return _elm_config->password_show_last;
1692 elm_config_password_show_last_set(Eina_Bool password_show_last)
1694 if (_elm_config->password_show_last == password_show_last) return;
1695 _elm_config->password_show_last = password_show_last;
1696 edje_password_show_last_set(_elm_config->password_show_last);
1700 elm_config_password_show_last_timeout_get(void)
1702 return _elm_config->password_show_last_timeout;
1706 elm_config_password_show_last_timeout_set(double password_show_last_timeout)
1708 if (password_show_last_timeout < 0.0) return;
1709 if (_elm_config->password_show_last_timeout == password_show_last_timeout) return;
1710 _elm_config->password_show_last_timeout = password_show_last_timeout;
1711 edje_password_show_last_timeout_set(_elm_config->password_show_last_timeout);
1715 elm_config_save(void)
1717 return _elm_config_save();
1721 elm_config_reload(void)
1723 _elm_config_reload();
1727 elm_config_profile_get(void)
1729 return _elm_config_current_profile_get();
1733 elm_config_profile_dir_get(const char *profile,
1736 return _elm_config_profile_dir_get(profile, is_user);
1740 elm_config_profile_dir_free(const char *p_dir)
1742 free((void *)p_dir);
1746 elm_config_profile_list_get(void)
1748 return _elm_config_profiles_list();
1752 elm_config_profile_list_free(Eina_List *l)
1756 EINA_LIST_FREE(l, dir)
1757 eina_stringshare_del(dir);
1761 elm_config_profile_set(const char *profile)
1763 EINA_SAFETY_ON_NULL_RETURN(profile);
1764 _elm_config_profile_set(profile);
1768 elm_config_profile_exists(const char *profile)
1770 EINA_SAFETY_ON_NULL_RETURN_VAL(profile, EINA_FALSE);
1771 return _elm_config_profile_exists(profile);
1775 elm_config_engine_get(void)
1777 return _elm_config->engine;
1781 elm_config_engine_set(const char *engine)
1783 EINA_SAFETY_ON_NULL_RETURN(engine);
1785 _elm_config_engine_set(engine);
1789 elm_config_text_classes_list_get(void)
1791 return _elm_config_text_classes_get();
1795 elm_config_text_classes_list_free(Eina_List *list)
1797 _elm_config_text_classes_free(list);
1800 EAPI const Eina_List *
1801 elm_config_font_overlay_list_get(void)
1803 return _elm_config_font_overlays_list();
1807 elm_config_access_get(void)
1809 return _elm_config_access_get();
1813 elm_config_access_set(Eina_Bool is_access)
1815 _elm_config_access_set(is_access);
1819 elm_config_selection_unfocused_clear_get(void)
1821 return _elm_config_selection_unfocused_clear_get();
1825 elm_config_selection_unfocused_clear_set(Eina_Bool enabled)
1827 _elm_config_selection_unfocused_clear_set(enabled);
1831 elm_config_font_overlay_set(const char *text_class,
1833 Evas_Font_Size size)
1835 EINA_SAFETY_ON_NULL_RETURN(text_class);
1836 _elm_config_font_overlay_set(text_class, font, size);
1840 elm_config_font_overlay_unset(const char *text_class)
1842 EINA_SAFETY_ON_NULL_RETURN(text_class);
1843 _elm_config_font_overlay_remove(text_class);
1847 elm_config_font_overlay_apply(void)
1849 _elm_config_font_overlay_apply();
1854 elm_finger_size_get(void)
1856 return elm_config_finger_size_get();
1860 elm_config_finger_size_get(void)
1862 return _elm_config->finger_size;
1866 elm_finger_size_set(Evas_Coord size)
1868 elm_config_finger_size_set(size);
1872 elm_config_finger_size_set(Evas_Coord size)
1874 if (size < 0) return;
1875 if (_elm_config->finger_size == size) return;
1876 _elm_config->finger_size = size;
1881 elm_config_cache_flush_interval_get(void)
1883 return _elm_config->cache_flush_poll_interval;
1887 elm_config_cache_flush_interval_set(int size)
1889 EINA_SAFETY_ON_FALSE_RETURN(size > 0);
1890 if (_elm_config->cache_flush_poll_interval == size) return;
1891 _elm_config->cache_flush_poll_interval = size;
1897 elm_config_cache_flush_enabled_get(void)
1899 return _elm_config->cache_flush_enable;
1903 elm_config_cache_flush_enabled_set(Eina_Bool enabled)
1905 enabled = !!enabled;
1906 if (_elm_config->cache_flush_enable == enabled) return;
1907 _elm_config->cache_flush_enable = enabled;
1913 elm_config_cache_font_cache_size_get(void)
1915 return _elm_config->font_cache;
1919 elm_config_cache_font_cache_size_set(int size)
1921 if (size < 0) return;
1922 if (_elm_config->font_cache == size) return;
1923 _elm_config->font_cache = size;
1929 elm_config_cache_image_cache_size_get(void)
1931 return _elm_config->image_cache;
1935 elm_config_cache_image_cache_size_set(int size)
1937 if (size < 0) return;
1938 if (_elm_config->image_cache == size) return;
1939 _elm_config->image_cache = size;
1945 elm_config_cache_edje_file_cache_size_get()
1947 return _elm_config->edje_cache;
1951 elm_config_cache_edje_file_cache_size_set(int size)
1953 if (size < 0) return;
1954 if (_elm_config->edje_cache == size) return;
1955 _elm_config->edje_cache = size;
1961 elm_config_cache_edje_collection_cache_size_get(void)
1963 return _elm_config->edje_collection_cache;
1967 elm_config_cache_edje_collection_cache_size_set(int size)
1969 if (_elm_config->edje_collection_cache == size) return;
1970 _elm_config->edje_collection_cache = size;
1976 elm_config_focus_highlight_enabled_get(void)
1978 return _elm_config->focus_highlight_enable;
1982 elm_config_focus_highlight_enabled_set(Eina_Bool enable)
1984 _elm_config->focus_highlight_enable = !!enable;
1988 elm_config_focus_highlight_animate_get(void)
1990 return _elm_config->focus_highlight_animate;
1994 elm_config_focus_highlight_animate_set(Eina_Bool animate)
1996 _elm_config->focus_highlight_animate = !!animate;
2000 elm_config_scroll_bounce_enabled_get(void)
2002 return _elm_config->thumbscroll_bounce_enable;
2006 elm_config_scroll_bounce_enabled_set(Eina_Bool enabled)
2008 _elm_config->thumbscroll_bounce_enable = enabled;
2012 elm_config_scroll_bounce_friction_get(void)
2014 return _elm_config->thumbscroll_bounce_friction;
2018 elm_config_scroll_bounce_friction_set(double friction)
2020 _elm_config->thumbscroll_bounce_friction = friction;
2024 elm_config_scroll_page_scroll_friction_get(void)
2026 return _elm_config->page_scroll_friction;
2030 elm_config_scroll_page_scroll_friction_set(double friction)
2032 _elm_config->page_scroll_friction = friction;
2036 elm_config_scroll_bring_in_scroll_friction_get(void)
2038 return _elm_config->bring_in_scroll_friction;
2042 elm_config_scroll_bring_in_scroll_friction_set(double friction)
2044 _elm_config->bring_in_scroll_friction = friction;
2048 elm_config_scroll_zoom_friction_get(void)
2050 return _elm_config->zoom_friction;
2054 elm_config_scroll_zoom_friction_set(double friction)
2056 _elm_config->zoom_friction = friction;
2060 elm_config_scroll_thumbscroll_enabled_get(void)
2062 return _elm_config->thumbscroll_enable;
2066 elm_config_scroll_thumbscroll_enabled_set(Eina_Bool enabled)
2068 _elm_config->thumbscroll_enable = enabled;
2072 elm_config_scroll_thumbscroll_threshold_get(void)
2074 return _elm_config->thumbscroll_threshold;
2078 elm_config_scroll_thumbscroll_threshold_set(unsigned int threshold)
2080 _elm_config->thumbscroll_threshold = threshold;
2084 elm_config_scroll_thumbscroll_hold_threshold_get(void)
2086 return _elm_config->thumbscroll_hold_threshold;
2090 elm_config_scroll_thumbscroll_hold_threshold_set(unsigned int threshold)
2092 _elm_config->thumbscroll_hold_threshold = threshold;
2096 elm_config_scroll_thumbscroll_momentum_threshold_get(void)
2098 return _elm_config->thumbscroll_momentum_threshold;
2102 elm_config_scroll_thumbscroll_momentum_threshold_set(double threshold)
2104 _elm_config->thumbscroll_momentum_threshold = threshold;
2108 elm_config_scroll_thumbscroll_friction_get(void)
2110 return _elm_config->thumbscroll_friction;
2114 elm_config_scroll_thumbscroll_friction_set(double friction)
2116 _elm_config->thumbscroll_friction = friction;
2120 elm_config_scroll_thumbscroll_border_friction_get(void)
2122 return _elm_config->thumbscroll_border_friction;
2126 elm_config_scroll_thumbscroll_border_friction_set(double friction)
2128 if (friction < 0.0) friction = 0.0;
2129 if (friction > 1.0) friction = 1.0;
2130 _elm_config->thumbscroll_border_friction = friction;
2134 elm_config_scroll_thumbscroll_sensitivity_friction_get(void)
2136 return _elm_config->thumbscroll_sensitivity_friction;
2140 elm_config_scroll_thumbscroll_sensitivity_friction_set(double friction)
2142 if (friction < 0.1) friction = 0.1;
2143 if (friction > 1.0) friction = 1.0;
2144 _elm_config->thumbscroll_sensitivity_friction = friction;
2148 elm_config_longpress_timeout_set(double longpress_timeout)
2150 _elm_config->longpress_timeout = longpress_timeout;
2154 elm_config_longpress_timeout_get(void)
2156 return _elm_config->longpress_timeout;
2160 elm_config_softcursor_mode_set(Elm_Softcursor_Mode mode)
2162 _elm_config->softcursor_mode = mode;
2165 EAPI Elm_Softcursor_Mode
2166 elm_config_softcursor_mode_get(void)
2168 return _elm_config->softcursor_mode;
2172 elm_config_all_flush(void)
2174 #ifdef HAVE_ELEMENTARY_X
2175 if (_prop_all_update_timer) ecore_timer_del(_prop_all_update_timer);
2176 _prop_all_update_timer = ecore_timer_add(0.1, _prop_all_update_cb, NULL);
2184 const char *cur_dom = textdomain(NULL);
2185 const char *trans_comment = gettext("");
2186 const char *msg_locale = setlocale(LC_MESSAGES, NULL);
2188 /* Same concept as what glib does:
2189 * We shouldn't translate if there are no translations for the
2190 * application in the current locale + domain. (Unless locale is
2191 * en_/C where translating only parts of the interface make some
2194 _elm_config->translate = !(strcmp (cur_dom, "messages") &&
2195 !*trans_comment && strncmp (msg_locale, "en_", 3) &&
2196 strcmp (msg_locale, "C"));
2197 /* Get RTL orientation from system */
2198 if (_elm_config->translate)
2200 bindtextdomain(PACKAGE, LOCALE_DIR);
2201 _elm_config->is_mirrored = !strcmp(E_("default:LTR"), "default:RTL");
2208 _elm_config_init(void)
2210 if (!ELM_EVENT_CONFIG_ALL_CHANGED)
2211 ELM_EVENT_CONFIG_ALL_CHANGED = ecore_event_type_new();
2213 _profile_fetch_from_conf();
2216 if (_elm_preferred_engine) eina_stringshare_del(_elm_preferred_engine);
2217 _elm_preferred_engine = NULL;
2218 _translation_init();
2220 _elm_config_font_overlay_apply();
2225 _elm_config_sub_shutdown(void)
2227 #ifdef HAVE_ELEMENTARY_X
2228 if (_prop_all_update_timer)
2230 ecore_timer_del(_prop_all_update_timer);
2231 _prop_all_update_timer = NULL;
2232 _prop_all_update_cb(NULL);
2234 if (_prop_change_delay_timer) ecore_timer_del(_prop_change_delay_timer);
2235 _prop_change_delay_timer = NULL;
2238 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2239 if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
2240 ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
2241 ENGINE_COMPARE(ELM_XRENDER_X11) ||
2242 ENGINE_COMPARE(ELM_OPENGL_X11) ||
2243 ENGINE_COMPARE(ELM_OPENGL_COCOA))
2244 #undef ENGINE_COMPARE
2246 #ifdef HAVE_ELEMENTARY_X
2253 _elm_config_sub_init(void)
2255 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2256 if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
2257 ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
2258 ENGINE_COMPARE(ELM_XRENDER_X11) ||
2259 ENGINE_COMPARE(ELM_OPENGL_X11) ||
2260 ENGINE_COMPARE(ELM_OPENGL_COCOA))
2261 #undef ENGINE_COMPARE
2263 #ifdef HAVE_ELEMENTARY_X
2264 if (ecore_x_init(NULL))
2266 _root_1st = ecore_x_window_root_first_get();
2268 if (!ecore_x_screen_is_composited(0))
2269 _elm_config->compositing = 0;
2271 ecore_x_atoms_get(_atom_names, ATOM_COUNT, _atom);
2272 ecore_x_event_mask_set(_root_1st,
2273 ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
2274 _prop_change_handler = ecore_event_handler_add
2275 (ECORE_X_EVENT_WINDOW_PROPERTY, _prop_change, NULL);
2276 if (!getenv("ELM_PROFILE"))
2280 s = ecore_x_window_prop_string_get(_root_1st,
2281 _atom[ATOM_E_PROFILE]);
2288 if (strcmp(_elm_profile, s)) changed = 1;
2292 if (changed) _prop_config_get();
2297 ERR("Cannot connect to X11 display. check $DISPLAY variable");
2300 _config_sub_apply();
2304 _elm_config_reload(void)
2309 _elm_config_font_overlay_apply();
2312 ecore_event_add(ELM_EVENT_CONFIG_ALL_CHANGED, NULL, NULL, NULL);
2316 _elm_config_engine_set(const char *engine)
2318 if (_elm_config->engine && strcmp(_elm_config->engine, engine))
2319 eina_stringshare_del(_elm_config->engine);
2321 _elm_config->engine = eina_stringshare_add(engine);
2325 elm_config_preferred_engine_get(void)
2327 return _elm_preferred_engine;
2331 elm_config_preferred_engine_set(const char *engine)
2334 eina_stringshare_replace(&(_elm_preferred_engine), engine);
2337 if (_elm_preferred_engine) eina_stringshare_del(_elm_preferred_engine);
2338 _elm_preferred_engine = NULL;
2343 elm_config_indicator_service_get(int rotation)
2348 return _elm_config->indicator_service_0;
2350 return _elm_config->indicator_service_90;
2352 return _elm_config->indicator_service_180;
2354 return _elm_config->indicator_service_270;
2361 ////JIYOUN:START We have to remove this code after cluster home application change their code
2363 elm_config_indicator_service_0_get(void)
2365 return _elm_config->indicator_service_0;
2369 elm_config_indicator_service_90_get(void)
2371 return _elm_config->indicator_service_90;
2375 elm_config_indicator_service_180_get(void)
2377 return _elm_config->indicator_service_180;
2381 elm_config_indicator_service_270_get(void)
2383 return _elm_config->indicator_service_270;
2385 ////JIYOUN:END We have to remove this code after cluster home application change their code
2387 _elm_config_profile_set(const char *profile)
2389 Eina_Bool changed = EINA_FALSE;
2393 if (strcmp(_elm_profile, profile))
2398 _elm_profile = strdup(profile);
2405 _elm_config_font_overlay_apply();
2412 _elm_config_profile_exists(const char *profile)
2414 Eina_List *profs = _elm_config_profiles_list();
2416 const char *p, *dir;
2417 Eina_Bool res = EINA_FALSE;
2419 EINA_LIST_FOREACH(profs, l, p)
2421 if (!strcmp(profile, p))
2428 EINA_LIST_FREE(profs, dir)
2429 eina_stringshare_del(dir);
2435 _elm_config_shutdown(void)
2437 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2438 if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
2439 ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
2440 ENGINE_COMPARE(ELM_XRENDER_X11) ||
2441 ENGINE_COMPARE(ELM_OPENGL_X11))
2442 #undef ENGINE_COMPARE
2444 #ifdef HAVE_ELEMENTARY_X
2445 ecore_event_handler_del(_prop_change_handler);
2446 _prop_change_handler = NULL;
2450 if (_elm_preferred_engine)
2452 eina_stringshare_del(_elm_preferred_engine);
2453 _elm_preferred_engine = NULL;
2458 _elm_profile = NULL;