summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2006-07-08 09:18:04 +0000
committerCarsten Haitzler <raster@rasterman.com>2006-07-08 09:18:04 +0000
commit50063cad9ce642b497b0ba394655eb9c51a500f5 (patch)
tree7b5274ef6c2e998b072ad32b6d199a644b4f5cb3
parent7b8c6e8b04d39f03ad9d7f5ca8120ac771a248dc (diff)
new thumbnailer system. works a bit more like epsilon - launches a
special-purpose executable and hands off workd to do via ipc (well the exe connects back to e's ipc port actually but either way - same thing). it can actually launch any numebr of thumbnailers - the default is 2, but this means it can make full use of smp systems. i need to make this # of thumbnailers configurable and add a config dialog for it. this does mean thew bg/theme etc. dialogs pop up much faster as they dont load all the thumbs to start - its farmed off and ipc tells us when they are ready (and if already generated - thats pretty damn fast). :) anyway - now thumbnailing works reliably (thoguh i think the queue handling isnt quite that good - well when it comes to interacting with efm... but i'll check into that later. dont worry though - it does actually generate all the thumbs - it just may be busy generating ones you don't see while it catches up). SVN revision: 23750
-rw-r--r--src/bin/Makefile.am8
-rw-r--r--src/bin/e_fileman_icon.c104
-rw-r--r--src/bin/e_fileman_mime.c21
-rw-r--r--src/bin/e_fileman_smart.c1
-rw-r--r--src/bin/e_icon.h2
-rw-r--r--src/bin/e_int_config_background.c32
-rw-r--r--src/bin/e_int_config_background_import.c13
-rw-r--r--src/bin/e_int_config_desklock.c39
-rw-r--r--src/bin/e_int_config_startup.c11
-rw-r--r--src/bin/e_int_config_theme.c16
-rw-r--r--src/bin/e_ipc.c18
-rw-r--r--src/bin/e_ipc.h1
-rw-r--r--src/bin/e_menu.c2
-rw-r--r--src/bin/e_thumb.c760
-rw-r--r--src/bin/e_thumb.h19
-rw-r--r--src/bin/e_thumb_main.c388
16 files changed, 737 insertions, 698 deletions
diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am
index a4ae1bb..1180643 100644
--- a/src/bin/Makefile.am
+++ b/src/bin/Makefile.am
@@ -14,7 +14,8 @@ enlightenment_remote \
14enlightenment_eapp \ 14enlightenment_eapp \
15enlightenment_eapp_cache_gen \ 15enlightenment_eapp_cache_gen \
16enlightenment_imc \ 16enlightenment_imc \
17enlightenment_start 17enlightenment_start \
18enlightenment_thumb
18 19
19ENLIGHTENMENTHEADERS = \ 20ENLIGHTENMENTHEADERS = \
20e.h \ 21e.h \
@@ -335,6 +336,11 @@ e_start_main.c
335 336
336enlightenment_start_LDFLAGS = 337enlightenment_start_LDFLAGS =
337 338
339enlightenment_thumb_SOURCES = \
340e_thumb_main.c
341
342enlightenment_thumb_LDFLAGS = @e_libs@ @dlopen_libs@
343
338installed_headersdir = $(prefix)/include/enlightenment 344installed_headersdir = $(prefix)/include/enlightenment
339installed_headers_DATA = $(ENLIGHTENMENTHEADERS) 345installed_headers_DATA = $(ENLIGHTENMENTHEADERS)
340 346
diff --git a/src/bin/e_fileman_icon.c b/src/bin/e_fileman_icon.c
index 0f64a2a..24ece0f 100644
--- a/src/bin/e_fileman_icon.c
+++ b/src/bin/e_fileman_icon.c
@@ -12,7 +12,6 @@ struct _E_Smart_Data
12 Evas *evas; 12 Evas *evas;
13 Evas_Object *obj; 13 Evas_Object *obj;
14 14
15 char *thumb_path;
16 char *saved_title; 15 char *saved_title;
17 16
18 Evas_Object *event_object; 17 Evas_Object *event_object;
@@ -137,50 +136,32 @@ e_fm_icon_file_set(Evas_Object *obj, E_Fm_File *file)
137 136
138 sd = evas_object_smart_data_get(obj); 137 sd = evas_object_smart_data_get(obj);
139 if (!sd) return; 138 if (!sd) return;
140 if(!sd->file) 139 if (!sd->file) e_object_ref(E_OBJECT(file));
141 e_object_ref(E_OBJECT(file));
142 sd->file = file; 140 sd->file = file;
143 file->icon_object = obj; 141 file->icon_object = obj;
144 142
145 /* FIXME fix this */
146 if (sd->file->mime->thumbnail) 143 if (sd->file->mime->thumbnail)
147 { 144 {
148 sd->thumb_path = e_thumb_file_get(sd->file->path); 145 /* FIXME: should use smart callback to change icon when thumb done */
149 if (e_thumb_exists(sd->file->path)) 146 sd->thumb_object = e_thumb_icon_add(sd->evas);
150 { 147 e_thumb_icon_file_set(sd->thumb_object, sd->file->path, NULL);
151 sd->thumb_object = e_thumb_evas_object_get(sd->file->path, 148 e_thumb_icon_size_set(sd->thumb_object, 64, 64);
152 sd->evas, 149 e_thumb_icon_begin(sd->thumb_object);
153 sd->iw, 150 evas_object_show(sd->thumb_object);
154 sd->ih, 151 sd->image_object = edje_object_add(sd->evas);
155 1); 152 e_theme_edje_object_set(sd->image_object, "base/theme/fileman",
156 // evas_object_geometry_get(sd->thumb_object, NULL, NULL, &icon_w, &icon_h); 153 "fileman/icon_thumb");
157 // sd->iw = icon_w; 154 edje_extern_object_min_size_set(sd->thumb_object, sd->iw, sd->ih);
158 // sd->ih = icon_h; 155 edje_extern_object_max_size_set(sd->thumb_object, sd->iw, sd->ih);
159 sd->image_object = edje_object_add(sd->evas); 156 edje_object_part_swallow(sd->image_object, "icon_swallow",
160 e_theme_edje_object_set(sd->image_object, "base/theme/fileman", 157 sd->thumb_object);
161 "fileman/icon_thumb"); 158 edje_object_size_min_calc(sd->image_object, &icon_w, &icon_h);
162 edje_extern_object_min_size_set(sd->thumb_object, sd->iw, sd->ih); 159 sd->iw = icon_w;
163 edje_extern_object_max_size_set(sd->thumb_object, sd->iw, sd->ih); 160 sd->ih = icon_h;
164 edje_object_part_swallow(sd->image_object, "icon_swallow", 161 edje_extern_object_min_size_set(sd->image_object, icon_w, icon_h);
165 sd->thumb_object); 162 edje_extern_object_max_size_set(sd->image_object, icon_w, icon_h);
166 edje_object_size_min_calc(sd->image_object, &icon_w, &icon_h); 163 edje_object_part_swallow(sd->icon_object, "icon_swallow",
167 sd->iw = icon_w; 164 sd->image_object);
168 sd->ih = icon_h;
169 edje_extern_object_min_size_set(sd->image_object, icon_w, icon_h);
170 edje_extern_object_max_size_set(sd->image_object, icon_w, icon_h);
171 edje_object_part_swallow(sd->icon_object, "icon_swallow",
172 sd->image_object);
173 }
174 else
175 {
176 sd->thumb_object = sd->file->mime->thumbnail(sd->file->path, sd->iw,
177 sd->ih, sd->evas,
178 &sd->thumb_object,
179 _e_fm_icon_thumb_generate_cb,
180 sd);
181
182 _e_fm_icon_icon_mime_get(sd);
183 }
184 } 165 }
185 else 166 else
186 { 167 {
@@ -513,49 +494,6 @@ _e_fm_icon_icon_mime_get(E_Smart_Data *sd)
513 sd->image_object); 494 sd->image_object);
514} 495}
515 496
516
517
518void
519_e_fm_icon_thumb_generate_cb(Evas_Object *obj, void *data)
520{
521 E_Smart_Data *sd;
522
523 sd = data;
524
525 /* FIXME fix this */
526#if 0
527 if (e_fm_file_has_mime(sd->file,".eap") || (ecore_file_exists(sd->thumb_path)))
528 {
529 Evas_Coord icon_w, icon_h;
530
531 if (sd->image_object) evas_object_del(sd->image_object);
532
533 sd->thumb_object = e_thumb_evas_object_get(sd->file->path,
534 sd->evas,
535 sd->iw,
536 sd->ih,
537 1);
538
539 sd->image_object = edje_object_add(sd->evas);
540 e_theme_edje_object_set(sd->image_object, "base/theme/fileman",
541 "fileman/icon_thumb");
542 evas_object_show(sd->image_object);
543 evas_object_show(sd->thumb_object);
544 edje_extern_object_min_size_set(sd->thumb_object, sd->iw, sd->ih);
545 edje_extern_object_max_size_set(sd->thumb_object, sd->iw, sd->ih);
546 edje_object_part_swallow(sd->image_object, "icon_swallow",
547 sd->thumb_object);
548 edje_object_size_min_calc(sd->image_object, &icon_w, &icon_h);
549 sd->iw = icon_w;
550 sd->ih = icon_h;
551 edje_extern_object_min_size_set(sd->image_object, icon_w, icon_h);
552 edje_extern_object_max_size_set(sd->image_object, icon_w, icon_h);
553 edje_object_part_swallow(sd->icon_object, "icon_swallow",
554 sd->image_object);
555 }
556#endif
557}
558
559static void 497static void
560_e_fm_icon_type_set(E_Smart_Data *sd) 498_e_fm_icon_type_set(E_Smart_Data *sd)
561{ 499{
diff --git a/src/bin/e_fileman_mime.c b/src/bin/e_fileman_mime.c
index ff4606d..a169464 100644
--- a/src/bin/e_fileman_mime.c
+++ b/src/bin/e_fileman_mime.c
@@ -610,8 +610,7 @@ _e_fm_mime_action_internal_folder_open(E_Fm_Smart_Data *sd)
610 E_Fm_File *file; 610 E_Fm_File *file;
611 611
612 file = sd->operation.files->data; 612 file = sd->operation.files->data;
613 e_fm_dir_set(sd->object, file->path); 613 if (file) e_fm_dir_set(sd->object, file->path);
614
615} 614}
616 615
617static void 616static void
@@ -621,8 +620,11 @@ _e_fm_mime_action_internal_folder_open_other(E_Fm_Smart_Data *sd)
621 E_Fm_File *file; 620 E_Fm_File *file;
622 621
623 file = sd->operation.files->data; 622 file = sd->operation.files->data;
624 fileman = e_fileman_new_to_dir(e_container_current_get(e_manager_current_get()), file->path); 623 if (file)
625 e_fileman_show(fileman); 624 {
625 fileman = e_fileman_new_to_dir(e_container_current_get(e_manager_current_get()), file->path);
626 e_fileman_show(fileman);
627 }
626} 628}
627static void 629static void
628_e_fm_mime_action_internal_copy_to(E_Fm_Smart_Data *sd) 630_e_fm_mime_action_internal_copy_to(E_Fm_Smart_Data *sd)
@@ -637,14 +639,15 @@ _e_fm_mime_action_internal_move_to(E_Fm_Smart_Data *sd)
637 639
638/* thumbnail functions */ 640/* thumbnail functions */
639/***********************/ 641/***********************/
640Evas_Object * _e_fm_mime_thumbnail_evas(char *path, Evas_Coord w, Evas_Coord h, Evas *evas, Evas_Object **tmp, void (*cb)(Evas_Object *obj, void *data), void *data) 642Evas_Object *
643_e_fm_mime_thumbnail_evas(char *path, Evas_Coord w, Evas_Coord h, Evas *evas, Evas_Object **tmp, void (*cb)(Evas_Object *obj, void *data), void *data)
641{ 644{
642 Evas_Object *r; 645 Evas_Object *r;
643 646
644 r = e_thumb_generate_begin(path, w, 647 r = e_thumb_icon_add(evas);
645 h, evas, tmp, cb, 648 e_thumb_icon_file_set(r, path, NULL);
646 data); 649 e_thumb_icon_size_set(r, w, h);
647 650 e_thumb_icon_begin(r);
648 return r; 651 return r;
649} 652}
650 653
diff --git a/src/bin/e_fileman_smart.c b/src/bin/e_fileman_smart.c
index fd7d257..b0e5c2c 100644
--- a/src/bin/e_fileman_smart.c
+++ b/src/bin/e_fileman_smart.c
@@ -501,7 +501,6 @@ e_fm_icon_destroy(Evas_Object *obj, void *data)
501 E_Fm_Icon *icon; 501 E_Fm_Icon *icon;
502 502
503 icon = data; 503 icon = data;
504 e_thumb_generate_end(icon->file->path);
505 evas_object_del(icon->icon_obj); 504 evas_object_del(icon->icon_obj);
506 icon->state.visible = 0; 505 icon->state.visible = 0;
507} 506}
diff --git a/src/bin/e_icon.h b/src/bin/e_icon.h
index 6afbbfe..b459508 100644
--- a/src/bin/e_icon.h
+++ b/src/bin/e_icon.h
@@ -10,7 +10,7 @@ EAPI Evas_Object *e_icon_add (Evas *evas);
10EAPI void e_icon_file_set (Evas_Object *obj, const char *file); 10EAPI void e_icon_file_set (Evas_Object *obj, const char *file);
11EAPI void e_icon_file_key_set (Evas_Object *obj, const char *file, const char *key); 11EAPI void e_icon_file_key_set (Evas_Object *obj, const char *file, const char *key);
12EAPI void e_icon_file_edje_set (Evas_Object *obj, const char *file, const char *part); 12EAPI void e_icon_file_edje_set (Evas_Object *obj, const char *file, const char *part);
13EAPI void e_icon_object_set(Evas_Object *obj, Evas_Object *o); 13EAPI void e_icon_object_set (Evas_Object *obj, Evas_Object *o);
14EAPI const char *e_icon_file_get (Evas_Object *obj); 14EAPI const char *e_icon_file_get (Evas_Object *obj);
15EAPI void e_icon_smooth_scale_set (Evas_Object *obj, int smooth); 15EAPI void e_icon_smooth_scale_set (Evas_Object *obj, int smooth);
16EAPI int e_icon_smooth_scale_get (Evas_Object *obj); 16EAPI int e_icon_smooth_scale_get (Evas_Object *obj);
diff --git a/src/bin/e_int_config_background.c b/src/bin/e_int_config_background.c
index 473c83b..e8cd35a 100644
--- a/src/bin/e_int_config_background.c
+++ b/src/bin/e_int_config_background.c
@@ -304,11 +304,12 @@ _load_bgs(E_Config_Dialog *cfd, Evas_Object *il)
304 { 304 {
305 Evas_Object *ic = NULL; 305 Evas_Object *ic = NULL;
306 306
307 if (!e_thumb_exists(c)) 307 ic = e_thumb_icon_add(cfd->dia->win->evas);
308 ic = e_thumb_generate_begin(c, 48, 48, cfd->dia->win->evas, &ic, NULL, NULL); 308 e_thumb_icon_file_set(ic, f, "desktop/background");
309 else 309 e_thumb_icon_size_set(ic, 64,
310 ic = e_thumb_evas_object_get(c, cfd->dia->win->evas, 48, 48, 1); 310 (64 * e_zone_current_get(cfd->dia->win->container)->h) /
311 311 e_zone_current_get(cfd->dia->win->container)->w);
312 e_thumb_icon_begin(ic);
312 e_widget_ilist_append(il, ic, _("Theme Wallpaper"), _ilist_cb_bg_selected, cfd, ""); 313 e_widget_ilist_append(il, ic, _("Theme Wallpaper"), _ilist_cb_bg_selected, cfd, "");
313 if (!e_config->desktop_default_background) selnum = i; 314 if (!e_config->desktop_default_background) selnum = i;
314 i++; 315 i++;
@@ -370,11 +371,12 @@ _load_bgs(E_Config_Dialog *cfd, Evas_Object *il)
370 if (ecore_file_is_dir(full_path)) continue; 371 if (ecore_file_is_dir(full_path)) continue;
371 if (!e_util_edje_collection_exists(full_path, "desktop/background")) continue; 372 if (!e_util_edje_collection_exists(full_path, "desktop/background")) continue;
372 373
373 if (!e_thumb_exists(full_path)) 374 ic = e_thumb_icon_add(cfd->dia->win->evas);
374 ic = e_thumb_generate_begin(full_path, 48, 48, evas, &ic, NULL, NULL); 375 e_thumb_icon_file_set(ic, full_path, "desktop/background");
375 else 376 e_thumb_icon_size_set(ic, 64,
376 ic = e_thumb_evas_object_get(full_path, evas, 48, 48, 1); 377 (64 * e_zone_current_get(cfd->dia->win->container)->h) /
377 378 e_zone_current_get(cfd->dia->win->container)->w);
379 e_thumb_icon_begin(ic);
378 e_widget_ilist_append(il, ic, ecore_file_strip_ext(bg_file), _ilist_cb_bg_selected, cfd, full_path); 380 e_widget_ilist_append(il, ic, ecore_file_strip_ext(bg_file), _ilist_cb_bg_selected, cfd, full_path);
379 if ((e_config->desktop_default_background) && 381 if ((e_config->desktop_default_background) &&
380 (!strcmp(e_config->desktop_default_background, full_path))) 382 (!strcmp(e_config->desktop_default_background, full_path)))
@@ -486,10 +488,12 @@ _bg_file_added(void *data, Ecore_File_Monitor *monitor, Ecore_File_Event event,
486 { 488 {
487 if (e_util_edje_collection_exists((char *)path, "desktop/background")) 489 if (e_util_edje_collection_exists((char *)path, "desktop/background"))
488 { 490 {
489 if (!e_thumb_exists((char *)path)) 491 ic = e_thumb_icon_add(cfd->dia->win->evas);
490 ic = e_thumb_generate_begin((char *)path, 48, 48, evas, &ic, NULL, NULL); 492 e_thumb_icon_file_set(ic, path, "desktop/background");
491 else 493 e_thumb_icon_size_set(ic, 64,
492 ic = e_thumb_evas_object_get((char *)path, evas, 48, 48, 1); 494 (64 * e_zone_current_get(cfd->dia->win->container)->h) /
495 e_zone_current_get(cfd->dia->win->container)->w);
496 e_thumb_icon_begin(ic);
493 e_widget_ilist_append(il, ic, noext, _ilist_cb_bg_selected, cfd, (char *)path); 497 e_widget_ilist_append(il, ic, noext, _ilist_cb_bg_selected, cfd, (char *)path);
494 } 498 }
495 } 499 }
diff --git a/src/bin/e_int_config_background_import.c b/src/bin/e_int_config_background_import.c
index 2fd8d11..64b3501 100644
--- a/src/bin/e_int_config_background_import.c
+++ b/src/bin/e_int_config_background_import.c
@@ -255,16 +255,18 @@ _bg_edj_gen(Evas *evas, char *filename, int method)
255 int w, h; 255 int w, h;
256 const char *file; 256 const char *file;
257 char buff[4096], cmd[4096]; 257 char buff[4096], cmd[4096];
258 char ipart[512]; 258 char ipart[4096];
259 char *imgdir = NULL; 259 char *imgdir = NULL;
260 static char tmpn[1024]; 260 static char tmpn[4096];
261 FILE *out = NULL; 261 FILE *out = NULL;
262 Ecore_Exe *x; 262 Ecore_Exe *x;
263 263
264 if (!filename) return; 264 if (!filename) return;
265 file = ecore_file_get_file(filename); 265 file = ecore_file_get_file(filename);
266 266
267 snprintf(buff, sizeof(buff), "%s/.e/e/backgrounds/%s.edj", e_user_homedir_get(), ecore_file_strip_ext(file)); 267 snprintf(buff, sizeof(buff), "%s/.e/e/backgrounds/%s.edj",
268 e_user_homedir_get(),
269 ecore_file_strip_ext(file));
268 strcpy(tmpn, "/tmp/e_bgdlg_new.edc-tmp-XXXXXX"); 270 strcpy(tmpn, "/tmp/e_bgdlg_new.edc-tmp-XXXXXX");
269 fd = mkstemp(tmpn); 271 fd = mkstemp(tmpn);
270 if (fd < 0) 272 if (fd < 0)
@@ -309,7 +311,10 @@ _bg_edj_gen(Evas *evas, char *filename, int method)
309 311
310 fclose(out); 312 fclose(out);
311 313
312 snprintf(cmd, sizeof(cmd), "edje_cc -v %s %s %s", ipart, tmpn, buff); 314 snprintf(cmd, sizeof(cmd), "edje_cc -v %s %s %s",
315 ipart,
316 tmpn,
317 e_util_filename_escape(buff));
313 318
314 _edj_exe_exit_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _edj_exe_exit_cb, NULL); 319 _edj_exe_exit_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _edj_exe_exit_cb, NULL);
315 x = ecore_exe_run(cmd, tmpn); 320 x = ecore_exe_run(cmd, tmpn);
diff --git a/src/bin/e_int_config_desklock.c b/src/bin/e_int_config_desklock.c
index 07ca2d4..c973023 100644
--- a/src/bin/e_int_config_desklock.c
+++ b/src/bin/e_int_config_desklock.c
@@ -532,13 +532,12 @@ _load_bgs(E_Config_Dialog_Data *cfdata)
532 e_widget_ilist_header_append(cfdata->gui.bg_list, NULL, _("Theme Backgrounds")); 532 e_widget_ilist_header_append(cfdata->gui.bg_list, NULL, _("Theme Backgrounds"));
533 if (edje_object_file_set(o, f1, "desklock/background")) 533 if (edje_object_file_set(o, f1, "desklock/background"))
534 { 534 {
535 if (!e_thumb_exists(c)) 535 ic = e_thumb_icon_add(cfd->dia->win->evas);
536 ic = e_thumb_generate_begin(c, BG_LIST_ICON_SIZE_W, BG_LIST_ICON_SIZE_H, 536 e_thumb_icon_file_set(ic, (char *)f1, "desktop/background");
537 cfdata->evas, &ic, NULL, NULL); 537 e_thumb_icon_size_set(ic, 64,
538 else 538 (64 * e_zone_current_get(cfd->dia->win->container)->h) /
539 ic = e_thumb_evas_object_get(c, cfdata->evas, BG_LIST_ICON_SIZE_W, 539 e_zone_current_get(cfd->dia->win->container)->w);
540 BG_LIST_ICON_SIZE_H, 1); 540 e_thumb_icon_begin(ic);
541
542 e_widget_ilist_append(cfdata->gui.bg_list, ic, _("Theme Desklock Background"), 541 e_widget_ilist_append(cfdata->gui.bg_list, ic, _("Theme Desklock Background"),
543 _ibg_list_cb_bg_selected, cfdata, DEF_DESKLOCK_BACKGROUND); 542 _ibg_list_cb_bg_selected, cfdata, DEF_DESKLOCK_BACKGROUND);
544 } 543 }
@@ -565,13 +564,12 @@ _load_bgs(E_Config_Dialog_Data *cfdata)
565 ic = NULL; 564 ic = NULL;
566 if (edje_object_file_set(o, f, "desktop/background")) 565 if (edje_object_file_set(o, f, "desktop/background"))
567 { 566 {
568 if (!e_thumb_exists(c)) 567 ic = e_thumb_icon_add(cfd->dia->win->evas);
569 ic = e_thumb_generate_begin(c, BG_LIST_ICON_SIZE_W, BG_LIST_ICON_SIZE_H, 568 e_thumb_icon_file_set(ic, (char *)f, "desktop/background");
570 cfdata->evas, &ic, NULL, NULL); 569 e_thumb_icon_size_set(ic, 64,
571 else 570 (64 * e_zone_current_get(cfd->dia->win->container)->h) /
572 ic = e_thumb_evas_object_get(c, cfdata->evas, BG_LIST_ICON_SIZE_W, 571 e_zone_current_get(cfd->dia->win->container)->w);
573 BG_LIST_ICON_SIZE_H, 1); 572 e_thumb_icon_begin(ic);
574
575 e_widget_ilist_append(cfdata->gui.bg_list, ic, _("Theme Background"), 573 e_widget_ilist_append(cfdata->gui.bg_list, ic, _("Theme Background"),
576 _ibg_list_cb_bg_selected, cfdata, DEF_THEME_BACKGROUND); 574 _ibg_list_cb_bg_selected, cfdata, DEF_THEME_BACKGROUND);
577 } 575 }
@@ -612,13 +610,12 @@ _load_bgs(E_Config_Dialog_Data *cfdata)
612 if (ecore_file_is_dir(full_path)) continue; 610 if (ecore_file_is_dir(full_path)) continue;
613 if (!e_util_edje_collection_exists(full_path, "desktop/background")) continue; 611 if (!e_util_edje_collection_exists(full_path, "desktop/background")) continue;
614 612
615 if (!e_thumb_exists(full_path)) 613 ic = e_thumb_icon_add(cfd->dia->win->evas);
616 ic = e_thumb_generate_begin(full_path, BG_LIST_ICON_SIZE_W, BG_LIST_ICON_SIZE_H, 614 e_thumb_icon_file_set(ic, full_path, "desktop/background");
617 cfdata->evas, &ic, NULL, NULL); 615 e_thumb_icon_size_set(ic, 64,
618 else 616 (64 * e_zone_current_get(cfd->dia->win->container)->h) /
619 ic = e_thumb_evas_object_get(full_path, cfdata->evas, BG_LIST_ICON_SIZE_W, 617 e_zone_current_get(cfd->dia->win->container)->w);
620 BG_LIST_ICON_SIZE_H, 1); 618 e_thumb_icon_begin(ic);
621
622 e_widget_ilist_append(cfdata->gui.bg_list, ic, ecore_file_strip_ext(bg_file), 619 e_widget_ilist_append(cfdata->gui.bg_list, ic, ecore_file_strip_ext(bg_file),
623 _ibg_list_cb_bg_selected, cfdata, full_path); 620 _ibg_list_cb_bg_selected, cfdata, full_path);
624 621
diff --git a/src/bin/e_int_config_startup.c b/src/bin/e_int_config_startup.c
index 971ef8c..ba1e598 100644
--- a/src/bin/e_int_config_startup.c
+++ b/src/bin/e_int_config_startup.c
@@ -195,11 +195,12 @@ _load_inits(E_Config_Dialog *cfd, Evas_Object *il)
195 if (ecore_file_is_dir(full_path)) continue; 195 if (ecore_file_is_dir(full_path)) continue;
196 if (!e_util_edje_collection_exists(full_path, "init/splash")) continue; 196 if (!e_util_edje_collection_exists(full_path, "init/splash")) continue;
197 197
198 if (!e_thumb_exists(full_path)) 198 ic = e_thumb_icon_add(cfd->dia->win->evas);
199 ic = e_thumb_generate_begin(full_path, 48, 48, cfd->dia->win->evas, &ic, NULL, NULL); 199 e_thumb_icon_file_set(ic, full_path, "desktop/background");
200 else 200 e_thumb_icon_size_set(ic, 64,
201 ic = e_thumb_evas_object_get(full_path, cfd->dia->win->evas, 48, 48, 1); 201 (64 * e_zone_current_get(cfd->dia->win->container)->h) /
202 202 e_zone_current_get(cfd->dia->win->container)->w);
203 e_thumb_icon_begin(ic);
203 e_widget_ilist_append(il, ic, ecore_file_strip_ext(init_file), _ilist_cb_init_selected, cfd, full_path); 204 e_widget_ilist_append(il, ic, ecore_file_strip_ext(init_file), _ilist_cb_init_selected, cfd, full_path);
204 205
205 if ((e_config->init_default_theme) && 206 if ((e_config->init_default_theme) &&
diff --git a/src/bin/e_int_config_theme.c b/src/bin/e_int_config_theme.c
index b1843f7..49c5fcd 100644
--- a/src/bin/e_int_config_theme.c
+++ b/src/bin/e_int_config_theme.c
@@ -104,7 +104,6 @@ _e_config_theme_cb_standard(void *data)
104 104
105 d = data; 105 d = data;
106 e_widget_preview_edje_set(d->cfd->data, d->file, "desktop/background"); 106 e_widget_preview_edje_set(d->cfd->data, d->file, "desktop/background");
107// e_widget_image_object_set(d->cfd->data, e_thumb_evas_object_get(d->file, d->cfd->dia->win->evas, 160, 120, 1));
108 107
109 cfdata = d->cfd->cfdata; 108 cfdata = d->cfd->cfdata;
110 if (cfdata->current_theme) 109 if (cfdata->current_theme)
@@ -199,10 +198,12 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
199 char *noext; 198 char *noext;
200 E_Cfg_Theme_Data *cb_data; 199 E_Cfg_Theme_Data *cb_data;
201 200
202 if (!e_thumb_exists(fulltheme)) 201 o3 = e_thumb_icon_add(cfd->dia->win->evas);
203 o3 = e_thumb_generate_begin(fulltheme, 48, 48, cfd->dia->win->evas, &o3, NULL, NULL); 202 e_thumb_icon_file_set(o3, fulltheme, "desktop/background");
204 else 203 e_thumb_icon_size_set(o3, 64,
205 o3 = e_thumb_evas_object_get(fulltheme, cfd->dia->win->evas, 48, 48, 1); 204 (64 * e_zone_current_get(cfd->dia->win->container)->h) /
205 e_zone_current_get(cfd->dia->win->container)->w);
206 e_thumb_icon_begin(o3);
206 207
207 noext = ecore_file_strip_ext(themefile); 208 noext = ecore_file_strip_ext(themefile);
208 209
@@ -221,8 +222,6 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
221 (320 * e_zone_current_get(cfd->dia->win->container)->h) / 222 (320 * e_zone_current_get(cfd->dia->win->container)->h) /
222 e_zone_current_get(cfd->dia->win->container)->w); 223 e_zone_current_get(cfd->dia->win->container)->w);
223 e_widget_preview_edje_set(im, fulltheme, "desktop/background"); 224 e_widget_preview_edje_set(im, fulltheme, "desktop/background");
224 // im = e_widget_image_add_from_object(evas, theme, 320, 240);
225 // e_widget_image_object_set(im, e_thumb_evas_object_get(fulltheme, evas, 320, 240, 1));
226 } 225 }
227 free(noext); 226 free(noext);
228 i++; 227 i++;
@@ -245,9 +244,6 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
245 (320 * e_zone_current_get(cfd->dia->win->container)->h) / 244 (320 * e_zone_current_get(cfd->dia->win->container)->h) /
246 e_zone_current_get(cfd->dia->win->container)->w); 245 e_zone_current_get(cfd->dia->win->container)->w);
247 e_widget_preview_edje_set(im, fulltheme, "desktop/background"); 246 e_widget_preview_edje_set(im, fulltheme, "desktop/background");
248// theme = e_thumb_generate_begin(fulltheme, 320, 240, evas, &theme, NULL, NULL);
249// im = e_widget_image_add_from_object(evas, theme, 320, 240);
250// e_widget_image_object_set(im, e_thumb_evas_object_get(fulltheme, evas, 320, 240, 1));
251 } 247 }
252 cfd->data = im; 248 cfd->data = im;
253 249
diff --git a/src/bin/e_ipc.c b/src/bin/e_ipc.c
index 7e67623..8361768 100644
--- a/src/bin/e_ipc.c
+++ b/src/bin/e_ipc.c
@@ -116,6 +116,7 @@ _e_ipc_cb_client_del(void *data __UNUSED__, int type __UNUSED__, void *event)
116 e = event; 116 e = event;
117 if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) return 1; 117 if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) return 1;
118 /* delete client sruct */ 118 /* delete client sruct */
119 e_thumb_client_del(e);
119 ecore_ipc_client_del(e->client); 120 ecore_ipc_client_del(e->client);
120 return 1; 121 return 1;
121} 122}
@@ -127,11 +128,24 @@ _e_ipc_cb_client_data(void *data __UNUSED__, int type __UNUSED__, void *event)
127 128
128 e = event; 129 e = event;
129 if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) return 1; 130 if (ecore_ipc_client_server_get(e->client) != _e_ipc_server) return 1;
130 switch (e->minor) 131 switch (e->major)
131 { 132 {
133 case E_IPC_DOMAIN_SETUP:
134 case E_IPC_DOMAIN_REQUEST:
135 case E_IPC_DOMAIN_REPLY:
136 case E_IPC_DOMAIN_EVENT:
137 switch (e->minor)
138 {
132#define TYPE E_WM_IN 139#define TYPE E_WM_IN
133#include "e_ipc_handlers.h" 140#include "e_ipc_handlers.h"
134#undef TYPE 141#undef TYPE
142 default:
143 break;
144 }
145 break;
146 case E_IPC_DOMAIN_THUMB:
147 e_thumb_client_data(e);
148 break;
135 default: 149 default:
136 break; 150 break;
137 } 151 }
diff --git a/src/bin/e_ipc.h b/src/bin/e_ipc.h
index 285ce6c..e880634 100644
--- a/src/bin/e_ipc.h
+++ b/src/bin/e_ipc.h
@@ -13,6 +13,7 @@ typedef enum _E_Ipc_Domain
13 E_IPC_DOMAIN_REQUEST, 13 E_IPC_DOMAIN_REQUEST,
14 E_IPC_DOMAIN_REPLY, 14 E_IPC_DOMAIN_REPLY,
15 E_IPC_DOMAIN_EVENT, 15 E_IPC_DOMAIN_EVENT,
16 E_IPC_DOMAIN_THUMB,
16 E_IPC_DOMAIN_LAST 17 E_IPC_DOMAIN_LAST
17} E_Ipc_Domain; 18} E_Ipc_Domain;
18 19
diff --git a/src/bin/e_menu.c b/src/bin/e_menu.c
index bfa4820..c8cc26f 100644
--- a/src/bin/e_menu.c
+++ b/src/bin/e_menu.c
@@ -1788,7 +1788,7 @@ _e_menu_submenu_activate(E_Menu_Item *mi)
1788static void 1788static void
1789_e_menu_submenu_deactivate(E_Menu_Item *mi) 1789_e_menu_submenu_deactivate(E_Menu_Item *mi)
1790{ 1790{
1791 if (mi->menu->active) return; 1791 if (!mi->menu->active) return;
1792 if (mi->submenu_post_cb.func) 1792 if (mi->submenu_post_cb.func)
1793 mi->submenu_post_cb.func(mi->submenu_post_cb.data, mi->menu, mi); 1793 mi->submenu_post_cb.func(mi->submenu_post_cb.data, mi->menu, mi);
1794} 1794}
diff --git a/src/bin/e_thumb.c b/src/bin/e_thumb.c
index 5f247cb..79cda7e 100644
--- a/src/bin/e_thumb.c
+++ b/src/bin/e_thumb.c
@@ -1,631 +1,317 @@
1/* 1/*
2* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2 2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3*/ 3 */
4
5#include "e.h" 4#include "e.h"
6 5
7#ifdef EFM_DEBUG 6typedef struct _E_Thumb E_Thumb;
8# define D(x) do {printf(__FILE__ ":%d: ", __LINE__); printf x; fflush(stdout);} while (0)
9#else
10# define D(x) ((void) 0)
11#endif
12
13typedef struct _E_Thumb_Item E_Thumb_Item;
14
15static char *_e_thumb_file_id(char *file);
16static void _e_thumb_generate(void);
17static int _e_thumb_cb_exe_exit(void *data, int type, void *event);
18 7
19static char *thumb_path = NULL; 8struct _E_Thumb
20static Evas_List *thumb_files = NULL;
21static Evas_List *event_handlers = NULL;
22static pid_t pid = -1;
23
24struct _E_Thumb_Item
25{ 9{
26 char path[PATH_MAX]; 10 int objid;
27 Evas_Object *obj; 11 int w, h;
28 Evas *evas; 12 char *file;
29 Evas_Coord w, h; 13 char *key;
30 void (*cb)(Evas_Object *obj, void *data); 14 unsigned char queued : 1;
31 void *data; 15 unsigned char busy : 1;
32}; 16};
33 17
18/* local subsystem functions */
19static void _e_thumb_gen_begin(int objid, char *file, char *key, int w, int h);
20static void _e_thumb_gen_end(int objid);
21static void _e_thumb_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info);
22static void _e_thumb_hash_add(int objid, Evas_Object *obj);
23static void _e_thumb_hash_del(int objid);
24static Evas_Object *_e_thumb_hash_find(int objid);
25static void _e_thumb_thumbnailers_kill(void);
26static int _e_thumb_cb_exe_event_del(void *data, int type, void *event);
27
28/* local subsystem globals */
29static Evas_List *_thumbnailers = NULL;
30static Evas_List *_thumbnailers_exe = NULL;
31static Evas_List *_thumb_queue = NULL;
32static int _objid = 0;
33static Evas_Hash *_thumbs = NULL;
34static int _pending = 0;
35static int _num_thumbnailers = 2;
36static Ecore_Event_Handler *_exe_del_handler = NULL;
37
38/* externally accessible functions */
34EAPI int 39EAPI int
35e_thumb_init(void) 40e_thumb_init(void)
36{ 41{
37 char *homedir; 42 _exe_del_handler = ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
38 char path[PATH_MAX]; 43 _e_thumb_cb_exe_event_del,
39 44 NULL);
40 homedir = e_user_homedir_get();
41 if (homedir)
42 {
43 snprintf(path, sizeof(path), "%s/.e/e/fileman/thumbnails", homedir);
44 if (!ecore_file_exists(path))
45 ecore_file_mkpath(path);
46 thumb_path = strdup(path);
47 free(homedir);
48 }
49 else return 0;
50
51 event_handlers =
52 evas_list_append(event_handlers,
53 ecore_event_handler_add(ECORE_EXE_EVENT_DEL,
54 _e_thumb_cb_exe_exit,
55 NULL));
56 return 1; 45 return 1;
57} 46}
58 47
59EAPI int 48EAPI int
60e_thumb_shutdown(void) 49e_thumb_shutdown(void)
61{ 50{
62 E_FREE(thumb_path); 51 ecore_event_handler_del(_exe_del_handler);
63 while (event_handlers) 52 _exe_del_handler = NULL;
64 {
65 ecore_event_handler_del(event_handlers->data);
66 event_handlers = evas_list_remove_list(event_handlers, event_handlers);
67 }
68 evas_list_free(thumb_files);
69
70 if (pid != -1)
71 kill(pid, SIGTERM);
72
73 return 1; 53 return 1;
74} 54}
75 55
76/* return dir where thumbs are saved */
77EAPI const char *
78e_thumb_dir_get(void)
79{
80 return thumb_path;
81}
82
83/* queue an image for thumbnailing or return the thumb if it exists */
84EAPI Evas_Object * 56EAPI Evas_Object *
85e_thumb_generate_begin(char *path, Evas_Coord w, Evas_Coord h, Evas *evas, Evas_Object **tmp, void (*cb)(Evas_Object *obj, void *data), void *data) 57e_thumb_icon_add(Evas *evas)
86{ 58{
87 E_Thumb_Item *t; 59 Evas_Object *obj;
88 60 E_Thumb *eth;
89 if(!ecore_file_exists(path)) return *tmp; 61 char buf[32];
90 if (e_thumb_exists(path)) 62
91 { 63 obj = e_icon_add(evas);
92 evas_object_del(*tmp); 64 _objid++;
93 *tmp = e_thumb_evas_object_get(path, evas, w, h, 1); 65 eth = E_NEW(E_Thumb, 1);
94 return *tmp; 66 eth->objid = _objid;
95 } 67 eth->w = 64;
96 68 eth->h = 64;
97 t = E_NEW(E_Thumb_Item, 1); 69 evas_object_data_set(obj, "e_thumbdata", eth);
98 t->w = w; 70 evas_object_event_callback_add(obj, EVAS_CALLBACK_FREE,
99 t->h = h; 71 _e_thumb_del_hook, NULL);
100 t->evas = evas; 72 _e_thumb_hash_add(eth->objid, obj);
101 t->cb = cb; 73 return obj;
102 t->data = data;
103 *tmp = e_icon_add(evas);
104 t->obj = *tmp;
105 snprintf(t->path, sizeof(t->path), "%s", path);
106 thumb_files = evas_list_append(thumb_files, t);
107 if (pid == -1) _e_thumb_generate();
108
109 return *tmp;
110} 74}
111 75
112/* delete an image from the thumb queue */
113EAPI void 76EAPI void
114e_thumb_generate_end(char *path) 77e_thumb_icon_file_set(Evas_Object *obj, char *file, char *key)
115{ 78{
116 Evas_List *l; 79 E_Thumb *eth;
117 E_Thumb_Item *t; 80
118 81 eth = evas_object_data_get(obj, "e_thumbdata");
119 for(l = thumb_files; l; l = l->next) 82 if (!eth) return;
120 { 83 E_FREE(eth->file);
121 t = l->data; 84 E_FREE(eth->key);
122 if(!strcmp(path, t->path)) 85 if (file) eth->file = strdup(file);
123 { 86 if (key) eth->key = strdup(key);
124 thumb_files = evas_list_remove_list(thumb_files, l);
125 break;
126 }
127 }
128} 87}
129 88
130/* return hashed path of thumb */ 89EAPI void
131EAPI char * 90e_thumb_icon_size_set(Evas_Object *obj, int w, int h)
132e_thumb_file_get(char *file)
133{ 91{
134 char *id; 92 E_Thumb *eth;
135 char thumb[PATH_MAX];
136 93
137 id = _e_thumb_file_id(file); 94 eth = evas_object_data_get(obj, "e_thumbdata");
138 if (!id) return NULL; 95 if (!eth) return;
139 snprintf(thumb, sizeof(thumb), "%s/%s", thumb_path, id); 96 if ((w < 1) || (h <1)) return;
140 free(id); 97 eth->w = w;
141 return strdup(thumb); 98 eth->h = h;
142} 99}
143 100
144/* return the width and height of a thumb, if from_eet is set, then we
145 * assume that the file being passed is the thumb's eet
146 */
147EAPI void 101EAPI void
148e_thumb_geometry_get(char *file, int *w, int *h, int from_eet) 102e_thumb_icon_begin(Evas_Object *obj)
149{ 103{
150 Eet_File *ef; 104 E_Thumb *eth, *eth2;
105 char buf[4096];
151 106
152 if(!from_eet) 107 eth = evas_object_data_get(obj, "e_thumbdata");
108 if (!eth) return;
109 if (!eth->file) return;
110 if (!_thumbnailers)
153 { 111 {
154 char *eet_file; 112 while (evas_list_count(_thumbnailers_exe) < _num_thumbnailers)
155
156 eet_file = _e_thumb_file_id(file);
157 if(!eet_file)
158 {
159 if(w) *w = -1;
160 if(h) *h = -1;
161 return;
162 }
163 ef = eet_open(eet_file, EET_FILE_MODE_READ);
164 if (!ef)
165 { 113 {
166 eet_close(ef); 114 Ecore_Exe *exe;
167 if(w) *w = -1; 115
168 if(h) *h = -1; 116 snprintf(buf, sizeof(buf), "%s/enlightenment_thumb", e_prefix_bin_get());
169 return; 117 exe = ecore_exe_run(buf, NULL);
118 _thumbnailers_exe = evas_list_append(_thumbnailers_exe, exe);
170 } 119 }
120 _thumb_queue = evas_list_append(_thumb_queue, eth);
121 eth->queued = 1;
122 return;
171 } 123 }
172 else 124 while (_thumb_queue)
173 { 125 {
174 ef = eet_open(file, EET_FILE_MODE_READ); 126 eth2 = _thumb_queue->data;
175 if (!ef) 127 _thumb_queue = evas_list_remove_list(_thumb_queue, _thumb_queue);
176 { 128 eth2->queued = 0;
177 eet_close(ef); 129 eth2->busy = 1;
178 if(w) *w = -1; 130 _pending++;
179 if(h) *h = -1; 131 _e_thumb_gen_begin(eth2->objid, eth2->file, eth2->key, eth2->w, eth2->h);
180 return;
181 }
182 } 132 }
183 if(!eet_data_image_header_read(ef, "/thumbnail/data", w, h, NULL, NULL, 133 eth->busy = 1;
184 NULL, NULL)) 134 _pending++;
185 { 135 _e_thumb_gen_begin(eth->objid, eth->file, eth->key, eth->w, eth->h);
186 eet_close(ef);
187 if(w) *w = -1;
188 if(h) *h = -1;
189 return;
190 }
191 eet_close(ef);
192} 136}
193 137
194/* return true if the saved thumb exists OR if its an eap */ 138EAPI void
195EAPI int 139e_thumb_icon_end(Evas_Object *obj)
196e_thumb_exists(char *file)
197{ 140{
198 char *thumb; 141 E_Thumb *eth;
199 char *ext; 142
200 143 eth = evas_object_data_get(obj, "e_thumbdata");
201 ext = strrchr(file, '.'); 144 if (!eth) return;
202 if ((ext) && (!strcasecmp(ext, ".eap"))) 145 if (eth->queued) _thumb_queue = evas_list_remove(_thumb_queue, eth);
203 return 1; 146 eth->queued = 0;
204 147 if (eth->busy) _e_thumb_gen_end(eth->objid);
205 thumb = e_thumb_file_get(file); 148 eth->busy = 0;
206 if ((thumb) && (ecore_file_exists(thumb))) 149 _pending--;
207 { 150 if (_pending == 0) _e_thumb_thumbnailers_kill();
208 free(thumb);
209 return 1;
210 }
211 return 0;
212} 151}
213 152
214EAPI int * 153EAPI void
215_e_thumb_image_create(char *file, Evas_Coord w, Evas_Coord h, int *ww, int *hh, int *alpha, Evas_Object **im, Ecore_Evas **buf) 154e_thumb_client_data(Ecore_Ipc_Event_Client_Data *e)
216{ 155{
217 Evas *evasbuf; 156 int objid;
218 int iw, ih; 157 char *icon;
219 158 E_Thumb *eth;
220 *buf = ecore_evas_buffer_new(1, 1); 159 Evas_Object *obj;
221 evasbuf = ecore_evas_get(*buf); 160
222 *im = evas_object_image_add(evasbuf); 161 if (!evas_list_find(_thumbnailers, e->client))
223 evas_object_image_file_set(*im, file, NULL); 162 _thumbnailers = evas_list_prepend(_thumbnailers, e->client);
224 iw = 0; ih = 0; 163 if (e->minor == 2)
225 evas_object_image_size_get(*im, &iw, &ih);
226 *alpha = evas_object_image_alpha_get(*im);
227 if ((iw > 0) && (ih > 0))
228 { 164 {
229 *ww = w; 165 objid = e->ref;
230 *hh = (w * ih) / iw; 166 icon = e->data;
231 if (*hh > h) 167 if ((icon) && (e->size > 1) && (icon[e->size - 1] == 0))
232 { 168 {
233 *hh = h; 169 obj = _e_thumb_hash_find(objid);
234 *ww = (h * iw) / ih; 170 if (obj)
171 {
172 eth = evas_object_data_get(obj, "e_thumbdata");
173 if (eth)
174 {
175 eth->busy = 0;
176 _pending--;
177 if (_pending == 0) _e_thumb_thumbnailers_kill();
178 e_icon_file_key_set(obj, icon, "/thumbnail/data");
179 evas_object_smart_callback_call(obj, "e_thumb_gen", NULL);
180 }
181 }
182 }
183 }
184 if (e->minor == 1)
185 {
186 /* hello message */
187 while (_thumb_queue)
188 {
189 eth = _thumb_queue->data;
190 _thumb_queue = evas_list_remove_list(_thumb_queue, _thumb_queue);
191 eth->queued = 0;
192 eth->busy = 1;
193 _pending++;
194 _e_thumb_gen_begin(eth->objid, eth->file, eth->key, eth->w, eth->h);
235 } 195 }
236 ecore_evas_resize(*buf, *ww, *hh);
237 evas_object_image_fill_set(*im, 0, 0, *ww, *hh);
238 evas_object_resize(*im, *ww, *hh);
239 evas_object_move(*im, 0, 0);
240 evas_object_show(*im);
241
242 return (int *)ecore_evas_buffer_pixels_get(*buf);
243 } 196 }
244 return NULL;
245} 197}
246 198
247/* thumbnail an e17 background and return pixel data */ 199EAPI void
248const int * 200e_thumb_client_del(Ecore_Ipc_Event_Client_Del *e)
249_e_thumb_ebg_create(char *file, Evas_Coord w, Evas_Coord h, int *ww, int *hh, int *alpha, Evas_Object **im, Ecore_Evas **buf)
250{ 201{
251 Evas *evasbuf; 202 if (!evas_list_find(_thumbnailers, e->client)) return;
252 Evas_Object *wallpaper; 203 _thumbnailers = evas_list_remove(_thumbnailers, e->client);
253 const int *pixels; 204}
254
255 *ww = 640;
256 *hh = 480;
257 *alpha = 0;
258
259 w = 640;
260 h = 480;
261
262 *buf = ecore_evas_buffer_new(w, h);
263 evasbuf = ecore_evas_get(*buf);
264
265 wallpaper = edje_object_add(evasbuf);
266 205
267 edje_object_file_set(wallpaper, file, "desktop/background"); 206/* local subsystem functions */
268 207static void
269 /* wallpaper */ 208_e_thumb_gen_begin(int objid, char *file, char *key, int w, int h)
270 evas_object_move(wallpaper, 0, 0); 209{
271 evas_object_resize(wallpaper, w, h); 210 char *buf;
272 211 int l1, l2;
273 evas_object_show(wallpaper); 212 Ecore_Ipc_Client *cli;
274 213
275 pixels = ecore_evas_buffer_pixels_get(*buf); 214 /* send thumb req */
276 215 l1 = strlen(file);
277 evas_object_del(wallpaper); 216 l2 = 0;
278 return pixels; 217 if (key) l2 = strlen(key);
218 buf = alloca(l1 + 1 + l2 + 1);
219 strcpy(buf, file);
220 if (key) strcpy(buf + l1 + 1, key);
221 else buf[l1 + 1] = 0;
222 cli = _thumbnailers->data;
223 if (!cli) return;
224 _thumbnailers = evas_list_remove_list(_thumbnailers, _thumbnailers);
225 _thumbnailers = evas_list_append(_thumbnailers, cli);
226 ecore_ipc_client_send(cli, E_IPC_DOMAIN_THUMB, 1, objid, w, h, buf, l1 + 1 + l2 + 1);
279} 227}
280 228
281/* thumbnail an e17 theme and return pixel data */ 229static void
282const int * 230_e_thumb_gen_end(int objid)
283_e_thumb_etheme_create(char *file, Evas_Coord w, Evas_Coord h, int *ww, int *hh, int *alpha, Evas_Object **im, Ecore_Evas **buf)
284{ 231{
285 Evas *evasbuf; 232 Evas_List *l;
286 Evas_Object *wallpaper, *window, *clock, *start, **pager, *init; 233 Ecore_Ipc_Client *cli;
287 const int *pixels;
288 int is_init;
289
290 *ww = 640;
291 *hh = 480;
292 *alpha = 0;
293
294 w = 640;
295 h = 480;
296 234
297 *buf = ecore_evas_buffer_new(w, h); 235 /* send thumb cancel */
298 evasbuf = ecore_evas_get(*buf); 236 for (l = _thumbnailers; l; l = l->next)
299
300 is_init = e_util_edje_collection_exists(file, "init/splash");
301 if (is_init)
302 { 237 {
303 init = edje_object_add(evasbuf); 238 cli = l->data;
304 edje_object_file_set(init, file, "init/splash"); 239 ecore_ipc_client_send(cli, E_IPC_DOMAIN_THUMB, 2, objid, 0, 0, NULL, 0);
305 evas_object_move(init, 0, 0);
306 evas_object_resize(init, w, h);
307 evas_object_show(init);
308 pixels = ecore_evas_buffer_pixels_get(*buf);
309 evas_object_del(init);
310 } 240 }
311 else
312 {
313 wallpaper = edje_object_add(evasbuf);
314 window = edje_object_add(evasbuf);
315 clock = edje_object_add(evasbuf);
316 start = edje_object_add(evasbuf);
317 pager = E_NEW(Evas_Object*, 3);
318 pager[0] = edje_object_add(evasbuf);
319 pager[1] = edje_object_add(evasbuf);
320 pager[2] = edje_object_add(evasbuf);
321
322 edje_object_file_set(wallpaper, file, "desktop/background");
323 edje_object_file_set(window, file, "widgets/border/default/border");
324 edje_object_file_set(clock, file, "modules/clock/main");
325 edje_object_file_set(clock, file, "modules/clock/main");
326 edje_object_file_set(start, file, "modules/start/main");
327 edje_object_file_set(pager[0], file, "modules/pager/main");
328 edje_object_file_set(pager[1], file, "modules/pager/desk");
329 edje_object_file_set(pager[2], file, "modules/pager/window");
330 edje_object_part_text_set(window, "title_text", file);
331 edje_object_part_swallow(pager[0], "items", pager[1]);
332 edje_object_part_swallow(pager[1], "items", pager[2]);
333
334 /* wallpaper */
335 evas_object_move(wallpaper, 0, 0);
336 evas_object_resize(wallpaper, w, h);
337 /* main window */
338 evas_object_move(window, (w * 0.1), (h * 0.05));
339 evas_object_resize(window, w * 0.8, h * 0.75);
340 /* clock */
341 evas_object_move(clock, (w * 0.9), (h * 0.9));
342 evas_object_resize(clock, w * 0.1, h * 0.1);
343 /* start */
344 evas_object_move(start, 0.1, (h * 0.9));
345 evas_object_resize(start, w * 0.1, h * 0.1);
346 /* pager */
347 evas_object_move(pager[0], (w * 0.3), (h * 0.9));
348 evas_object_resize(pager[0], w * 0.1, h * 0.1);
349
350 evas_object_show(wallpaper);
351 evas_object_show(window);
352 evas_object_show(clock);
353 evas_object_show(start);
354 evas_object_show(pager[0]);
355 evas_object_show(pager[1]);
356 evas_object_show(pager[2]);
357
358 pixels = ecore_evas_buffer_pixels_get(*buf);
359
360 evas_object_del(wallpaper);
361 evas_object_del(window);
362 evas_object_del(clock);
363 evas_object_del(start);
364 evas_object_del(pager[0]);
365 evas_object_del(pager[1]);
366 evas_object_del(pager[2]);
367 free(pager);
368 }
369
370 return pixels;
371} 241}
372 242
373/* create and save a thumb to disk */ 243static void
374EAPI int 244_e_thumb_del_hook(void *data, Evas *e, Evas_Object *obj, void *event_info)
375e_thumb_create(char *file, Evas_Coord w, Evas_Coord h)
376{ 245{
377 Eet_File *ef; 246 E_Thumb *eth;
378 char *thumbpath, *ext;
379 Evas_Object *im = NULL;
380 const int *data;
381 int size, ww, hh;
382 Ecore_Evas *buf;
383 int alpha;
384 247
385 ext = strrchr(file, '.'); 248 eth = evas_object_data_get(obj, "e_thumbdata");
386 if ((ext) && (!strcasecmp(ext, ".eap"))) 249 if (!eth) return;
387 return 1; 250 evas_object_data_del(obj, "e_thumbdata");
388 251 _e_thumb_hash_del(eth->objid);
389 thumbpath = e_thumb_file_get(file); 252 if (eth->busy)
390 if (!thumbpath)
391 return -1;
392
393 if (ext)
394 { 253 {
395 if (!strcasecmp(ext, ".edj")) 254 _e_thumb_gen_end(eth->objid);
396 { 255 _pending--;
397 /* for now, this function does both the bg and theme previews */ 256 if (_pending == 0) _e_thumb_thumbnailers_kill();
398 data = _e_thumb_etheme_create(file, w, h, &ww, &hh, &alpha, &im, &buf);
399 }
400 else
401 data = _e_thumb_image_create(file, w, h, &ww, &hh, &alpha, &im, &buf);
402 } 257 }
403 else 258 if (eth->queued)
404 data = _e_thumb_image_create(file, w, h, &ww, &hh, &alpha, &im, &buf); 259 _thumb_queue = evas_list_remove(_thumb_queue, eth);
405 260 E_FREE(eth->file);
406 if (data) 261 E_FREE(eth->key);
407 { 262 free(eth);
408 ef = eet_open(thumbpath, EET_FILE_MODE_WRITE);
409 if (!ef)
410 {
411 free(thumbpath);
412 if (im) evas_object_del(im);
413 ecore_evas_free(buf);
414 return -1;
415 }
416 free(thumbpath);
417
418 eet_write(ef, "/thumbnail/orig_path", file, strlen(file), 1);
419 if ((size = eet_data_image_write(ef, "/thumbnail/data",
420 (void *)data, ww, hh, alpha,
421 0, 91, 1)) <= 0)
422 {
423 if (im) evas_object_del(im);
424 ecore_evas_free(buf);
425 eet_close(ef);
426 return -1;
427 }
428 eet_close(ef);
429 }
430 if (im) evas_object_del(im);
431 ecore_evas_free(buf);
432 return 1;
433} 263}
434 264
435/* get evas object containing image of the thumb */ 265static void
436EAPI Evas_Object * 266_e_thumb_hash_add(int objid, Evas_Object *obj)
437e_thumb_evas_object_get(char *file, Evas *evas, Evas_Coord width, Evas_Coord height, int shrink)
438{ 267{
439 Eet_File *ef; 268 char buf[32];
440 char *thumb, *ext;
441 Evas_Object *im = NULL;
442
443#define DEF_THUMB_RETURN im = evas_object_rectangle_add(evas); \
444 evas_object_color_set(im, 255, 255, 255, 255); \
445 evas_object_resize(im, width, height); \
446 return im
447 269
448 D(("e_thumb_evas_object_get: (%s)\n", file)); 270 snprintf(buf, sizeof(buf), "%i", objid);
449 271 _thumbs = evas_hash_add(_thumbs, buf, obj);
450 /* eap thumbnailer */ 272}
451 ext = strrchr(file, '.');
452 if (ext)
453 {
454 if (!strcasecmp(ext, ".eap"))
455 {
456 E_App *app;
457 273
458 D(("e_thumb_evas_object_get: eap found\n")); 274static void
459 app = e_app_new(file, 0); 275_e_thumb_hash_del(int objid)
460 D(("e_thumb_evas_object_get: eap loaded\n")); 276{
461 if (!app) 277 char buf[32];
462 {
463 D(("e_thumb_evas_object_get: invalid eap\n"));
464 DEF_THUMB_RETURN;
465 }
466 else
467 {
468 D(("e_thumb_evas_object_get: creating eap thumb\n"));
469 im = e_icon_add(evas);
470 e_icon_file_edje_set(im, file, "icon");
471 e_object_unref(E_OBJECT(app));
472 D(("e_thumb_evas_object_get: returning eap thumb\n"));
473 return im;
474 }
475 }
476 }
477
478 /* saved thumb */
479 /* TODO: add ability to fetch thumbs from freedesktop dirs */
480 if (!e_thumb_exists(file))
481 {
482 if (!e_thumb_create(file, width, height))
483 {
484 DEF_THUMB_RETURN;
485 }
486 }
487
488 thumb = e_thumb_file_get(file);
489 if (!thumb)
490 {
491 DEF_THUMB_RETURN;
492 }
493
494 ef = eet_open(thumb, EET_FILE_MODE_READ);
495 if (!ef)
496 {
497 eet_close(ef);
498 free(thumb);
499 DEF_THUMB_RETURN;
500 }
501 278
502 im = e_icon_add(evas); 279 snprintf(buf, sizeof(buf), "%i", objid);
503 e_icon_file_key_set(im, thumb, "/thumbnail/data"); 280 _thumbs = evas_hash_del(_thumbs, buf, NULL);
504 if (shrink)
505 {
506 Evas_Coord sw, sh;
507
508 e_icon_size_get(im, &sw, &sh);
509 evas_object_resize(im, sw, sh);
510 }
511 e_icon_fill_inside_set(im, 1);
512 free(thumb);
513 eet_close(ef);
514 return im;
515} 281}
516 282
517/* return hash for a file */ 283static Evas_Object *
518static char * 284_e_thumb_hash_find(int objid)
519_e_thumb_file_id(char *file)
520{ 285{
521 char s[256], *sp; 286 char buf[32];
522 const char *chmap =
523 "0123456789abcdef"
524 "ghijklmnopqrstuv"
525 "wxyz`~!@#$%^&*()"
526 "[];',.{}<>?-=_+|";
527 unsigned int id[4], i;
528 struct stat st;
529
530 if (stat(file, &st) < 0)
531 return NULL;
532 287
533 id[0] = st.st_ino; 288 snprintf(buf, sizeof(buf), "%i", objid);
534 id[1] = st.st_dev; 289 return evas_hash_find(_thumbs, buf);
535 id[2] = (st.st_size & 0xffffffff);
536 id[3] = (st.st_mtime & 0xffffffff);
537
538 sp = s;
539 for (i = 0; i < 4; i++)
540 {
541 unsigned int t, tt;
542 int j;
543
544 t = id[i];
545 j = 32;
546 while (j > 0)
547 {
548 tt = t & ((1 << 6) - 1);
549 *sp = chmap[tt];
550 t >>= 6;
551 j -= 6;
552 sp++;
553 }
554 }
555 *sp = 0;
556 return strdup(s);
557} 290}
558 291
559/* generate a thumb from the list of queued thumbs */
560static void 292static void
561_e_thumb_generate(void) 293_e_thumb_thumbnailers_kill(void)
562{ 294{
563 E_Thumb_Item *t; 295 Evas_List *l;
564 296
565 if ((!thumb_files) || (pid != -1)) return; 297 for (l = _thumbnailers_exe; l; l = l->next)
566 pid = fork(); 298 ecore_exe_terminate(l->data);
567 if (pid == 0)
568 {
569 /* reset signal handlers for the child */
570 signal(SIGSEGV, SIG_DFL);
571 signal(SIGILL, SIG_DFL);
572 signal(SIGFPE, SIG_DFL);
573 signal(SIGBUS, SIG_DFL);
574
575 t = thumb_files->data;
576 if (!e_thumb_exists(t->path))
577 e_thumb_create(t->path, t->w, t->h);
578 eet_clearcache();
579 exit(0);
580 }
581} 299}
582 300
583/* called when a thumb is generated */
584static int 301static int
585_e_thumb_cb_exe_exit(void *data, int type, void *event) 302_e_thumb_cb_exe_event_del(void *data, int type, void *event)
586{ 303{
587 Ecore_Exe_Event_Del *ev; 304 Ecore_Exe_Event_Del *ev;
588 E_Thumb_Item *t; 305 Evas_List *l;
589 char *ext;
590 306
591 ev = event; 307 ev = event;
592 if (ev->pid != pid) return 1; 308 for (l = _thumbnailers_exe; l; l = l->next)
593 if (!thumb_files)
594 { 309 {
595 pid = -1; 310 if (l->data == ev->exe)
596 return 1;
597 }
598
599 t = thumb_files->data;
600 thumb_files = evas_list_remove_list(thumb_files, thumb_files);
601
602 ext = strrchr(t->path, '.');
603 if ((ext) && (strcasecmp(ext, ".eap")))
604 ext = NULL;
605
606 if ((ext) || (ecore_file_exists(t->path)))
607 {
608 Evas_Coord w, h;
609 Evas_Object *tmp;
610 void *data;
611
612 tmp = e_thumb_evas_object_get(t->path,
613 t->evas,
614 t->w,
615 t->h,
616 1);
617 if (tmp && t)
618 { 311 {
619 data = e_icon_data_get(tmp, &w, &h); 312 _thumbnailers_exe = evas_list_remove_list(_thumbnailers_exe, l);
620 e_icon_data_set(t->obj, data, w, h); 313 break;
621 evas_object_del(tmp);
622 if(t->cb)
623 t->cb(t->obj, t->data);
624 free(t);
625 } 314 }
626 } 315 }
627
628 pid = -1;
629 _e_thumb_generate();
630 return 1; 316 return 1;
631} 317}
diff --git a/src/bin/e_thumb.h b/src/bin/e_thumb.h
index 49fd968..7624da0 100644
--- a/src/bin/e_thumb.h
+++ b/src/bin/e_thumb.h
@@ -10,14 +10,15 @@
10 10
11EAPI int e_thumb_init(void); 11EAPI int e_thumb_init(void);
12EAPI int e_thumb_shutdown(void); 12EAPI int e_thumb_shutdown(void);
13EAPI const char *e_thumb_dir_get(void); 13
14EAPI char *e_thumb_file_get(char *file); 14EAPI Evas_Object *e_thumb_icon_add(Evas *evas);
15EAPI void e_thumb_geometry_get(char *file, int *w, int *h, int from_eet); 15EAPI void e_thumb_icon_file_set(Evas_Object *obj, char *file, char *key);
16EAPI int e_thumb_exists(char *file); 16EAPI void e_thumb_icon_size_set(Evas_Object *obj, int w, int h);
17EAPI int e_thumb_create(char *file, Evas_Coord w, Evas_Coord h); 17EAPI void e_thumb_icon_begin(Evas_Object *obj);
18EAPI Evas_Object *e_thumb_evas_object_get(char *file, Evas *evas, Evas_Coord width, Evas_Coord height, int shrink); 18EAPI void e_thumb_icon_end(Evas_Object *obj);
19EAPI Evas_Object *e_thumb_generate_begin(char *path, Evas_Coord w, Evas_Coord h, Evas *evas, Evas_Object **tmp, void (*cb)(Evas_Object *obj, void *data), void *data); 19
20EAPI void e_thumb_generate_end(char *path); 20EAPI void e_thumb_client_data(Ecore_Ipc_Event_Client_Data *e);
21 21EAPI void e_thumb_client_del(Ecore_Ipc_Event_Client_Del *e);
22
22#endif 23#endif
23#endif 24#endif
diff --git a/src/bin/e_thumb_main.c b/src/bin/e_thumb_main.c
new file mode 100644
index 0000000..ceadddc
--- /dev/null
+++ b/src/bin/e_thumb_main.c
@@ -0,0 +1,388 @@
1/*
2 * vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
3 */
4#include <stdio.h>
5#include <stdlib.h>
6#include <unistd.h>
7#include <string.h>
8#include <Ecore.h>
9#include <Ecore_Evas.h>
10#include <Ecore_Ipc.h>
11#include <Ecore_File.h>
12#include <Evas.h>
13#include <Eet.h>
14#include <Edje.h>
15
16typedef struct _E_Thumb E_Thumb;
17
18struct _E_Thumb
19{
20 int objid;
21 int w, h;
22 char *file;
23 char *key;
24};
25
26/* local subsystem functions */
27static int _e_ipc_init(void);
28static int _e_ipc_cb_server_add(void *data, int type, void *event);
29static int _e_ipc_cb_server_del(void *data, int type, void *event);
30static int _e_ipc_cb_server_data(void *data, int type, void *event);
31static int _e_cb_timer(void *data);
32static void _e_thumb_generate(E_Thumb *eth);
33static char *_e_thumb_file_id(char *file, char *key);
34
35/* local subsystem globals */
36static Ecore_Ipc_Server *_e_ipc_server = NULL;
37static Evas_List *_thumblist = NULL;
38static Ecore_Timer *_timer = NULL;
39static char _thumbdir[4096] = "";
40
41/* externally accessible functions */
42int
43main(int argc, char **argv)
44{
45 int i;
46
47 for (i = 1; i < argc; i++)
48 {
49 if ((!strcmp(argv[i], "-h")) ||
50 (!strcmp(argv[i], "-help")) ||
51 (!strcmp(argv[i], "--help")))
52 {
53 printf(
54 "This is an internal tool for Enlightenment.\n"
55 "do not use it.\n"
56 );
57 exit(0);
58 }
59 }
60
61 ecore_init();
62 ecore_app_args_set(argc, (const char **)argv);
63 eet_init();
64 evas_init();
65 ecore_evas_init();
66 edje_init();
67 ecore_file_init();
68 ecore_ipc_init();
69
70 snprintf(_thumbdir, sizeof(_thumbdir), "%s/.e/e/fileman/thumbnails",
71 getenv("HOME"));
72 ecore_file_mkpath(_thumbdir);
73
74 if (_e_ipc_init()) ecore_main_loop_begin();
75
76 if (_e_ipc_server)
77 {
78 ecore_ipc_server_del(_e_ipc_server);
79 _e_ipc_server = NULL;
80 }
81 ecore_ipc_shutdown();
82 ecore_file_shutdown();
83 ecore_evas_shutdown();
84 edje_shutdown();
85 evas_shutdown();
86 eet_shutdown();
87 ecore_shutdown();
88
89 return 0;
90}
91
92/* local subsystem functions */
93static int
94_e_ipc_init(void)
95{
96 char *sdir;
97
98 sdir = getenv("E_IPC_SOCKET");
99 if (!sdir)
100 {
101 printf("The E_IPC_SOCKET environment variable is not set. This is\n"
102 "exported by Enlightenment to all processes it launches.\n"
103 "This environment variable must be set and must point to\n"
104 "Enlightenment's IPC socket file (minus port number).\n");
105 return 0;
106 }
107 _e_ipc_server = ecore_ipc_server_connect(ECORE_IPC_LOCAL_SYSTEM, sdir, 0, NULL);
108 if (!_e_ipc_server) return 0;
109
110 ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_ADD, _e_ipc_cb_server_add, NULL);
111 ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DEL, _e_ipc_cb_server_del, NULL);
112 ecore_event_handler_add(ECORE_IPC_EVENT_SERVER_DATA, _e_ipc_cb_server_data, NULL);
113
114 return 1;
115}
116
117static int
118_e_ipc_cb_server_add(void *data, int type, void *event)
119{
120 Ecore_Ipc_Event_Server_Add *e;
121
122 e = event;
123 ecore_ipc_server_send(e->server, 5, 1, 0, 0, 0, NULL, 0); /* send hello */
124 return 1;
125}
126
127static int
128_e_ipc_cb_server_del(void *data, int type, void *event)
129{
130 Ecore_Ipc_Event_Server_Del *e;
131
132 e = event;
133 /* quit now */
134 ecore_main_loop_quit();
135 return 1;
136}
137
138static int
139_e_ipc_cb_server_data(void *data, int type, void *event)
140{
141 Ecore_Ipc_Event_Server_Data *e;
142 E_Thumb *eth;
143 Evas_List *l;
144 char *file = NULL;
145 char *key = NULL;
146
147 e = event;
148 if (e->major != 5) return 1;
149 if (!e->data) return 1;
150 switch (e->minor)
151 {
152 case 1:
153 /* begin thumb */
154 /* don't check stuff. since this connects TO e17 it is connecting */
155 /* TO a trusted process that WILL send this message properly */
156 /* formatted. if the thumbnailer dies anyway - it's not a big loss */
157 /* but it is a sign of a bug in e formattign messages maybe */
158 file = e->data;
159 key = file + strlen(file) + 1;
160 if (!key[0]) key = NULL;
161 eth = calloc(1, sizeof(E_Thumb));
162 if (eth)
163 {
164 eth->objid = e->ref;
165 eth->w = e->ref_to;
166 eth->h = e->response;
167 eth->file = strdup(file);
168 if (key) eth->key = strdup(key);
169 _thumblist = evas_list_append(_thumblist, eth);
170 if (!_timer) _timer = ecore_timer_add(0.001, _e_cb_timer, NULL);
171 }
172 break;
173 case 2:
174 /* end thumb */
175 for (l = _thumblist; l; l = l->next)
176 {
177 eth = l->data;
178 if (eth->objid == e->ref)
179 {
180 _thumblist = evas_list_remove_list(_thumblist, l);
181 if (eth->file) free(eth->file);
182 if (eth->key) free(eth->key);
183 free(eth);
184 break;
185 }
186 }
187 break;
188 case 3:
189 /* quit now */
190 ecore_main_loop_quit();
191 break;
192 default:
193 break;
194 }
195 return 1;
196}
197
198static int
199_e_cb_timer(void *data)
200{
201 E_Thumb *eth;
202
203 /* take thumb at head of list */
204 if (_thumblist)
205 {
206 eth = _thumblist->data;
207 _thumblist = evas_list_remove_list(_thumblist, _thumblist);
208 _e_thumb_generate(eth);
209 if (eth->file) free(eth->file);
210 if (eth->key) free(eth->key);
211 free(eth);
212 if (_thumblist) _timer = ecore_timer_add(0.001, _e_cb_timer, NULL);
213 else _timer = NULL;
214 }
215 else
216 _timer = NULL;
217 return 0;
218}
219
220static void
221_e_thumb_generate(E_Thumb *eth)
222{
223 char buf[4096], *id, *td, *ext = NULL;
224 Evas *evas = NULL, *evas_im = NULL;
225 Ecore_Evas *ee = NULL, *ee_im = NULL;
226 Evas_Object *im = NULL, *edje = NULL;
227 Eet_File *ef;
228 int iw, ih, alpha, ww, hh;
229 int *data = NULL;
230 time_t mtime_orig, mtime_thumb;
231
232 id = _e_thumb_file_id(eth->file, eth->key);
233 if (!id) return;
234
235 td = strdup(id);
236 if (!td)
237 {
238 free(id);
239 return;
240 }
241 td[3] = 0;
242
243 snprintf(buf, sizeof(buf), "%s/%s", _thumbdir, td);
244 ecore_file_mkdir(buf);
245
246 snprintf(buf, sizeof(buf), "%s/%s/%s.thm", _thumbdir, td, id + 3);
247 free(id);
248 free(td);
249
250 mtime_orig = ecore_file_mod_time(eth->file);
251 mtime_thumb = ecore_file_mod_time(buf);
252 if (mtime_thumb <= mtime_orig)
253 {
254 edje_file_cache_set(0);
255 edje_collection_cache_set(0);
256 ee = ecore_evas_buffer_new(1, 1);
257 evas = ecore_evas_get(ee);
258 evas_image_cache_set(evas, 0);
259 evas_font_cache_set(evas, 0);
260 ww = 0;
261 hh = 0;
262 ext = strrchr(eth->file, '.');
263 if ((ext) && (!strcasecmp(ext, ".edj")) && (eth->key))
264 {
265 ww = eth->w;
266 hh = eth->h;
267 im = ecore_evas_object_image_new(ee);
268 ee_im = evas_object_data_get(im, "Ecore_Evas");
269 evas_im = ecore_evas_get(ee_im);
270 evas_image_cache_set(evas_im, 0);
271 evas_font_cache_set(evas_im, 0);
272 evas_object_image_size_set(im, ww * 8, hh * 8);
273 evas_object_image_fill_set(im, 0, 0, ww, hh);
274 edje = edje_object_add(evas_im);
275 if (edje_object_file_set(edje, eth->file, eth->key))
276 {
277 evas_object_move(edje, 0, 0);
278 evas_object_resize(edje, ww * 8, hh * 8);
279 evas_object_show(edje);
280 }
281 }
282 else
283 {
284 im = evas_object_image_add(evas);
285 evas_object_image_file_set(im, eth->file, NULL);
286 iw = 0; ih = 0;
287 evas_object_image_size_get(im, &iw, &ih);
288 alpha = evas_object_image_alpha_get(im);
289 if ((iw > 0) && (ih > 0))
290 {
291 ww = eth->w;
292 hh = (eth->w * ih) / iw;
293 if (hh > eth->h)
294 {
295 hh = eth->h;
296 ww = (eth->h * iw) / ih;
297 }
298 evas_object_image_fill_set(im, 0, 0, ww, hh);
299 }
300 }
301 evas_object_move(im, 0, 0);
302 evas_object_resize(im, ww, hh);
303 ecore_evas_resize(ee, ww, hh);
304 evas_object_show(im);
305 if (ww > 0)
306 {
307 data = (int *)ecore_evas_buffer_pixels_get(ee);
308 if (data)
309 {
310 ef = eet_open(buf, EET_FILE_MODE_WRITE);
311 if (ef)
312 {
313 eet_write(ef, "/thumbnail/orig_file",
314 eth->file, strlen(eth->file), 1);
315 if (eth->key)
316 eet_write(ef, "/thumbnail/orig_key",
317 eth->key, strlen(eth->key), 1);
318 eet_data_image_write(ef, "/thumbnail/data",
319 (void *)data, ww, hh, alpha,
320 0, 91, 1);
321 eet_close(ef);
322 }
323 }
324 }
325 /* will free all */
326 if (edje) evas_object_del(edje);
327 if (ee_im) ecore_evas_free(ee_im);
328 else if (im) evas_object_del(im);
329 ecore_evas_free(ee);
330 eet_clearcache();
331 }
332 /* send back path to thumb */
333 ecore_ipc_server_send(_e_ipc_server, 5, 2, eth->objid, 0, 0, buf, strlen(buf) + 1);
334}
335
336static char *
337_e_thumb_file_id(char *file, char *key)
338{
339 char s[512], *sp;
340 const char *chmap =
341 "0123456789abcdef"
342 "ghijklmnopqrstuv";
343 unsigned int id[8], i, t, tt;
344 int j;
345
346 for (i = 0; i < 8; i++) id[i] = 0x55555555;
347
348 j = 0;
349 sp = file;
350 while (*sp)
351 {
352 i = ((int)*sp) & 0x7;
353 id[i] ^= ((int)*sp) << j;
354 j++;
355 if (j == 25) j = 0;
356 sp++;
357 }
358
359 sp = key;
360 if (sp)
361 {
362 while (*sp)
363 {
364 i = ((int)*sp) & 0x7;
365 id[i] ^= ((int)*sp) << j;
366 j++;
367 if (j == 25) j = 0;
368 sp++;
369 }
370 }
371
372 sp = s;
373 for (i = 0; i < 8; i++)
374 {
375 t = id[i];
376 j = 32;
377 while (j > 0)
378 {
379 tt = t & ((1 << 5) - 1);
380 *sp = chmap[tt];
381 t >>= 5;
382 j -= 5;
383 sp++;
384 }
385 }
386 *sp = 0;
387 return strdup(s);
388}