11 #include <Ecore_File.h>
15 #define FREE(x) do { free(x); x = NULL; } while (0);
17 static Eina_Bool _hash_keys(Eina_Hash *hash, const char *key, void *list);
18 static void ef_icon_theme_themes_find(const char *search_dir,
20 static void ef_icons_find(Efreet_Icon_Theme *theme, Eina_Hash *icons);
21 static void ef_read_dir(const char *dir, Eina_Hash *icons);
24 ef_cb_efreet_icon_theme(void)
29 unsetenv("XDG_DATA_HOME");
31 putenv("HOME=/var/tmp");
34 tmp = efreet_icon_user_dir_get();
35 if (strcmp(tmp, "/var/tmp/.local/share/icons"))
37 printf("efreet_icon_user_dir_get() returned incorrect "
38 "value (%s) on HOME=/var/tmp\n", tmp);
45 unsetenv("USERPROFILE");
49 tmp = efreet_icon_user_dir_get();
50 if (strcmp(tmp, "/tmp/.local/share/icons"))
52 printf("efreet_icon_user_dir_get() returned incorrect "
53 "value (%s) on HOME=\n", tmp);
61 _hash_keys(Eina_Hash *hash __UNUSED__, const char *key, void *list)
65 *l = eina_list_append(*l, key);
70 ef_cb_efreet_icon_theme_list(void)
78 Efreet_Icon_Theme *theme;
82 dirs = eina_hash_string_superfast_new(free);
84 icon_dirs = efreet_data_dirs_get();
86 ef_icon_theme_themes_find(efreet_icon_user_dir_get(), dirs);
87 EINA_LIST_FOREACH(icon_dirs, l, dir)
89 snprintf(buf, sizeof(buf), "%s/icons", dir);
90 ef_icon_theme_themes_find(buf, dirs);
92 EINA_LIST_FOREACH(icon_dirs, l, dir)
94 snprintf(buf, sizeof(buf), "%s/pixmaps", dir);
95 ef_icon_theme_themes_find(buf, dirs);
97 ef_icon_theme_themes_find("/usr/share/pixmaps", dirs);
99 themes = efreet_icon_theme_list_get();
100 EINA_LIST_FOREACH(themes, l, theme)
102 if ((eina_hash_find(dirs, theme->name.internal)))
103 eina_hash_del(dirs, theme->name.internal, NULL);
106 printf("efreet_icon_theme_list_get() returned %s which we didn't "
107 "see when scanning the directories.\n", theme->name.internal);
113 themes = eina_list_remove_list(themes, themes);
117 it = eina_hash_iterator_key_new(dirs);
118 eina_iterator_foreach(it, EINA_EACH_CB(_hash_keys), &themes);
119 eina_iterator_free(it);
121 if (eina_list_count(themes) > 0)
123 printf("efreet_icon_theme_list_get() missed: ");
124 EINA_LIST_FOREACH(themes, l, dir)
132 themes = eina_list_remove_list(themes, themes);
134 eina_hash_free(dirs);
140 ef_icon_theme_themes_find(const char *search_dir, Eina_Hash *themes)
145 if (!search_dir || !themes) return;
147 dirs = ecore_file_ls(search_dir);
150 while ((dir = eina_list_data_get(dirs)))
154 dirs = eina_list_remove_list(dirs, dirs);
155 /* if we've already added the theme we're done */
156 if (eina_hash_find(themes, dir))
162 /* if the index.theme file exists we open it and look for the hidden
164 snprintf(p, sizeof(p), "%s/%s/index.theme", search_dir, dir);
165 if (ecore_file_exists(p))
171 ini = efreet_ini_new(p);
172 efreet_ini_section_set(ini, "Icon Theme");
174 //if (efreet_ini_boolean_get(ini, "Hidden")) skip = 1;
175 if (!efreet_ini_localestring_get(ini, "Name")) skip = 1;
176 efreet_ini_free(ini);
181 eina_hash_add(themes, dir, d);
188 const char *system_icons[] =
200 "document-open-recent",
201 "document-page-setup",
203 "document-print-preview",
204 "document-properties",
217 "format-indent-less",
218 "format-indent-more",
219 "format-justify-center",
220 "format-justify-fill",
221 "format-justify-left",
222 "format-justify-right",
223 "format-text-direction-ltr",
224 "format-text-direction-rtl",
226 "format-text-italic",
227 "format-text-underline",
228 "format-text-strikethrough",
249 "mail-mark-important",
259 "media-playback-pause",
260 "media-playback-start",
261 "media-playback-stop",
263 "media-seek-backward",
264 "media-seek-forward",
265 "media-skip-backward",
266 "media-skip-forward",
267 "system-lock-screen",
272 "tools-check-spelling",
275 "view-sort-ascending",
276 "view-sort-descending",
284 "accessories-calculator",
285 "accessories-character-map",
286 "accessories-dictionary",
287 "accessories-text-editor",
289 "multimedia-volume-control",
291 "preferences-desktop-accessibility",
292 "preferences-desktop-font",
293 "preferences-desktop-keyboard",
294 "preferences-desktop-locale",
295 "preferences-desktop-multimedia",
296 "preferences-desktop-screensaver",
297 "preferences-desktop-theme",
298 "preferences-desktop-wallpaper",
299 "system-file-manager",
300 "system-software-update",
301 "utilities-terminal",
302 "applications-accessories",
303 "applications-development",
304 "applications-games",
305 "applications-graphics",
306 "applications-internet",
307 "applications-multimedia",
308 "applications-office",
309 "applications-other",
310 "applications-system",
311 "applications-utilities",
312 "preferences-desktop",
313 "preferences-desktop-accessibility",
314 "preferences-desktop-peripherals",
315 "preferences-desktop-personal",
317 "preferences-system",
318 "preferences-system-network",
321 "audio-input-microphone",
328 "drive-removable-media",
348 "emblem-symbolic-link",
349 "emblem-synchronized",
366 "application-x-executable",
373 "text-x-generic-template",
376 "x-office-address-book",
379 "x-office-presentation",
380 "x-office-spreadsheet",
389 "appointment-missed",
393 "audio-volume-medium",
394 "audio-volume-muted",
398 "dialog-information",
402 "folder-drag-accept",
412 "mail-signed-verified",
413 "media-playlist-repeat",
414 "media-playlist-shuffle",
420 "network-transmit-receive",
423 "software-update-available",
424 "software-update-urgent",
426 "sync-synchronizing",
435 "weather-clear-night",
436 "weather-few-clouds",
437 "weather-few-clouds-night",
440 "weather-severe-alert",
442 "weather-showers-scattered",
450 ef_cb_efreet_icon_match(void)
453 Eina_Hash *icon_hash;
454 Efreet_Icon_Theme *theme;
456 theme = efreet_icon_theme_find(THEME);
457 icon_hash = eina_hash_string_superfast_new(free);
459 ef_icons_find(theme, icon_hash);
461 double start = ecore_time_get();
462 for (i = 0; system_icons[i]; i++)
467 path = efreet_icon_path_find(THEME, system_icons[i], SIZE);
472 if (eina_hash_find(icon_hash, system_icons[i]))
474 printf("NOT FOUND %s\n", system_icons[i]);
480 else if (!eina_hash_find(icon_hash, system_icons[i]))
482 printf("Found icon not in hash: %s\n", system_icons[i]);
491 if (s && strcmp(s, system_icons[i]))
493 printf("Name mismatch name (%s) vs ef (%s)\n", system_icons[i], s);
498 printf("Time: %f\n", (ecore_time_get() - start));
499 eina_hash_free(icon_hash);
501 start = ecore_time_get();
502 for (i = 0; system_icons[i]; i++)
507 path = efreet_icon_path_find(THEME, system_icons[i], SIZE);
517 if (s && strcmp(s, system_icons[i]))
519 printf("Name mismatch name (%s) vs ef (%s)\n", system_icons[i], s);
524 printf("Time: %f\n", (ecore_time_get() - start));
530 ef_icons_find(Efreet_Icon_Theme *theme, Eina_Hash *icons)
534 const char *theme_path;
536 if (!theme || !icons) return;
538 EINA_LIST_FOREACH(theme->paths, l, theme_path)
540 Efreet_Icon_Theme_Directory *dir;
542 EINA_LIST_FOREACH(theme->directories, ll, dir)
544 snprintf(path, sizeof(path), "%s/%s/", theme_path, dir->name);
545 ef_read_dir(path, icons);
551 Efreet_Icon_Theme *parent_theme;
554 EINA_LIST_FOREACH(theme->inherits, l, parent)
556 parent_theme = efreet_icon_theme_find(parent);
558 ef_icons_find(parent_theme, icons);
561 else if (strcmp(theme->name.internal, "hicolor"))
563 Efreet_Icon_Theme *parent_theme;
565 parent_theme = efreet_icon_theme_find("hicolor");
567 ef_icons_find(parent_theme, icons);
570 ef_read_dir("/usr/share/pixmaps", icons);
574 ef_read_dir(const char *dir, Eina_Hash *icons)
579 if (!dir || !icons) return;
581 files = ecore_file_ls(dir);
584 while ((file = eina_list_data_get(files)))
588 files = eina_list_remove_list(files, files);
589 p = strrchr(file, '.');
596 if (!strcmp(p, ".png") || !strcmp(p, ".xpm"))
600 eina_hash_add(icons, file, strdup(file));