3 //#define USE_ICON_CACHE
5 typedef struct _E_Smart_Data E_Smart_Data;
6 typedef struct _Cache_Item Cache_Item;
7 typedef struct _Cache Cache;
11 Evas_Coord x, y, w, h;
13 Evas_Object *eventarea;
16 int frame, frame_count;
18 unsigned char fill_inside : 1;
19 unsigned char scale_up : 1;
20 unsigned char preload : 1;
21 unsigned char loading : 1;
30 unsigned int timestamp;
32 Evas_Object *icon, *obj;
44 Eina_List *load_queue;
47 /* local subsystem functions */
48 static void _e_icon_smart_reconfigure(E_Smart_Data *sd);
49 static void _e_icon_smart_init(void);
50 static void _e_icon_smart_add(Evas_Object *obj);
51 static void _e_icon_smart_del(Evas_Object *obj);
52 static void _e_icon_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
53 static void _e_icon_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
54 static void _e_icon_smart_show(Evas_Object *obj);
55 static void _e_icon_smart_hide(Evas_Object *obj);
56 static void _e_icon_smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
57 static void _e_icon_smart_clip_set(Evas_Object *obj, Evas_Object * clip);
58 static void _e_icon_smart_clip_unset(Evas_Object *obj);
59 static void _e_icon_obj_prepare(Evas_Object *obj, E_Smart_Data *sd);
60 static void _e_icon_preloaded(void *data, Evas *e, Evas_Object *obj, void *event_info);
63 static Eina_Bool _e_icon_cache_find(Evas_Object *o, const char *file);
64 static void _e_icon_cache_icon_loaded(Cache_Item *ci);
65 static void _e_icon_cache_icon_try_next(Cache_Item *ci);
66 static void _e_icon_cache_item_free(void *data);
67 static void _e_icon_obj_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
70 /* local subsystem globals */
71 static Evas_Smart *_e_smart = NULL;
74 static Cache *_cache = NULL;
75 static E_Config_DD *cache_edd = NULL;
76 static E_Config_DD *cache_item_edd = NULL;
91 #define D cache_item_edd
92 D = E_CONFIG_DD_NEW("Cache_Item", T);
93 E_CONFIG_VAL(D, T, timestamp, UINT);
98 D = E_CONFIG_DD_NEW("Cache", T);
99 E_CONFIG_HASH(D, T, hash, cache_item_edd);
103 e_user_dir_concat_static(buf, "icon_cache.eet");
105 ef = eet_open(buf, EET_FILE_MODE_READ_WRITE);
106 if (!ef) return 1; /* not critical */
108 _cache = eet_data_read(ef, cache_edd, "idx");
110 _cache = E_NEW(Cache, 1);
113 _cache->hash = eina_hash_string_superfast_new(_e_icon_cache_item_free);
117 _cache->file = strdup(buf);
125 e_icon_shutdown(void)
127 #ifdef USE_ICON_CACHE
130 E_FREE(_cache->file);
133 eet_close(_cache->ef);
135 if (_cache->load_queue)
136 eina_list_free(_cache->load_queue);
138 eina_hash_free(_cache->hash);
142 E_CONFIG_DD_FREE(cache_item_edd);
143 E_CONFIG_DD_FREE(cache_edd);
149 /* externally accessible functions */
151 e_icon_add(Evas *evas)
153 _e_icon_smart_init();
154 return evas_object_smart_add(evas, _e_smart);
158 _e_icon_obj_prepare(Evas_Object *obj, E_Smart_Data *sd)
160 if (!sd->obj) return;
162 if (!strcmp(evas_object_type_get(sd->obj), "edje"))
166 pclip = evas_object_clip_get(sd->obj);
167 evas_object_del(sd->obj);
168 #ifdef USE_ICON_CACHE
170 eina_stringshare_replace(&sd->file, NULL);
172 sd->obj = evas_object_image_add(evas_object_evas_get(obj));
173 evas_object_image_scale_hint_set(sd->obj, EVAS_IMAGE_SCALE_HINT_STATIC);
174 evas_object_smart_member_add(sd->obj, obj);
175 evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_IMAGE_PRELOADED,
176 _e_icon_preloaded, obj);
177 evas_object_clip_set(sd->obj, pclip);
182 _frame_anim(void *data)
184 E_Smart_Data *sd = data;
189 fr = (sd->frame % (sd->frame_count)) + 1;
190 evas_object_image_animated_frame_set(sd->obj, fr);
191 t = evas_object_image_animated_frame_duration_get(sd->obj, fr, 0);
192 sd->timer = ecore_timer_add(t, _frame_anim, sd);
197 _handle_anim(E_Smart_Data *sd)
201 if (sd->timer) ecore_timer_del(sd->timer);
205 if (!evas_object_image_animated_get(sd->obj)) return 0;
206 // FIXME: hack around jiyouns BUG!!!!!!!!
210 snprintf(buf, sizeof(buf), "%ld", (long)sd);
211 evas_object_image_file_get(sd->obj, &file, NULL);
212 evas_object_image_file_set(sd->obj, file, buf);
214 sd->frame_count = evas_object_image_animated_frame_count_get(sd->obj);
215 if (sd->frame_count < 2) return 0;
216 evas_object_show(sd->obj);
217 t = evas_object_image_animated_frame_duration_get(sd->obj, sd->frame, 0);
218 sd->timer = ecore_timer_add(t, _frame_anim, sd);
223 e_icon_file_set(Evas_Object *obj, const char *file)
228 if (!file) return EINA_FALSE;
229 if (!(sd = evas_object_smart_data_get(obj)))
233 if ((len > 4) && (!strcasecmp(file + len - 4, ".edj")))
234 return e_icon_file_edje_set(obj, file, "icon");
236 /* smart code here */
237 _e_icon_obj_prepare(obj, sd);
238 /* FIXME: 64x64 - unhappy about this. use icon size */
242 eina_stringshare_del(sd->fdo);
246 if (sd->timer) ecore_timer_del(sd->timer);
252 evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
253 if (sd->preload) evas_object_hide(sd->obj);
255 #ifdef USE_ICON_CACHE
256 if (_e_icon_cache_find(obj, file))
258 _e_icon_smart_reconfigure(sd);
263 evas_object_image_file_set(sd->obj, file, NULL);
264 if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
267 if (!_handle_anim(sd))
272 evas_object_image_preload(sd->obj, EINA_FALSE);
274 else if (evas_object_visible_get(obj))
276 evas_object_show(sd->obj);
277 #ifdef USE_ICON_CACHE
278 _e_icon_cache_icon_loaded(sd->ci);
282 #ifdef USE_ICON_CACHE
285 evas_object_event_callback_del_full(sd->obj, EVAS_CALLBACK_DEL,
286 _e_icon_obj_del, obj);
287 _cache->load_queue = eina_list_remove(_cache->load_queue, sd->ci);
288 eina_stringshare_del(sd->ci->id);
294 _e_icon_smart_reconfigure(sd);
299 e_icon_file_key_set(Evas_Object *obj, const char *file, const char *key)
303 if (!(sd = evas_object_smart_data_get(obj)))
306 /* smart code here */
310 eina_stringshare_del(sd->fdo);
314 if (sd->timer) ecore_timer_del(sd->timer);
319 _e_icon_obj_prepare(obj, sd);
321 evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
322 if (sd->preload) evas_object_hide(sd->obj);
323 evas_object_image_file_set(sd->obj, file, key);
324 if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
326 if (!_handle_anim(sd))
331 evas_object_image_preload(sd->obj, 0);
333 else if (evas_object_visible_get(obj))
334 evas_object_show(sd->obj);
336 _e_icon_smart_reconfigure(sd);
341 e_icon_file_edje_set(Evas_Object *obj, const char *file, const char *part)
345 if (!(sd = evas_object_smart_data_get(obj)))
348 /* smart code here */
349 if (sd->obj) evas_object_del(sd->obj);
353 eina_stringshare_del(sd->fdo);
357 if (sd->timer) ecore_timer_del(sd->timer);
362 sd->obj = edje_object_add(evas_object_evas_get(obj));
363 edje_object_file_set(sd->obj, file, part);
364 if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
366 if (evas_object_visible_get(obj)) evas_object_show(sd->obj);
367 evas_object_smart_member_add(sd->obj, obj);
368 _e_icon_smart_reconfigure(sd);
373 e_icon_fdo_icon_set(Evas_Object *obj, const char *icon)
379 if (!icon) return EINA_TRUE;
380 if (icon[0] == '/') return e_icon_file_set(obj, icon);
382 if (!(sd = evas_object_smart_data_get(obj)))
385 if (sd->timer) ecore_timer_del(sd->timer);
390 eina_stringshare_replace(&sd->fdo, icon);
391 if (!sd->fdo) return EINA_FALSE;
393 path = efreet_icon_path_find(e_config->icon_theme, sd->fdo, sd->size);
394 if (!path) return EINA_TRUE;
397 if ((len > 4) && (!strcasecmp(icon + len - 4, ".edj")))
398 return e_icon_file_edje_set(obj, path, "icon");
400 /* smart code here */
401 _e_icon_obj_prepare(obj, sd);
404 evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
405 if (sd->preload) evas_object_hide(sd->obj);
406 evas_object_image_file_set(sd->obj, path, NULL);
407 if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
412 evas_object_image_preload(sd->obj, 0);
414 else if (evas_object_visible_get(obj))
415 evas_object_show(sd->obj);
416 _e_icon_smart_reconfigure(sd);
421 e_icon_object_set(Evas_Object *obj, Evas_Object *o)
425 if (!(sd = evas_object_smart_data_get(obj))) return;
427 if (sd->timer) ecore_timer_del(sd->timer);
432 /* smart code here */
433 if (sd->obj) evas_object_del(sd->obj);
436 evas_object_smart_member_add(sd->obj, obj);
437 if (evas_object_visible_get(obj)) evas_object_show(sd->obj);
438 _e_icon_smart_reconfigure(sd);
442 e_icon_file_get(const Evas_Object *obj)
447 if (!(sd = evas_object_smart_data_get(obj))) return NULL;
448 #ifdef USE_ICON_CACHE
449 if (sd->file) return sd->file;
451 if (!strcmp(evas_object_type_get(sd->obj), "edje"))
453 edje_object_file_get(sd->obj, &file, NULL);
456 evas_object_image_file_get(sd->obj, &file, NULL);
461 e_icon_smooth_scale_set(Evas_Object *obj, Eina_Bool smooth)
465 if (!(sd = evas_object_smart_data_get(obj))) return;
466 if (!strcmp(evas_object_type_get(sd->obj), "edje")) return;
467 evas_object_image_smooth_scale_set(sd->obj, smooth);
471 e_icon_smooth_scale_get(const Evas_Object *obj)
475 if (!(sd = evas_object_smart_data_get(obj))) return EINA_FALSE;
476 if (!strcmp(evas_object_type_get(sd->obj), "edje"))
478 return evas_object_image_smooth_scale_get(sd->obj);
482 e_icon_alpha_set(Evas_Object *obj, Eina_Bool alpha)
486 if (!(sd = evas_object_smart_data_get(obj))) return;
487 if (!strcmp(evas_object_type_get(sd->obj), "edje")) return;
488 evas_object_image_alpha_set(sd->obj, alpha);
492 e_icon_alpha_get(const Evas_Object *obj)
496 if (!(sd = evas_object_smart_data_get(obj))) return EINA_FALSE;
497 if (!strcmp(evas_object_type_get(sd->obj), "edje")) return EINA_FALSE;
498 return evas_object_image_alpha_get(sd->obj);
502 e_icon_preload_set(Evas_Object *obj, Eina_Bool preload)
506 if (!(sd = evas_object_smart_data_get(obj))) return;
507 sd->preload = preload;
511 e_icon_preload_get(const Evas_Object *obj)
515 if (!(sd = evas_object_smart_data_get(obj))) return EINA_FALSE;
520 e_icon_size_get(const Evas_Object *obj, int *w, int *h)
524 if (!(sd = evas_object_smart_data_get(obj)))
530 evas_object_image_size_get(sd->obj, w, h);
534 e_icon_fill_inside_get(const Evas_Object *obj)
538 if (!(sd = evas_object_smart_data_get(obj))) return EINA_FALSE;
539 return sd->fill_inside;
543 e_icon_fill_inside_set(Evas_Object *obj, Eina_Bool fill_inside)
547 if (!(sd = evas_object_smart_data_get(obj))) return;
548 fill_inside = !!fill_inside;
549 if (sd->fill_inside == fill_inside) return;
550 sd->fill_inside = fill_inside;
551 _e_icon_smart_reconfigure(sd);
555 e_icon_scale_up_get(const Evas_Object *obj)
559 if (!(sd = evas_object_smart_data_get(obj))) return EINA_FALSE;
564 e_icon_scale_up_set(Evas_Object *obj, Eina_Bool scale_up)
568 if (!(sd = evas_object_smart_data_get(obj))) return;
569 scale_up = !!scale_up;
570 if (sd->scale_up == scale_up) return;
571 sd->scale_up = scale_up;
572 _e_icon_smart_reconfigure(sd);
576 e_icon_data_set(Evas_Object *obj, void *data, int w, int h)
580 if (!(sd = evas_object_smart_data_get(obj))) return;
581 if (!strcmp(evas_object_type_get(sd->obj), "edje")) return;
582 evas_object_image_size_set(sd->obj, w, h);
583 evas_object_image_data_copy_set(sd->obj, data);
587 e_icon_data_get(const Evas_Object *obj, int *w, int *h)
591 if (!(sd = evas_object_smart_data_get(obj))) return NULL;
592 if (!strcmp(evas_object_type_get(sd->obj), "edje")) return NULL;
593 evas_object_image_size_get(sd->obj, w, h);
594 return evas_object_image_data_get(sd->obj, 0);
598 e_icon_scale_size_set(Evas_Object *obj, int size)
602 if (!(sd = evas_object_smart_data_get(obj))) return;
604 if (!strcmp(evas_object_type_get(sd->obj), "edje"))
606 evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
610 e_icon_scale_size_get(const Evas_Object *obj)
614 if (!(sd = evas_object_smart_data_get(obj))) return 0;
619 e_icon_selected_set(const Evas_Object *obj, Eina_Bool selected)
623 if (!(sd = evas_object_smart_data_get(obj))) return;
624 if (strcmp(evas_object_type_get(sd->obj), "edje")) return;
626 edje_object_signal_emit(sd->obj, "e,state,selected", "e");
628 edje_object_signal_emit(sd->obj, "e,state,unselected", "e");
631 /* local subsystem globals */
633 _e_icon_smart_reconfigure(E_Smart_Data *sd)
636 Evas_Coord x, y, w, h;
638 if (!sd->obj) return;
639 if (!strcmp(evas_object_type_get(sd->obj), "edje"))
645 evas_object_move(sd->obj, x, y);
646 evas_object_resize(sd->obj, w, h);
647 evas_object_move(sd->eventarea, x, y);
648 evas_object_resize(sd->eventarea, w, h);
654 evas_object_image_size_get(sd->obj, &iw, &ih);
661 h = ((double)ih * w) / (double)iw;
665 w = ((double)iw * h) / (double)ih;
671 h = ((double)ih * w) / (double)iw;
675 w = ((double)iw * h) / (double)ih;
680 if ((w > iw) || (h > ih))
686 x = sd->x + ((sd->w - w) / 2);
687 y = sd->y + ((sd->h - h) / 2);
688 evas_object_move(sd->obj, x, y);
689 evas_object_image_fill_set(sd->obj, 0, 0, w, h);
690 evas_object_resize(sd->obj, w, h);
691 evas_object_move(sd->eventarea, x, y);
692 evas_object_resize(sd->eventarea, w, h);
697 _e_icon_smart_init(void)
699 if (_e_smart) return;
701 static Evas_Smart_Class sc = EVAS_SMART_CLASS_INIT_NAME_VERSION("e_icon");
704 sc.add = _e_icon_smart_add;
705 sc.del = _e_icon_smart_del;
706 sc.move = _e_icon_smart_move;
707 sc.resize = _e_icon_smart_resize;
708 sc.show = _e_icon_smart_show;
709 sc.hide = _e_icon_smart_hide;
710 sc.color_set = _e_icon_smart_color_set;
711 sc.clip_set = _e_icon_smart_clip_set;
712 sc.clip_unset = _e_icon_smart_clip_unset;
714 _e_smart = evas_smart_class_new(&sc);
719 _e_icon_preloaded(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
723 if (!(sd = evas_object_smart_data_get(data))) return;
725 evas_object_smart_callback_call(data, "preloaded", NULL);
726 evas_object_show(sd->obj);
729 #ifdef USE_ICON_CACHE
730 _e_icon_cache_icon_loaded(sd->ci);
735 _e_icon_smart_add(Evas_Object *obj)
739 if (!(sd = calloc(1, sizeof(E_Smart_Data)))) return;
740 sd->eventarea = evas_object_rectangle_add(evas_object_evas_get(obj));
741 evas_object_color_set(sd->eventarea, 0, 0, 0, 0);
742 evas_object_smart_member_add(sd->eventarea, obj);
744 sd->obj = evas_object_image_add(evas_object_evas_get(obj));
745 evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_IMAGE_PRELOADED,
746 _e_icon_preloaded, obj);
754 evas_object_smart_member_add(sd->obj, obj);
755 evas_object_smart_data_set(obj, sd);
759 _e_icon_smart_del(Evas_Object *obj)
763 if (!(sd = evas_object_smart_data_get(obj))) return;
764 evas_object_del(sd->obj);
765 evas_object_del(sd->eventarea);
766 if (sd->fdo) eina_stringshare_del(sd->fdo);
767 #ifdef USE_ICON_CACHE
768 if (sd->file) eina_stringshare_del(sd->file);
770 if (sd->timer) ecore_timer_del(sd->timer);
775 _e_icon_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
779 if (!(sd = evas_object_smart_data_get(obj))) return;
780 if ((sd->x == x) && (sd->y == y)) return;
783 _e_icon_smart_reconfigure(sd);
787 _e_icon_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
791 if (!(sd = evas_object_smart_data_get(obj))) return;
792 if ((sd->w == w) && (sd->h == h)) return;
799 sd->size = MAX(w, h);
800 path = efreet_icon_path_find(e_config->icon_theme, sd->fdo, sd->size);
803 /* smart code here */
804 evas_object_image_load_size_set(sd->obj, sd->size, sd->size);
805 evas_object_image_file_set(sd->obj, path, NULL);
809 evas_object_image_preload(sd->obj, 0);
813 _e_icon_smart_reconfigure(sd);
817 _e_icon_smart_show(Evas_Object *obj)
821 if (!(sd = evas_object_smart_data_get(obj))) return;
822 if (!((sd->preload) && (sd->loading)))
824 evas_object_show(sd->obj);
825 #ifdef USE_ICON_CACHE
827 _e_icon_cache_icon_loaded(sd->ci);
831 evas_object_show(sd->eventarea);
835 _e_icon_smart_hide(Evas_Object *obj)
839 if (!(sd = evas_object_smart_data_get(obj))) return;
840 evas_object_hide(sd->obj);
841 evas_object_hide(sd->eventarea);
845 _e_icon_smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
849 if (!(sd = evas_object_smart_data_get(obj))) return;
850 evas_object_color_set(sd->obj, r, g, b, a);
854 _e_icon_smart_clip_set(Evas_Object *obj, Evas_Object * clip)
858 if (!(sd = evas_object_smart_data_get(obj))) return;
859 evas_object_clip_set(sd->obj, clip);
860 evas_object_clip_set(sd->eventarea, clip);
864 _e_icon_smart_clip_unset(Evas_Object *obj)
868 if (!(sd = evas_object_smart_data_get(obj))) return;
869 evas_object_clip_unset(sd->obj);
870 evas_object_clip_unset(sd->eventarea);
873 #ifdef USE_ICON_CACHE
876 _e_icon_cache_item_free(void *data)
878 Cache_Item *ci = data;
879 eina_stringshare_del(ci->id);
884 _e_icon_cache_save(void *data)
886 if (_cache->load_queue)
891 /* EINA_LIST_FOREACH(_cache->load_queue, l, ci)
892 * printf(" : %s\n", ci->id); */
894 return ECORE_CALLBACK_RENEW;
897 eet_sync(_cache->ef);
898 eet_close(_cache->ef);
901 _cache->timer = NULL;
903 return ECORE_CALLBACK_CANCEL;
907 _e_icon_cache_find(Evas_Object *obj, const char *file)
915 if (!_cache) return EINA_FALSE;
917 if (!(sd = evas_object_smart_data_get(obj)))
920 snprintf(buf, PATH_MAX, "%d:%s", sd->size, file);
922 if ((ci = eina_hash_find(_cache->hash, buf)))
924 unsigned int w, h, alpha;
929 _cache->ef = eet_open(_cache->file, EET_FILE_MODE_READ_WRITE);
931 if (_cache->ef && (data = eet_data_image_read(_cache->ef, buf,
935 evas_object_image_size_set(sd->obj, w, h);
936 evas_object_image_alpha_set(sd->obj, alpha);
937 evas_object_image_data_copy_set(sd->obj, data);
938 evas_object_smart_callback_call(obj, "preloaded", NULL);
939 evas_object_show(sd->obj);
944 if ((_cache->ef) && !(_cache->timer))
945 _cache->timer = ecore_timer_add(3.0, _e_icon_cache_save, NULL);
950 eina_hash_del_by_key(_cache->hash, ci->id);
954 id = eina_stringshare_add(buf);
956 /* not found in cache, check load queue */
957 EINA_LIST_FOREACH(_cache->load_queue, l, ci)
959 if (ci->id != id) continue;
960 ci->objs = eina_list_append(ci->objs, obj);
962 evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_DEL,
963 _e_icon_obj_del, obj);
964 eina_stringshare_del(id);
968 ci = E_NEW(Cache_Item, 1);
973 sd->file = eina_stringshare_add(file);
975 evas_object_event_callback_add(sd->obj, EVAS_CALLBACK_DEL, _e_icon_obj_del, obj);
977 _cache->load_queue = eina_list_append(_cache->load_queue, ci);
983 _e_icon_cache_icon_try_next(Cache_Item *ci)
990 /* no more e_icon wait for this object to bet loaded */
991 _cache->load_queue = eina_list_remove(_cache->load_queue, ci);
992 _e_icon_cache_item_free(ci);
996 obj = eina_list_data_get(ci->objs);
997 ci->objs = eina_list_remove_list(ci->objs, ci->objs);
1002 if (!(sd = evas_object_smart_data_get(obj)))
1005 evas_object_image_file_set(sd->obj, sd->file, NULL);
1006 if (evas_object_image_load_error_get(sd->obj) != EVAS_LOAD_ERROR_NONE)
1009 sd->ci->icon = sd->obj;
1011 evas_object_image_preload(sd->obj, EINA_FALSE);
1015 evas_object_event_callback_del_full(sd->obj, EVAS_CALLBACK_DEL,
1016 _e_icon_obj_del, obj);
1017 _e_icon_cache_icon_try_next(ci);
1021 _e_icon_obj_del(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info __UNUSED__)
1025 if (!(sd = evas_object_smart_data_get(data))) return;
1026 if (!sd->ci) return;
1028 /* check if the deleted object is the one that is used for
1029 preloading. when other objs wait for this image data start
1030 preloading again with the next. */
1032 if (sd->ci->icon == obj)
1034 _e_icon_cache_icon_try_next(sd->ci);
1039 sd->ci->objs = eina_list_remove(sd->ci->objs, data);
1045 _e_icon_cache_icon_loaded(Cache_Item *ci)
1052 if (!_cache) return;
1054 if (!ci || !ci->id) return;
1055 _cache->load_queue = eina_list_remove(_cache->load_queue, ci);
1057 data = evas_object_image_data_get(ci->icon, EINA_FALSE);
1058 evas_object_image_size_get(ci->icon, &w, &h);
1059 alpha = evas_object_image_alpha_get(ci->icon);
1061 evas_object_event_callback_del_full(ci->icon, EVAS_CALLBACK_DEL,
1062 _e_icon_obj_del, ci->obj);
1063 evas_object_smart_callback_call(ci->obj, "preloaded", NULL);
1065 DBG("icon loaded %p, %s\n", data, ci->id);
1067 sd = evas_object_smart_data_get(ci->obj);
1070 /* pass loaded data to other e_icon wating for this */
1071 EINA_LIST_FREE(ci->objs, obj)
1073 sd = evas_object_smart_data_get(obj);
1075 evas_object_event_callback_del_full(sd->obj, EVAS_CALLBACK_DEL,
1076 _e_icon_obj_del, obj);
1077 if (!data) continue;
1079 evas_object_image_size_set(sd->obj, w, h);
1080 evas_object_image_alpha_set(sd->obj, alpha);
1081 evas_object_image_data_copy_set(sd->obj, data);
1082 evas_object_show(sd->obj);
1083 evas_object_smart_callback_call(obj, "preloaded", NULL);
1089 _cache->ef = eet_open(_cache->file, EET_FILE_MODE_READ_WRITE);
1090 if (_cache->ef && eet_data_image_write(_cache->ef, ci->id, data,
1091 w, h, alpha, 1, 100, 0))
1093 eina_hash_add(_cache->hash, ci->id, ci);
1094 eet_data_write(_cache->ef, cache_edd, "idx", _cache, 1);
1097 _cache->timer = ecore_timer_add(3.0, _e_icon_cache_save, NULL);
1099 eina_stringshare_replace(&ci->id, NULL);
1104 DBG("couldnt write cache %p !!!\n", _cache->ef);
1105 _e_icon_cache_item_free(ci);