New 1.18 API: elm.GengridItem.all_contents_unset()
with test
This commit is contained in:
parent
83656bff33
commit
9381d46765
|
@ -121,6 +121,8 @@ cdef extern from "Elementary.h":
|
|||
void elm_gengrid_item_bring_in(Elm_Object_Item *item, Elm_Genlist_Item_Scrollto_Type scrollto_type)
|
||||
void elm_gengrid_item_update(Elm_Object_Item *item)
|
||||
void elm_gengrid_item_pos_get(const Elm_Object_Item *item, unsigned int *x, unsigned int *y)
|
||||
void elm_gengrid_item_all_contents_unset(Elm_Object_Item *obj, Eina_List **l)
|
||||
|
||||
Elm_Object_Item * elm_gengrid_nth_item_get(const Evas_Object *obj, unsigned int nth)
|
||||
Elm_Object_Item * elm_gengrid_at_xy_item_get(const Evas_Object *obj, Evas_Coord x, Evas_Coord y, int *xposret, int *yposret)
|
||||
Elm_Object_Item * elm_gengrid_search_by_text_item_get(const Evas_Object *obj, Elm_Object_Item *item_to_search_from, const char *part_name, const char *pattern, Elm_Glob_Match_Flags flags)
|
||||
|
|
|
@ -318,3 +318,28 @@ cdef class GengridItem(ObjectItem):
|
|||
def select_mode_get(self):
|
||||
return elm_gengrid_item_select_mode_get(self.item)
|
||||
|
||||
def all_contents_unset(self):
|
||||
"""Unset all contents fetched by the item class
|
||||
|
||||
This instructs gengrid to release references to contents in the item,
|
||||
meaning that they will no longer be managed by gengrid and are
|
||||
floating "orphans" that can be re-used elsewhere.
|
||||
|
||||
: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 *l = NULL
|
||||
list ret
|
||||
elm_gengrid_item_all_contents_unset(self.item, &l)
|
||||
ret = eina_list_objects_to_python_list(l)
|
||||
eina_list_free(l)
|
||||
return ret
|
||||
|
||||
|
|
|
@ -308,6 +308,24 @@ def gengrid_clicked(obj):
|
|||
tb.pack(bt, 4, 4, 1, 1)
|
||||
bt.show()
|
||||
|
||||
# item content unset
|
||||
def content_unset_clicked(bt, gg):
|
||||
item = gg.selected_item
|
||||
if item is None:
|
||||
print("You must select an item first!")
|
||||
else:
|
||||
contents = item.all_contents_unset()
|
||||
for obj in contents:
|
||||
obj.pos = (0, 0)
|
||||
obj.show()
|
||||
# Now all the unsetted objects are orphan in the canvas,
|
||||
# the user should do something with them
|
||||
|
||||
bt = Button(win, size_hint_align=FILL_HORIZ, text="Item content unset")
|
||||
bt.callback_clicked_add(content_unset_clicked, gg)
|
||||
tb.pack(bt, 5, 4, 1, 1)
|
||||
bt.show()
|
||||
|
||||
# scroll_to methods
|
||||
rdg = rd = Radio(win, text='SCROLL_IN',
|
||||
state_value=elm.ELM_GENGRID_ITEM_SCROLLTO_IN)
|
||||
|
|
Loading…
Reference in New Issue