summaryrefslogtreecommitdiff
path: root/src/lib/elementary/efl_ui_image.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/elementary/efl_ui_image.c')
-rw-r--r--src/lib/elementary/efl_ui_image.c325
1 files changed, 162 insertions, 163 deletions
diff --git a/src/lib/elementary/efl_ui_image.c b/src/lib/elementary/efl_ui_image.c
index 90ec820..a29ce75 100644
--- a/src/lib/elementary/efl_ui_image.c
+++ b/src/lib/elementary/efl_ui_image.c
@@ -46,11 +46,12 @@ static const Evas_Smart_Cb_Description _smart_callbacks[] = {
46}; 46};
47 47
48static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params); 48static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params);
49static Eina_Bool _efl_ui_image_smart_internal_file_set(Eo *obj, Efl_Ui_Image_Data *sd, const char *file, const Eina_File *f, const char *key); 49static Eina_Error _efl_ui_image_smart_internal_file_set(Eo *obj, Efl_Ui_Image_Data *sd);
50static void _efl_ui_image_remote_copier_cancel(Eo *obj, Efl_Ui_Image_Data *sd); 50static void _efl_ui_image_remote_copier_cancel(Eo *obj, Efl_Ui_Image_Data *sd);
51void _efl_ui_image_sizing_eval(Evas_Object *obj); 51void _efl_ui_image_sizing_eval(Evas_Object *obj);
52static void _efl_ui_image_model_properties_changed_cb(void *data, const Efl_Event *event); 52static void _efl_ui_image_model_properties_changed_cb(void *data, const Efl_Event *event);
53static void _on_size_hints_changed(void *data, const Efl_Event *e); 53static void _on_size_hints_changed(void *data, const Efl_Event *e);
54static Eina_Bool _efl_ui_image_download(Eo *obj, Efl_Ui_Image_Data *sd, const char *url);
54 55
55static const Elm_Action key_actions[] = { 56static const Elm_Action key_actions[] = {
56 {"activate", _key_action_activate}, 57 {"activate", _key_action_activate},
@@ -80,8 +81,8 @@ static void
80_recover_status(Eo *obj, Efl_Ui_Image_Data *sd) 81_recover_status(Eo *obj, Efl_Ui_Image_Data *sd)
81{ 82{
82 int r, g, b, a; 83 int r, g, b, a;
83 Evas_Object *pclip = efl_canvas_object_clip_get(obj); 84 Evas_Object *pclip = efl_canvas_object_clipper_get(obj);
84 if (pclip) efl_canvas_object_clip_set(sd->img, pclip); 85 if (pclip) efl_canvas_object_clipper_set(sd->img, pclip);
85 86
86 efl_gfx_color_get(obj, &r, &g, &b, &a); 87 efl_gfx_color_get(obj, &r, &g, &b, &a);
87 efl_gfx_color_set(sd->img, r, g, b, a); 88 efl_gfx_color_set(sd->img, r, g, b, a);
@@ -396,7 +397,7 @@ static void
396_efl_ui_image_async_open_done(void *data, Ecore_Thread *thread) 397_efl_ui_image_async_open_done(void *data, Ecore_Thread *thread)
397{ 398{
398 Async_Open_Data *todo = data; 399 Async_Open_Data *todo = data;
399 Eina_Stringshare *file, *key; 400 const char *key;
400 Eina_Bool ok; 401 Eina_Bool ok;
401 Eina_File *f; 402 Eina_File *f;
402 void *map; 403 void *map;
@@ -414,19 +415,21 @@ _efl_ui_image_async_open_done(void *data, Ecore_Thread *thread)
414 map = todo->map; 415 map = todo->map;
415 f = todo->f_open; 416 f = todo->f_open;
416 ok = f && map; 417 ok = f && map;
417 if (todo->file) file = todo->file;
418 else file = f ? eina_file_filename_get(f) : NULL;
419 418
420 if (ok) 419 if (ok)
421 { 420 {
422 if (sd->edje) 421 efl_file_key_set(sd->self, key);
422 ok = !efl_file_mmap_set(sd->self, f);
423 if (ok)
423 { 424 {
424 _prev_img_del(sd); 425 if (sd->edje)
425 ok = edje_object_mmap_set(sd->img, f, key); 426 {
427 _prev_img_del(sd);
428 ok = edje_object_mmap_set(sd->img, f, key);
429 }
430 else
431 ok = !_efl_ui_image_smart_internal_file_set(sd->self, sd);
426 } 432 }
427 else
428 ok = _efl_ui_image_smart_internal_file_set
429 (sd->self, sd, file, f, key);
430 } 433 }
431 if (ok) evas_object_smart_callback_call(sd->self, SIG_LOAD_OPEN, NULL); 434 if (ok) evas_object_smart_callback_call(sd->self, SIG_LOAD_OPEN, NULL);
432 else evas_object_smart_callback_call(sd->self, SIG_LOAD_ERROR, NULL); 435 else evas_object_smart_callback_call(sd->self, SIG_LOAD_ERROR, NULL);
@@ -437,18 +440,20 @@ _efl_ui_image_async_open_done(void *data, Ecore_Thread *thread)
437 _async_open_data_free(todo); 440 _async_open_data_free(todo);
438} 441}
439 442
440static Eina_Bool 443static Eina_Error
441_efl_ui_image_async_file_set(Eo *obj, Efl_Ui_Image_Data *sd, const char *file, 444_efl_ui_image_async_file_set(Eo *obj, Efl_Ui_Image_Data *sd)
442 const Eina_File *f, const char *key)
443{ 445{
444 Async_Open_Data *todo; 446 Async_Open_Data *todo;
447 const char *file = efl_file_get(obj);
448 const char *key = efl_file_key_get(obj);
449 const Eina_File *f = efl_file_mmap_get(obj);
445 450
446 if (sd->async.th && 451 if (sd->async.th &&
447 ((file == sd->async.file) || 452 ((file == sd->async.file) ||
448 (file && sd->async.file && !strcmp(file, sd->async.file))) && 453 (file && sd->async.file && !strcmp(file, sd->async.file))) &&
449 ((key == sd->async.key) || 454 ((key == sd->async.key) ||
450 (key && sd->async.key && !strcmp(key, sd->async.key)))) 455 (key && sd->async.key && !strcmp(key, sd->async.key))))
451 return EINA_TRUE; 456 return 0;
452 457
453 todo = calloc(1, sizeof(Async_Open_Data)); 458 todo = calloc(1, sizeof(Async_Open_Data));
454 if (!todo) return EINA_FALSE; 459 if (!todo) return EINA_FALSE;
@@ -467,22 +472,28 @@ _efl_ui_image_async_file_set(Eo *obj, Efl_Ui_Image_Data *sd, const char *file,
467 sd->async.th = ecore_thread_run(_efl_ui_image_async_open_do, 472 sd->async.th = ecore_thread_run(_efl_ui_image_async_open_do,
468 _efl_ui_image_async_open_done, 473 _efl_ui_image_async_open_done,
469 _efl_ui_image_async_open_cancel, todo); 474 _efl_ui_image_async_open_cancel, todo);
470 if (sd->async.th) return EINA_TRUE; 475 if (sd->async.th) return 0;
471 476
472 _async_open_data_free(todo); 477 _async_open_data_free(todo);
473 _async_clear(sd); 478 _async_clear(sd);
474 DBG("Could not spawn an async thread!"); 479 DBG("Could not spawn an async thread!");
475 return EINA_FALSE; 480 return EFL_GFX_IMAGE_LOAD_ERROR_GENERIC;
476} 481}
477 482
478static Eina_Bool 483static Eina_Error
479_efl_ui_image_edje_file_set(Evas_Object *obj, 484_efl_ui_image_edje_file_set(Evas_Object *obj)
480 const char *file,
481 const Eina_File *f,
482 const char *group)
483{ 485{
486 Eina_Error err;
487 const Eina_File *f;
488 const char *key;
489
484 EFL_UI_IMAGE_DATA_GET(obj, sd); 490 EFL_UI_IMAGE_DATA_GET(obj, sd);
485 491
492 err = efl_file_load(efl_super(obj, MY_CLASS));
493 if (err) return err;
494
495 f = efl_file_mmap_get(obj);
496 key = efl_file_key_get(obj);
486 _prev_img_del(sd); 497 _prev_img_del(sd);
487 498
488 if (!sd->edje) 499 if (!sd->edje)
@@ -500,32 +511,23 @@ _efl_ui_image_edje_file_set(Evas_Object *obj,
500 511
501 if (!sd->async_enable) 512 if (!sd->async_enable)
502 { 513 {
503 if (f) 514 efl_file_key_set(sd->img, key);
504 { 515 err = efl_file_mmap_set(sd->img, f);
505 if (!edje_object_mmap_set(sd->img, f, group)) 516 if (!err) err = efl_file_load(sd->img);
506 { 517 if (err)
507 ERR("failed to set edje file '%s', group '%s': %s", file, group,
508 edje_load_error_str(edje_object_load_error_get(sd->img)));
509 return EINA_FALSE;
510 }
511 }
512 else
513 { 518 {
514 if (!edje_object_file_set(sd->img, file, group)) 519 ERR("failed to set edje file '%s', group '%s': %s", eina_file_filename_get(f), key,
515 { 520 edje_load_error_str(edje_object_load_error_get(sd->img)));
516 ERR("failed to set edje file '%s', group '%s': %s", file, group, 521 return err;
517 edje_load_error_str(edje_object_load_error_get(sd->img)));
518 return EINA_FALSE;
519 }
520 } 522 }
521 } 523 }
522 else 524 else
523 return _efl_ui_image_async_file_set(obj, sd, file, f, group); 525 return _efl_ui_image_async_file_set(obj, sd);
524 526
525 /* FIXME: do i want to update icon on file change ? */ 527 /* FIXME: do i want to update icon on file change ? */
526 _efl_ui_image_sizing_eval(obj); 528 _efl_ui_image_sizing_eval(obj);
527 529
528 return EINA_TRUE; 530 return 0;
529} 531}
530 532
531EOLIAN static void 533EOLIAN static void
@@ -547,7 +549,7 @@ _efl_ui_image_drag_n_drop_cb(void *elm_obj,
547 Elm_Selection_Data *drop) 549 Elm_Selection_Data *drop)
548{ 550{
549 Eina_Bool ret = EINA_FALSE; 551 Eina_Bool ret = EINA_FALSE;
550 ret = efl_file_set(obj, drop->data, NULL); 552 ret = efl_file_simple_load(obj, drop->data, NULL);
551 if (ret) 553 if (ret)
552 { 554 {
553 DBG("dnd: %s, %s, %s", elm_widget_type_get(elm_obj), 555 DBG("dnd: %s, %s, %s", elm_widget_type_get(elm_obj),
@@ -704,27 +706,27 @@ _efl_ui_image_efl_gfx_color_color_set(Eo *obj, Efl_Ui_Image_Data *sd, int r, int
704} 706}
705 707
706EOLIAN static void 708EOLIAN static void
707_efl_ui_image_efl_canvas_object_clip_set(Eo *obj, Efl_Ui_Image_Data *sd, Evas_Object *clip) 709_efl_ui_image_efl_canvas_object_clipper_set(Eo *obj, Efl_Ui_Image_Data *sd, Evas_Object *clip)
708{ 710{
709 if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_CLIP_SET, 0, clip)) 711 if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_CLIP_SET, 0, clip))
710 return; 712 return;
711 713
712 efl_canvas_object_clip_set(efl_super(obj, MY_CLASS), clip); 714 efl_canvas_object_clipper_set(efl_super(obj, MY_CLASS), clip);
713 715
714 if (sd->img) evas_object_clip_set(sd->img, clip); 716 if (sd->img) evas_object_clip_set(sd->img, clip);
715 if (sd->prev_img) evas_object_clip_set(sd->prev_img, clip); 717 if (sd->prev_img) evas_object_clip_set(sd->prev_img, clip);
716} 718}
717 719
718EOLIAN static Efl_Ui_Theme_Apply_Result 720EOLIAN static Eina_Error
719_efl_ui_image_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Image_Data *sd EINA_UNUSED) 721_efl_ui_image_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Image_Data *sd EINA_UNUSED)
720{ 722{
721 Efl_Ui_Theme_Apply_Result int_ret = EFL_UI_THEME_APPLY_RESULT_FAIL; 723 Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC;
722 724
723 if (sd->stdicon) 725 if (sd->stdicon)
724 _elm_theme_object_icon_set(obj, sd->stdicon, elm_widget_style_get(obj)); 726 _elm_theme_object_icon_set(obj, sd->stdicon, elm_widget_style_get(obj));
725 727
726 int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS)); 728 int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
727 if (!int_ret) return EFL_UI_THEME_APPLY_RESULT_FAIL; 729 if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
728 730
729 _efl_ui_image_sizing_eval(obj); 731 _efl_ui_image_sizing_eval(obj);
730 732
@@ -864,12 +866,33 @@ _efl_ui_image_efl_object_constructor(Eo *obj, Efl_Ui_Image_Data *pd)
864 return obj; 866 return obj;
865} 867}
866 868
867EOLIAN Eina_Bool 869static const Eina_Slice remote_uri[] = {
868_efl_ui_image_efl_file_mmap_set(Eo *obj, Efl_Ui_Image_Data *sd, 870 EINA_SLICE_STR_LITERAL("http://"),
869 const Eina_File *file, const char *key) 871 EINA_SLICE_STR_LITERAL("https://"),
872 EINA_SLICE_STR_LITERAL("ftp://"),
873 { }
874};
875
876static inline Eina_Bool
877_efl_ui_image_is_remote(const char *file)
870{ 878{
871 Eina_Bool ret = EINA_FALSE; 879 Eina_Slice s = EINA_SLICE_STR(file);
880 const Eina_Slice *itr;
881
882 for (itr = remote_uri; itr->mem; itr++)
883 if (eina_slice_startswith(s, *itr))
884 return EINA_TRUE;
885
886 return EINA_FALSE;
887}
888
889EOLIAN Eina_Error
890_efl_ui_image_efl_file_load(Eo *obj, Efl_Ui_Image_Data *sd)
891{
892 Eina_Error ret;
893 const char *file = efl_file_get(obj);
872 894
895 if (efl_file_loaded_get(obj)) return 0;
873 _async_cancel(sd); 896 _async_cancel(sd);
874 897
875 /* stop preloading as it may hit to-be-freed memory */ 898 /* stop preloading as it may hit to-be-freed memory */
@@ -879,48 +902,100 @@ _efl_ui_image_efl_file_mmap_set(Eo *obj, Efl_Ui_Image_Data *sd,
879 if (sd->remote.copier) _efl_ui_image_remote_copier_cancel(obj, sd); 902 if (sd->remote.copier) _efl_ui_image_remote_copier_cancel(obj, sd);
880 if (sd->remote.binbuf) ELM_SAFE_FREE(sd->remote.binbuf, eina_binbuf_free); 903 if (sd->remote.binbuf) ELM_SAFE_FREE(sd->remote.binbuf, eina_binbuf_free);
881 904
905 if (sd->anim)
906 {
907 ELM_SAFE_FREE(sd->anim_timer, ecore_timer_del);
908 sd->play = EINA_FALSE;
909 sd->anim = EINA_FALSE;
910 }
911
912 if (file && _efl_ui_image_is_remote(file))
913 {
914 evas_object_hide(sd->img);
915 if (_efl_ui_image_download(obj, sd, file))
916 {
917 evas_object_smart_callback_call(obj, SIG_DOWNLOAD_START, NULL);
918 return 0;
919 }
920 }
921
882 if (!sd->async_enable) 922 if (!sd->async_enable)
883 ret = _efl_ui_image_smart_internal_file_set(obj, sd, eina_file_filename_get(file), file, key); 923 ret = _efl_ui_image_smart_internal_file_set(obj, sd);
884 else 924 else
885 ret = _efl_ui_image_async_file_set(obj, sd, eina_file_filename_get(file), file, key); 925 ret = _efl_ui_image_async_file_set(obj, sd);
886 926
887 return ret; 927 return ret;
888} 928}
889 929
890EOLIAN void 930EOLIAN void
891_efl_ui_image_efl_file_mmap_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, const Eina_File **file, const char **group) 931_efl_ui_image_efl_file_unload(Eo *obj, Efl_Ui_Image_Data *sd)
892{ 932{
893 if (sd->img) efl_file_mmap_get(sd->img, file, group); 933 _async_cancel(sd);
934
935 /* stop preloading as it may hit to-be-freed memory */
936 if (sd->img && sd->preload_status == EFL_UI_IMAGE_PRELOADING)
937 evas_object_image_preload(sd->img, EINA_TRUE);
938
939 if (sd->remote.copier) _efl_ui_image_remote_copier_cancel(obj, sd);
940 if (sd->remote.binbuf) ELM_SAFE_FREE(sd->remote.binbuf, eina_binbuf_free);
941
942 if (sd->anim)
943 {
944 ELM_SAFE_FREE(sd->anim_timer, ecore_timer_del);
945 sd->play = EINA_FALSE;
946 sd->anim = EINA_FALSE;
947 }
948
949 if (sd->prev_img)
950 _prev_img_del(sd);
951 _efl_ui_image_file_set_do(obj);
952 efl_file_unload(sd->img);
953 efl_file_unload(efl_super(obj, MY_CLASS));
954 if (sd->preload_status == EFL_UI_IMAGE_PRELOAD_DISABLED)
955 _prev_img_del(sd);
956 else
957 {
958 evas_object_hide(sd->img);
959 sd->preload_status = EFL_UI_IMAGE_PRELOADING;
960 evas_object_image_preload(sd->img, EINA_FALSE);
961 }
962
963 _efl_ui_image_sizing_eval(obj);
894} 964}
895 965
896static Eina_Bool 966static Eina_Error
897_efl_ui_image_smart_internal_file_set(Eo *obj, Efl_Ui_Image_Data *sd, 967_efl_ui_image_smart_internal_file_set(Eo *obj, Efl_Ui_Image_Data *sd)
898 const char *file, const Eina_File *f, const char *key)
899{ 968{
900 Evas_Load_Error err; 969 Eina_Error err;
970 const Eina_File *f;
971 const char *key;
972 const char *file = efl_file_get(obj);
901 973
902 if (eina_str_has_extension(file, ".edj")) 974 if (eina_str_has_extension(file, ".edj"))
903 return _efl_ui_image_edje_file_set(obj, file, f, key); 975 return _efl_ui_image_edje_file_set(obj);
976
977 err = efl_file_load(efl_super(obj, MY_CLASS));
978 if (err) return err;
979
980 f = efl_file_mmap_get(obj);
981 key = efl_file_key_get(obj);
904 982
905 _efl_ui_image_file_set_do(obj); 983 _efl_ui_image_file_set_do(obj);
906 984
907 if (f) 985 evas_object_image_mmap_set(sd->img, f, key);
908 evas_object_image_mmap_set(sd->img, f, key);
909 else
910 evas_object_image_file_set(sd->img, file, key);
911 986
912 err = evas_object_image_load_error_get(sd->img); 987 err = evas_object_image_load_error_get(sd->img);
913 if (err != EVAS_LOAD_ERROR_NONE) 988 if (err)
914 { 989 {
915 if (file || f) 990 if (file || f)
916 { 991 {
917 if (key) 992 if (key)
918 ERR("Failed to load image '%s' '%s': %s. (%p)", 993 ERR("Failed to load image '%s' '%s': %s. (%p)",
919 file ? file : eina_file_filename_get(f), key, 994 eina_file_filename_get(f), key,
920 evas_load_error_str(err), obj); 995 evas_load_error_str(err), obj);
921 else 996 else
922 ERR("Failed to load image '%s': %s. (%p)", 997 ERR("Failed to load image '%s': %s. (%p)",
923 file ? file : eina_file_filename_get(f), 998 eina_file_filename_get(f),
924 evas_load_error_str(err), obj); 999 evas_load_error_str(err), obj);
925 } 1000 }
926 else 1001 else
@@ -928,7 +1003,7 @@ _efl_ui_image_smart_internal_file_set(Eo *obj, Efl_Ui_Image_Data *sd,
928 ERR("NULL image file passed! (%p)", obj); 1003 ERR("NULL image file passed! (%p)", obj);
929 } 1004 }
930 _prev_img_del(sd); 1005 _prev_img_del(sd);
931 return EINA_FALSE; 1006 return err;
932 } 1007 }
933 1008
934 if (sd->preload_status == EFL_UI_IMAGE_PRELOAD_DISABLED) 1009 if (sd->preload_status == EFL_UI_IMAGE_PRELOAD_DISABLED)
@@ -942,7 +1017,7 @@ _efl_ui_image_smart_internal_file_set(Eo *obj, Efl_Ui_Image_Data *sd,
942 1017
943 _efl_ui_image_sizing_eval(obj); 1018 _efl_ui_image_sizing_eval(obj);
944 1019
945 return EINA_TRUE; 1020 return 0;
946} 1021}
947 1022
948static void 1023static void
@@ -979,7 +1054,7 @@ _efl_ui_image_remote_copier_done(void *data, const Efl_Event *event EINA_UNUSED)
979 Eina_File *f; 1054 Eina_File *f;
980 Eo *dialer; 1055 Eo *dialer;
981 const char *url; 1056 const char *url;
982 Eina_Bool ret = EINA_FALSE; 1057 Eina_Error ret;
983 1058
984 /* we're called from _efl_ui_image_remote_copier_cancel() */ 1059 /* we're called from _efl_ui_image_remote_copier_cancel() */
985 if (!sd->remote.copier) return; 1060 if (!sd->remote.copier) return;
@@ -997,11 +1072,11 @@ _efl_ui_image_remote_copier_done(void *data, const Efl_Event *event EINA_UNUSED)
997 eina_binbuf_string_get(sd->remote.binbuf), 1072 eina_binbuf_string_get(sd->remote.binbuf),
998 eina_binbuf_length_get(sd->remote.binbuf), 1073 eina_binbuf_length_get(sd->remote.binbuf),
999 EINA_FALSE); 1074 EINA_FALSE);
1000 1075 efl_file_mmap_set(obj, f);
1001 ret = _efl_ui_image_smart_internal_file_set(obj, sd, url, f, sd->remote.key); 1076 ret = _efl_ui_image_smart_internal_file_set(obj, sd);
1002 eina_file_close(f); 1077 eina_file_close(f);
1003 1078
1004 if (!ret) 1079 if (ret)
1005 { 1080 {
1006 Efl_Ui_Image_Error err = { 0, EINA_TRUE }; 1081 Efl_Ui_Image_Error err = { 0, EINA_TRUE };
1007 1082
@@ -1057,11 +1132,12 @@ EFL_CALLBACKS_ARRAY_DEFINE(_efl_ui_image_remote_copier_cbs,
1057 { EFL_IO_COPIER_EVENT_PROGRESS, _efl_ui_image_remote_copier_progress }); 1132 { EFL_IO_COPIER_EVENT_PROGRESS, _efl_ui_image_remote_copier_progress });
1058 1133
1059static Eina_Bool 1134static Eina_Bool
1060_efl_ui_image_download(Eo *obj, Efl_Ui_Image_Data *sd, const char *url, const char *key) 1135_efl_ui_image_download(Eo *obj, Efl_Ui_Image_Data *sd, const char *url)
1061{ 1136{
1062 Eo *dialer; 1137 Eo *dialer;
1063 Efl_Ui_Image_Error img_err = { ENOSYS, EINA_FALSE }; 1138 Efl_Ui_Image_Error img_err = { ENOSYS, EINA_FALSE };
1064 Eina_Error err; 1139 Eina_Error err;
1140 const char *key = efl_file_key_get(obj);
1065 1141
1066 dialer = efl_add(EFL_NET_DIALER_HTTP_CLASS, obj, 1142 dialer = efl_add(EFL_NET_DIALER_HTTP_CLASS, obj,
1067 efl_net_dialer_http_allow_redirects_set(efl_added, EINA_TRUE)); 1143 efl_net_dialer_http_allow_redirects_set(efl_added, EINA_TRUE));
@@ -1096,72 +1172,6 @@ _efl_ui_image_download(Eo *obj, Efl_Ui_Image_Data *sd, const char *url, const ch
1096 return EINA_FALSE; 1172 return EINA_FALSE;
1097} 1173}
1098 1174
1099static const Eina_Slice remote_uri[] = {
1100 EINA_SLICE_STR_LITERAL("http://"),
1101 EINA_SLICE_STR_LITERAL("https://"),
1102 EINA_SLICE_STR_LITERAL("ftp://"),
1103 { }
1104};
1105
1106static inline Eina_Bool
1107_efl_ui_image_is_remote(const char *file)
1108{
1109 Eina_Slice s = EINA_SLICE_STR(file);
1110 const Eina_Slice *itr;
1111
1112 for (itr = remote_uri; itr->mem; itr++)
1113 if (eina_slice_startswith(s, *itr))
1114 return EINA_TRUE;
1115
1116 return EINA_FALSE;
1117}
1118
1119EOLIAN static Eina_Bool
1120_efl_ui_image_efl_file_file_set(Eo *obj, Efl_Ui_Image_Data *sd, const char *file, const char *key)
1121{
1122 Eina_Bool ret = EINA_FALSE;
1123
1124 _async_cancel(sd);
1125
1126 /* stop preloading as it may hit to-be-freed memory */
1127 if (sd->img && sd->preload_status == EFL_UI_IMAGE_PRELOADING)
1128 evas_object_image_preload(sd->img, EINA_TRUE);
1129
1130 if (sd->remote.copier) _efl_ui_image_remote_copier_cancel(obj, sd);
1131 if (sd->remote.binbuf) ELM_SAFE_FREE(sd->remote.binbuf, eina_binbuf_free);
1132
1133 if (sd->anim)
1134 {
1135 ELM_SAFE_FREE(sd->anim_timer, ecore_timer_del);
1136 sd->play = EINA_FALSE;
1137 sd->anim = EINA_FALSE;
1138 }
1139
1140 if (!file)
1141 {
1142 if (sd->prev_img)
1143 _prev_img_del(sd);
1144 return _efl_ui_image_smart_internal_file_set(obj, sd, file, NULL, key);;
1145 }
1146
1147 if (_efl_ui_image_is_remote(file))
1148 {
1149 evas_object_hide(sd->img);
1150 if (_efl_ui_image_download(obj, sd, file, key))
1151 {
1152 evas_object_smart_callback_call(obj, SIG_DOWNLOAD_START, NULL);
1153 return EINA_TRUE;
1154 }
1155 }
1156
1157 if (!sd->async_enable)
1158 ret = _efl_ui_image_smart_internal_file_set(obj, sd, file, NULL, key);
1159 else
1160 ret = _efl_ui_image_async_file_set(obj, sd, file, NULL, key);
1161
1162 return ret;
1163}
1164
1165EOLIAN static const char* 1175EOLIAN static const char*
1166_efl_ui_image_efl_layout_group_group_data_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, const char *key) 1176_efl_ui_image_efl_layout_group_group_data_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, const char *key)
1167{ 1177{
@@ -1264,18 +1274,6 @@ _efl_ui_image_efl_layout_calc_calc_auto_update_hints_get(const Eo *obj EINA_UNUS
1264 return EINA_TRUE; 1274 return EINA_TRUE;
1265} 1275}
1266 1276
1267EOLIAN static void
1268_efl_ui_image_efl_file_file_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, const char **file, const char **key)
1269{
1270 if (sd->async.th)
1271 {
1272 if (file) *file = sd->async.file;
1273 if (key) *key = sd->async.key;
1274 return;
1275 }
1276 efl_file_get(sd->img, file, key);
1277}
1278
1279#if 0 1277#if 0
1280// Kept for reference: wait for async open to complete - probably unused. 1278// Kept for reference: wait for async open to complete - probably unused.
1281static Eina_Bool 1279static Eina_Bool
@@ -1725,7 +1723,7 @@ _icon_freedesktop_set(Evas_Object *obj, const char *name, int size)
1725 if (sd->freedesktop.use) 1723 if (sd->freedesktop.use)
1726 { 1724 {
1727 sd->freedesktop.requested_size = size; 1725 sd->freedesktop.requested_size = size;
1728 efl_file_set(obj, path, NULL); 1726 efl_file_simple_load(obj, path, NULL);
1729 return EINA_TRUE; 1727 return EINA_TRUE;
1730 } 1728 }
1731 return EINA_FALSE; 1729 return EINA_FALSE;
@@ -1793,7 +1791,7 @@ _internal_efl_ui_image_icon_set(Evas_Object *obj, const char *name, Eina_Bool *f
1793 { 1791 {
1794 if (fdo) 1792 if (fdo)
1795 *fdo = EINA_FALSE; 1793 *fdo = EINA_FALSE;
1796 return efl_file_set(obj, name, NULL); 1794 return efl_file_simple_load(obj, name, NULL);
1797 } 1795 }
1798 1796
1799 /* if that fails, see if icon name is in the format size/name. if so, 1797 /* if that fails, see if icon name is in the format size/name. if so,
@@ -1875,13 +1873,13 @@ _update_viewmodel(Eo *obj, Efl_Ui_Image_Data *pd)
1875 { 1873 {
1876 eina_value_get(vfile, &f); 1874 eina_value_get(vfile, &f);
1877 1875
1878 efl_file_mmap_set(obj, f, key); 1876 efl_file_simple_mmap_load(obj, f, key);
1879 } 1877 }
1880 else 1878 else
1881 { 1879 {
1882 file = eina_value_to_string(vfile); 1880 file = eina_value_to_string(vfile);
1883 1881
1884 efl_file_set(obj, file, key); 1882 efl_file_simple_load(obj, file, key);
1885 } 1883 }
1886 } 1884 }
1887 1885
@@ -1951,7 +1949,7 @@ _efl_ui_image_efl_ui_view_model_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data
1951 return pd->property.model; 1949 return pd->property.model;
1952} 1950}
1953 1951
1954EOLIAN static void 1952EOLIAN static Eina_Error
1955_efl_ui_image_efl_ui_property_bind_property_bind(Eo *obj, Efl_Ui_Image_Data *pd, const char *key, const char *property) 1953_efl_ui_image_efl_ui_property_bind_property_bind(Eo *obj, Efl_Ui_Image_Data *pd, const char *key, const char *property)
1956{ 1954{
1957 if (strcmp(key, "filename") == 0) 1955 if (strcmp(key, "filename") == 0)
@@ -1969,9 +1967,10 @@ _efl_ui_image_efl_ui_property_bind_property_bind(Eo *obj, Efl_Ui_Image_Data *pd,
1969 { 1967 {
1970 eina_stringshare_replace(&pd->property.key, property); 1968 eina_stringshare_replace(&pd->property.key, property);
1971 } 1969 }
1972 else return; 1970 else return EINA_FALSE;
1973 1971
1974 _update_viewmodel(obj, pd); 1972 _update_viewmodel(obj, pd);
1973 return 0;
1975} 1974}
1976 1975
1977EAPI void 1976EAPI void
@@ -2010,7 +2009,7 @@ elm_image_file_set(Evas_Object *obj, const char *file, const char *group)
2010 Eina_Bool ret = EINA_FALSE; 2009 Eina_Bool ret = EINA_FALSE;
2011 2010
2012 EFL_UI_IMAGE_CHECK(obj) EINA_FALSE; 2011 EFL_UI_IMAGE_CHECK(obj) EINA_FALSE;
2013 ret = efl_file_set(obj, file, group); 2012 ret = efl_file_simple_load(obj, file, group);
2014 _efl_ui_image_sizing_eval(obj); 2013 _efl_ui_image_sizing_eval(obj);
2015 return ret; 2014 return ret;
2016} 2015}
@@ -2018,14 +2017,14 @@ elm_image_file_set(Evas_Object *obj, const char *file, const char *group)
2018EAPI void 2017EAPI void
2019elm_image_file_get(const Eo *obj, const char **file, const char **group) 2018elm_image_file_get(const Eo *obj, const char **file, const char **group)
2020{ 2019{
2021 efl_file_get((Eo *) obj, file, group); 2020 efl_file_simple_get((Eo *) obj, file, group);
2022} 2021}
2023 2022
2024EAPI Eina_Bool 2023EAPI Eina_Bool
2025elm_image_mmap_set(Evas_Object *obj, const Eina_File *file, const char *group) 2024elm_image_mmap_set(Evas_Object *obj, const Eina_File *file, const char *group)
2026{ 2025{
2027 EFL_UI_IMAGE_CHECK(obj) EINA_FALSE; 2026 EFL_UI_IMAGE_CHECK(obj) EINA_FALSE;
2028 return efl_file_mmap_set(obj, file, group); 2027 return efl_file_simple_mmap_load(obj, file, group);
2029} 2028}
2030 2029
2031EAPI Eina_Bool 2030EAPI Eina_Bool
@@ -2287,7 +2286,7 @@ ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(efl_ui_image, Efl_Ui_Image_Data)
2287 2286
2288#include "efl_ui_image.eo.c" 2287#include "efl_ui_image.eo.c"
2289 2288
2290#include "efl_ui_image_legacy.eo.h" 2289#include "efl_ui_image_legacy_eo.h"
2291 2290
2292#define MY_CLASS_NAME_LEGACY "elm_image" 2291#define MY_CLASS_NAME_LEGACY "elm_image"
2293 2292
@@ -2317,4 +2316,4 @@ elm_image_add(Evas_Object *parent)
2317 return obj; 2316 return obj;
2318} 2317}
2319 2318
2320#include "efl_ui_image_legacy.eo.c" 2319#include "efl_ui_image_legacy_eo.c"