3 static void *_create_data(E_Config_Dialog *cfd);
4 static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
5 static int _basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
6 static int _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
7 static Evas_Object *_basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
8 static int _sort_icon_themes(const void *data1, const void *data2);
9 static Evas_Object *_icon_new(Evas *evas, const char *theme, const char *icon, unsigned int size);
11 struct _E_Config_Dialog_Data
14 Eina_List *icon_themes;
15 const char *themename;
17 int enable_icon_theme;
22 Evas_Object *checkbox;
23 Evas_Object *preview[4]; /* same size as _icon_previews */
25 Ecore_Idler *fill_icon_themes_delayed;
28 static const char *_icon_previews[4] =
31 "system-file-manager",
32 "preferences-desktop-theme",
36 #define PREVIEW_SIZE (48)
39 e_int_config_icon_themes(E_Container *con, const char *params __UNUSED__)
42 E_Config_Dialog_View *v;
44 if (e_config_dialog_find("E", "appearance/icon_theme")) return NULL;
45 v = E_NEW(E_Config_Dialog_View, 1);
47 v->create_cfdata = _create_data;
48 v->free_cfdata = _free_data;
49 v->basic.create_widgets = _basic_create;
50 v->basic.apply_cfdata = _basic_apply;
51 v->basic.check_changed = _basic_check_changed;
53 cfd = e_config_dialog_new(con, _("Icon Theme Settings"),
54 "E", "appearance/icon_theme",
55 "preferences-icon-theme", 0, v, NULL);
60 _fill_data(E_Config_Dialog_Data *cfdata)
62 cfdata->icon_themes = efreet_icon_theme_list_get();
63 cfdata->icon_themes = eina_list_sort(cfdata->icon_themes,
64 eina_list_count(cfdata->icon_themes),
69 _create_data(E_Config_Dialog *cfd)
71 E_Config_Dialog_Data *cfdata;
73 cfdata = E_NEW(E_Config_Dialog_Data, 1);
75 cfdata->themename = eina_stringshare_add(e_config->icon_theme);
76 cfdata->overrides = e_config->icon_theme_overrides;
77 cfdata->enable_icon_theme = !!(e_config->icon_theme);
82 _free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
84 if (cfdata->fill_icon_themes_delayed)
85 free(ecore_idler_del(cfdata->fill_icon_themes_delayed));
87 eina_list_free(cfdata->icon_themes);
88 eina_stringshare_del(cfdata->themename);
93 _basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
95 if (cfdata->overrides != e_config->icon_theme_overrides)
98 if (cfdata->enable_icon_theme != !!(e_config->icon_theme))
101 if ((!cfdata->themename) && (!e_config->icon_theme))
104 if ((!cfdata->themename) || (!e_config->icon_theme))
107 return strcmp(cfdata->themename, e_config->icon_theme) != 0;
111 _basic_apply(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
113 E_Event_Config_Icon_Theme *ev;
115 if (!_basic_check_changed(cfd, cfdata)) return 1;
117 eina_stringshare_del(e_config->icon_theme);
118 if (cfdata->enable_icon_theme)
119 e_config->icon_theme = eina_stringshare_ref(cfdata->themename);
121 e_config->icon_theme = NULL;
123 e_config->icon_theme_overrides = !!cfdata->overrides;
124 e_config_save_queue();
126 e_util_env_set("E_ICON_THEME", e_config->icon_theme);
128 ev = E_NEW(E_Event_Config_Icon_Theme, 1);
131 ev->icon_theme = e_config->icon_theme;
132 ecore_event_add(E_EVENT_CONFIG_ICON_THEME, ev, NULL, NULL);
138 _populate_preview(E_Config_Dialog_Data *cfdata)
140 const char *t = cfdata->themename;
143 for (i = 0; i < sizeof(_icon_previews)/sizeof(_icon_previews[0]); i++)
147 if (!(path = efreet_icon_path_find(t, _icon_previews[i], PREVIEW_SIZE)))
149 if (e_icon_file_set(cfdata->gui.preview[i], path))
150 e_icon_fill_inside_set(cfdata->gui.preview[i], EINA_TRUE);
154 struct _fill_icon_themes_data
159 E_Config_Dialog_Data *cfdata;
160 Eina_Bool themes_loaded;
164 _fill_icon_themes(void *data)
166 struct _fill_icon_themes_data *d = data;
167 Efreet_Icon_Theme *theme;
168 Evas_Object *oc = NULL;
169 const char **example_icon, *example_icons[] =
176 "preferences-system",
180 if (!d->themes_loaded)
182 d->cfdata->icon_themes = eina_list_free(d->cfdata->icon_themes);
183 _fill_data(d->cfdata);
184 d->l = d->cfdata->icon_themes;
186 d->themes_loaded = 1;
187 return ECORE_CALLBACK_RENEW;
194 e_widget_ilist_go(d->cfdata->gui.list);
196 e_widget_size_min_get(d->cfdata->gui.list, &mw, &mh);
197 e_widget_size_min_set(d->cfdata->gui.list, mw, 100);
199 d->cfdata->fill_icon_themes_delayed = NULL;
200 d->cfdata->populating = EINA_FALSE;
201 _populate_preview(d->cfdata);
203 return ECORE_CALLBACK_CANCEL;
207 if (theme->example_icon)
209 example_icons[0] = theme->example_icon;
210 example_icon = example_icons;
213 example_icon = example_icons + 1;
215 for (; (*example_icon) && (!oc); example_icon++)
216 oc = _icon_new(d->evas, theme->name.internal, *example_icon, 24);
220 e_widget_ilist_append(d->cfdata->gui.list, oc, theme->name.name,
221 NULL, NULL, theme->name.internal);
222 if ((d->cfdata->themename) && (theme->name.internal) &&
223 (strcmp(d->cfdata->themename, theme->name.internal) == 0))
224 e_widget_ilist_selected_set(d->cfdata->gui.list, d->i);
229 return ECORE_CALLBACK_RENEW;
233 _icon_theme_changed(void *data, Evas_Object *o __UNUSED__)
235 E_Config_Dialog_Data *cfdata;
238 if (cfdata->populating) return;
239 _populate_preview(cfdata);
243 _basic_create(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
245 Evas_Object *o, *ilist, *checkbox, *ol;
246 struct _fill_icon_themes_data *d;
249 o = e_widget_list_add(evas, 0, 0);
250 ilist = e_widget_ilist_add(evas, 24, 24, &(cfdata->themename));
251 cfdata->gui.list = ilist;
252 e_widget_size_min_set(cfdata->gui.list, 100, 100);
254 cfdata->populating = EINA_TRUE;
255 e_widget_on_change_hook_set(ilist, _icon_theme_changed, cfdata);
256 e_widget_list_object_append(o, ilist, 1, 1, 0.5);
258 ol = e_widget_framelist_add(evas, _("Preview"), 1);
259 for (i = 0; i < sizeof(_icon_previews)/sizeof(_icon_previews[0]); i++)
261 cfdata->gui.preview[i] = e_icon_add(evas);
262 e_icon_preload_set(cfdata->gui.preview[i], EINA_TRUE);
263 e_icon_scale_size_set(cfdata->gui.preview[i], PREVIEW_SIZE);
264 e_widget_framelist_object_append_full(ol, cfdata->gui.preview[i],
265 0, 0, 0, 0, 0.5, 0.5,
266 PREVIEW_SIZE, PREVIEW_SIZE,
267 PREVIEW_SIZE, PREVIEW_SIZE);
269 e_widget_list_object_append(o, ol, 0, 0, 0.5);
271 checkbox = e_widget_check_add(evas, _("Enable icon theme"),
272 &(cfdata->enable_icon_theme));
273 e_widget_on_change_hook_set(checkbox, _icon_theme_changed, cfdata);
274 e_widget_list_object_append(o, checkbox, 0, 0, 0.0);
276 checkbox = e_widget_check_add(evas, _("Icons override general theme"),
277 &(cfdata->overrides));
278 e_widget_on_change_hook_set(checkbox, _icon_theme_changed, cfdata);
279 e_widget_list_object_append(o, checkbox, 0, 0, 0.0);
281 e_dialog_resizable_set(cfd->dia, 1);
283 if (cfdata->fill_icon_themes_delayed)
284 free(ecore_idler_del(cfdata->fill_icon_themes_delayed));
286 d = malloc(sizeof(*d));
289 d->themes_loaded = 0;
291 cfdata->fill_icon_themes_delayed = ecore_idler_add(_fill_icon_themes, d);
297 _sort_icon_themes(const void *data1, const void *data2)
299 const Efreet_Icon_Theme *m1, *m2;
301 if (!data2) return -1;
306 if (!m1->name.name) return 1;
307 if (!m2->name.name) return -1;
309 return (strcmp(m1->name.name, m2->name.name));
313 _icon_new(Evas *evas, const char *theme, const char *icon, unsigned int size)
318 if (!(path = efreet_icon_path_find(theme, icon, size))) return NULL;
319 o = e_icon_add(evas);
320 if (e_icon_file_set(o, path))
321 e_icon_fill_inside_set(o, 1);