davemds pushed a commit to branch master.

http://git.enlightenment.org/bindings/python/python-efl.git/commit/?id=99113cd9909de6917d98c35556129e0ec60aea0d

commit 99113cd9909de6917d98c35556129e0ec60aea0d
Author: Dave Andreoli <[email protected]>
Date:   Tue Aug 9 12:56:00 2016 +0200

    Fix implementation of elm.GenlistItem.all_contents_unset()
    
    the old implementation was not working at all, so I marked it @since 1.18
    also added a test for it
---
 efl/elementary/genlist_item.pxi       | 19 ++++++++++++++++---
 examples/elementary/test_genlist_1.py | 19 +++++++++++++++++++
 2 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/efl/elementary/genlist_item.pxi b/efl/elementary/genlist_item.pxi
index 409b52d..259c60d 100644
--- a/efl/elementary/genlist_item.pxi
+++ b/efl/elementary/genlist_item.pxi
@@ -486,10 +486,23 @@ cdef class GenlistItem(ObjectItem):
         item, meaning that they will no longer be managed by genlist and are
         floating "orphans" that can be re-used elsewhere if the user wants to.
 
+        :return: The list of now orphans objects
+        :rtype: list
+
+        .. versionadded:: 1.18
+
+        .. warning:: Don't forget to do something with the returned objects,
+            they are hidden in the canvas, but still alive. You should
+            at least delete them if you don't need to reuse.
+
         """
-        cdef Eina_List *lst
-        elm_genlist_item_all_contents_unset(self.item, &lst)
-        return _object_item_list_to_python(lst)
+        cdef:
+            Eina_List *l = NULL
+            list ret
+        elm_genlist_item_all_contents_unset(self.item, &l)
+        ret = eina_list_objects_to_python_list(l)
+        eina_list_free(l)
+        return ret
 
     def promote(self):
         """Promote an item to the top of the list"""
diff --git a/examples/elementary/test_genlist_1.py 
b/examples/elementary/test_genlist_1.py
index ff67832..3827c73 100644
--- a/examples/elementary/test_genlist_1.py
+++ b/examples/elementary/test_genlist_1.py
@@ -178,6 +178,25 @@ def test_genlist_1(parent):
     hbox.pack_end(bt)
     bt.show()
 
+    # item content unset
+    def content_unset_clicked(bt, gl):
+        item = gl.selected_item
+        if item is None:
+            print("You must select an item first!")
+        else:
+            contents = item.all_contents_unset()
+            print(contents)
+            for obj in contents:
+                obj.pos = (200, 0)
+                obj.show()
+            # Now all the unsetted objects are orphan in the canvas,
+            # the user should do something with them
+        
+    bt = Button(win, text="Item content unset")
+    bt.callback_clicked_add(content_unset_clicked, gl)
+    hbox.pack_end(bt)
+    bt.show()
+
     # show the window
     win.show()
 

-- 


Reply via email to