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 _elm_win_access(_elm_config->access_mode);
169 ecore_event_add(ELM_EVENT_CONFIG_ALL_CHANGED, NULL, NULL, NULL);
174 _prop_config_set(void)
176 unsigned char *config_data = NULL;
179 config_data = eet_data_descriptor_encode(_config_edd, _elm_config, &size);
185 snprintf(buf, sizeof(buf), "ELM_CONFIG_%s", _elm_profile);
186 atom = ecore_x_atom_get(buf);
189 ecore_x_window_prop_property_set(_root_1st, _atom_config,
190 _atom[ATOM_E_CONFIG], 8,
197 _prop_change_delay_cb(void *data __UNUSED__)
201 if (!getenv("ELM_PROFILE"))
203 s = ecore_x_window_prop_string_get(_root_1st, _atom[ATOM_E_PROFILE]);
206 if (_elm_profile) free(_elm_profile);
211 _prop_change_delay_timer = NULL;
216 _prop_change(void *data __UNUSED__,
217 int ev_type __UNUSED__,
220 Ecore_X_Event_Window_Property *event = ev;
222 if (event->win == _root_1st)
224 if (event->atom == _atom[ATOM_E_PROFILE])
226 if (_prop_change_delay_timer) ecore_timer_del(_prop_change_delay_timer);
227 _prop_change_delay_timer = ecore_timer_add(0.1, _prop_change_delay_cb, NULL);
229 else if (((_atom_config > 0) && (event->atom == _atom_config)) ||
230 (event->atom == _atom[ATOM_E_CONFIG]))
232 if (_prop_change_delay_timer) ecore_timer_del(_prop_change_delay_timer);
233 _prop_change_delay_timer = ecore_timer_add(0.1, _prop_change_delay_cb, NULL);
236 return ECORE_CALLBACK_PASS_ON;
244 Eet_Data_Descriptor_Class eddc;
246 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Config);
247 eddc.func.str_direct_alloc = NULL;
248 eddc.func.str_direct_free = NULL;
250 _config_edd = eet_data_descriptor_file_new(&eddc);
253 printf("EEEK! eet_data_descriptor_file_new() failed\n");
257 memset(&eddc, 0, sizeof(eddc)); /* just in case... */
258 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Font_Overlay);
259 eddc.func.str_direct_alloc = NULL;
260 eddc.func.str_direct_free = NULL;
262 _config_font_overlay_edd = eet_data_descriptor_stream_new(&eddc);
263 if (!_config_font_overlay_edd)
265 printf("EEEK! eet_data_descriptor_stream_new() failed\n");
266 eet_data_descriptor_free(_config_edd);
270 memset(&eddc, 0, sizeof(eddc)); /* just in case... */
271 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Color_RGBA);
272 eddc.func.str_direct_alloc = NULL;
273 eddc.func.str_direct_free = NULL;
275 _config_color_edd = eet_data_descriptor_stream_new(&eddc);
276 if (!_config_color_edd)
278 printf("EEEK! eet_data_descriptor_stream_new() failed\n");
279 eet_data_descriptor_free(_config_edd);
283 memset(&eddc, 0, sizeof(eddc)); /* just in case... */
284 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Custom_Palette);
285 eddc.func.str_direct_alloc = NULL;
286 eddc.func.str_direct_free = NULL;
288 _config_color_palette_edd = eet_data_descriptor_stream_new(&eddc);
289 if (!_config_color_palette_edd)
291 printf("EEEK! eet_data_descriptor_stream_new() failed\n");
292 eet_data_descriptor_free(_config_edd);
296 #define T_INT EET_T_INT
297 #define T_DOUBLE EET_T_DOUBLE
298 #define T_STRING EET_T_STRING
299 #define T_UCHAR EET_T_UCHAR
301 #define T Elm_Font_Overlay
302 #define D _config_font_overlay_edd
303 ELM_CONFIG_VAL(D, T, text_class, EET_T_STRING);
304 ELM_CONFIG_VAL(D, T, font, EET_T_STRING);
305 ELM_CONFIG_VAL(D, T, size, EET_T_INT);
309 #define T Elm_Color_RGBA
310 #define D _config_color_edd
311 ELM_CONFIG_VAL(D, T, r, EET_T_UINT);
312 ELM_CONFIG_VAL(D, T, g, EET_T_UINT);
313 ELM_CONFIG_VAL(D, T, b, EET_T_UINT);
314 ELM_CONFIG_VAL(D, T, a, EET_T_UINT);
318 #define T Elm_Custom_Palette
319 #define D _config_color_palette_edd
320 ELM_CONFIG_VAL(D, T, palette_name, EET_T_STRING);
321 ELM_CONFIG_LIST(D, T, color_list, _config_color_edd);
326 #define D _config_edd
327 ELM_CONFIG_VAL(D, T, config_version, T_INT);
328 ELM_CONFIG_VAL(D, T, engine, T_STRING);
329 ELM_CONFIG_VAL(D, T, vsync, T_UCHAR);
330 ELM_CONFIG_VAL(D, T, thumbscroll_enable, T_UCHAR);
331 ELM_CONFIG_VAL(D, T, thumbscroll_threshold, T_INT);
332 ELM_CONFIG_VAL(D, T, thumbscroll_hold_threshold, T_INT);
333 ELM_CONFIG_VAL(D, T, thumbscroll_momentum_threshold, T_DOUBLE);
334 ELM_CONFIG_VAL(D, T, thumbscroll_friction, T_DOUBLE);
335 ELM_CONFIG_VAL(D, T, thumbscroll_bounce_friction, T_DOUBLE);
336 ELM_CONFIG_VAL(D, T, thumbscroll_border_friction, T_DOUBLE);
337 ELM_CONFIG_VAL(D, T, thumbscroll_sensitivity_friction, T_DOUBLE);
338 ELM_CONFIG_VAL(D, T, page_scroll_friction, T_DOUBLE);
339 ELM_CONFIG_VAL(D, T, bring_in_scroll_friction, T_DOUBLE);
340 ELM_CONFIG_VAL(D, T, zoom_friction, T_DOUBLE);
341 ELM_CONFIG_VAL(D, T, thumbscroll_bounce_enable, T_UCHAR);
342 ELM_CONFIG_VAL(D, T, scroll_smooth_time_interval, T_DOUBLE);
343 ELM_CONFIG_VAL(D, T, scroll_smooth_amount, T_DOUBLE);
344 ELM_CONFIG_VAL(D, T, scroll_smooth_history_weight, T_DOUBLE);
345 ELM_CONFIG_VAL(D, T, scroll_smooth_future_time, T_DOUBLE);
346 ELM_CONFIG_VAL(D, T, scroll_smooth_time_window, T_DOUBLE);
347 ELM_CONFIG_VAL(D, T, scale, T_DOUBLE);
348 ELM_CONFIG_VAL(D, T, bgpixmap, T_INT);
349 ELM_CONFIG_VAL(D, T, compositing, T_INT);
350 /* EET_DATA_DESCRIPTOR_ADD_LIST(D, T, "font_dirs", font_dirs, sub_edd); */
351 ELM_CONFIG_LIST(D, T, font_overlays, _config_font_overlay_edd);
352 ELM_CONFIG_VAL(D, T, font_hinting, T_INT);
353 ELM_CONFIG_VAL(D, T, cache_flush_poll_interval, T_INT);
354 ELM_CONFIG_VAL(D, T, cache_flush_enable, T_UCHAR);
355 ELM_CONFIG_VAL(D, T, image_cache, T_INT);
356 ELM_CONFIG_VAL(D, T, font_cache, T_INT);
357 ELM_CONFIG_VAL(D, T, edje_cache, T_INT);
358 ELM_CONFIG_VAL(D, T, edje_collection_cache, T_INT);
359 ELM_CONFIG_VAL(D, T, finger_size, T_INT);
360 ELM_CONFIG_VAL(D, T, fps, T_DOUBLE);
361 ELM_CONFIG_VAL(D, T, theme, T_STRING);
362 ELM_CONFIG_VAL(D, T, modules, T_STRING);
363 ELM_CONFIG_VAL(D, T, tooltip_delay, T_DOUBLE);
364 ELM_CONFIG_VAL(D, T, cursor_engine_only, T_UCHAR);
365 ELM_CONFIG_VAL(D, T, focus_highlight_enable, T_UCHAR);
366 ELM_CONFIG_VAL(D, T, focus_highlight_animate, T_UCHAR);
367 ELM_CONFIG_VAL(D, T, toolbar_shrink_mode, T_INT);
368 ELM_CONFIG_VAL(D, T, fileselector_expand_enable, T_UCHAR);
369 ELM_CONFIG_VAL(D, T, inwin_dialogs_enable, T_UCHAR);
370 ELM_CONFIG_VAL(D, T, icon_size, T_INT);
371 ELM_CONFIG_VAL(D, T, longpress_timeout, T_DOUBLE);
372 ELM_CONFIG_VAL(D, T, effect_enable, T_UCHAR);
373 ELM_CONFIG_VAL(D, T, desktop_entry, T_UCHAR);
374 ELM_CONFIG_VAL(D, T, password_show_last, T_UCHAR);
375 ELM_CONFIG_VAL(D, T, password_show_last_timeout, T_DOUBLE);
376 ELM_CONFIG_VAL(D, T, glayer_zoom_finger_enable, T_UCHAR);
377 ELM_CONFIG_VAL(D, T, glayer_zoom_finger_factor, T_DOUBLE);
378 ELM_CONFIG_VAL(D, T, glayer_zoom_wheel_factor, T_DOUBLE);
379 ELM_CONFIG_VAL(D, T, glayer_zoom_distance_tolerance, T_DOUBLE);
380 ELM_CONFIG_VAL(D, T, glayer_rotate_finger_enable, T_UCHAR);
381 ELM_CONFIG_VAL(D, T, glayer_rotate_angular_tolerance, T_DOUBLE);
382 ELM_CONFIG_VAL(D, T, glayer_line_min_length, T_DOUBLE);
383 ELM_CONFIG_VAL(D, T, glayer_line_distance_tolerance, T_DOUBLE);
384 ELM_CONFIG_VAL(D, T, glayer_line_angular_tolerance, T_DOUBLE);
385 ELM_CONFIG_VAL(D, T, glayer_flick_time_limit_ms, T_INT);
386 ELM_CONFIG_VAL(D, T, glayer_long_tap_start_timeout, T_DOUBLE);
387 ELM_CONFIG_VAL(D, T, glayer_double_tap_timeout, T_DOUBLE);
388 ELM_CONFIG_VAL(D, T, access_mode, T_UCHAR);
389 ELM_CONFIG_VAL(D, T, selection_clear_enable, T_UCHAR);
390 ELM_CONFIG_VAL(D, T, glayer_continues_enable, T_UCHAR);
391 ELM_CONFIG_VAL(D, T, week_start, T_INT);
392 ELM_CONFIG_VAL(D, T, weekend_start, T_INT);
393 ELM_CONFIG_VAL(D, T, weekend_len, T_INT);
394 ELM_CONFIG_VAL(D, T, year_min, T_INT);
395 ELM_CONFIG_VAL(D, T, year_max, T_INT);
396 ELM_CONFIG_LIST(D, T, color_palette, _config_color_palette_edd);
397 ELM_CONFIG_VAL(D, T, softcursor_mode, T_UCHAR);
398 ELM_CONFIG_VAL(D, T, auto_norender_withdrawn, T_UCHAR);
399 ELM_CONFIG_VAL(D, T, auto_norender_iconified_same_as_withdrawn, T_UCHAR);
400 ELM_CONFIG_VAL(D, T, auto_flush_withdrawn, T_UCHAR);
401 ELM_CONFIG_VAL(D, T, auto_dump_withdrawn, T_UCHAR);
402 ELM_CONFIG_VAL(D, T, auto_throttle, T_UCHAR);
403 ELM_CONFIG_VAL(D, T, auto_throttle_amount, T_DOUBLE);
404 ELM_CONFIG_VAL(D, T, indicator_service_0, T_STRING);
405 ELM_CONFIG_VAL(D, T, indicator_service_90, T_STRING);
406 ELM_CONFIG_VAL(D, T, indicator_service_180, T_STRING);
407 ELM_CONFIG_VAL(D, T, indicator_service_270, T_STRING);
421 eet_data_descriptor_free(_config_edd);
425 if (_config_font_overlay_edd)
427 eet_data_descriptor_free(_config_font_overlay_edd);
428 _config_font_overlay_edd = NULL;
431 if (_config_color_edd)
433 eet_data_descriptor_free(_config_color_edd);
434 _config_color_edd = NULL;
437 if (_config_color_palette_edd)
439 eet_data_descriptor_free(_config_color_palette_edd);
440 _config_color_palette_edd = NULL;
445 _sort_files_cb(const void *f1,
448 return strcmp(f1, f2);
452 _elm_config_current_profile_get(void)
458 _elm_data_dir_snprintf(char *dst,
463 size_t data_dir_len, off;
466 data_dir_len = eina_strlcpy(dst, _elm_data_dir, size);
468 off = data_dir_len + 1;
473 dst[data_dir_len] = '/';
475 off = off + vsnprintf(dst + off, size - off, fmt, ap);
483 _elm_user_dir_snprintf(char *dst,
489 size_t user_dir_len, off;
493 home = evil_homedir_get();
495 home = getenv("HOME");
500 user_dir_len = eina_str_join_len(dst, size, '/', home, strlen(home),
501 ELEMENTARY_BASE_DIR, sizeof(ELEMENTARY_BASE_DIR) - 1);
503 off = user_dir_len + 1;
508 dst[user_dir_len] = '/';
510 off = off + vsnprintf(dst + off, size - off, fmt, ap);
518 _elm_config_profile_dir_get(const char *prof,
526 _elm_user_dir_snprintf(buf, sizeof(buf), "config/%s", prof);
528 if (ecore_file_is_dir(buf))
534 snprintf(buf, sizeof(buf), "%s/config/%s", _elm_data_dir, prof);
536 if (ecore_file_is_dir(buf))
543 _elm_config_font_overlays_list(void)
545 return _elm_config->font_overlays;
548 Eina_Bool _elm_config_access_get(void)
550 return _elm_config->access_mode;
553 void _elm_config_access_set(Eina_Bool is_access)
555 is_access = !!is_access;
556 if (_elm_config->access_mode == is_access) return;
557 _elm_config->access_mode = is_access;
558 _elm_win_access(is_access);
560 if (!is_access) _elm_access_shutdown();
563 Eina_Bool _elm_config_selection_unfocused_clear_get(void)
565 return _elm_config->selection_clear_enable;
568 void _elm_config_selection_unfocused_clear_set(Eina_Bool enabled)
571 if (_elm_config->selection_clear_enable == enabled) return;
572 _elm_config->selection_clear_enable = enabled;
576 _elm_config_font_overlay_set(const char *text_class,
580 Elm_Font_Overlay *efd;
583 EINA_LIST_FOREACH(_elm_config->font_overlays, l, efd)
585 if (strcmp(efd->text_class, text_class))
588 if (efd->font) eina_stringshare_del(efd->font);
589 efd->font = eina_stringshare_add(font);
591 _elm_config->font_overlays =
592 eina_list_promote_list(_elm_config->font_overlays, l);
596 /* the text class doesn't exist */
597 efd = calloc(1, sizeof(Elm_Font_Overlay));
598 efd->text_class = eina_stringshare_add(text_class);
599 efd->font = eina_stringshare_add(font);
602 _elm_config->font_overlays = eina_list_prepend(_elm_config->font_overlays,
607 _elm_config_font_overlay_remove(const char *text_class)
609 Elm_Font_Overlay *efd;
612 EINA_LIST_FOREACH(_elm_config->font_overlays, l, efd)
614 if (strcmp(efd->text_class, text_class))
617 _elm_config->font_overlays =
618 eina_list_remove_list(_elm_config->font_overlays, l);
619 if (efd->text_class) eina_stringshare_del(efd->text_class);
620 if (efd->font) eina_stringshare_del(efd->font);
628 _elm_config_font_overlay_apply(void)
630 Elm_Font_Overlay *efd;
634 for (i = 0; _elm_text_classes[i].desc; i++)
635 edje_text_class_del(_elm_text_classes[i].name);
637 EINA_LIST_FOREACH(_elm_config->font_overlays, l, efd)
638 edje_text_class_set(efd->text_class, efd->font, efd->size);
642 _elm_config_text_classes_get(void)
644 Eina_List *ret = NULL;
647 for (i = 0; _elm_text_classes[i].desc; i++)
650 tc = malloc(sizeof(*tc));
653 *tc = _elm_text_classes[i];
655 ret = eina_list_append(ret, tc);
662 _elm_config_text_classes_free(Eina_List *l)
666 EINA_LIST_FREE(l, tc)
671 _elm_config_color_list_get(const char *palette_name)
674 Elm_Custom_Palette *cpalette;
675 EINA_LIST_FOREACH(_elm_config->color_palette, plist, cpalette)
677 if (strcmp(cpalette->palette_name, palette_name))
679 return cpalette->color_list;
685 _elm_config_color_set(const char *palette_name,
692 Elm_Custom_Palette *cpalette;
693 Elm_Color_RGBA *color;
694 EINA_LIST_FOREACH(_elm_config->color_palette, plist, cpalette)
696 if (strcmp(cpalette->palette_name, palette_name))
699 color = calloc(1, sizeof(Elm_Color_RGBA));
704 cpalette->color_list = eina_list_prepend(cpalette->color_list,
710 _elm_config_colors_free(const char *palette_name)
713 Elm_Custom_Palette *cpalette;
714 Elm_Color_RGBA *color;
715 EINA_LIST_FOREACH(_elm_config->color_palette, plist, cpalette)
717 if (strcmp(cpalette->palette_name, palette_name))
720 EINA_LIST_FREE(cpalette->color_list, color)
728 _elm_config_profiles_list(void)
730 Eina_File_Direct_Info *info;
731 Eina_List *flist = NULL;
732 Eina_Iterator *file_it;
737 len = _elm_user_dir_snprintf(buf, sizeof(buf), "config");
739 file_it = eina_file_stat_ls(buf);
746 len = sizeof(buf) - len;
748 EINA_ITERATOR_FOREACH(file_it, info)
750 if (info->name_length >= len)
753 if (info->type == EINA_FILE_DIR)
756 eina_list_sorted_insert(flist, _sort_files_cb,
757 eina_stringshare_add(info->path +
762 eina_iterator_free(file_it);
765 len = eina_str_join_len(buf, sizeof(buf), '/', _elm_data_dir,
766 strlen(_elm_data_dir), "config",
767 sizeof("config") - 1);
769 file_it = eina_file_direct_ls(buf);
776 len = sizeof(buf) - len;
777 EINA_ITERATOR_FOREACH(file_it, info)
779 if (info->name_length >= len)
789 EINA_LIST_FOREACH(flist, l, tmp)
790 if (!strcmp(info->path + info->name_start, tmp))
795 eina_list_sorted_insert(flist, _sort_files_cb,
796 eina_stringshare_add(info->path +
805 eina_iterator_free(file_it);
809 EINA_LIST_FREE(flist, dir)
810 eina_stringshare_del(dir);
816 _profile_fetch_from_conf(void)
818 char buf[PATH_MAX], *p, *s;
822 _elm_profile = strdup("default");
824 // if env var - use profile without question
825 s = getenv("ELM_PROFILE");
829 _elm_profile = strdup(s);
834 _elm_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
835 ef = eet_open(buf, EET_FILE_MODE_READ);
838 p = eet_read(ef, "config", &len);
842 _elm_profile = malloc(len + 1);
843 memcpy(_elm_profile, p, len);
844 _elm_profile[len] = 0;
853 _elm_data_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
854 ef = eet_open(buf, EET_FILE_MODE_READ);
857 p = eet_read(ef, "config", &len);
861 _elm_profile = malloc(len + 1);
862 memcpy(_elm_profile, p, len);
863 _elm_profile[len] = 0;
873 Elm_Font_Overlay *fo;
875 Elm_Custom_Palette *palette;
876 Elm_Color_RGBA *color;
878 if (!_elm_config) return;
879 EINA_LIST_FREE(_elm_config->font_dirs, fontdir)
881 eina_stringshare_del(fontdir);
883 if (_elm_config->engine) eina_stringshare_del(_elm_config->engine);
884 EINA_LIST_FREE(_elm_config->font_overlays, fo)
886 if (fo->text_class) eina_stringshare_del(fo->text_class);
887 if (fo->font) eina_stringshare_del(fo->font);
890 EINA_LIST_FREE(_elm_config->color_palette, palette)
892 if (palette->palette_name) eina_stringshare_del(palette->palette_name);
893 EINA_LIST_FREE(palette->color_list, color) free(color);
896 if (_elm_config->theme) eina_stringshare_del(_elm_config->theme);
897 if (_elm_config->modules) eina_stringshare_del(_elm_config->modules);
905 _elm_theme_parse(NULL, _elm_config->theme);
906 ecore_animator_frametime_set(1.0 / _elm_config->fps);
910 _config_sub_apply(void)
912 edje_frametime_set(1.0 / _elm_config->fps);
913 edje_scale_set(_elm_config->scale);
914 edje_password_show_last_set(_elm_config->password_show_last);
915 edje_password_show_last_timeout_set(_elm_config->password_show_last_timeout);
916 if (_elm_config->modules) _elm_module_parse(_elm_config->modules);
920 _elm_cache_flush_cb(void *data __UNUSED__)
922 elm_cache_all_flush();
923 return ECORE_CALLBACK_RENEW;
926 /* kind of abusing this call right now -- shared between all of those
927 * properties -- but they are not meant to be called that periodically
935 elm_cache_all_flush();
937 EINA_LIST_FOREACH(_elm_win_list, l, win)
939 Evas *e = evas_object_evas_get(win);
940 evas_image_cache_set(e, _elm_config->image_cache * 1024);
941 evas_font_cache_set(e, _elm_config->font_cache * 1024);
943 edje_file_cache_set(_elm_config->edje_cache);
944 edje_collection_cache_set(_elm_config->edje_collection_cache);
946 if (_elm_cache_flush_poller)
948 ecore_poller_del(_elm_cache_flush_poller);
949 _elm_cache_flush_poller = NULL;
951 if (_elm_config->cache_flush_enable)
953 if (_elm_config->cache_flush_poll_interval > 0)
955 _elm_cache_flush_poller =
956 ecore_poller_add(ECORE_POLLER_CORE,
957 _elm_config->cache_flush_poll_interval,
958 _elm_cache_flush_cb, NULL);
964 _config_user_load(void)
966 Elm_Config *cfg = NULL;
970 _elm_user_dir_snprintf(buf, sizeof(buf), "config/%s/base.cfg",
973 ef = eet_open(buf, EET_FILE_MODE_READ);
976 cfg = eet_data_read(ef, _config_edd, "config");
983 _config_system_load(void)
985 Elm_Config *cfg = NULL;
989 _elm_data_dir_snprintf(buf, sizeof(buf), "config/%s/base.cfg",
992 ef = eet_open(buf, EET_FILE_MODE_READ);
995 cfg = eet_data_read(ef, _config_edd, "config");
1004 _elm_config = _config_user_load();
1007 if (_elm_config->config_version < ELM_CONFIG_VERSION)
1012 /* no user config, fallback for system. No need to check version for
1013 * this one, if it's not the right one, someone screwed up at the time
1014 * of installing it */
1015 _elm_config = _config_system_load();
1016 if (_elm_config) return;
1017 /* FIXME: config load could have failed because of a non-existent
1018 * profile. Fallback to default before moving on */
1020 // config load fail - defaults
1021 // why are these here? well if they are, it means you can make a gui
1022 // config recovery app i guess...
1023 _elm_config = ELM_NEW(Elm_Config);
1024 _elm_config->config_version = ELM_CONFIG_VERSION;
1025 _elm_config->engine = eina_stringshare_add("software_x11");
1026 _elm_config->vsync = 0;
1027 _elm_config->thumbscroll_enable = EINA_TRUE;
1028 _elm_config->thumbscroll_threshold = 24;
1029 _elm_config->thumbscroll_hold_threshold = 24;
1030 _elm_config->thumbscroll_momentum_threshold = 100.0;
1031 _elm_config->thumbscroll_friction = 1.0;
1032 _elm_config->thumbscroll_bounce_friction = 0.5;
1033 _elm_config->thumbscroll_bounce_enable = EINA_TRUE;
1034 _elm_config->page_scroll_friction = 0.5;
1035 _elm_config->bring_in_scroll_friction = 0.5;
1036 _elm_config->zoom_friction = 0.5;
1037 _elm_config->thumbscroll_border_friction = 0.5;
1038 _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
1039 _elm_config->scroll_smooth_time_interval = 0.008;
1040 _elm_config->scroll_smooth_amount = 1.0;
1041 _elm_config->scroll_smooth_history_weight = 0.3;
1042 _elm_config->scroll_smooth_future_time = 0.0;
1043 _elm_config->scroll_smooth_time_window = 0.2;
1044 _elm_config->scale = 1.0;
1045 _elm_config->bgpixmap = 0;
1046 _elm_config->compositing = 1;
1047 _elm_config->font_hinting = 2;
1048 _elm_config->cache_flush_poll_interval = 512;
1049 _elm_config->cache_flush_enable = EINA_TRUE;
1050 _elm_config->font_dirs = NULL;
1051 _elm_config->image_cache = 4096;
1052 _elm_config->font_cache = 512;
1053 _elm_config->edje_cache = 32;
1054 _elm_config->edje_collection_cache = 64;
1055 _elm_config->finger_size = 40;
1056 _elm_config->fps = 60.0;
1057 _elm_config->theme = eina_stringshare_add("default");
1058 _elm_config->modules = NULL;
1059 _elm_config->tooltip_delay = 1.0;
1060 _elm_config->cursor_engine_only = EINA_TRUE;
1061 _elm_config->focus_highlight_enable = EINA_FALSE;
1062 _elm_config->focus_highlight_animate = EINA_TRUE;
1063 _elm_config->toolbar_shrink_mode = 2;
1064 _elm_config->fileselector_expand_enable = EINA_FALSE;
1065 _elm_config->inwin_dialogs_enable = EINA_FALSE;
1066 _elm_config->icon_size = 32;
1067 _elm_config->longpress_timeout = 1.0;
1068 _elm_config->effect_enable = EINA_TRUE;
1069 _elm_config->desktop_entry = EINA_FALSE;
1070 _elm_config->is_mirrored = EINA_FALSE; /* Read sys value in env_get() */
1071 _elm_config->password_show_last = EINA_FALSE;
1072 _elm_config->password_show_last_timeout = 2.0;
1073 _elm_config->glayer_zoom_finger_enable = EINA_TRUE;
1074 _elm_config->glayer_zoom_finger_factor = 1.0;
1075 _elm_config->glayer_zoom_wheel_factor = 0.05;
1076 _elm_config->glayer_zoom_distance_tolerance = 1.0; /* 1 times elm_finger_size_get() */
1077 _elm_config->glayer_rotate_finger_enable = EINA_TRUE;
1078 _elm_config->glayer_rotate_angular_tolerance = 2.0; /* 2 DEG */
1079 _elm_config->glayer_line_min_length = 1.0; /* 1 times elm_finger_size_get() */
1080 _elm_config->glayer_line_distance_tolerance = 3.0; /* 3 times elm_finger_size_get() */
1081 _elm_config->glayer_line_angular_tolerance = 20.0; /* 20 DEG */
1082 _elm_config->glayer_flick_time_limit_ms = 120; /* ms to finish flick */
1083 _elm_config->glayer_long_tap_start_timeout = 1.2; /* 1.2 second to start long-tap */
1084 _elm_config->glayer_double_tap_timeout = 0.25; /* 0.25 seconds between 2 mouse downs of a tap. */
1085 _elm_config->glayer_continues_enable = EINA_TRUE; /* Continue gestures default */
1086 _elm_config->access_mode = ELM_ACCESS_MODE_OFF;
1087 _elm_config->selection_clear_enable = EINA_TRUE;
1088 _elm_config->week_start = 1; /* monday */
1089 _elm_config->weekend_start = 6; /* saturday */
1090 _elm_config->weekend_len = 2;
1091 _elm_config->year_min = 2;
1092 _elm_config->year_max = 137;
1093 _elm_config->softcursor_mode = 0; /* 0 = auto, 1 = on, 2 = off */
1094 _elm_config->color_palette = NULL;
1095 _elm_config->auto_norender_withdrawn = 0;
1096 _elm_config->auto_norender_iconified_same_as_withdrawn = 1;
1097 _elm_config->auto_flush_withdrawn = 0;
1098 _elm_config->auto_dump_withdrawn = 0;
1099 _elm_config->auto_throttle = 0;
1100 _elm_config->auto_throttle_amount = 0.1;
1101 _elm_config->indicator_service_0 = eina_stringshare_add("elm_indicator_portrait");
1102 _elm_config->indicator_service_90 = eina_stringshare_add("elm_indicator_landscape");
1103 _elm_config->indicator_service_180 = eina_stringshare_add("elm_indicator_portrait");
1104 _elm_config->indicator_service_270 = eina_stringshare_add("elm_indicator_landscape");
1108 _elm_config_eet_close_error_get(Eet_File *ef,
1112 const char *erstr = NULL;
1114 err = eet_close(ef);
1117 case EET_ERROR_WRITE_ERROR:
1118 erstr = "An error occurred while saving Elementary's "
1119 "settings to disk. The error could not be "
1120 "deterimined. The file where the error occurred was: "
1121 "%s. This file has been deleted to avoid corrupt data.";
1124 case EET_ERROR_WRITE_ERROR_FILE_TOO_BIG:
1125 erstr = "Elementary's settings files are too big "
1126 "for the file system they are being saved to. "
1127 "This error is very strange as the files should "
1128 "be extremely small. Please check the settings "
1129 "for your home directory. "
1130 "The file where the error occurred was: %s ."
1131 "This file has been deleted to avoid corrupt data.";
1134 case EET_ERROR_WRITE_ERROR_IO_ERROR:
1135 erstr = "An output error occurred when writing the settings "
1136 "files for Elementary. Your disk is having troubles "
1137 "and possibly needs replacement. "
1138 "The file where the error occurred was: %s ."
1139 "This file has been deleted to avoid corrupt data.";
1142 case EET_ERROR_WRITE_ERROR_OUT_OF_SPACE:
1143 erstr = "Elementary cannot write its settings file "
1144 "because it ran out of space to write the file. "
1145 "You have either run out of disk space or have "
1146 "gone over your quota limit. "
1147 "The file where the error occurred was: %s ."
1148 "This file has been deleted to avoid corrupt data.";
1151 case EET_ERROR_WRITE_ERROR_FILE_CLOSED:
1152 erstr = "Elementary unexpectedly had the settings file "
1153 "it was writing closed on it. This is very unusual. "
1154 "The file where the error occurred was: %s "
1155 "This file has been deleted to avoid corrupt data.";
1163 /* delete any partially-written file */
1164 ecore_file_unlink(file);
1165 return strdup(erstr);
1172 _elm_config_profile_save(void)
1174 char buf[4096], buf2[4096];
1180 len = _elm_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
1181 if (len + 1 >= sizeof(buf))
1184 len = _elm_user_dir_snprintf(buf2, sizeof(buf2), "config/profile.cfg.tmp");
1185 if (len + 1 >= sizeof(buf2))
1188 ef = eet_open(buf2, EET_FILE_MODE_WRITE);
1192 ok = eet_write(ef, "config", _elm_profile, strlen(_elm_profile), 0);
1196 err = _elm_config_eet_close_error_get(ef, buf2);
1204 ret = ecore_file_mv(buf2, buf);
1207 ERR("Error saving Elementary's configuration profile file");
1211 ecore_file_unlink(buf2);
1215 ecore_file_unlink(buf2);
1220 _elm_config_save(void)
1222 char buf[4096], buf2[4096];
1228 len = _elm_user_dir_snprintf(buf, sizeof(buf), "config/%s", _elm_profile);
1229 if (len + 1 >= sizeof(buf))
1232 ok = ecore_file_mkpath(buf);
1235 ERR("Problem accessing Elementary's user configuration directory: %s",
1240 if (!_elm_config_profile_save())
1246 if (len + sizeof("base.cfg") >= sizeof(buf) - len)
1249 memcpy(buf + len, "base.cfg", sizeof("base.cfg"));
1250 len += sizeof("base.cfg") - 1;
1252 if (len + sizeof(".tmp") >= sizeof(buf))
1255 memcpy(buf2, buf, len);
1256 memcpy(buf2 + len, ".tmp", sizeof(".tmp"));
1258 ef = eet_open(buf2, EET_FILE_MODE_WRITE);
1262 ok = eet_data_write(ef, _config_edd, "config", _elm_config, 1);
1266 err = _elm_config_eet_close_error_get(ef, buf2);
1274 ret = ecore_file_mv(buf2, buf);
1277 ERR("Error saving Elementary's configuration file");
1281 ecore_file_unlink(buf2);
1285 ecore_file_unlink(buf2);
1290 _config_update(void)
1294 tcfg = _config_system_load();
1297 /* weird profile or something? We should probably fill
1298 * with hardcoded defaults, or get from default previx */
1301 #define IFCFG(v) if ((_elm_config->config_version & 0xffff) < (v)) {
1302 #define IFCFGELSE } else {
1304 #define COPYVAL(x) do {_elm_config->x = tcfg->x; } while (0)
1305 #define COPYPTR(x) do {_elm_config->x = tcfg->x; tcfg->x = NULL; } while (0)
1306 #define COPYSTR(x) COPYPTR(x)
1308 /* we also need to update for property changes in the root window
1309 * if needed, but that will be dependent on new properties added
1310 * with each version */
1313 COPYVAL(longpress_timeout);
1323 /* after updating user config, we must save */
1332 s = getenv("ELM_ENGINE");
1335 if ((!strcasecmp(s, "x11")) ||
1336 (!strcasecmp(s, "x")) ||
1337 (!strcasecmp(s, "software-x11")) ||
1338 (!strcasecmp(s, "software_x11")))
1339 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_X11);
1340 else if ((!strcasecmp(s, "opengl")) ||
1341 (!strcasecmp(s, "gl")) ||
1342 (!strcasecmp(s, "opengl-x11")) ||
1343 (!strcasecmp(s, "opengl_x11")))
1344 eina_stringshare_replace(&_elm_config->engine, ELM_OPENGL_X11);
1345 else if ((!strcasecmp(s, "x11-8")) ||
1346 (!strcasecmp(s, "x8")) ||
1347 (!strcasecmp(s, "software-8-x11")) ||
1348 (!strcasecmp(s, "software_8_x11")))
1349 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_8_X11);
1350 else if ((!strcasecmp(s, "x11-16")) ||
1351 (!strcasecmp(s, "x16")) ||
1352 (!strcasecmp(s, "software-16-x11")) ||
1353 (!strcasecmp(s, "software_16_x11")))
1354 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_16_X11);
1356 else if ((!strcasecmp(s, "xrender")) ||
1357 (!strcasecmp(s, "xr")) ||
1358 (!strcasecmp(s, "xrender-x11")) ||
1359 (!strcasecmp(s, "xrender_x11")))
1360 eina_stringshare_replace(&_elm_config->engine, ELM_XRENDER_X11);
1362 else if ((!strcasecmp(s, "fb")) ||
1363 (!strcasecmp(s, "software-fb")) ||
1364 (!strcasecmp(s, "software_fb")))
1365 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_FB);
1366 else if ((!strcasecmp(s, "directfb")) ||
1367 (!strcasecmp(s, "dfb")))
1368 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_DIRECTFB);
1369 else if ((!strcasecmp(s, "psl1ght")))
1370 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_PSL1GHT);
1371 else if ((!strcasecmp(s, "sdl")) ||
1372 (!strcasecmp(s, "software-sdl")) ||
1373 (!strcasecmp(s, "software_sdl")))
1374 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_SDL);
1375 else if ((!strcasecmp(s, "sdl-16")) ||
1376 (!strcasecmp(s, "software-16-sdl")) ||
1377 (!strcasecmp(s, "software_16_sdl")))
1378 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_16_SDL);
1379 else if ((!strcasecmp(s, "opengl-sdl")) ||
1380 (!strcasecmp(s, "opengl_sdl")) ||
1381 (!strcasecmp(s, "gl-sdl")) ||
1382 (!strcasecmp(s, "gl_sdl")))
1383 eina_stringshare_replace(&_elm_config->engine, ELM_OPENGL_SDL);
1384 else if ((!strcasecmp(s, "opengl-cocoa")) ||
1385 (!strcasecmp(s, "opengl_cocoa")) ||
1386 (!strcasecmp(s, "gl-cocoa")) ||
1387 (!strcasecmp(s, "gl_cocoa")))
1388 eina_stringshare_replace(&_elm_config->engine, ELM_OPENGL_COCOA);
1389 else if ((!strcasecmp(s, "gdi")) ||
1390 (!strcasecmp(s, "software-gdi")) ||
1391 (!strcasecmp(s, "software_gdi")))
1392 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_WIN32);
1393 else if ((!strcasecmp(s, "wince-gdi")) ||
1394 (!strcasecmp(s, "software-16-wince-gdi")) ||
1395 (!strcasecmp(s, "software_16_wince_gdi")))
1396 eina_stringshare_replace(&_elm_config->engine, ELM_SOFTWARE_16_WINCE);
1397 else if (!strcasecmp(s, "buffer"))
1398 eina_stringshare_replace(&_elm_config->engine, ELM_BUFFER);
1399 else if ((!strncmp(s, "shot:", 5)))
1400 eina_stringshare_replace(&_elm_config->engine, s);
1401 else if ((!strcasecmp(s, "ews")))
1402 eina_stringshare_replace(&_elm_config->engine, ELM_EWS);
1403 else if ((!strcasecmp(s, "wayland_shm")))
1404 eina_stringshare_replace(&_elm_config->engine, ELM_WAYLAND_SHM);
1405 else if ((!strcasecmp(s, "wayland_egl")))
1406 eina_stringshare_replace(&_elm_config->engine, ELM_WAYLAND_EGL);
1408 ERR("Unknown engine '%s'.", s);
1411 s = getenv("ELM_VSYNC");
1412 if (s) _elm_config->vsync = !!atoi(s);
1414 s = getenv("ELM_THUMBSCROLL_ENABLE");
1415 if (s) _elm_config->thumbscroll_enable = !!atoi(s);
1416 s = getenv("ELM_THUMBSCROLL_THRESHOLD");
1417 if (s) _elm_config->thumbscroll_threshold = atoi(s);
1418 s = getenv("ELM_THUMBSCROLL_HOLD_THRESHOLD");
1419 if (s) _elm_config->thumbscroll_hold_threshold = atoi(s);
1420 // FIXME: floatformat locale issues here 1.0 vs 1,0 - should just be 1.0
1421 s = getenv("ELM_THUMBSCROLL_MOMENTUM_THRESHOLD");
1422 if (s) _elm_config->thumbscroll_momentum_threshold = _elm_atof(s);
1423 s = getenv("ELM_THUMBSCROLL_FRICTION");
1424 if (s) _elm_config->thumbscroll_friction = _elm_atof(s);
1425 s = getenv("ELM_THUMBSCROLL_BOUNCE_ENABLE");
1426 if (s) _elm_config->thumbscroll_bounce_enable = !!atoi(s);
1427 s = getenv("ELM_THUMBSCROLL_BOUNCE_FRICTION");
1428 if (s) _elm_config->thumbscroll_bounce_friction = _elm_atof(s);
1429 s = getenv("ELM_PAGE_SCROLL_FRICTION");
1430 if (s) _elm_config->page_scroll_friction = _elm_atof(s);
1431 s = getenv("ELM_BRING_IN_SCROLL_FRICTION");
1432 if (s) _elm_config->bring_in_scroll_friction = _elm_atof(s);
1433 s = getenv("ELM_ZOOM_FRICTION");
1434 if (s) _elm_config->zoom_friction = _elm_atof(s);
1435 s = getenv("ELM_THUMBSCROLL_BORDER_FRICTION");
1438 friction = _elm_atof(s);
1445 _elm_config->thumbscroll_border_friction = friction;
1447 s = getenv("ELM_THUMBSCROLL_SENSITIVITY_FRICTION");
1450 friction = _elm_atof(s);
1457 _elm_config->thumbscroll_sensitivity_friction = friction;
1459 s = getenv("ELM_SCROLL_SMOOTH_TIME_INTERVAL");
1460 if (s) _elm_config->scroll_smooth_time_interval = atof(s);
1461 s = getenv("ELM_SCROLL_SMOOTH_AMOUNT");
1462 if (s) _elm_config->scroll_smooth_amount = _elm_atof(s);
1463 s = getenv("ELM_SCROLL_SMOOTH_HISTORY_WEIGHT");
1464 if (s) _elm_config->scroll_smooth_history_weight = _elm_atof(s);
1465 s = getenv("ELM_SCROLL_SMOOTH_FUTURE_TIME");
1466 if (s) _elm_config->scroll_smooth_future_time = _elm_atof(s);
1467 s = getenv("ELM_SCROLL_SMOOTH_TIME_WINDOW");
1468 if (s) _elm_config->scroll_smooth_time_window = _elm_atof(s);
1469 s = getenv("ELM_THEME");
1470 if (s) eina_stringshare_replace(&_elm_config->theme, s);
1472 s = getenv("ELM_FONT_HINTING");
1475 if (!strcasecmp(s, "none")) _elm_config->font_hinting = 0;
1476 else if (!strcasecmp(s, "auto"))
1477 _elm_config->font_hinting = 1;
1478 else if (!strcasecmp(s, "bytecode"))
1479 _elm_config->font_hinting = 2;
1482 s = getenv("ELM_FONT_PATH");
1488 EINA_LIST_FREE(_elm_config->font_dirs, p)
1490 eina_stringshare_del(p);
1493 buf2 = alloca(strlen(s) + 1);
1498 if ((*p == ':') || (*p == 0))
1503 strncpy(buf2, pp, len);
1505 _elm_config->font_dirs =
1506 eina_list_append(_elm_config->font_dirs,
1507 eina_stringshare_add(buf2));
1520 s = getenv("ELM_IMAGE_CACHE");
1521 if (s) _elm_config->image_cache = atoi(s);
1523 s = getenv("ELM_FONT_CACHE");
1524 if (s) _elm_config->font_cache = atoi(s);
1526 s = getenv("ELM_SCALE");
1527 if (s) _elm_config->scale = _elm_atof(s);
1529 s = getenv("ELM_FINGER_SIZE");
1530 if (s) _elm_config->finger_size = atoi(s);
1532 s = getenv("ELM_PASSWORD_SHOW_LAST");
1533 if (s) _elm_config->password_show_last = !!atoi(s);
1535 s = getenv("ELM_PASSWORD_SHOW_LAST_TIMEOUT");
1538 double pw_show_last_timeout = _elm_atof(s);
1539 if (pw_show_last_timeout >= 0.0)
1540 _elm_config->password_show_last_timeout = pw_show_last_timeout;
1543 s = getenv("ELM_FPS");
1544 if (s) _elm_config->fps = _elm_atof(s);
1545 if (_elm_config->fps < 1.0) _elm_config->fps = 1.0;
1547 s = getenv("ELM_MODULES");
1548 if (s) eina_stringshare_replace(&_elm_config->modules, s);
1550 s = getenv("ELM_TOOLTIP_DELAY");
1553 double delay = _elm_atof(s);
1555 _elm_config->tooltip_delay = delay;
1558 s = getenv("ELM_CURSOR_ENGINE_ONLY");
1559 if (s) _elm_config->cursor_engine_only = !!atoi(s);
1561 s = getenv("ELM_FOCUS_HIGHLIGHT_ENABLE");
1562 if (s) _elm_config->focus_highlight_enable = !!atoi(s);
1564 s = getenv("ELM_FOCUS_HIGHLIGHT_ANIMATE");
1565 if (s) _elm_config->focus_highlight_animate = !!atoi(s);
1567 s = getenv("ELM_TOOLBAR_SHRINK_MODE");
1568 if (s) _elm_config->toolbar_shrink_mode = atoi(s);
1570 s = getenv("ELM_FILESELECTOR_EXPAND_ENABLE");
1571 if (s) _elm_config->fileselector_expand_enable = !!atoi(s);
1573 s = getenv("ELM_INWIN_DIALOGS_ENABLE");
1574 if (s) _elm_config->inwin_dialogs_enable = !!atoi(s);
1576 s = getenv("ELM_ICON_SIZE");
1577 if (s) _elm_config->icon_size = atoi(s);
1579 s = getenv("ELM_LONGPRESS_TIMEOUT");
1580 if (s) _elm_config->longpress_timeout = _elm_atof(s);
1581 if (_elm_config->longpress_timeout < 0.0)
1582 _elm_config->longpress_timeout = 0.0;
1584 s = getenv("ELM_EFFECT_ENABLE");
1585 if (s) _elm_config->effect_enable = !!atoi(s);
1587 s = getenv("ELM_DESKTOP_ENTRY");
1588 if (s) _elm_config->desktop_entry = !!atoi(s);
1589 s = getenv("ELM_ACCESS_MODE");
1590 if (s) _elm_config->access_mode = ELM_ACCESS_MODE_ON;
1592 s = getenv("ELM_SELECTION_CLEAR_ENABLE");
1593 if (s) _elm_config->selection_clear_enable = !!atoi(s);
1595 s = getenv("ELM_AUTO_THROTTLE");
1596 if (s) _elm_config->auto_throttle = EINA_TRUE;
1597 s = getenv("ELM_AUTO_THROTTLE_AMOUNT");
1598 if (s) _elm_config->auto_throttle_amount = _elm_atof(s);
1599 s = getenv("ELM_AUTO_NORENDER_WITHDRAWN");
1600 if (s) _elm_config->auto_norender_withdrawn = EINA_TRUE;
1601 s = getenv("ELM_AUTO_NORENDER_ICONIFIED_SAME_AS_WITHDRAWN");
1602 if (s) _elm_config->auto_norender_iconified_same_as_withdrawn = EINA_TRUE;
1603 s = getenv("ELM_AUTO_FLUSH_WITHDRAWN");
1604 if (s) _elm_config->auto_flush_withdrawn = EINA_TRUE;
1605 s = getenv("ELM_AUTO_DUMP_WIDTHDRAWN");
1606 if (s) _elm_config->auto_dump_withdrawn = EINA_TRUE;
1608 s = getenv("ELM_INDICATOR_SERVICE_0");
1609 if (s) eina_stringshare_replace(&_elm_config->indicator_service_0, s);
1610 s = getenv("ELM_INDICATOR_SERVICE_90");
1611 if (s) eina_stringshare_replace(&_elm_config->indicator_service_90, s);
1612 s = getenv("ELM_INDICATOR_SERVICE_180");
1613 if (s) eina_stringshare_replace(&_elm_config->indicator_service_180, s);
1614 s = getenv("ELM_INDICATOR_SERVICE_270");
1615 if (s) eina_stringshare_replace(&_elm_config->indicator_service_270, s);
1619 elm_config_mirrored_get(void)
1621 return _elm_config->is_mirrored;
1625 elm_config_mirrored_set(Eina_Bool mirrored)
1627 mirrored = !!mirrored;
1628 if (_elm_config->is_mirrored == mirrored) return;
1629 _elm_config->is_mirrored = mirrored;
1634 elm_config_cursor_engine_only_get(void)
1636 return _elm_config->cursor_engine_only;
1640 elm_config_cursor_engine_only_set(Eina_Bool engine_only)
1642 engine_only = !!engine_only;
1643 _elm_config->cursor_engine_only = engine_only;
1647 elm_config_tooltip_delay_get(void)
1649 return _elm_config->tooltip_delay;
1653 elm_config_tooltip_delay_set(double delay)
1655 if (delay < 0.0) return;
1656 _elm_config->tooltip_delay = delay;
1662 return elm_config_scale_get();
1666 elm_config_scale_get(void)
1668 return _elm_config->scale;
1672 elm_scale_set(double scale)
1674 elm_config_scale_set(scale);
1678 elm_config_scale_set(double scale)
1680 if (scale < 0.0) return;
1681 if (_elm_config->scale == scale) return;
1682 _elm_config->scale = scale;
1687 elm_config_password_show_last_get(void)
1689 return _elm_config->password_show_last;
1693 elm_config_password_show_last_set(Eina_Bool password_show_last)
1695 if (_elm_config->password_show_last == password_show_last) return;
1696 _elm_config->password_show_last = password_show_last;
1697 edje_password_show_last_set(_elm_config->password_show_last);
1701 elm_config_password_show_last_timeout_get(void)
1703 return _elm_config->password_show_last_timeout;
1707 elm_config_password_show_last_timeout_set(double password_show_last_timeout)
1709 if (password_show_last_timeout < 0.0) return;
1710 if (_elm_config->password_show_last_timeout == password_show_last_timeout) return;
1711 _elm_config->password_show_last_timeout = password_show_last_timeout;
1712 edje_password_show_last_timeout_set(_elm_config->password_show_last_timeout);
1716 elm_config_save(void)
1718 return _elm_config_save();
1722 elm_config_reload(void)
1724 _elm_config_reload();
1728 elm_config_profile_get(void)
1730 return _elm_config_current_profile_get();
1734 elm_config_profile_dir_get(const char *profile,
1737 return _elm_config_profile_dir_get(profile, is_user);
1741 elm_config_profile_dir_free(const char *p_dir)
1743 free((void *)p_dir);
1747 elm_config_profile_list_get(void)
1749 return _elm_config_profiles_list();
1753 elm_config_profile_list_free(Eina_List *l)
1757 EINA_LIST_FREE(l, dir)
1758 eina_stringshare_del(dir);
1762 elm_config_profile_set(const char *profile)
1764 EINA_SAFETY_ON_NULL_RETURN(profile);
1765 _elm_config_profile_set(profile);
1769 elm_config_profile_exists(const char *profile)
1771 EINA_SAFETY_ON_NULL_RETURN_VAL(profile, EINA_FALSE);
1772 return _elm_config_profile_exists(profile);
1776 elm_config_engine_get(void)
1778 return _elm_config->engine;
1782 elm_config_engine_set(const char *engine)
1784 EINA_SAFETY_ON_NULL_RETURN(engine);
1786 _elm_config_engine_set(engine);
1790 elm_config_text_classes_list_get(void)
1792 return _elm_config_text_classes_get();
1796 elm_config_text_classes_list_free(Eina_List *list)
1798 _elm_config_text_classes_free(list);
1801 EAPI const Eina_List *
1802 elm_config_font_overlay_list_get(void)
1804 return _elm_config_font_overlays_list();
1808 elm_config_access_get(void)
1810 return _elm_config_access_get();
1814 elm_config_access_set(Eina_Bool is_access)
1816 _elm_config_access_set(is_access);
1820 elm_config_selection_unfocused_clear_get(void)
1822 return _elm_config_selection_unfocused_clear_get();
1826 elm_config_selection_unfocused_clear_set(Eina_Bool enabled)
1828 _elm_config_selection_unfocused_clear_set(enabled);
1832 elm_config_font_overlay_set(const char *text_class,
1834 Evas_Font_Size size)
1836 EINA_SAFETY_ON_NULL_RETURN(text_class);
1837 _elm_config_font_overlay_set(text_class, font, size);
1841 elm_config_font_overlay_unset(const char *text_class)
1843 EINA_SAFETY_ON_NULL_RETURN(text_class);
1844 _elm_config_font_overlay_remove(text_class);
1848 elm_config_font_overlay_apply(void)
1850 _elm_config_font_overlay_apply();
1855 elm_finger_size_get(void)
1857 return elm_config_finger_size_get();
1861 elm_config_finger_size_get(void)
1863 return _elm_config->finger_size;
1867 elm_finger_size_set(Evas_Coord size)
1869 elm_config_finger_size_set(size);
1873 elm_config_finger_size_set(Evas_Coord size)
1875 if (size < 0) return;
1876 if (_elm_config->finger_size == size) return;
1877 _elm_config->finger_size = size;
1882 elm_config_cache_flush_interval_get(void)
1884 return _elm_config->cache_flush_poll_interval;
1888 elm_config_cache_flush_interval_set(int size)
1890 EINA_SAFETY_ON_FALSE_RETURN(size > 0);
1891 if (_elm_config->cache_flush_poll_interval == size) return;
1892 _elm_config->cache_flush_poll_interval = size;
1898 elm_config_cache_flush_enabled_get(void)
1900 return _elm_config->cache_flush_enable;
1904 elm_config_cache_flush_enabled_set(Eina_Bool enabled)
1906 enabled = !!enabled;
1907 if (_elm_config->cache_flush_enable == enabled) return;
1908 _elm_config->cache_flush_enable = enabled;
1914 elm_config_cache_font_cache_size_get(void)
1916 return _elm_config->font_cache;
1920 elm_config_cache_font_cache_size_set(int size)
1922 if (size < 0) return;
1923 if (_elm_config->font_cache == size) return;
1924 _elm_config->font_cache = size;
1930 elm_config_cache_image_cache_size_get(void)
1932 return _elm_config->image_cache;
1936 elm_config_cache_image_cache_size_set(int size)
1938 if (size < 0) return;
1939 if (_elm_config->image_cache == size) return;
1940 _elm_config->image_cache = size;
1946 elm_config_cache_edje_file_cache_size_get()
1948 return _elm_config->edje_cache;
1952 elm_config_cache_edje_file_cache_size_set(int size)
1954 if (size < 0) return;
1955 if (_elm_config->edje_cache == size) return;
1956 _elm_config->edje_cache = size;
1962 elm_config_cache_edje_collection_cache_size_get(void)
1964 return _elm_config->edje_collection_cache;
1968 elm_config_cache_edje_collection_cache_size_set(int size)
1970 if (_elm_config->edje_collection_cache == size) return;
1971 _elm_config->edje_collection_cache = size;
1977 elm_config_focus_highlight_enabled_get(void)
1979 return _elm_config->focus_highlight_enable;
1983 elm_config_focus_highlight_enabled_set(Eina_Bool enable)
1985 _elm_config->focus_highlight_enable = !!enable;
1989 elm_config_focus_highlight_animate_get(void)
1991 return _elm_config->focus_highlight_animate;
1995 elm_config_focus_highlight_animate_set(Eina_Bool animate)
1997 _elm_config->focus_highlight_animate = !!animate;
2001 elm_config_scroll_bounce_enabled_get(void)
2003 return _elm_config->thumbscroll_bounce_enable;
2007 elm_config_scroll_bounce_enabled_set(Eina_Bool enabled)
2009 _elm_config->thumbscroll_bounce_enable = enabled;
2013 elm_config_scroll_bounce_friction_get(void)
2015 return _elm_config->thumbscroll_bounce_friction;
2019 elm_config_scroll_bounce_friction_set(double friction)
2021 _elm_config->thumbscroll_bounce_friction = friction;
2025 elm_config_scroll_page_scroll_friction_get(void)
2027 return _elm_config->page_scroll_friction;
2031 elm_config_scroll_page_scroll_friction_set(double friction)
2033 _elm_config->page_scroll_friction = friction;
2037 elm_config_scroll_bring_in_scroll_friction_get(void)
2039 return _elm_config->bring_in_scroll_friction;
2043 elm_config_scroll_bring_in_scroll_friction_set(double friction)
2045 _elm_config->bring_in_scroll_friction = friction;
2049 elm_config_scroll_zoom_friction_get(void)
2051 return _elm_config->zoom_friction;
2055 elm_config_scroll_zoom_friction_set(double friction)
2057 _elm_config->zoom_friction = friction;
2061 elm_config_scroll_thumbscroll_enabled_get(void)
2063 return _elm_config->thumbscroll_enable;
2067 elm_config_scroll_thumbscroll_enabled_set(Eina_Bool enabled)
2069 _elm_config->thumbscroll_enable = enabled;
2073 elm_config_scroll_thumbscroll_threshold_get(void)
2075 return _elm_config->thumbscroll_threshold;
2079 elm_config_scroll_thumbscroll_threshold_set(unsigned int threshold)
2081 _elm_config->thumbscroll_threshold = threshold;
2085 elm_config_scroll_thumbscroll_hold_threshold_get(void)
2087 return _elm_config->thumbscroll_hold_threshold;
2091 elm_config_scroll_thumbscroll_hold_threshold_set(unsigned int threshold)
2093 _elm_config->thumbscroll_hold_threshold = threshold;
2097 elm_config_scroll_thumbscroll_momentum_threshold_get(void)
2099 return _elm_config->thumbscroll_momentum_threshold;
2103 elm_config_scroll_thumbscroll_momentum_threshold_set(double threshold)
2105 _elm_config->thumbscroll_momentum_threshold = threshold;
2109 elm_config_scroll_thumbscroll_friction_get(void)
2111 return _elm_config->thumbscroll_friction;
2115 elm_config_scroll_thumbscroll_friction_set(double friction)
2117 _elm_config->thumbscroll_friction = friction;
2121 elm_config_scroll_thumbscroll_border_friction_get(void)
2123 return _elm_config->thumbscroll_border_friction;
2127 elm_config_scroll_thumbscroll_border_friction_set(double friction)
2129 if (friction < 0.0) friction = 0.0;
2130 if (friction > 1.0) friction = 1.0;
2131 _elm_config->thumbscroll_border_friction = friction;
2135 elm_config_scroll_thumbscroll_sensitivity_friction_get(void)
2137 return _elm_config->thumbscroll_sensitivity_friction;
2141 elm_config_scroll_thumbscroll_sensitivity_friction_set(double friction)
2143 if (friction < 0.1) friction = 0.1;
2144 if (friction > 1.0) friction = 1.0;
2145 _elm_config->thumbscroll_sensitivity_friction = friction;
2149 elm_config_longpress_timeout_set(double longpress_timeout)
2151 _elm_config->longpress_timeout = longpress_timeout;
2155 elm_config_longpress_timeout_get(void)
2157 return _elm_config->longpress_timeout;
2161 elm_config_softcursor_mode_set(Elm_Softcursor_Mode mode)
2163 _elm_config->softcursor_mode = mode;
2166 EAPI Elm_Softcursor_Mode
2167 elm_config_softcursor_mode_get(void)
2169 return _elm_config->softcursor_mode;
2173 elm_config_all_flush(void)
2175 #ifdef HAVE_ELEMENTARY_X
2176 if (_prop_all_update_timer) ecore_timer_del(_prop_all_update_timer);
2177 _prop_all_update_timer = ecore_timer_add(0.1, _prop_all_update_cb, NULL);
2185 const char *cur_dom = textdomain(NULL);
2186 const char *trans_comment = gettext("");
2187 const char *msg_locale = setlocale(LC_MESSAGES, NULL);
2189 /* Same concept as what glib does:
2190 * We shouldn't translate if there are no translations for the
2191 * application in the current locale + domain. (Unless locale is
2192 * en_/C where translating only parts of the interface make some
2195 _elm_config->translate = !(strcmp (cur_dom, "messages") &&
2196 !*trans_comment && strncmp (msg_locale, "en_", 3) &&
2197 strcmp (msg_locale, "C"));
2198 /* Get RTL orientation from system */
2199 if (_elm_config->translate)
2201 bindtextdomain(PACKAGE, LOCALE_DIR);
2202 _elm_config->is_mirrored = !strcmp(E_("default:LTR"), "default:RTL");
2209 _elm_config_init(void)
2211 if (!ELM_EVENT_CONFIG_ALL_CHANGED)
2212 ELM_EVENT_CONFIG_ALL_CHANGED = ecore_event_type_new();
2214 _profile_fetch_from_conf();
2217 if (_elm_preferred_engine) eina_stringshare_del(_elm_preferred_engine);
2218 _elm_preferred_engine = NULL;
2219 _translation_init();
2221 _elm_config_font_overlay_apply();
2226 _elm_config_sub_shutdown(void)
2228 #ifdef HAVE_ELEMENTARY_X
2229 if (_prop_all_update_timer)
2231 ecore_timer_del(_prop_all_update_timer);
2232 _prop_all_update_timer = NULL;
2233 _prop_all_update_cb(NULL);
2235 if (_prop_change_delay_timer) ecore_timer_del(_prop_change_delay_timer);
2236 _prop_change_delay_timer = NULL;
2239 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2240 if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
2241 ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
2242 ENGINE_COMPARE(ELM_XRENDER_X11) ||
2243 ENGINE_COMPARE(ELM_OPENGL_X11) ||
2244 ENGINE_COMPARE(ELM_OPENGL_COCOA))
2245 #undef ENGINE_COMPARE
2247 #ifdef HAVE_ELEMENTARY_X
2254 _elm_config_sub_init(void)
2256 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2257 if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
2258 ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
2259 ENGINE_COMPARE(ELM_XRENDER_X11) ||
2260 ENGINE_COMPARE(ELM_OPENGL_X11) ||
2261 ENGINE_COMPARE(ELM_OPENGL_COCOA))
2262 #undef ENGINE_COMPARE
2264 #ifdef HAVE_ELEMENTARY_X
2265 if (ecore_x_init(NULL))
2267 _root_1st = ecore_x_window_root_first_get();
2269 if (!ecore_x_screen_is_composited(0))
2270 _elm_config->compositing = 0;
2272 ecore_x_atoms_get(_atom_names, ATOM_COUNT, _atom);
2273 ecore_x_event_mask_set(_root_1st,
2274 ECORE_X_EVENT_MASK_WINDOW_PROPERTY);
2275 _prop_change_handler = ecore_event_handler_add
2276 (ECORE_X_EVENT_WINDOW_PROPERTY, _prop_change, NULL);
2277 if (!getenv("ELM_PROFILE"))
2281 s = ecore_x_window_prop_string_get(_root_1st,
2282 _atom[ATOM_E_PROFILE]);
2289 if (strcmp(_elm_profile, s)) changed = 1;
2293 if (changed) _prop_config_get();
2298 ERR("Cannot connect to X11 display. check $DISPLAY variable");
2301 _config_sub_apply();
2305 _elm_config_reload(void)
2310 _elm_config_font_overlay_apply();
2313 ecore_event_add(ELM_EVENT_CONFIG_ALL_CHANGED, NULL, NULL, NULL);
2317 _elm_config_engine_set(const char *engine)
2319 if (_elm_config->engine && strcmp(_elm_config->engine, engine))
2320 eina_stringshare_del(_elm_config->engine);
2322 _elm_config->engine = eina_stringshare_add(engine);
2326 elm_config_preferred_engine_get(void)
2328 return _elm_preferred_engine;
2332 elm_config_preferred_engine_set(const char *engine)
2335 eina_stringshare_replace(&(_elm_preferred_engine), engine);
2338 if (_elm_preferred_engine) eina_stringshare_del(_elm_preferred_engine);
2339 _elm_preferred_engine = NULL;
2344 elm_config_indicator_service_get(int rotation)
2349 return _elm_config->indicator_service_0;
2351 return _elm_config->indicator_service_90;
2353 return _elm_config->indicator_service_180;
2355 return _elm_config->indicator_service_270;
2362 ////JIYOUN:START We have to remove this code after cluster home application change their code
2364 elm_config_indicator_service_0_get(void)
2366 return _elm_config->indicator_service_0;
2370 elm_config_indicator_service_90_get(void)
2372 return _elm_config->indicator_service_90;
2376 elm_config_indicator_service_180_get(void)
2378 return _elm_config->indicator_service_180;
2382 elm_config_indicator_service_270_get(void)
2384 return _elm_config->indicator_service_270;
2386 ////JIYOUN:END We have to remove this code after cluster home application change their code
2388 _elm_config_profile_set(const char *profile)
2390 Eina_Bool changed = EINA_FALSE;
2394 if (strcmp(_elm_profile, profile))
2399 _elm_profile = strdup(profile);
2406 _elm_config_font_overlay_apply();
2413 _elm_config_profile_exists(const char *profile)
2415 Eina_List *profs = _elm_config_profiles_list();
2417 const char *p, *dir;
2418 Eina_Bool res = EINA_FALSE;
2420 EINA_LIST_FOREACH(profs, l, p)
2422 if (!strcmp(profile, p))
2429 EINA_LIST_FREE(profs, dir)
2430 eina_stringshare_del(dir);
2436 _elm_config_shutdown(void)
2438 #define ENGINE_COMPARE(name) (!strcmp(_elm_config->engine, name))
2439 if (ENGINE_COMPARE(ELM_SOFTWARE_X11) ||
2440 ENGINE_COMPARE(ELM_SOFTWARE_16_X11) ||
2441 ENGINE_COMPARE(ELM_XRENDER_X11) ||
2442 ENGINE_COMPARE(ELM_OPENGL_X11))
2443 #undef ENGINE_COMPARE
2445 #ifdef HAVE_ELEMENTARY_X
2446 ecore_event_handler_del(_prop_change_handler);
2447 _prop_change_handler = NULL;
2451 if (_elm_preferred_engine)
2453 eina_stringshare_del(_elm_preferred_engine);
2454 _elm_preferred_engine = NULL;
2459 _elm_profile = NULL;