summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2021-05-06 13:13:39 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2021-05-07 14:25:12 +0100
commit4e70c3f3581a540c010817af0f9bafe448c0e3ec (patch)
treea81257fe8cb0f81c0dbb478f43fbcc44b12d2a7b /src
parent64e02a04135caeff5607232db2ffed2bbc7cc9a8 (diff)
elm config - replace old colorclass systme with newer pallete one
the old one was a bit... rough. the new one relies on the new fallback to parent classes in edje to simplify colorclasses and can now apply immediately. i've started on a palette editor gui - and it works relatively well and applies live as you slide colors around. it looks vaguely good too. i don't thnk we should hsave a widget to do this as it's probably too much in elementary (the lib) that is far too niche in use.
Diffstat (limited to 'src')
-rw-r--r--src/lib/elementary/elm_config.c590
-rw-r--r--src/lib/elementary/elm_config.h26
-rw-r--r--src/lib/elementary/elm_priv.h1
3 files changed, 375 insertions, 242 deletions
diff --git a/src/lib/elementary/elm_config.c b/src/lib/elementary/elm_config.c
index 3c8537d8b0..ef6581a7ce 100644
--- a/src/lib/elementary/elm_config.c
+++ b/src/lib/elementary/elm_config.c
@@ -14,6 +14,8 @@ EAPI void __efl_internal_elm_config_set(Efl_Config *cfg);
14Elm_Config *_elm_config = NULL; 14Elm_Config *_elm_config = NULL;
15Efl_Config *_efl_config_obj = NULL; 15Efl_Config *_efl_config_obj = NULL;
16static char *_elm_profile = NULL; 16static char *_elm_profile = NULL;
17static Eet_Data_Descriptor *_config_palette_color_edd = NULL;
18static Eet_Data_Descriptor *_config_palette_edd = NULL;
17static Eet_Data_Descriptor *_config_edd = NULL; 19static Eet_Data_Descriptor *_config_edd = NULL;
18static Eet_Data_Descriptor *_config_font_overlay_edd = NULL; 20static Eet_Data_Descriptor *_config_font_overlay_edd = NULL;
19static Eet_Data_Descriptor *_config_color_edd = NULL; 21static Eet_Data_Descriptor *_config_color_edd = NULL;
@@ -94,91 +96,6 @@ static const Elm_Text_Class _elm_text_classes[] = {
94 {NULL, NULL} 96 {NULL, NULL}
95}; 97};
96 98
97/* whenever you want to add a new class class support into Elementary,
98 declare it both here and in the (default) theme */
99static const Elm_Color_Class _elm_color_classes[] = {
100 {"button_text", "Button Text"},
101 {"button_text_disabled", "Button Disabled Text"},
102 {"button_text_anchor", "Anchor Button Text"},
103 {"button_text_anchor_disabled", "Anchor Button Disabled Text"},
104 {"calendar_year_text", "Year Text in Title Area"},
105 {"calendar_month_text", "Month Text in Title Area"},
106 {"calendar_weekday_text", "Weekday Text"},
107 {"calendar_day_text", "Day Text"},
108 {"calendar_day_text_holiday", "Holiday Text"},
109 {"calendar_day_text_today", "Today Text"},
110 {"calendar_day_text_disabled", "Disabled Day Text"},
111 {"calendar_day_selected", "Selected Day Effect"},
112 {"calendar_day_highlighted", "Highlighted Day Effect"},
113 {"calendar_day_checked", "Checked Day Effect"},
114 {"datetime_bg", "Datetime Background"},
115 {"datepicker_bg", "Datepicker Background"},
116 {"timepicker_bg", "Timepicker Background"},
117 {"datetime_separator_text", "Datetime Separator Text"},
118 {"datetime_separator_text_disabled", "Datetime Separator Disabled Text"},
119 {"hoversel_item_active", "Hoversel Item Text"},
120 {"hoversel_text_disabled", "Hoversel Item Disabled Text"},
121 {"radio_text", "Radio Text"},
122 {"frame", "Frame Text"},
123 {"entry_text", "Entry Text"},
124 {"entry_text_disabled", "Entry Disabled Text"},
125 {"entry_guide_text", "Entry Guide Text"},
126 {"entry_cursor", "Entry Cursor"},
127 {"entry_selection_handler", "Entry Selection Handler"},
128 {"entry_scrollframe_base", "Entry Scrollframe Base"},
129 {"check_text", "Check Text"},
130 {"check_on_text", "Check On Text"},
131 {"check_off_text", "Check Off Text"},
132 {"list_item_base", "List Item Base"},
133 {"list_item_base_odd", "List Odd Item Base"},
134 {"list_item_disabled", "List Item Disabled Base"},
135 {"list_item_selected", "List Item Selected Base"},
136 {"grid_item", "Grid Item Text"},
137 {"grid_item_disabled", "Grid Item Disabled Text"},
138 {"grid_item_selected", "Grid Item Selected Text"},
139 {"index_bg", "Index Background"},
140 {"index_item_bg", "Index Item Background"},
141 {"index_highlight_text", "Index Highlight Text"},
142 {"index_item_text", "Index Items Text"},
143 {"index_item_text_selected", "Index Selected Items Text"},
144 {"toolbar_item", "Toolbar Item Text"},
145 {"toolbar_item_disabled", "Toolbar Item Disabled Text"},
146 {"toolbar_item_selected", "Toolbar Item Selected Text"},
147 {"toolbar_item_active", "Toolbar Item Active Text"},
148 {"slider_text", "Slider Text"},
149 {"slider_text_disabled", "Slider Disabled Text"},
150 {"slider_indicator", "Slider Indicator Text"},
151 {"spinner_bg", "Spinner Background"},
152 {"progressbar_text", "Progressbar Text"},
153 {"progressbar_text_disabled", "Progressbar Disabled Text"},
154 {"progressbar_status", "Progressbar Status Text"},
155 {"bubble_text", "Bubble Text"},
156 {"bubble_info", "Bubble Info Text"},
157 {"menu_item_active", "Menu Item Text"},
158 {"menu_item_disabled", "Menu Item Disabled Text"},
159 {"multibuttonentry_bg", "Multibuttonentry Background"},
160 {"multibuttonentry_item_bg", "Multibuttonentry Item Background"},
161 {"multibuttonentry_item_bg_selected", "Multibuttonentry Item Selected Background"},
162 {"multibuttonentry_item_text", "Multibuttonentry Item Text"},
163 {"multibuttonentry_item_text_pressed", "Multibuttonentry Item Pressed Text"},
164 {"multibuttonentry_item_text_disabled", "Multibuttonentry Item Disabled Text"},
165 {"tags_bg", "Tags Background"},
166 {"tags_item_bg", "Tags Item Background"},
167 {"tags_item_bg_selected", "Tags Item Selected Background"},
168 {"tags_item_text", "Tags Item Text"},
169 {"tags_item_text_pressed", "Tags Item Pressed Text"},
170 {"tags_item_text_disabled", "Tags Item Disabled Text"},
171 {"border_title", "Border Title Text"},
172 {"border_title_active", "Border Title Active Text"},
173 {"datetime_text", "Datetime Text"},
174 {"multibuttonentry_label", "Multibuttonentry Text"},
175 {"tags_label", "Tags Text"},
176 {"tags_number", "Tags Number Text"},
177 {"spinner", "Spinner Text"},
178 {"spinner_disabled", "Spinner Disabled Text"},
179 {NULL, NULL}
180};
181
182static void _config_free(Elm_Config *cfg); 99static void _config_free(Elm_Config *cfg);
183static void _config_apply(void); 100static void _config_apply(void);
184static void _config_sub_apply(void); 101static void _config_sub_apply(void);
@@ -215,6 +132,32 @@ _desc_init(void)
215{ 132{
216 Eet_Data_Descriptor_Class eddc; 133 Eet_Data_Descriptor_Class eddc;
217 134
135 memset(&eddc, 0, sizeof(eddc)); /* just in case... */
136 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Palette_Color);
137 eddc.func.str_direct_alloc = NULL;
138 eddc.func.str_direct_free = NULL;
139
140 _config_palette_color_edd = eet_data_descriptor_stream_new(&eddc);
141 if (!_config_palette_color_edd)
142 {
143 ERR("EEEK! eet_data_descriptor_stream_new() failed.");
144 return;
145 }
146
147 memset(&eddc, 0, sizeof(eddc)); /* just in case... */
148 EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Palette);
149 eddc.func.str_direct_alloc = NULL;
150 eddc.func.str_direct_free = NULL;
151
152 _config_palette_edd = eet_data_descriptor_stream_new(&eddc);
153 if (!_config_palette_edd)
154 {
155 ERR("EEEK! eet_data_descriptor_stream_new() failed.");
156 eet_data_descriptor_free(_config_palette_color_edd);
157 return;
158 }
159
160 memset(&eddc, 0, sizeof(eddc)); /* just in case... */
218 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Config); 161 EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Elm_Config);
219 eddc.func.str_direct_alloc = NULL; 162 eddc.func.str_direct_alloc = NULL;
220 eddc.func.str_direct_free = NULL; 163 eddc.func.str_direct_free = NULL;
@@ -322,8 +265,29 @@ _desc_init(void)
322#define T_STRING EET_T_STRING 265#define T_STRING EET_T_STRING
323#define T_UCHAR EET_T_UCHAR 266#define T_UCHAR EET_T_UCHAR
324 267
325#define T Elm_Font_Overlay 268//////////////////////////////////////////////////////////////////////////////
326#define D _config_font_overlay_edd 269
270#define T Elm_Palette_Color
271#define D _config_palette_color_edd
272 ELM_CONFIG_VAL(D, T, name, EET_T_STRING);
273 ELM_CONFIG_VAL(D, T, r, EET_T_UCHAR);
274 ELM_CONFIG_VAL(D, T, g, EET_T_UCHAR);
275 ELM_CONFIG_VAL(D, T, b, EET_T_UCHAR);
276 ELM_CONFIG_VAL(D, T, a, EET_T_UCHAR);
277#undef T
278#undef D
279
280#define T Elm_Palette
281#define D _config_palette_edd
282 ELM_CONFIG_VAL(D, T, version, EET_T_INT);
283 ELM_CONFIG_LIST(D, T, colors, _config_palette_color_edd);
284#undef T
285#undef D
286
287//////////////////////////////////////////////////////////////////////////////
288
289#define T Elm_Font_Overlay
290#define D _config_font_overlay_edd
327 ELM_CONFIG_VAL(D, T, text_class, EET_T_STRING); 291 ELM_CONFIG_VAL(D, T, text_class, EET_T_STRING);
328 ELM_CONFIG_VAL(D, T, font, EET_T_STRING); 292 ELM_CONFIG_VAL(D, T, font, EET_T_STRING);
329 ELM_CONFIG_VAL(D, T, size, EET_T_INT); 293 ELM_CONFIG_VAL(D, T, size, EET_T_INT);
@@ -364,15 +328,15 @@ _desc_init(void)
364#undef T 328#undef T
365#undef D 329#undef D
366 330
367#define T Elm_Config_Bindings_Widget 331#define T Elm_Config_Bindings_Widget
368#define D _config_bindings_widget_edd 332#define D _config_bindings_widget_edd
369 ELM_CONFIG_VAL(D, T, name, EET_T_STRING); 333 ELM_CONFIG_VAL(D, T, name, EET_T_STRING);
370 ELM_CONFIG_LIST(D, T, key_bindings, _config_binding_key_edd); 334 ELM_CONFIG_LIST(D, T, key_bindings, _config_binding_key_edd);
371#undef T 335#undef T
372#undef D 336#undef D
373 337
374#define T Elm_Config_Binding_Key 338#define T Elm_Config_Binding_Key
375#define D _config_binding_key_edd 339#define D _config_binding_key_edd
376 ELM_CONFIG_VAL(D, T, context, EET_T_INT); 340 ELM_CONFIG_VAL(D, T, context, EET_T_INT);
377 ELM_CONFIG_VAL(D, T, key, EET_T_STRING); 341 ELM_CONFIG_VAL(D, T, key, EET_T_STRING);
378 ELM_CONFIG_VAL(D, T, action, EET_T_STRING); 342 ELM_CONFIG_VAL(D, T, action, EET_T_STRING);
@@ -381,8 +345,8 @@ _desc_init(void)
381#undef T 345#undef T
382#undef D 346#undef D
383 347
384#define T Elm_Config_Binding_Modifier 348#define T Elm_Config_Binding_Modifier
385#define D _config_binding_modifier_edd 349#define D _config_binding_modifier_edd
386 ELM_CONFIG_VAL(D, T, mod, EET_T_STRING); 350 ELM_CONFIG_VAL(D, T, mod, EET_T_STRING);
387 ELM_CONFIG_VAL(D, T, flag, EET_T_UCHAR); 351 ELM_CONFIG_VAL(D, T, flag, EET_T_UCHAR);
388#undef T 352#undef T
@@ -526,6 +490,7 @@ _desc_init(void)
526 ELM_CONFIG_VAL(D, T, popup_scrollable, T_UCHAR); 490 ELM_CONFIG_VAL(D, T, popup_scrollable, T_UCHAR);
527 ELM_CONFIG_VAL(D, T, spinner_min_max_filter_enable, T_UCHAR); 491 ELM_CONFIG_VAL(D, T, spinner_min_max_filter_enable, T_UCHAR);
528 ELM_CONFIG_VAL(D, T, icon_theme, T_STRING); 492 ELM_CONFIG_VAL(D, T, icon_theme, T_STRING);
493 ELM_CONFIG_VAL(D, T, palette, T_STRING);
529 ELM_CONFIG_VAL(D, T, entry_select_allow, T_UCHAR); 494 ELM_CONFIG_VAL(D, T, entry_select_allow, T_UCHAR);
530 ELM_CONFIG_VAL(D, T, offline, T_UCHAR); 495 ELM_CONFIG_VAL(D, T, offline, T_UCHAR);
531 ELM_CONFIG_VAL(D, T, powersave, T_INT); 496 ELM_CONFIG_VAL(D, T, powersave, T_INT);
@@ -542,10 +507,16 @@ _desc_init(void)
542static void 507static void
543_desc_shutdown(void) 508_desc_shutdown(void)
544{ 509{
545 if (_config_edd) 510 if (_config_palette_edd)
546 { 511 {
547 eet_data_descriptor_free(_config_edd); 512 eet_data_descriptor_free(_config_palette_edd);
548 _config_edd = NULL; 513 _config_palette_edd = NULL;
514 }
515
516 if (_config_palette_color_edd)
517 {
518 eet_data_descriptor_free(_config_palette_color_edd);
519 _config_palette_color_edd = NULL;
549 } 520 }
550 521
551 if (_config_font_overlay_edd) 522 if (_config_font_overlay_edd)
@@ -629,6 +600,262 @@ end:
629 return off; 600 return off;
630} 601}
631 602
603static Elm_Palette *
604_palette_load(const char *file)
605{
606 Elm_Palette *pal;
607 Eet_File *ef = eet_open(file, EET_FILE_MODE_READ);
608
609 if (!ef) return NULL;
610 pal = eet_data_read(ef, _config_palette_edd, "palette");
611 eet_close(ef);
612 return pal;
613}
614
615static void
616_palette_free(Elm_Palette *pal)
617{
618 Elm_Palette_Color *col;
619
620 EINA_LIST_FREE(pal->colors, col)
621 {
622 eina_stringshare_del(col->name);
623 free(col);
624 }
625 free(pal);
626}
627
628static Eina_Bool
629_palette_save(Elm_Palette *pal, const char *file)
630{
631 Eina_Bool ok = EINA_FALSE;
632 Eet_File *ef = eet_open(file, EET_FILE_MODE_WRITE);
633 if (!ef) return EINA_FALSE;
634 if (eet_data_write(ef, _config_palette_edd, "palette",
635 pal, EET_COMPRESSION_VERYFAST) > 0)
636 ok = EINA_TRUE;
637 eet_close(ef);
638 return ok;
639}
640
641static Elm_Palette *
642_palette_find(const char *name)
643{
644 Elm_Palette *pal;
645 char buf[PATH_MAX];
646
647 if (!name) return NULL;
648 if (strchr(name, '/')) return NULL;
649 _elm_config_user_dir_snprintf(buf, sizeof(buf), "colors/%s.pal", name);
650 pal = _palette_load(buf);
651 if (!pal)
652 {
653 _elm_data_dir_snprintf(buf, sizeof(buf), "colors/%s.pal", name);
654 pal = _palette_load(buf);
655 }
656 return pal;
657}
658
659static Elm_Palette *
660_palette_new(void)
661{
662 Elm_Palette *pal = calloc(1, sizeof(*pal));
663 if (!pal) return NULL;
664 pal->version = 1000;
665 return pal;
666}
667
668static Eina_Bool
669_palette_store(Elm_Palette *pal, const char *name)
670{
671 char buf[PATH_MAX];
672
673 if (!pal) return EINA_FALSE;
674 _elm_config_user_dir_snprintf(buf, sizeof(buf), "colors");
675 ecore_file_mkpath(buf);
676 _elm_config_user_dir_snprintf(buf, sizeof(buf), "colors/%s.pal", name);
677 return _palette_save(pal, buf);
678}
679
680static void
681_palette_set(Elm_Palette *pal, const char *clas, int r, int g, int b, int a)
682{
683 Eina_List *l;
684 Elm_Palette_Color *c;
685
686 if (!pal) return;
687 EINA_LIST_FOREACH(pal->colors, l, c)
688 {
689 if ((c->name) && (!strcmp(c->name, clas)))
690 {
691 c->r = r;
692 c->g = g;
693 c->b = b;
694 c->a = a;
695 return;
696 }
697 }
698 c = calloc(1, sizeof(*c));
699 if (!c) return;
700 c->name = eina_stringshare_add(clas);
701 c->r = r;
702 c->g = g;
703 c->b = b;
704 c->a = a;
705 pal->colors = eina_list_append(pal->colors, c);
706}
707
708static void
709_palette_unset(Elm_Palette *pal, const char *clas)
710{
711 Eina_List *l;
712 Elm_Palette_Color *c;
713
714 if (!pal) return;
715 EINA_LIST_FOREACH(pal->colors, l, c)
716 {
717 if ((c->name) && (!strcmp(c->name, clas)))
718 {
719 pal->colors = eina_list_remove_list(pal->colors, l);
720 if (c->name) eina_stringshare_del(c->name);
721 free(c);
722 }
723 }
724}
725
726EAPI Elm_Palette *
727elm_config_palette_load(const char *palette)
728{
729 Elm_Palette *pal;
730
731 pal = _palette_find(palette);
732 if (!pal) pal = _palette_new();
733 return pal;
734}
735
736EAPI void
737elm_config_palette_color_set(Elm_Palette *pal, const char *name, int r, int g, int b, int a)
738{
739 _palette_set(pal, name, r, g, b, a);
740}
741
742EAPI void
743elm_config_palette_color_unset(Elm_Palette *pal, const char *name)
744{
745 _palette_unset(pal, name);
746}
747
748EAPI void
749elm_config_palette_save(Elm_Palette *pal, const char *palette)
750{
751 _palette_store(pal, palette);
752}
753
754EAPI void
755elm_config_palette_free(Elm_Palette *pal)
756{
757 _palette_free(pal);
758}
759
760EAPI void
761elm_config_palette_delete(const char *palette)
762{
763 char buf[PATH_MAX];
764
765 if (!palette) return;
766 if (strchr(palette, '/')) return;
767 _elm_config_user_dir_snprintf(buf, sizeof(buf), "colors/%s.pal", palette);
768 ecore_file_unlink(buf);
769}
770
771EAPI Eina_List *
772elm_config_palette_list(void)
773{
774 Eina_List *list = NULL, *files, *l;
775 char buf[PATH_MAX], *s, *s2;
776
777 _elm_data_dir_snprintf(buf, sizeof(buf), "colors");
778 files = ecore_file_ls(buf);
779 EINA_LIST_FREE(files, s)
780 {
781 char *ext = strrchr(s, '.');
782
783 if ((ext) && (!strcmp(ext, ".pal")))
784 {
785 *ext = 0;
786 list = eina_list_append(list, eina_stringshare_add(s));
787 }
788 free(s);
789 }
790 _elm_config_user_dir_snprintf(buf, sizeof(buf), "colors");
791 files = ecore_file_ls(buf);
792 EINA_LIST_FREE(files, s)
793 {
794 char *ext = strrchr(s, '.');
795
796 if ((ext) && (!strcmp(ext, ".pal")))
797 {
798 Eina_Bool found = EINA_FALSE;
799
800 *ext = 0;
801 EINA_LIST_FOREACH(list, l, s2)
802 {
803 if (!strcmp(s, s2))
804 {
805 found = EINA_TRUE;
806 break;
807 }
808 }
809 if (!found)
810 list = eina_list_append(list, eina_stringshare_add(s));
811 }
812 free(s);
813 }
814 return list;
815}
816
817EAPI void
818elm_config_palette_list_free(Eina_List *list)
819{
820 const char *s;
821
822 EINA_LIST_FREE(list, s) eina_stringshare_del(s);
823}
824
825static void
826_palette_apply(const char *name)
827{
828 Elm_Palette *pal;
829 Elm_Palette_Color *col;
830 Eina_List *l;
831 char *s;
832
833 // clear old colors
834 l = edje_color_class_list();
835 EINA_LIST_FREE(l, s)
836 {
837 if ((s) && (s[0] == '/')) edje_color_class_del(s);
838 free(s);
839 }
840 pal = _palette_find(name);
841 if (!pal) return;
842 // if version new enough...
843 if (pal->version >= 1000)
844 {
845 // for each color - set that colorclass
846 EINA_LIST_FOREACH(pal->colors, l, col)
847 {
848 if (!col->name) continue;
849 edje_color_class_set(col->name,
850 col->r, col->g, col->b, col->a,
851 col->r, col->g, col->b, col->a,
852 col->r, col->g, col->b, col->a);
853 }
854 }
855 edje_color_class_apply();
856 _palette_free(pal);
857}
858
632static Eina_Hash *_getenv_once_envs = NULL; 859static Eina_Hash *_getenv_once_envs = NULL;
633static const char *_getenv_once_empty = ""; 860static const char *_getenv_once_empty = "";
634 861
@@ -1165,21 +1392,7 @@ _elm_config_text_classes_free(Eina_List *l)
1165Eina_List * 1392Eina_List *
1166_elm_config_color_classes_get(void) 1393_elm_config_color_classes_get(void)
1167{ 1394{
1168 Eina_List *ret = NULL; 1395 return NULL;
1169 int i;
1170
1171 for (i = 0; _elm_color_classes[i].desc; i++)
1172 {
1173 Elm_Color_Class *cc;
1174 cc = malloc(sizeof(*cc));
1175 if (!cc) continue;
1176
1177 *cc = _elm_color_classes[i];
1178
1179 ret = eina_list_append(ret, cc);
1180 }
1181
1182 return ret;
1183} 1396}
1184 1397
1185void 1398void
@@ -1206,118 +1419,6 @@ _elm_config_color_overlays_list(void)
1206 return _elm_config->color_overlays; 1419 return _elm_config->color_overlays;
1207} 1420}
1208 1421
1209void
1210_elm_config_color_overlay_set(const char *color_class,
1211 int r, int g, int b, int a,
1212 int r2, int g2, int b2, int a2,
1213 int r3, int g3, int b3, int a3)
1214{
1215 Elm_Color_Overlay *ecd;
1216 Eina_List *l;
1217
1218#define CHECK_COLOR_VAL(v) v = (v > 255)? 255 : (v < 0)? 0: v
1219 CHECK_COLOR_VAL(r);
1220 CHECK_COLOR_VAL(g);
1221 CHECK_COLOR_VAL(b);
1222 CHECK_COLOR_VAL(a);
1223 CHECK_COLOR_VAL(r2);
1224 CHECK_COLOR_VAL(g2);
1225 CHECK_COLOR_VAL(b2);
1226 CHECK_COLOR_VAL(a2);
1227 CHECK_COLOR_VAL(r3);
1228 CHECK_COLOR_VAL(g3);
1229 CHECK_COLOR_VAL(b3);
1230 CHECK_COLOR_VAL(a3);
1231#undef CHECK_COLOR_VAL
1232
1233 EINA_LIST_FOREACH(_elm_config->color_overlays, l, ecd)
1234 {
1235 if (!eina_streq(ecd->color_class, color_class))
1236 continue;
1237
1238 ecd->color.r = r;
1239 ecd->color.g = g;
1240 ecd->color.b = b;
1241 ecd->color.a = a;
1242 ecd->outline.r = r2;
1243 ecd->outline.g = g2;
1244 ecd->outline.b = b2;
1245 ecd->outline.a = a2;
1246 ecd->shadow.r = r3;
1247 ecd->shadow.g = g3;
1248 ecd->shadow.b = b3;
1249 ecd->shadow.a = a3;
1250
1251 _elm_config->color_overlays =
1252 eina_list_promote_list(_elm_config->color_overlays, l);
1253 return;
1254 }
1255
1256 /* the color class doesn't exist */
1257 ecd = calloc(1, sizeof(Elm_Color_Overlay));
1258 if (!ecd) return;
1259
1260 ecd->color_class = eina_stringshare_add(color_class);
1261 ecd->color.r = r;
1262 ecd->color.g = g;
1263 ecd->color.b = b;
1264 ecd->color.a = a;
1265 ecd->outline.r = r2;
1266 ecd->outline.g = g2;
1267 ecd->outline.b = b2;
1268 ecd->outline.a = a2;
1269 ecd->shadow.r = r3;
1270 ecd->shadow.g = g3;
1271 ecd->shadow.b = b3;
1272 ecd->shadow.a = a3;
1273
1274 _elm_config->color_overlays =
1275 eina_list_prepend(_elm_config->color_overlays, ecd);
1276}
1277
1278void
1279_elm_config_color_overlay_remove(const char *color_class)
1280{
1281 Elm_Color_Overlay *ecd;
1282 Eina_List *l;
1283
1284 EINA_LIST_FOREACH(_elm_config->color_overlays, l, ecd)
1285 {
1286 if (!ecd->color_class) continue;
1287 if (!eina_streq(ecd->color_class, color_class)) continue;
1288
1289 _color_overlays_del =
1290 eina_list_append(_color_overlays_del,
1291 eina_stringshare_add(color_class));
1292 _elm_config->color_overlays =
1293 eina_list_remove_list(_elm_config->color_overlays, l);
1294 eina_stringshare_del(ecd->color_class);
1295 free(ecd);
1296
1297 return;
1298 }
1299}
1300
1301void
1302_elm_config_color_overlay_apply(void)
1303{
1304 Elm_Color_Overlay *ecd;
1305 Eina_List *l;
1306 char *color_class;
1307
1308 EINA_LIST_FREE(_color_overlays_del, color_class)
1309 {
1310 edje_color_class_del(color_class);
1311 eina_stringshare_del(color_class);
1312 }
1313
1314 EINA_LIST_FOREACH(_elm_config->color_overlays, l, ecd)
1315 edje_color_class_set(ecd->color_class,
1316 ecd->color.r, ecd->color.g, ecd->color.b, ecd->color.a,
1317 ecd->outline.r, ecd->outline.g, ecd->outline.b, ecd->outline.a,
1318 ecd->shadow.r, ecd->shadow.g, ecd->shadow.b, ecd->shadow.a);
1319}
1320
1321Eina_List * 1422Eina_List *
1322_elm_config_color_list_get(const char *palette_name) 1423_elm_config_color_list_get(const char *palette_name)
1323{ 1424{
@@ -1592,6 +1693,7 @@ _config_free(Elm_Config *cfg)
1592 eina_stringshare_del(cfg->indicator_service_180); 1693 eina_stringshare_del(cfg->indicator_service_180);
1593 eina_stringshare_del(cfg->indicator_service_270); 1694 eina_stringshare_del(cfg->indicator_service_270);
1594 eina_stringshare_del(cfg->icon_theme); 1695 eina_stringshare_del(cfg->icon_theme);
1696 eina_stringshare_del(cfg->palette);
1595 free(cfg); 1697 free(cfg);
1596} 1698}
1597 1699
@@ -1782,6 +1884,7 @@ _config_load(void)
1782 if (_elm_config->config_version < ELM_CONFIG_VERSION) 1884 if (_elm_config->config_version < ELM_CONFIG_VERSION)
1783 _config_update(); 1885 _config_update();
1784 _env_get(); 1886 _env_get();
1887 _palette_apply(_elm_config->palette);
1785 return; 1888 return;
1786 } 1889 }
1787 } 1890 }
@@ -1793,6 +1896,7 @@ _config_load(void)
1793 _elm_config = _config_system_load(); 1896 _elm_config = _config_system_load();
1794 if (_elm_config) 1897 if (_elm_config)
1795 { 1898 {
1899 _palette_apply(_elm_config->palette);
1796 _env_get(); 1900 _env_get();
1797 return; 1901 return;
1798 } 1902 }
@@ -2041,7 +2145,6 @@ _config_flush_get(void)
2041 _config_sub_apply(); 2145 _config_sub_apply();
2042 evas_font_reinit(); 2146 evas_font_reinit();
2043 _elm_config_font_overlay_apply(); 2147 _elm_config_font_overlay_apply();
2044 _elm_config_color_overlay_apply();
2045 if (!EINA_DBL_EQ(pre_scale, _elm_config->scale)) 2148 if (!EINA_DBL_EQ(pre_scale, _elm_config->scale))
2046 _elm_rescale(); 2149 _elm_rescale();
2047 _elm_old_clouseau_reload(); 2150 _elm_old_clouseau_reload();
@@ -2860,6 +2963,9 @@ _env_get(void)
2860 2963
2861 s = _getenv_once("ELM_WIN_NO_BORDER"); 2964 s = _getenv_once("ELM_WIN_NO_BORDER");
2862 if (s) _elm_config->win_no_border = EINA_TRUE; 2965 if (s) _elm_config->win_no_border = EINA_TRUE;
2966
2967 s = _getenv_once("ELM_PALETTE");
2968 if (s) eina_stringshare_replace(&_elm_config->palette, s);
2863} 2969}
2864 2970
2865static void 2971static void
@@ -3016,6 +3122,19 @@ elm_config_icon_theme_set(const char *theme)
3016 _elm_config->icon_theme = eina_stringshare_add(ELM_CONFIG_ICON_THEME_ELEMENTARY); 3122 _elm_config->icon_theme = eina_stringshare_add(ELM_CONFIG_ICON_THEME_ELEMENTARY);
3017} 3123}
3018 3124
3125EAPI const char *
3126elm_config_palette_get(void)
3127{
3128 return _elm_config->palette;
3129}
3130
3131EAPI void
3132elm_config_palette_set(const char *palette)
3133{
3134 eina_stringshare_replace(&(_elm_config->palette), palette);
3135 _palette_apply(_elm_config->palette);
3136}
3137
3019EAPI Eina_Bool 3138EAPI Eina_Bool
3020elm_config_password_show_last_get(void) 3139elm_config_password_show_last_get(void)
3021{ 3140{
@@ -3252,31 +3371,21 @@ elm_config_color_overlay_list_get(void)
3252} 3371}
3253 3372
3254EAPI void 3373EAPI void
3255elm_config_color_overlay_set(const char *color_class, 3374elm_config_color_overlay_set(const char *color_class EINA_UNUSED,
3256 int r, int g, int b, int a, 3375 int r EINA_UNUSED, int g EINA_UNUSED, int b EINA_UNUSED, int a EINA_UNUSED,
3257 int r2, int g2, int b2, int a2, 3376 int r2 EINA_UNUSED, int g2 EINA_UNUSED, int b2 EINA_UNUSED, int a2 EINA_UNUSED,
3258 int r3, int g3, int b3, int a3) 3377 int r3 EINA_UNUSED, int g3 EINA_UNUSED, int b3 EINA_UNUSED, int a3 EINA_UNUSED)
3259{ 3378{
3260 _elm_config->priv.color_overlays = EINA_TRUE;
3261 EINA_SAFETY_ON_NULL_RETURN(color_class);
3262 _elm_config_color_overlay_set(color_class,
3263 r, g, b, a,
3264 r2, g2, b2, a2,
3265 r3, g3, b3, a3);
3266} 3379}
3267 3380
3268EAPI void 3381EAPI void
3269elm_config_color_overlay_unset(const char *color_class) 3382elm_config_color_overlay_unset(const char *color_class EINA_UNUSED)
3270{ 3383{
3271 _elm_config->priv.color_overlays = EINA_TRUE;
3272 EINA_SAFETY_ON_NULL_RETURN(color_class);
3273 _elm_config_color_overlay_remove(color_class);
3274} 3384}
3275 3385
3276EAPI void 3386EAPI void
3277elm_config_color_overlay_apply(void) 3387elm_config_color_overlay_apply(void)
3278{ 3388{
3279 _elm_config_color_overlay_apply();
3280} 3389}
3281 3390
3282EAPI Evas_Coord 3391EAPI Evas_Coord
@@ -4301,7 +4410,6 @@ _elm_config_init(void)
4301 _elm_recache(); 4410 _elm_recache();
4302 _config_apply(); 4411 _config_apply();
4303 _elm_config_font_overlay_apply(); 4412 _elm_config_font_overlay_apply();
4304 _elm_config_color_overlay_apply();
4305 _elm_old_clouseau_reload(); 4413 _elm_old_clouseau_reload();
4306 _elm_config_key_binding_hash(); 4414 _elm_config_key_binding_hash();
4307} 4415}
@@ -4475,7 +4583,6 @@ _elm_config_reload(void)
4475 _elm_recache(); 4583 _elm_recache();
4476 _config_apply(); 4584 _config_apply();
4477 _elm_config_font_overlay_apply(); 4585 _elm_config_font_overlay_apply();
4478 _elm_config_color_overlay_apply();
4479#define CMP(x) (p##x != _elm_config->x) 4586#define CMP(x) (p##x != _elm_config->x)
4480#define DBL_CMP(x) !EINA_DBL_EQ(p##x, _elm_config->x) 4587#define DBL_CMP(x) !EINA_DBL_EQ(p##x, _elm_config->x)
4481 if ( 4588 if (
@@ -4780,7 +4887,6 @@ _elm_config_profile_set(const char *profile)
4780 _elm_recache(); 4887 _elm_recache();
4781 _config_apply(); 4888 _config_apply();
4782 _elm_config_font_overlay_apply(); 4889 _elm_config_font_overlay_apply();
4783 _elm_config_color_overlay_apply();
4784 _elm_rescale(); 4890 _elm_rescale();
4785 _elm_old_clouseau_reload(); 4891 _elm_old_clouseau_reload();
4786 _elm_config_key_binding_hash(); 4892 _elm_config_key_binding_hash();
diff --git a/src/lib/elementary/elm_config.h b/src/lib/elementary/elm_config.h
index f3c6c6b5df..a437c31e4a 100644
--- a/src/lib/elementary/elm_config.h
+++ b/src/lib/elementary/elm_config.h
@@ -1116,6 +1116,32 @@ EAPI const char *elm_config_icon_theme_get(void);
1116 */ 1116 */
1117EAPI void elm_config_icon_theme_set(const char *theme); 1117EAPI void elm_config_icon_theme_set(const char *theme);
1118 1118
1119/** new palette code - nbot sure if this should be final yet **/
1120typedef struct _Elm_Palette_Color
1121{
1122 const char *name;
1123 unsigned char r, g, b, a;
1124} Elm_Palette_Color;
1125
1126typedef struct _Elm_Palette
1127{
1128 int version;
1129 Eina_List *colors;
1130} Elm_Palette;
1131
1132EAPI const char *elm_config_palette_get(void);
1133EAPI void elm_config_palette_set(const char *palette);
1134
1135EAPI Elm_Palette *elm_config_palette_load(const char *palette);
1136EAPI void elm_config_palette_color_set(Elm_Palette *pal, const char *name, int r, int g, int b, int a);
1137EAPI void elm_config_palette_color_unset(Elm_Palette *pal, const char *name);
1138EAPI void elm_config_palette_save(Elm_Palette *pal, const char *palette);
1139EAPI void elm_config_palette_free(Elm_Palette *pal);
1140EAPI void elm_config_palette_delete(const char *palette);
1141EAPI Eina_List *elm_config_palette_list(void);
1142EAPI void elm_config_palette_list_free(Eina_List *list);
1143/** end new palette code **/
1144
1119/** 1145/**
1120 * @defgroup Elm_Password_last_show Password show last 1146 * @defgroup Elm_Password_last_show Password show last
1121 * @ingroup Elementary 1147 * @ingroup Elementary
diff --git a/src/lib/elementary/elm_priv.h b/src/lib/elementary/elm_priv.h
index 52aee0fd26..66aed98380 100644
--- a/src/lib/elementary/elm_priv.h
+++ b/src/lib/elementary/elm_priv.h
@@ -602,6 +602,7 @@ struct _Elm_Config
602 int gl_stencil; 602 int gl_stencil;
603 int gl_msaa; 603 int gl_msaa;
604 const char *icon_theme; 604 const char *icon_theme;
605 const char *palette;
605 unsigned char entry_select_allow; 606 unsigned char entry_select_allow;
606 Eina_Bool offline; 607 Eina_Bool offline;
607 int powersave; 608 int powersave;