11
# include <evil_private.h>
15
#include <Ecore_File.h>
20
#define FREE(x) do { free(x); x = NULL; } while (0);
22
static Eina_Bool _hash_keys(Eina_Hash *hash, const char *key, void *list);
23
static void ef_icon_theme_themes_find(const char *search_dir,
25
static void ef_icons_find(Efreet_Icon_Theme *theme, Eina_Hash *icons);
26
static void ef_read_dir(const char *dir, Eina_Hash *icons);
29
ef_cb_efreet_icon_theme(void)
34
unsetenv("XDG_DATA_HOME");
36
putenv("HOME=/var/tmp");
39
tmp = efreet_icon_user_dir_get();
40
if (strcmp(tmp, "/var/tmp/.local/share/icons"))
42
printf("efreet_icon_user_dir_get() returned incorrect "
43
"value (%s) on HOME=/var/tmp\n", tmp);
50
unsetenv("USERPROFILE");
54
tmp = efreet_icon_user_dir_get();
55
if (strcmp(tmp, "/tmp/.local/share/icons"))
57
printf("efreet_icon_user_dir_get() returned incorrect "
58
"value (%s) on HOME=\n", tmp);
66
_hash_keys(Eina_Hash *hash EINA_UNUSED, const char *key, void *list)
70
*l = eina_list_append(*l, key);
75
ef_cb_efreet_icon_theme_list(void)
83
Efreet_Icon_Theme *theme;
87
dirs = eina_hash_string_superfast_new(free);
89
icon_dirs = efreet_data_dirs_get();
91
ef_icon_theme_themes_find(efreet_icon_user_dir_get(), dirs);
92
EINA_LIST_FOREACH(icon_dirs, l, dir)
94
snprintf(buf, sizeof(buf), "%s/icons", dir);
95
ef_icon_theme_themes_find(buf, dirs);
97
EINA_LIST_FOREACH(icon_dirs, l, dir)
99
snprintf(buf, sizeof(buf), "%s/pixmaps", dir);
100
ef_icon_theme_themes_find(buf, dirs);
102
ef_icon_theme_themes_find("/usr/share/pixmaps", dirs);
104
themes = efreet_icon_theme_list_get();
105
EINA_LIST_FOREACH(themes, l, theme)
107
if ((eina_hash_find(dirs, theme->name.internal)))
108
eina_hash_del(dirs, theme->name.internal, NULL);
111
printf("efreet_icon_theme_list_get() returned %s which we didn't "
112
"see when scanning the directories.\n", theme->name.internal);
118
themes = eina_list_remove_list(themes, themes);
122
it = eina_hash_iterator_key_new(dirs);
123
eina_iterator_foreach(it, EINA_EACH_CB(_hash_keys), &themes);
124
eina_iterator_free(it);
126
if (eina_list_count(themes) > 0)
128
printf("efreet_icon_theme_list_get() missed: ");
129
EINA_LIST_FOREACH(themes, l, dir)
137
themes = eina_list_remove_list(themes, themes);
139
eina_hash_free(dirs);
145
ef_icon_theme_themes_find(const char *search_dir, Eina_Hash *themes)
150
if (!search_dir || !themes) return;
152
dirs = ecore_file_ls(search_dir);
155
while ((dir = eina_list_data_get(dirs)))
159
dirs = eina_list_remove_list(dirs, dirs);
161
if (eina_hash_find(themes, dir))
169
snprintf(p, sizeof(p), "%s/%s/index.theme", search_dir, dir);
170
if (ecore_file_exists(p))
176
ini = efreet_ini_new(p);
177
efreet_ini_section_set(ini, "Icon Theme");
180
if (!efreet_ini_localestring_get(ini, "Name")) skip = 1;
181
efreet_ini_free(ini);
186
eina_hash_add(themes, dir, d);
193
const char *system_icons[] =
205
"document-open-recent",
206
"document-page-setup",
208
"document-print-preview",
209
"document-properties",
222
"format-indent-less",
223
"format-indent-more",
224
"format-justify-center",
225
"format-justify-fill",
226
"format-justify-left",
227
"format-justify-right",
228
"format-text-direction-ltr",
229
"format-text-direction-rtl",
231
"format-text-italic",
232
"format-text-underline",
233
"format-text-strikethrough",
254
"mail-mark-important",
264
"media-playback-pause",
265
"media-playback-start",
266
"media-playback-stop",
268
"media-seek-backward",
269
"media-seek-forward",
270
"media-skip-backward",
271
"media-skip-forward",
272
"system-lock-screen",
277
"tools-check-spelling",
280
"view-sort-ascending",
281
"view-sort-descending",
289
"accessories-calculator",
290
"accessories-character-map",
291
"accessories-dictionary",
292
"accessories-text-editor",
294
"multimedia-volume-control",
296
"preferences-desktop-accessibility",
297
"preferences-desktop-font",
298
"preferences-desktop-keyboard",
299
"preferences-desktop-locale",
300
"preferences-desktop-multimedia",
301
"preferences-desktop-screensaver",
302
"preferences-desktop-theme",
303
"preferences-desktop-wallpaper",
304
"system-file-manager",
305
"system-software-update",
306
"utilities-terminal",
307
"applications-accessories",
308
"applications-development",
309
"applications-games",
310
"applications-graphics",
311
"applications-internet",
312
"applications-multimedia",
313
"applications-office",
314
"applications-other",
315
"applications-system",
316
"applications-utilities",
317
"preferences-desktop",
318
"preferences-desktop-accessibility",
319
"preferences-desktop-peripherals",
320
"preferences-desktop-personal",
322
"preferences-system",
323
"preferences-system-network",
326
"audio-input-microphone",
333
"drive-removable-media",
353
"emblem-symbolic-link",
354
"emblem-synchronized",
371
"application-x-executable",
378
"text-x-generic-template",
381
"x-office-address-book",
384
"x-office-presentation",
385
"x-office-spreadsheet",
394
"appointment-missed",
398
"audio-volume-medium",
399
"audio-volume-muted",
403
"dialog-information",
407
"folder-drag-accept",
417
"mail-signed-verified",
418
"media-playlist-repeat",
419
"media-playlist-shuffle",
425
"network-transmit-receive",
428
"software-update-available",
429
"software-update-urgent",
431
"sync-synchronizing",
440
"weather-clear-night",
441
"weather-few-clouds",
442
"weather-few-clouds-night",
445
"weather-severe-alert",
447
"weather-showers-scattered",
455
ef_cb_efreet_icon_match(void)
458
Eina_Hash *icon_hash;
459
Efreet_Icon_Theme *theme;
461
theme = efreet_icon_theme_find(THEME);
462
icon_hash = eina_hash_string_superfast_new(free);
464
ef_icons_find(theme, icon_hash);
466
double start = ecore_time_get();
467
for (i = 0; system_icons[i]; i++)
472
path = efreet_icon_path_find(THEME, system_icons[i], SIZE);
477
if (eina_hash_find(icon_hash, system_icons[i]))
479
printf("NOT FOUND %s\n", system_icons[i]);
485
else if (!eina_hash_find(icon_hash, system_icons[i]))
487
printf("Found icon not in hash: %s\n", system_icons[i]);
496
if (s && strcmp(s, system_icons[i]))
498
printf("Name mismatch name (%s) vs ef (%s)\n", system_icons[i], s);
503
printf("Time: %f\n", (ecore_time_get() - start));
504
eina_hash_free(icon_hash);
506
start = ecore_time_get();
507
for (i = 0; system_icons[i]; i++)
512
path = efreet_icon_path_find(THEME, system_icons[i], SIZE);
522
if (s && strcmp(s, system_icons[i]))
524
printf("Name mismatch name (%s) vs ef (%s)\n", system_icons[i], s);
529
printf("Time: %f\n", (ecore_time_get() - start));
535
ef_icons_find(Efreet_Icon_Theme *theme, Eina_Hash *icons)
539
const char *theme_path;
541
if (!theme || !icons) return;
543
EINA_LIST_FOREACH(theme->paths, l, theme_path)
545
Efreet_Icon_Theme_Directory *dir;
547
EINA_LIST_FOREACH(theme->directories, ll, dir)
549
snprintf(path, sizeof(path), "%s/%s/", theme_path, dir->name);
550
ef_read_dir(path, icons);
556
Efreet_Icon_Theme *parent_theme;
559
EINA_LIST_FOREACH(theme->inherits, l, parent)
561
parent_theme = efreet_icon_theme_find(parent);
563
ef_icons_find(parent_theme, icons);
566
else if (strcmp(theme->name.internal, "hicolor"))
568
Efreet_Icon_Theme *parent_theme;
570
parent_theme = efreet_icon_theme_find("hicolor");
572
ef_icons_find(parent_theme, icons);
575
ef_read_dir("/usr/share/pixmaps", icons);
579
ef_read_dir(const char *dir, Eina_Hash *icons)
584
if (!dir || !icons) return;
586
files = ecore_file_ls(dir);
589
while ((file = eina_list_data_get(files)))
593
files = eina_list_remove_list(files, files);
594
p = strrchr(file, '.');
601
if (!strcmp(p, ".png") || !strcmp(p, ".xpm"))
605
eina_hash_add(icons, file, strdup(file));