summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Andreoli <dave@gurumeditation.it>2017-02-26 22:50:25 +0100
committerDave Andreoli <dave@gurumeditation.it>2017-02-26 22:50:25 +0100
commit71354b3bb8a0ec3c22a728a285e455fd1266500b (patch)
treeca8e1215dee296c407a7e59b1fff365a65253c8e
parenta293b4e1244cf924174d02df3fd1d4d1e4c01117 (diff)
New 1.19 API: elm.Image.async_open + 4 new callbacks
with test
-rw-r--r--doc/elementary/image.rst7
-rw-r--r--efl/elementary/image.pxi64
-rw-r--r--efl/elementary/image_cdef.pxi1
-rwxr-xr-xexamples/elementary/test.py1
-rw-r--r--examples/elementary/test_image_async.py78
5 files changed, 150 insertions, 1 deletions
diff --git a/doc/elementary/image.rst b/doc/elementary/image.rst
index 8abb85e..1b8d31a 100644
--- a/doc/elementary/image.rst
+++ b/doc/elementary/image.rst
@@ -38,6 +38,13 @@ Emitted signals
38- ``download,progress`` - url download in progress 38- ``download,progress`` - url download in progress
39- ``download,end`` - remote url download has finished 39- ``download,end`` - remote url download has finished
40- ``download,error`` - remote url download has finished with errors 40- ``download,error`` - remote url download has finished with errors
41- ``load,open`` - Triggered when the file has been opened, if async open is
42 enabled (image size is known). (since 1.19)
43- ``load,ready`` - Triggered when the image file is ready for display, if
44 preload is enabled. (since 1.19)
45- ``load,error`` - Triggered if an async I/O or decoding error occurred, if
46 async open or preload is enabled (since 1.19)
47- ``load,cancel`` - Triggered whenener async I/O was cancelled. (since 1.19)
41 48
42 49
43Enumerations 50Enumerations
diff --git a/efl/elementary/image.pxi b/efl/elementary/image.pxi
index 3cf4411..0389aef 100644
--- a/efl/elementary/image.pxi
+++ b/efl/elementary/image.pxi
@@ -406,7 +406,7 @@ cdef class Image(Object):
406 property preload_disabled: 406 property preload_disabled:
407 """Enable or disable preloading of the image 407 """Enable or disable preloading of the image
408 408
409 :type: bool 409 :type: bool (**writeonly**)
410 410
411 """ 411 """
412 def __set__(self, disabled): 412 def __set__(self, disabled):
@@ -415,6 +415,22 @@ cdef class Image(Object):
415 def preload_disabled_set(self, disabled): 415 def preload_disabled_set(self, disabled):
416 elm_image_preload_disabled_set(self.obj, disabled) 416 elm_image_preload_disabled_set(self.obj, disabled)
417 417
418 property async_open:
419 """ Enable asynchronous file I/O for file set.
420
421 If True, this will make elm_image_file_set() an asynchronous operation.
422
423 :type: bool (**writeonly**)
424
425 .. versionadded:: 1.19
426
427 """
428 def __set__(self, bint async):
429 elm_image_async_open_set(self.obj, async)
430
431 def async_open_set(self, bint async):
432 elm_image_async_open_set(self.obj, async)
433
418 property orient: 434 property orient:
419 """The image orientation. 435 """The image orientation.
420 436
@@ -602,5 +618,51 @@ cdef class Image(Object):
602 def callback_download_error_del(self, func): 618 def callback_download_error_del(self, func):
603 self._callback_del_full("download,error", _image_download_error_conv, func) 619 self._callback_del_full("download,error", _image_download_error_conv, func)
604 620
621 def callback_load_open_add(self, func, *args, **kwargs):
622 """ Triggered when the file has been opened, if async open is enabled
623 (image size is known)
624
625 .. versionadded:: 1.19
626
627 """
628 self._callback_add("load,open", func, args, kwargs)
629
630 def callback_load_open_del(self, func):
631 self._callback_del("load,open", func)
632
633 def callback_load_ready_add(self, func, *args, **kwargs):
634 """ Triggered when the image file is ready for display,
635 if preload is enabled
636
637 .. versionadded:: 1.19
638
639 """
640 self._callback_add("load,ready", func, args, kwargs)
641
642 def callback_load_ready_del(self, func):
643 self._callback_del("load,ready", func)
644
645 def callback_load_error_add(self, func, *args, **kwargs):
646 """ Triggered if an async I/O or decoding error occurred,
647 if async open or preload is enabled
648
649 .. versionadded:: 1.19
650
651 """
652 self._callback_add("load,error", func, args, kwargs)
653
654 def callback_load_error_del(self, func):
655 self._callback_del("load,error", func)
656
657 def callback_load_cancel_add(self, func, *args, **kwargs):
658 """ Triggered whenener async I/O was cancelled
659
660 .. versionadded:: 1.19
661
662 """
663 self._callback_add("load,cancel", func, args, kwargs)
664
665 def callback_load_cancel_del(self, func):
666 self._callback_del("load,cancel", func)
605 667
606_object_mapping_register("Efl.Ui.Image", Image) 668_object_mapping_register("Efl.Ui.Image", Image)
diff --git a/efl/elementary/image_cdef.pxi b/efl/elementary/image_cdef.pxi
index f187cd3..a3f7531 100644
--- a/efl/elementary/image_cdef.pxi
+++ b/efl/elementary/image_cdef.pxi
@@ -38,3 +38,4 @@ cdef extern from "Elementary.h":
38 Eina_Bool elm_image_no_scale_get(const Evas_Object *obj) 38 Eina_Bool elm_image_no_scale_get(const Evas_Object *obj)
39 void elm_image_aspect_fixed_set(Evas_Object *obj, Eina_Bool fixed) 39 void elm_image_aspect_fixed_set(Evas_Object *obj, Eina_Bool fixed)
40 Eina_Bool elm_image_aspect_fixed_get(const Evas_Object *obj) 40 Eina_Bool elm_image_aspect_fixed_get(const Evas_Object *obj)
41 void elm_image_async_open_set(Evas_Object *obj, Eina_Bool async)
diff --git a/examples/elementary/test.py b/examples/elementary/test.py
index bcb5aa5..3192006 100755
--- a/examples/elementary/test.py
+++ b/examples/elementary/test.py
@@ -157,6 +157,7 @@ items = [
157 ("Icon Standard", "test_icon", "icon_standard_clicked"), 157 ("Icon Standard", "test_icon", "icon_standard_clicked"),
158 ("Image", "test_image", "test_image"), 158 ("Image", "test_image", "test_image"),
159 ("Image with memfile", "test_image_memfile", "test_image_memfile"), 159 ("Image with memfile", "test_image_memfile", "test_image_memfile"),
160 ("Image async load", "test_image_async", "test_image_async"),
160 ("Photo", "test_photo", "photo_clicked"), 161 ("Photo", "test_photo", "photo_clicked"),
161 ("Photocam", "test_photocam", "photocam_clicked"), 162 ("Photocam", "test_photocam", "photocam_clicked"),
162 ("Slideshow", "test_slideshow", "slideshow_clicked"), 163 ("Slideshow", "test_slideshow", "slideshow_clicked"),
diff --git a/examples/elementary/test_image_async.py b/examples/elementary/test_image_async.py
new file mode 100644
index 0000000..016f5dd
--- /dev/null
+++ b/examples/elementary/test_image_async.py
@@ -0,0 +1,78 @@
1#!/usr/bin/env python
2# encoding: utf-8
3
4import os
5
6from efl import elementary as elm
7from efl.elementary import StandardWindow, Box, Image, Check, Button
8from efl.evas import EXPAND_BOTH, FILL_BOTH, EXPAND_HORIZ, FILL_HORIZ
9
10
11script_path = os.path.dirname(os.path.abspath(__file__))
12img_path = os.path.join(script_path, "images")
13img_file = os.path.join(img_path, "insanely_huge_test_image.jpg")
14
15
16def create_image(win):
17 box = win.data["box"]
18 async = win.data["async_chk"].state
19 preload_disabled = win.data["preload_chk"].state
20
21 if "image" in win.data:
22 print("Deleting old image")
23 win.data["image"].delete()
24
25 print("Creating image, async: %s, preload_disabled: %s" % (
26 async, preload_disabled))
27
28 im = Image(win, async_open=async, preload_disabled=preload_disabled,
29 size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
30 box.pack_start(im)
31 win.data["image"] = im
32
33 im.callback_load_open_add(lambda i: print("load,open"))
34 im.callback_load_ready_add(lambda i: print("load,ready"))
35 im.callback_load_error_add(lambda i: print("load,error"))
36 im.callback_load_cancel_add(lambda i: print("load,cancel"))
37
38 im.show()
39 im.file = img_file
40
41
42def test_image_async(obj, it=None):
43 win = StandardWindow("image-async", "Image Async Test",
44 autodel=True, size=(320, 480))
45
46 box = Box(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
47 win.resize_object_add(box)
48 box.show()
49 win.data["box"] = box
50
51 hbox = Box(box, horizontal=True,
52 size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
53 box.pack_end(hbox)
54 hbox.show()
55
56 ck = Check(hbox, text="Async file open")
57 hbox.pack_end(ck)
58 ck.show()
59 win.data["async_chk"] = ck
60
61 ck = Check(hbox, text="Disable preload")
62 hbox.pack_end(ck)
63 ck.show()
64 win.data["preload_chk"] = ck
65
66 bt = Button(box, text="Image Reload")
67 bt.callback_clicked_add(lambda b: create_image(win))
68 box.pack_end(bt)
69 bt.show()
70
71 create_image(win)
72 win.show()
73
74
75if __name__ == "__main__":
76 elm.policy_set(elm.ELM_POLICY_QUIT, elm.ELM_POLICY_QUIT_LAST_WINDOW_CLOSED)
77 test_image_async(None)
78 elm.run()