diff options
author | Dave Andreoli <dave@gurumeditation.it> | 2015-04-14 22:21:35 +0200 |
---|---|---|
committer | Dave Andreoli <dave@gurumeditation.it> | 2015-04-14 22:21:35 +0200 |
commit | 61590afc6f86cd1ff800f19b3387b54f606386b0 (patch) | |
tree | faea11e2609131ca4a0b8b00e353bb34037df977 | |
parent | 3765021dc0fce7b1bd63396a4e05665e7ff45554 (diff) |
New 1.14 API: file_get for Video and Layout
with stupid tests
-rw-r--r-- | efl/elementary/layout_class.pyx | 12 | ||||
-rw-r--r-- | efl/elementary/video.pxd | 1 | ||||
-rw-r--r-- | efl/elementary/video.pyx | 11 | ||||
-rw-r--r-- | examples/elementary/test_layout.py | 2 | ||||
-rw-r--r-- | examples/elementary/test_video.py | 2 |
5 files changed, 28 insertions, 0 deletions
diff --git a/efl/elementary/layout_class.pyx b/efl/elementary/layout_class.pyx index 7949be4..e95becb 100644 --- a/efl/elementary/layout_class.pyx +++ b/efl/elementary/layout_class.pyx | |||
@@ -193,6 +193,9 @@ cdef class LayoutClass(Object): | |||
193 | .. versionchanged:: 1.8 | 193 | .. versionchanged:: 1.8 |
194 | Raises RuntimeError if setting the file fails | 194 | Raises RuntimeError if setting the file fails |
195 | 195 | ||
196 | .. versionchanged:: 1.14 | ||
197 | Property is now also readable | ||
198 | |||
196 | """ | 199 | """ |
197 | def __set__(self, value): | 200 | def __set__(self, value): |
198 | filename, group = value | 201 | filename, group = value |
@@ -203,6 +206,13 @@ cdef class LayoutClass(Object): | |||
203 | <const char *>group if group is not None else NULL): | 206 | <const char *>group if group is not None else NULL): |
204 | raise RuntimeError("Could not set file.") | 207 | raise RuntimeError("Could not set file.") |
205 | 208 | ||
209 | def __get__(self): | ||
210 | cdef: | ||
211 | const char *file | ||
212 | const char *group | ||
213 | elm_layout_file_get(self.obj, &file, &group) | ||
214 | return (_ctouni(file), _ctouni(group)) | ||
215 | |||
206 | def file_set(self, filename, group = None): | 216 | def file_set(self, filename, group = None): |
207 | if isinstance(filename, unicode): filename = PyUnicode_AsUTF8String(filename) | 217 | if isinstance(filename, unicode): filename = PyUnicode_AsUTF8String(filename) |
208 | if isinstance(group, unicode): group = PyUnicode_AsUTF8String(group) | 218 | if isinstance(group, unicode): group = PyUnicode_AsUTF8String(group) |
@@ -210,6 +220,8 @@ cdef class LayoutClass(Object): | |||
210 | <const char *>filename if filename is not None else NULL, | 220 | <const char *>filename if filename is not None else NULL, |
211 | <const char *>group if group is not None else NULL): | 221 | <const char *>group if group is not None else NULL): |
212 | raise RuntimeError("Could not set file.") | 222 | raise RuntimeError("Could not set file.") |
223 | def file_get(self): | ||
224 | return self.file | ||
213 | 225 | ||
214 | def freeze(self): | 226 | def freeze(self): |
215 | """Freezes the Elementary layout object. | 227 | """Freezes the Elementary layout object. |
diff --git a/efl/elementary/video.pxd b/efl/elementary/video.pxd index b35b923..1c2c1eb 100644 --- a/efl/elementary/video.pxd +++ b/efl/elementary/video.pxd | |||
@@ -4,6 +4,7 @@ cdef extern from "Elementary.h": | |||
4 | Evas_Object *elm_player_add(Evas_Object *parent) | 4 | Evas_Object *elm_player_add(Evas_Object *parent) |
5 | Evas_Object *elm_video_add(Evas_Object *parent) | 5 | Evas_Object *elm_video_add(Evas_Object *parent) |
6 | Eina_Bool elm_video_file_set(Evas_Object *video, const char *filename) | 6 | Eina_Bool elm_video_file_set(Evas_Object *video, const char *filename) |
7 | void elm_video_file_get(Evas_Object *video, const char **filename) | ||
7 | Evas_Object *elm_video_emotion_get(const Evas_Object *video) | 8 | Evas_Object *elm_video_emotion_get(const Evas_Object *video) |
8 | void elm_video_play(Evas_Object *video) | 9 | void elm_video_play(Evas_Object *video) |
9 | void elm_video_pause(Evas_Object *video) | 10 | void elm_video_pause(Evas_Object *video) |
diff --git a/efl/elementary/video.pyx b/efl/elementary/video.pyx index 88d10ad..151fe2e 100644 --- a/efl/elementary/video.pyx +++ b/efl/elementary/video.pyx | |||
@@ -88,6 +88,9 @@ cdef class Video(LayoutClass): | |||
88 | .. versionchanged:: 1.8 | 88 | .. versionchanged:: 1.8 |
89 | Raises RuntimeError if setting the file/uri fails | 89 | Raises RuntimeError if setting the file/uri fails |
90 | 90 | ||
91 | .. versionchanged:: 1.14 | ||
92 | Property is now also readable | ||
93 | |||
91 | """ | 94 | """ |
92 | def __set__(self, filename): | 95 | def __set__(self, filename): |
93 | if isinstance(filename, unicode): filename = PyUnicode_AsUTF8String(filename) | 96 | if isinstance(filename, unicode): filename = PyUnicode_AsUTF8String(filename) |
@@ -95,12 +98,20 @@ cdef class Video(LayoutClass): | |||
95 | <const char *>filename if filename is not None else NULL): | 98 | <const char *>filename if filename is not None else NULL): |
96 | raise RuntimeError("Could not set file.") | 99 | raise RuntimeError("Could not set file.") |
97 | 100 | ||
101 | def __get__(self): | ||
102 | cdef: | ||
103 | const char *file | ||
104 | elm_video_file_get(self.obj, &file) | ||
105 | return _ctouni(file) | ||
106 | |||
98 | # NOTE: clash with layout.file_set | 107 | # NOTE: clash with layout.file_set |
99 | def file_set(self, filename, group = None): | 108 | def file_set(self, filename, group = None): |
100 | if isinstance(filename, unicode): filename = PyUnicode_AsUTF8String(filename) | 109 | if isinstance(filename, unicode): filename = PyUnicode_AsUTF8String(filename) |
101 | if not elm_video_file_set(self.obj, | 110 | if not elm_video_file_set(self.obj, |
102 | <const char *>filename if filename is not None else NULL): | 111 | <const char *>filename if filename is not None else NULL): |
103 | raise RuntimeError("Could not set file.") | 112 | raise RuntimeError("Could not set file.") |
113 | def file_get(self): | ||
114 | return self.file | ||
104 | 115 | ||
105 | property emotion: | 116 | property emotion: |
106 | """The underlying Emotion object. | 117 | """The underlying Emotion object. |
diff --git a/examples/elementary/test_layout.py b/examples/elementary/test_layout.py index 36bea8b..2540c9d 100644 --- a/examples/elementary/test_layout.py +++ b/examples/elementary/test_layout.py | |||
@@ -25,6 +25,8 @@ def layout_clicked(obj): | |||
25 | size_hint_weight=EXPAND_BOTH) | 25 | size_hint_weight=EXPAND_BOTH) |
26 | win.resize_object_add(ly) | 26 | win.resize_object_add(ly) |
27 | ly.show() | 27 | ly.show() |
28 | print(ly.file) | ||
29 | print(ly.file_get()) | ||
28 | 30 | ||
29 | bt = Button(win, text="Button 1") | 31 | bt = Button(win, text="Button 1") |
30 | ly.part_content_set("element1", bt) | 32 | ly.part_content_set("element1", bt) |
diff --git a/examples/elementary/test_video.py b/examples/elementary/test_video.py index 3c0cd98..795b58d 100644 --- a/examples/elementary/test_video.py +++ b/examples/elementary/test_video.py | |||
@@ -17,6 +17,8 @@ def my_bt_open(bt, vfile, video): | |||
17 | if (vfile and video): | 17 | if (vfile and video): |
18 | video.file_set(vfile) | 18 | video.file_set(vfile) |
19 | video.play() | 19 | video.play() |
20 | print(video.file) | ||
21 | print(video.file_get()) | ||
20 | 22 | ||
21 | def notify_show(video, event, no): | 23 | def notify_show(video, event, no): |
22 | no.show() | 24 | no.show() |