davemds pushed a commit to branch master.

http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=61590afc6f86cd1ff800f19b3387b54f606386b0

commit 61590afc6f86cd1ff800f19b3387b54f606386b0
Author: Dave Andreoli <d...@gurumeditation.it>
Date:   Tue Apr 14 22:21:35 2015 +0200

    New 1.14 API: file_get for Video and Layout
    
    with stupid tests
---
 efl/elementary/layout_class.pyx    | 12 ++++++++++++
 efl/elementary/video.pxd           |  1 +
 efl/elementary/video.pyx           | 11 +++++++++++
 examples/elementary/test_layout.py |  2 ++
 examples/elementary/test_video.py  |  2 ++
 5 files changed, 28 insertions(+)

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):
         .. versionchanged:: 1.8
             Raises RuntimeError if setting the file fails
 
+        .. versionchanged:: 1.14
+            Property is now also readable
+
         """
         def __set__(self, value):
             filename, group = value
@@ -203,6 +206,13 @@ cdef class LayoutClass(Object):
                 <const char *>group if group is not None else NULL):
                     raise RuntimeError("Could not set file.")
 
+        def __get__(self):
+            cdef:
+                const char *file
+                const char *group
+            elm_layout_file_get(self.obj, &file, &group)
+            return (_ctouni(file), _ctouni(group)) 
+
     def file_set(self, filename, group = None):
         if isinstance(filename, unicode): filename = 
PyUnicode_AsUTF8String(filename)
         if isinstance(group, unicode): group = PyUnicode_AsUTF8String(group)
@@ -210,6 +220,8 @@ cdef class LayoutClass(Object):
             <const char *>filename if filename is not None else NULL,
             <const char *>group if group is not None else NULL):
                 raise RuntimeError("Could not set file.")
+    def file_get(self):
+        return self.file
 
     def freeze(self):
         """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":
     Evas_Object             *elm_player_add(Evas_Object *parent)
     Evas_Object             *elm_video_add(Evas_Object *parent)
     Eina_Bool                elm_video_file_set(Evas_Object *video, const char 
*filename)
+    void                     elm_video_file_get(Evas_Object *video, const char 
**filename)
     Evas_Object             *elm_video_emotion_get(const Evas_Object *video)
     void                     elm_video_play(Evas_Object *video)
     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):
         .. versionchanged:: 1.8
             Raises RuntimeError if setting the file/uri fails
 
+        .. versionchanged:: 1.14
+            Property is now also readable
+
         """
         def __set__(self, filename):
             if isinstance(filename, unicode): filename = 
PyUnicode_AsUTF8String(filename)
@@ -95,12 +98,20 @@ cdef class Video(LayoutClass):
                 <const char *>filename if filename is not None else NULL):
                     raise RuntimeError("Could not set file.")
 
+        def __get__(self):
+            cdef:
+                const char *file
+            elm_video_file_get(self.obj, &file)
+            return _ctouni(file)
+
     # NOTE: clash with layout.file_set
     def file_set(self, filename, group = None):
         if isinstance(filename, unicode): filename = 
PyUnicode_AsUTF8String(filename)
         if not elm_video_file_set(self.obj,
             <const char *>filename if filename is not None else NULL):
                 raise RuntimeError("Could not set file.")
+    def file_get(self):
+        return self.file
 
     property emotion:
         """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):
         size_hint_weight=EXPAND_BOTH)
     win.resize_object_add(ly)
     ly.show()
+    print(ly.file)
+    print(ly.file_get())
 
     bt = Button(win, text="Button 1")
     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):
     if (vfile and video):
         video.file_set(vfile)
         video.play()
+    print(video.file)
+    print(video.file_get())
 
 def notify_show(video, event, no):
     no.show()

-- 


Reply via email to