Genlist

../_images/genlist-preview.png

Widget description

This widget aims to have more expansive list than the simple list in Elementary that could have more flexible items and allow many more entries while still being fast and low on memory usage. At the same time it was also made to be able to do tree structures. But the price to pay is more complexity when it comes to usage. If all you want is a simple list (not much items) with icons and a single text, use the normal List object.

Genlist has a fairly large API, mostly because it’s relatively complex, trying to be both expansive, powerful and efficient. First we will begin an overview on the theory behind genlist.

Genlist item classes - creating items

In order to have the ability to add and delete items on the fly, genlist implements the item class (callback) system where the application provides a structure with information about that type of item (genlist may contain multiple different items with different classes, states and styles). Genlist will call the functions in this class (methods) when an item is “realized” (i.e., created dynamically, while the user is scrolling the grid). All objects will simply be deleted when no longer needed with efl.evas.Object.delete(). GenlistItemClass contains the following members:

  • item_style - This is a constant string and define the name of the default item style. It must be provided.

  • decorate_item_style - This is a constant string and define the name of the style to be used in the “decorate” mode. See GenlistItem.decorate_mode.

  • decorate_all_item_style - This is a constant string and define the name of the style to be used in the “decorate all” mode. See Genlist.decorate_mode.

  • text_get - This function will be called for every text part. Should return the text to display. See GenlistItemClass.text_get().

  • content_get - This function will be called for every content part. Should return an object to display, the object will be deleted by the genlist on its deletion or when the item is “unrealized”. See GenlistItemClass.content_get().

  • state_get - This function will be called for every state part. Must return True for false/off or True for true/on. Genlists will emit a signal to its theming Edje object with "elm,state,xxx,active" and "elm" as “emission” and “source” arguments, respectively, when the state is true (the default is false), where xxx is the name of the (state) part. See GenlistItemClass.state_get().

  • func.del - This is intended for use when genlist items are deleted, so any data attached to the item (e.g. its data parameter on creation) can be deleted. See GenlistItemClass.delete().

Available item styles

  • default The default style: icon, text, end icon

  • default_style The text part is a textblock and can use markups

  • double_label Two different text parts

  • icon_top_text_bottom

  • group_index

  • one_icon Only 1 icon (left) (since: 1.1)

  • end_icon Only 1 icon (at end/right) (since: 1.1)

  • no_icon No icon (since: 1.1)

  • full Only one object, elm.swallow.content, which consumes whole area of the genlist item (since: 1.7)

  • indent Has indentation to match tree group items (since: 1.19)

Structure of items

An item in a genlist can have 0 or more texts (they can be regular text or textblock Evas objects - that’s up to the style to determine), 0 or more contents (which are simply objects swallowed into the genlist item’s theming Edje object) and 0 or more boolean states, which have the behavior left to the user to define. The Edje part names for each of these properties will be looked up, in the theme file for the genlist, under the Edje (string) data items named labels, contents and states, respectively. For each of those properties, if more than one part is provided, they must have names listed separated by spaces in the data fields. For the default genlist item theme, we have one text part (elm.text), two content parts (elm.swallow.icon and elm.swallow.end) and no state parts.

Editing and Navigating

Items can be added by several calls. All of them return a GenlistItem handle that is an internal member inside the genlist. They all take a data parameter that is meant to be used for a handle to the applications internal data (eg. the struct with the original item data). The parent parameter is the parent genlist item this belongs to if it is a tree or an indexed group, and None if there is no parent. The flags can be a bitmask of ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_TREE and ELM_GENLIST_ITEM_GROUP. If ELM_GENLIST_ITEM_TREE is set then this item is displayed as an item that is able to expand and have child items. If ELM_GENLIST_ITEM_GROUP is set then this item is group index item that is displayed at the top until the next group comes. The func parameter is a convenience callback that is called when the item is selected and the data parameter will be the func_data parameter, obj be the genlist object and event_info will be the genlist item.

GenlistItem.append_to() adds an item to the end of the list, or if there is a parent, to the end of all the child items of the parent. GenlistItem.prepend_to() is the same but adds to the beginning of the list or children list. GenlistItem.insert_before() inserts at item before another item and GenlistItem.insert_after() inserts after the indicated item.

The application can clear the list with Genlist.clear() which deletes all the items in the list and delete() will delete a specific item. GenlistItem.subitems_clear() will clear all items that are children of the indicated parent item.

To help inspect list items you can jump to the item at the top of the list with Genlist.first_item which will return the first item, and similarly Genlist.last_item gets the item at the end of the list. GenlistItem.next and GenlistItem.prev get the next and previous items respectively relative to the indicated item. Using these calls you can walk the entire item list/tree. Note that as a tree the items are flattened in the list, so GenlistItem.parent will let you know which item is the parent (and thus know how to skip them if wanted).

Multi-selection

If the application wants multiple items to be able to be selected, Genlist.multi_select can enable this. If the list is single-selection only (the default), then Genlist.selected_item will return the selected item, if any, or None if none is selected. If the list is multi-select then Genlist.selected_items will return a list (that is only valid as long as no items are modified (added, deleted, selected or unselected)).

Usage hints

There are also convenience functions. efl.elementary.object_item.ObjectItem.widget will return the genlist object the item belongs to. GenlistItem.show() will make the scroller scroll to show that specific item so its visible. efl.elementary.object_item.ObjectItem.data returns the data pointer set by the item creation functions.

If an item changes (state of boolean changes, text or contents change), then use GenlistItem.update() to have genlist update the item with the new state. Genlist will re-realize the item and thus call the functions in the _Elm_Genlist_Item_Class for that item.

Use GenlistItem.selected to programmatically (un)select an item or get its selected state. Similarly to expand/contract an item and get its expanded state, use GenlistItem.expanded. And again to make an item disabled (unable to be selected and appear differently) use GenlistItem.disabled to set this and get the disabled state.

In general to indicate how the genlist should expand items horizontally to fill the list area, use Genlist.mode. Valid modes are ELM_LIST_LIMIT, ELM_LIST_COMPRESS and ELM_LIST_SCROLL. The default is ELM_LIST_SCROLL. This mode means that if items are too wide to fit, the scroller will scroll horizontally. Otherwise items are expanded to fill the width of the viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded to the viewport width if larger than the item, but genlist widget with is limited to the largest item. D not use ELM_LIST_LIMIT mode with homogeneous mode turned on. ELM_LIST_COMPRESS can be combined with a different style that uses Edje’s ellipsis feature (cutting text off like this: “tex…”).

Items will only call their selection func and callback when first becoming selected. Any further clicks will do nothing, unless you enable always select with Genlist.select_mode as ELM_OBJECT_SELECT_MODE_ALWAYS. This means even if selected, every click will make the selected callbacks be called. Genlist.select_mode as ELM_OBJECT_SELECT_MODE_NONE will turn off the ability to select items entirely and they will neither appear selected nor call selected callback functions.

Remember that you can create new styles and add your own theme augmentation per application with efl.elementary.theme.Theme.extension_add(). If you absolutely must have a specific style that overrides any theme the user or system sets up you can use efl.elementary.theme.Theme.overlay_add() to add such a file.

Scrollable Interface

This widget supports the scrollable interface.

If you wish to control the scrolling behaviour using these functions, inherit both the widget class and the Scrollable class using multiple inheritance, for example:

class ScrollableGenlist(Genlist, Scrollable):
    def __init__(self, canvas, *args, **kwargs):
        Genlist.__init__(self, canvas)

Implementation

Evas tracks every object you create. Every time it processes an event (mouse move, down, up etc.) it needs to walk through objects and find out what event that affects. Even worse every time it renders display updates, in order to just calculate what to re-draw, it needs to walk through many many many objects. Thus, the more objects you keep active, the more overhead Evas has in just doing its work. It is advisable to keep your active objects to the minimum working set you need. Also remember that object creation and deletion carries an overhead, so there is a middle-ground, which is not easily determined. But don’t keep massive lists of objects you can’t see or use. Genlist does this with list objects. It creates and destroys them dynamically as you scroll around. It groups them into blocks so it can determine the visibility etc. of a whole block at once as opposed to having to walk the whole list. This 2-level list allows for very large numbers of items to be in the list (tests have used up to 2,000,000 items). Also genlist employs a queue for adding items. As items may be different sizes, every item added needs to be calculated as to its size and thus this presents a lot of overhead on populating the list, this genlist employs a queue. Any item added is queued and spooled off over time, actually appearing some time later, so if your list has many members you may find it takes a while for them to all appear, with your process consuming a lot of CPU while it is busy spooling.

Genlist also implements a tree structure, but it does so with callbacks to the application, with the application filling in tree structures when requested (allowing for efficient building of a very deep tree that could even be used for file-management). See the above smart signal callbacks for details.

Emitted signals

  • activated - The user has double-clicked or pressed (enter|return|spacebar) on an item. The event_info parameter is the item that was activated.

  • clicked,double - The user has double-clicked an item. The event_info parameter is the item that was double-clicked.

  • clicked,right - The user has right-clicked an item. The event_info parameter is the item that was right-clicked. (since: 1.13)

  • selected - This is called when a user has made an item selected. The event_info parameter is the genlist item that was selected.

  • unselected - This is called when a user has made an item unselected. The event_info parameter is the genlist item that was unselected.

  • expanded - This is called when GenlistItem.expanded is called and the item is now meant to be expanded. The event_info parameter is the genlist item that was indicated to expand. It is the job of this callback to then fill in the child items.

  • contracted - This is called when GenlistItem.expanded is called and the item is now meant to be contracted. The event_info parameter is the genlist item that was indicated to contract. It is the job of this callback to then delete the child items.

  • expand,request - This is called when a user has indicated they want to expand a tree branch item. The callback should decide if the item can expand (has any children) and then call GenlistItem.expanded appropriately to set the state. The event_info parameter is the genlist item that was indicated to expand.

  • contract,request - This is called when a user has indicated they want to contract a tree branch item. The callback should decide if the item can contract (has any children) and then call GenlistItem.expanded appropriately to set the state. The event_info parameter is the genlist item that was indicated to contract.

  • realized - This is called when the item in the list is created as a real evas object. event_info parameter is the genlist item that was created.

  • unrealized - This is called just before an item is unrealized. After this call content objects provided will be deleted and the item object itself delete or be put into a floating cache.

  • drag,start,up - This is called when the item in the list has been dragged (not scrolled) up.

  • drag,start,down - This is called when the item in the list has been dragged (not scrolled) down.

  • drag,start,left - This is called when the item in the list has been dragged (not scrolled) left.

  • drag,start,right - This is called when the item in the list has been dragged (not scrolled) right.

  • drag,stop - This is called when the item in the list has stopped being dragged.

  • drag - This is called when the item in the list is being dragged.

  • longpressed - This is called when the item is pressed for a certain amount of time. By default it’s 1 second. The event_info parameter is the longpressed genlist item.

  • scroll,anim,start - This is called when scrolling animation has started.

  • scroll,anim,stop - This is called when scrolling animation has stopped.

  • scroll,drag,start - This is called when dragging the content has started.

  • scroll,drag,stop - This is called when dragging the content has stopped.

  • edge,top - This is called when the genlist is scrolled until the top edge.

  • edge,bottom - This is called when the genlist is scrolled until the bottom edge.

  • edge,left - This is called when the genlist is scrolled until the left edge.

  • edge,right - This is called when the genlist is scrolled until the right edge.

  • multi,swipe,left - This is called when the genlist is multi-touch swiped left.

  • multi,swipe,right - This is called when the genlist is multi-touch swiped right.

  • multi,swipe,up - This is called when the genlist is multi-touch swiped up.

  • multi,swipe,down - This is called when the genlist is multi-touch swiped down.

  • multi,pinch,out - This is called when the genlist is multi-touch pinched out.

  • multi,pinch,in - This is called when the genlist is multi-touch pinched in.

  • swipe - This is called when the genlist is swiped.

  • moved - This is called when a genlist item is moved in reorder mode.

  • moved,after - This is called when a genlist item is moved after another item in reorder mode. The event_info parameter is the reordered item. To get the relative previous item, use GenlistItem.prev. This signal is called along with “moved” signal.

  • moved,before - This is called when a genlist item is moved before another item in reorder mode. The event_info parameter is the reordered item. To get the relative previous item, use GenlistItem.next. This signal is called along with “moved” signal.

  • language,changed - This is called when the program’s language is changed.

  • tree,effect,finished - This is called when a genlist tree effect is finished.

  • highlighted - an item in the list is highlighted. This is called when the user presses an item or keyboard selection is done so the item is physically highlighted. The event_info parameter is the item that was highlighted.

  • unhighlighted - an item in the list is unhighlighted. This is called when the user releases an item or keyboard selection is moved so the item is physically unhighlighted. The event_info parameter is the item that was unhighlighted.

  • item,focused - When the genlist item has received focus. (since 1.10)

  • item,unfocused - When the genlist item has lost focus. (since 1.10)

  • changed - Genlist is now changed their items and properties and all calculation is finished. (since 1.16)

  • filter,done - Genlist filter operation is completed.. (since 1.17)

Enumerations

Genlist item types

efl.elementary.ELM_GENLIST_ITEM_NONE

Simple item

efl.elementary.ELM_GENLIST_ITEM_TREE

The item may be expanded and have child items

efl.elementary.ELM_GENLIST_ITEM_GROUP

An index item of a group of items

Genlist items’ field types

efl.elementary.ELM_GENLIST_ITEM_FIELD_ALL

Match all fields

efl.elementary.ELM_GENLIST_ITEM_FIELD_TEXT

Match text fields

efl.elementary.ELM_GENLIST_ITEM_FIELD_CONTENT

Match content fields

efl.elementary.ELM_GENLIST_ITEM_FIELD_STATE

Match state fields

Genlist items’ scroll-to types

efl.elementary.ELM_GENLIST_ITEM_SCROLLTO_NONE

No scroll to

efl.elementary.ELM_GENLIST_ITEM_SCROLLTO_IN

Scroll to the nearest viewport

efl.elementary.ELM_GENLIST_ITEM_SCROLLTO_TOP

Scroll to the top of viewport

efl.elementary.ELM_GENLIST_ITEM_SCROLLTO_MIDDLE

Scroll to the middle of viewport

efl.elementary.ELM_GENLIST_ITEM_SCROLLTO_BOTTTOM

Scroll to the bottom of viewport

New in version 1.17.

Inheritance diagram

Inheritance diagram of Genlist, GenlistItem, GenlistItemClass
class efl.elementary.Genlist(Object parent, *args, **kwargs)

Bases: efl.elementary.__init__.Object

This is the class that actually implements the widget.

Parameters
  • parent (efl.evas.Object) – The parent object

  • **kwargs – All the remaining keyword arguments are interpreted as properties of the instance

at_xy_item_get(x, y)

Get the item that is at the x, y canvas coords.

Parameters
  • x – The input x coordinate

  • y – The input y coordinate

  • posret – The position relative to the item returned here

Returns

(ObjectItem it, int posret)

This returns the item at the given coordinates (which are canvas relative, not object-relative). If an item is at that coordinate, that item handle is returned, and if posret is not None, the integer pointed to is set to a value of -1, 0 or 1, depending if the coordinate is on the upper portion of that item (-1), on the middle section (0) or on the lower part (1). If None is returned as an item (no item found there), then posret may indicate -1 or 1 based if the coordinate is above or below all items respectively in the genlist.

block_count

This will configure the block count to tune to the target with particular performance matrix.

A block of objects will be used to reduce the number of operations due to many objects in the screen. It can determine the visibility, or if the object has changed, it theme needs to be updated, etc. doing this kind of calculation to the entire block, instead of per object.

The default value for the block count is enough for most lists, so unless you know you will have a lot of objects visible in the screen at the same time, don’t try to change this.

block_count_get()
block_count_set(n)
bounce

Deprecated since version 1.8: You should combine with Scrollable class instead.

bounce_get()

Deprecated since version 1.8: You should combine with Scrollable class instead.

bounce_set(h, v)

Deprecated since version 1.8: You should combine with Scrollable class instead.

callback_activated_add(func, *args, **kwargs)
callback_activated_del(func)
callback_changed_add(func, *args, **kwargs)
Genlist is now changed their items and properties and all

calculation is finished.

New in version 1.16.

callback_changed_del(func)
callback_clicked_double_add(func, *args, **kwargs)
callback_clicked_double_del(func)
callback_clicked_right_add(func, *args, **kwargs)

The user has right-clicked an item.

New in version 1.13.

callback_clicked_right_del(func)
callback_contract_request_add(func, *args, **kwargs)
callback_contract_request_del(func)
callback_contracted_add(func, *args, **kwargs)
callback_contracted_del(func)
callback_drag_add(func, *args, **kwargs)
callback_drag_del(func)
callback_drag_start_down_add(func, *args, **kwargs)
callback_drag_start_down_del(func)
callback_drag_start_left_add(func, *args, **kwargs)
callback_drag_start_left_del(func)
callback_drag_start_right_add(func, *args, **kwargs)
callback_drag_start_right_del(func)
callback_drag_start_up_add(func, *args, **kwargs)
callback_drag_start_up_del(func)
callback_drag_stop_add(func, *args, **kwargs)
callback_drag_stop_del(func)
callback_expand_request_add(func, *args, **kwargs)
callback_expand_request_del(func)
callback_expanded_add(func, *args, **kwargs)
callback_expanded_del(func)
callback_filter_done_add(func, *args, **kwargs)

Genlist filter operation is completed.

New in version 1.17.

callback_filter_done_del(func)
callback_highlighted_add(func, *args, **kwargs)

an item in the list is highlighted. This is called when the user presses an item or keyboard selection is done so the item is physically highlighted. The %c event_info parameter is the item that was highlighted.

callback_highlighted_del(func)
callback_item_focused_add(func, *args, **kwargs)

When the genlist item has received focus.

New in version 1.10.

callback_item_focused_del(func)
callback_item_unfocused_add(func, *args, **kwargs)

When the genlist item has lost focus.

New in version 1.10.

callback_item_unfocused_del(func)
callback_longpressed_add(func, *args, **kwargs)
callback_longpressed_del(func)
callback_moved_add(func, *args, **kwargs)
callback_moved_after_add(func, *args, **kwargs)
callback_moved_after_del(func)
callback_moved_before_add(func, *args, **kwargs)
callback_moved_before_del(func)
callback_moved_del(func)
callback_multi_pinch_in_add(func, *args, **kwargs)
callback_multi_pinch_in_del(func)
callback_multi_pinch_out_add(func, *args, **kwargs)
callback_multi_pinch_out_del(func)
callback_multi_swipe_down_add(func, *args, **kwargs)
callback_multi_swipe_down_del(func)
callback_multi_swipe_left_add(func, *args, **kwargs)
callback_multi_swipe_left_del(func)
callback_multi_swipe_right_add(func, *args, **kwargs)
callback_multi_swipe_right_del(func)
callback_multi_swipe_up_add(func, *args, **kwargs)
callback_multi_swipe_up_del(func)
callback_realized_add(func, *args, **kwargs)
callback_realized_del(func)
callback_selected_add(func, *args, **kwargs)
callback_selected_del(func)
callback_swipe_add(func, *args, **kwargs)
callback_swipe_del(func)
callback_tree_effect_finished_add(func, *args, **kwargs)
callback_tree_effect_finished_del(func)
callback_unhighlighted_add(func, *args, **kwargs)

an item in the list is unhighlighted. This is called when the user releases an item or keyboard selection is moved so the item is physically unhighlighted. The %c event_info parameter is the item that was unhighlighted.

callback_unhighlighted_del(func)
callback_unrealized_add(func, *args, **kwargs)
callback_unrealized_del(func)
callback_unselected_add(func, *args, **kwargs)
callback_unselected_del(func)
clear()

Remove all items from a given genlist widget.

decorate_mode

Genlist decorate mode for all items.

Type

bool

decorate_mode_get()
decorate_mode_set(decorated)
decorated_item

This function returns the item that was activated with a mode, by the function elm_genlist_item_decorate_mode_set().

Type

GenlistItem

decorated_item_get()
drag_item_container_add(tm_to_anim, tm_to_drag, itemgetcb=None, data_get=None)

Set a item container (list, genlist, grid) as source of drag

Parameters
  • tm_to_anim – Time period to wait before start animation.

  • tm_to_drag – Time period to wait before start dragging.

  • itemgetcb – Callback to get Evas object for item at (x,y)

  • data_get – Callback to get drag info

Raises

RuntimeError – if setting drag source failed.

New in version 1.17.

drag_item_container_del()

Deletes a item container from drag-source list

Raises

RuntimeError – if deleting drag source failed.

New in version 1.17.

drop_item_container_add(format, itemgetcb=None, entercb=None, enterdata=None, leavecb=None, leavedata=None, poscb=None, posdata=None, dropcb=None, cbdata=None)

Set a item container (list, genlist, grid) as target for drop.

Parameters
  • format – The formats supported for dropping

  • itemgetcb – Callback to get Evas object for item at (x,y)

  • entercb – The function to call when the object is entered with a drag

  • enterdata – The application data to pass to enterdata

  • leavecb – The function to call when the object is left with a drag

  • leavedata – The application data to pass to leavedata

  • poscb – The function to call when the object has a drag over it

  • posdata – The application data to pass to posdata

  • dropcb – The function to call when a drop has occurred

  • cbdata – The application data to pass to dropcb

Raises

RuntimeError – if setting drop target failed.

New in version 1.17.

drop_item_container_del()

Removes a container from list of drop targets.

Raises

RuntimeError – if deleting drop target failed.

New in version 1.17.

filter

Set filter mode with key.

This initiates the filter mode of genlist with user/application provided key. If key is None, the filter mode is turned off.

The given key will be passed back in the filter_get function of the GenlistItemClass

Type

any python object

New in version 1.17.

filter_get()
filter_set(key)
filtered_items_count()

Return how many items have passed the filter currently.

This behaviour is O(1) and may or may not return the filtered count for complete genlist based on the timing of the call. To get complete count, call after “filter,done” callback.

Returns

The number of filtered items

Return type

int

New in version 1.18.

first_item

This returns the first item in the list.

Type

GenlistItem

first_item_get()
focus_on_selection

Focus upon items selection mode

Type

bool

When enabled, every selection of an item inside the genlist will automatically set focus to its first focusable widget from the left. This is true of course if the selection was made by clicking an unfocusable area in an item or selecting it with a key movement. Clicking on a focusable widget inside an item will cause this particular item to get focus as usual.

New in version 1.8.

highlight_mode

Whether the item will, or will not highlighted on selection. The selected and clicked callback functions will still be called.

Highlight is enabled by default.

Type

bool

highlight_mode_get()
highlight_mode_set(highlight)
homogeneous

This will enable the homogeneous mode where items are of the same height and width so that genlist may do the lazy-loading at its maximum (which increases the performance for scrolling the list).

See also

mode

Type

bool

homogeneous_get()
homogeneous_set(homogeneous)
item_append(item_class, item_data, parent_item=None, flags=enums.ELM_GENLIST_ITEM_NONE, func=None)

Append a new item (add as last row) to this genlist.

Parameters
  • item_class – a valid instance that defines the behavior of this row. See GenlistItemClass.

  • item_data – some data that defines the model of this row. This value will be given to methods of item_class such as GenlistItemClass.text_get(). It will also be provided to func as its last parameter.

  • parent_item – if this is a tree child, then the parent item must be given here, otherwise it may be None. The parent must have the flag ELM_GENLIST_ITEM_SUBITEMS set.

  • flags – defines special behavior of this item, can be one of: ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_TREE or ELM_GENLIST_ITEM_GROUP

  • func

    if not None, this must be a callable to be called back when the item is selected. The function signature is:

    func(item, obj, item_data)
    

    Where item is the handle, obj is the Evas object that represents this item, and item_data is the value given as parameter to this function.

Return type

GenlistItem

item_insert_after(item_class, item_data, after_item=None, flags=enums.ELM_GENLIST_ITEM_NONE, func=None)

Insert a new item after another item to this genlist.

Parameters
  • item_class – a valid instance that defines the behavior of this row. See GenlistItemClass.

  • item_data – some data that defines the model of this row. This value will be given to methods of item_class such as GenlistItemClass.text_get(). It will also be provided to func as its last parameter.

  • after_item – the new item will be inserted after this one.

  • flags – defines special behavior of this item, can be one of: ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_TREE or ELM_GENLIST_ITEM_GROUP

  • func

    if not None, this must be a callable to be called back when the item is selected. The function signature is:

    func(item, obj, item_data)
    

    Where item is the handle, obj is the Evas object that represents this item, and item_data is the value given as parameter to this function.

Return type

GenlistItem

item_insert_before(item_class, item_data, before_item=None, flags=enums.ELM_GENLIST_ITEM_NONE, func=None)

Insert a new item before another item to this genlist.

Parameters
  • item_class – a valid instance that defines the behavior of this row. See GenlistItemClass.

  • item_data – some data that defines the model of this row. This value will be given to methods of item_class such as GenlistItemClass.text_get(). It will also be provided to func as its last parameter.

  • before_item – the new item will be inserted before this one.

  • flags – defines special behavior of this item, can be one of: ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_TREE or ELM_GENLIST_ITEM_GROUP

  • func

    if not None, this must be a callable to be called back when the item is selected. The function signature is:

    func(item, obj, item_data)
    

    Where item is the handle, obj is the Evas object that represents this item, and item_data is the value given as parameter to this function.

Return type

GenlistItem

item_prepend(item_class, item_data, parent_item=None, flags=enums.ELM_GENLIST_ITEM_NONE, func=None)

Prepend a new item (add as first row) to this genlist.

Parameters
  • item_class – a valid instance that defines the behavior of this row. See GenlistItemClass.

  • item_data – some data that defines the model of this row. This value will be given to methods of item_class such as GenlistItemClass.text_get(). It will also be provided to func as its last parameter.

  • parent_item – if this is a tree child, then the parent item must be given here, otherwise it may be None. The parent must have the flag ELM_GENLIST_ITEM_SUBITEMS set.

  • flags – defines special behavior of this item, can be one of: ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_TREE or ELM_GENLIST_ITEM_GROUP

  • func

    if not None, this must be a callable to be called back when the item is selected. The function signature is:

    func(item, obj, item_data)
    

    Where item is the handle, obj is the Evas object that represents this item, and item_data is the value given as parameter to this function.

Return type

GenlistItem

item_sorted_insert(item_class, item_data, comparison_func, parent_item=None, flags=enums.ELM_GENLIST_ITEM_NONE, func=None)

This inserts a new item in the genlist based on a user defined comparison function.

Parameters
  • item_class – a valid instance that defines the behavior of this row. See GenlistItemClass.

  • item_data – some data that defines the model of this row. This value will be given to methods of item_class such as GenlistItemClass.text_get(). It will also be provided to func as its last parameter.

  • comparison_func

    The function called for the sort. this must be a callable and will be called to insert the item in the right position. The two arguments passed are two GenlistItem to compare. The function must return 1 if item1 comes before item2, 0 if the two items are equal or -1 otherwise. Signature is:

    func(item1, item2)->int
    

  • parent_item – if this is a tree child, then the parent item must be given here, otherwise it may be None. The parent must have the flag ELM_GENLIST_ITEM_SUBITEMS set.

  • flags – defines special behavior of this item, can be one of: ELM_GENLIST_ITEM_NONE, ELM_GENLIST_ITEM_TREE or ELM_GENLIST_ITEM_GROUP

  • func

    if not None, this must be a callable to be called back when the item is selected. The function signature is:

    func(item, obj, item_data)
    

    Where item is the handle, obj is the Evas object that represents this item, and item_data is the value given as parameter to this function.

Return type

GenlistItem

items_count

Return how many items are currently in a list

Type

int

last_item

This returns the last item in the list.

Type

GenlistItem

last_item_get()
longpress_timeout

This option will change how long it takes to send an event “longpressed” after the mouse down signal is sent to the list. If this event occurs, no “clicked” event will be sent.

Warning

If you set the longpress timeout value with this API, your genlist will not be affected by the longpress value of elementary config value later.

longpress_timeout_get()
longpress_timeout_set(timeout)
mode

The mode used for sizing items horizontally.

Default value is ELM_LIST_SCROLL. This mode means that if items are too wide to fit, the scroller will scroll horizontally. Otherwise items are expanded to fill the width of the viewport of the scroller. If it is ELM_LIST_LIMIT, items will be expanded to the viewport width and limited to that size. If it is ELM_LIST_COMPRESS, the item width will be fixed (restricted to a minimum of) to the list width when calculating its size in order to allow the height to be calculated based on it. This allows, for instance, text block to wrap lines if the Edje part is configured with “text.min: 0 1”.

Type

List sizing modes

Note

ELM_LIST_COMPRESS will make list resize slower as it will have to recalculate every item height again whenever the list width changes!

Note

With homogeneous mode all items in the genlist have the same width/height. With ELM_LIST_COMPRESS the genlist items have fast initializing. However there are no sub-objects in genlist which can be on-the-fly resizable (such as TEXTBLOCK), as some dynamic resizable objects would not be diplayed properly.

mode_get()
mode_set(mode)
multi_select

This enables (True) or disables (False) multi-selection in the list. This allows more than 1 item to be selected. To retrieve the list of selected items, use elm_genlist_selected_items_get().

Type

bool

multi_select_get()
multi_select_mode

The genlist multi select mode.

Whenever the user need to pres Ctrl to perform multiselect or not.

Type

Object multi select policy values

New in version 1.20.

multi_select_mode_get()
multi_select_mode_set(mode)
multi_select_set(multi)
nth_item_get(nth)

Get the nth item, in a given genlist widget, placed at position nth, in its internal items list

Parameters

nth – The number of the item to grab (0 being the first)

Returns

The item stored in the object at position nth or None, if there’s no item with that index (and on errors)

New in version 1.8.

realized_items

This returns a list of the realized items in the genlist. The list contains genlist items. The list must be freed by the caller when done with eina_list_free(). The item pointers in the list are only valid so long as those items are not deleted or the genlist is not deleted.

Type

tuple of GenlistItem

realized_items_get()
realized_items_update()

This updates all realized items by calling all the item class functions again to get the contents, texts and states. Use this when the original item data has changed and the changes are desired to be reflected.

To update just one item, use Genlist.item_update().

See also

realized_items

reorder_mode

Reorder mode.

Type

bool

reorder_mode_get()
reorder_mode_set(reorder_mode)
scroller_policy

Deprecated since version 1.8: You should combine with Scrollable class instead.

scroller_policy_get()

Deprecated since version 1.8: You should combine with Scrollable class instead.

scroller_policy_set(policy_h, policy_v)

Deprecated since version 1.8: You should combine with Scrollable class instead.

search_by_text_item_get(item_to_search_from, part_name, pattern, flags)

Search genlist item by given string.

This function uses globs (like “*.jpg”) for searching and takes search flags as last parameter. That is a bitfield with values to be ored together or 0 for no flags.

Parameters
  • item_to_search_from (GenlistItem) – item to start search from, or None to search from the first item.

  • part_name (string) – Name of the TEXT part of genlist item to search string in (usually “elm.text”).

  • pattern (string) – The search pattern.

  • flags (Glob matching) – Search flags

Returns

The first item found

Return type

GenlistItem

New in version 1.11.

select_mode

Selection mode of the Genlist widget.

  • ELM_OBJECT_SELECT_MODE_DEFAULTItems will only call their

    selection func and callback when first becoming selected. Any further clicks will do nothing, unless you set always select mode.

  • ELM_OBJECT_SELECT_MODE_ALWAYSThis means that, even if selected,

    every click will make the selected callbacks be called.

  • ELM_OBJECT_SELECT_MODE_NONEThis will turn off the ability to

    select items entirely and they will neither appear selected nor call selected callback functions.

Type

Selection modes

select_mode_get()
select_mode_set(mode)
selected_item

This gets the selected item in the list (if multi-selection is enabled, only the item that was first selected in the list is returned - which is not very useful, so see elm_genlist_selected_items_get() for when multi-selection is used).

If no item is selected, None is returned.

See also

selected_items

Type

GenlistItem

selected_item_get()
selected_items

It returns a list of the selected items. This list is only valid so long as the selection doesn’t change (no items are selected or unselected, or unselected implicitly by deletion). The list contains genlist items. The order of the items in this list is the order which they were selected, i.e. the first item in this list is the first item that was selected, and so on.

Note

If not in multi-select mode, consider using function Genlist.selected_item instead.

Type

tuple of GenlistItem

selected_items_get()
tree_effect_enabled

Genlist tree effect.

Type

bool

tree_effect_enabled_get()
tree_effect_enabled_set(enabled)
class efl.elementary.GenlistItem(GenlistItemClass item_class, item_data=None, GenlistItem parent_item=None, Elm_Genlist_Item_Type flags=enums.ELM_GENLIST_ITEM_NONE, func=None, func_data=None, *args, **kwargs)

Bases: efl.elementary.__init__.ObjectItem

An item for the Genlist widget.

Parameters
  • item_data – Data that defines the model of this row. This value will be given to methods of item_class such as GenlistItemClass.text_get().

  • item_class (GenlistItemClass) – a valid instance that defines the behavior of this row.

  • parent_item (GenlistItem) – If this is a tree child, then the parent item must be given here, otherwise it may be None. The parent must have the flag ELM_GENLIST_ITEM_SUBITEMS set.

  • flags (Genlist item types) – defines special behavior of this item:

  • func

    if not None, this must be a callable to be called back when the item is selected. The function signature is:

    func(item, obj, item_data)
    

    Where item is the handle, obj is the Evas object that represents this item, and item_data is the value given as parameter to this function.

  • func_data – This value will be passed to the callback.

all_contents_unset()

This instructs genlist to release references to contents in the 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.

Returns

The list of now orphans objects

Return type

list

New in version 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.

append_to(genlist)

Append a new item (add as last row) to this genlist.

Parameters

genlist (Genlist) – The Genlist upon which this item is to be appended.

Return type

GenlistItem

bring_in(scrollto_type=enums.ELM_GENLIST_ITEM_SCROLLTO_IN)

This causes genlist to jump to the item and show it (by animatedly scrolling), if it is not fully visible. This may use animation and take a some time to do so.

Parameters

scrollto_type (Genlist items’ scroll-to types) – Where to position the item in the viewport.

See also

show()

data

User data (model) for the item.

Changed in version 1.16: Property is now also writable

data_get()
data_set(data)
decorate_mode

A genlist mode is a different way of selecting an item. Once a mode is activated on an item, any other selected item is immediately unselected. This feature provides an easy way of implementing a new kind of animation for selecting an item, without having to entirely rewrite the item style theme. However, the Genlist.selected_* API can’t be used to get what item is activate for a mode.

The current item style will still be used, but applying a genlist mode to an item will select it using a different kind of animation.

The current active item for a mode can be found at Genlist.decorated_item.

The characteristics of genlist mode are:

  • Only one mode can be active at any time, and for only one item.

  • Genlist handles deactivating other items when one item is activated.

  • A mode is defined in the genlist theme (edc), and more modes can easily be added.

  • A mode style and the genlist item style are different things. They can be combined to provide a default style to the item, with some kind of animation for that item when the mode is activated.

When a mode is activated on an item, a new view for that item is created. The theme of this mode defines the animation that will be used to transit the item from the old view to the new view. This second (new) view will be active for that item while the mode is active on the item, and will be destroyed after the mode is totally deactivated from that item.

Type

(unicode decorate_it_type, bool decorate_it_set)

See also

Genlist.mode

decorate_mode_get()
decorate_mode_set(decorate_it_type, decorate_it_set)
demote()

Demote an item to the end of the list

expanded

This function flags the item of type #ELM_GENLIST_ITEM_TREE as expanded or not.

The theme will respond to this change visually, and a signal “expanded” or “contracted” will be sent from the genlist with a the item that has been expanded/contracted.

Calling this function won’t show or hide any child of this item (if it is a parent). You must manually delete and create them on the callbacks of the “expanded” or “contracted” signals.

Type

bool

expanded_depth

Get the depth of expanded item.

Type

int

expanded_depth_get()
expanded_get()
expanded_set(expanded)
fields_update(parts, itf)

This updates an item’s part by calling item’s fetching functions again to get the contents, texts and states. Use this when the original item data has changed and the changes are desired to be reflected. Parts argument is used for globbing to match ‘*’, ‘?’, and ‘.’ It can be used at updating multi fields.

Use elm_genlist_realized_items_update() to update an item’s all property.

Parameters

See also

update()

flip

The flip state of a given genlist item. Flip mode overrides current item object. It can be used for on-the-fly item replace. Flip mode can be used with/without decorate mode.

Type

bool

flip_get()
flip_set(flip)
index

Get the index of the item. It is only valid once displayed.

Type

int

index_get()
insert_after(after_item=None)

Insert a new item (row) after another item in this genlist.

Parameters

after_item (GenlistItem) – a reference item to use, the new item will be inserted after it.

Return type

GenlistItem

insert_before(before_item=None)

Insert a new item (row) before another item in this genlist.

Parameters

before_item (GenlistItem) – a reference item to use, the new item will be inserted before it.

Return type

GenlistItem

item_class_update(itc)

This sets another class of the item, changing the way that it is displayed. After changing the item class, elm_genlist_item_update() is called on the item.

next

This returns the item placed after the item, on the container genlist.

See also

prev

Type

GenlistItem

next_get()
parent

This returns the item that was specified as parent of the item on elm_genlist_item_append() and insertion related functions.

Type

GenlistItem

parent_get()
prepend_to(genlist)

Prepend a new item (add as first row) to this Genlist.

Parameters

genlist (Genlist) – The Genlist upon which this item is to be prepended.

Return type

GenlistItem

prev

This returns the item placed before the item, on the container genlist.

See also

next

Type

GenlistItem

prev_get()
promote()

Promote an item to the top of the list

select_mode

Item’s select mode. Possible values are:

Type

Selection modes

select_mode_get()
select_mode_set(mode)
selected

This sets the selected state of an item. If multi selection is not enabled on the containing genlist and selected is True, any other previously selected items will get unselected in favor of this new one.

Type

bool

selected_get()
selected_set(selected)
show(scrollto_type=enums.ELM_GENLIST_ITEM_SCROLLTO_IN)

This causes genlist to jump to the item and show it (by jumping to that position), if it is not fully visible.

Parameters

scrollto_type (Genlist items’ scroll-to types) – Where to position the item in the viewport.

See also

bring_in()

sorted_insert(genlist, comparison_func)

Insert a new item into the sorted genlist object

Parameters
  • genlist (Genlist) – The Genlist object

  • comparison_func

    The function called for the sort. This must be a callable and will be called to insert the item in the right position. The two arguments passed are two GenlistItem to compare. The function must return 1 if item1 comes before item2, 0 if the two items are equal or -1 otherwise. Signature is:

    func(item1, item2)->int
    

Return type

GenlistItem

This inserts an item in the genlist based on user defined comparison function. The two arguments passed to the function are genlist items to compare.

subitems_clear()

This removes all items that are children (and their descendants) of the item.

subitems_count()

Get the number of subitems.

Returns

The number of subitems, 0 on error.

Return type

int

New in version 1.9.

subitems_get()

Get the list of subitems.

Returns

The list of subitems.

Rype

list of GenlistItem

New in version 1.9.

type

This function returns the item’s type. Normally the item’s type. If it failed, return value is ELM_GENLIST_ITEM_MAX

Type

Genlist item types

type_get()
update()

This updates an item by calling all the item class functions again to get the contents, texts and states. Use this when the original item data has changed and the changes are desired to be reflected.

Use elm_genlist_realized_items_update() to update all already realized items.

class efl.elementary.GenlistItemClass(item_style=None, text_get_func=None, content_get_func=None, state_get_func=None, del_func=None, decorate_item_style=None, decorate_all_item_style=None, filter_get_func=None, reusable_content_get_func=None, *args, **kwargs)

Bases: object

Defines the behavior of each list item.

This class should be created and handled to the Genlist itself.

It may be subclassed, in this case the methods text_get(), content_get(), state_get() and delete() will be used.

It may also be instantiated directly, given getters to override as constructor parameters.

Parameters
  • item_style – the string that defines the genlist item theme to be used. The corresponding edje group will have this as suffix.

  • text_get_func – if provided will override the behavior defined by text_get() in this class. Its purpose is to return the label string to be used by a given part and row. This function should have the signature: func(obj, part, item_data) -> string

  • content_get_func – if provided will override the behavior defined by content_get() in this class. Its purpose is to return the icon object to be used (swallowed) by a given part and row. This function should have the signature: func(obj, part, item_data) -> obj

  • state_get_func – if provided will override the behavior defined by state_get() in this class. Its purpose is to return the boolean state to be used by a given part and row. This function should have the signature: func(obj, part, item_data) -> bool

  • del_func – if provided will override the behavior defined by delete() in this class. Its purpose is to be called when row is deleted, thus finalizing resources and similar. This function should have the signature: func(obj, part, item_data)

  • reusable_content_get_func – if provided will override the behavior defined by reusable_content_get() in this class. Its purpose is to return the icon object to be used (swallowed) by a given part and row. This can be used to reuse (cache) contents (since 1.18) This function should have the signature: func(obj, part, item_data, old_content) -> obj

Note

In all these signatures, ‘obj’ means Genlist and ‘item_data’ is the value given to Genlist item append/prepend methods, it should represent your row model as you want.

content_get(obj, part, item_data)

To be called by Genlist for each row to get its icon.

Parameters
  • obj – the Genlist instance

  • part – the part that is being handled.

  • item_data – the value given to genlist append/prepend.

Returns

icon object to be used and swallowed.

Return type

evas Object or None

decorate_all_item_style

Decorate all style of this item class.

decorate_item_style

The decoration style of this item class.

filter_get(obj, key, item_data)

To be called by Genlist for each row when filter is enabled.

Parameters
  • obj – the Genlist instance

  • key – the filter key given in the filter_set function

  • item_data – the value given to genlist append/prepend.

Returns

Wheter the item should be visible or not

Return type

bool

free()

Free the C level struct.

New in version 1.8.

item_style

The style of this item class.

ref()

Increase the C level reference count.

New in version 1.8.

reusable_content_get(obj, part, item_data, old_content)

To be called by Genlist for each row to get its icon.

Parameters
  • obj – the Genlist instance

  • part – the part that is being handled.

  • item_data – the value given to genlist append/prepend.

  • old_content – the old (if available) content that can be used instead of creating a new object every time.

Returns

icon object to be used and swallowed.

Return type

evas Object or None

state_get(obj, part, item_data)

To be called by Genlist for each row to get its state.

Parameters
  • obj – the Genlist instance

  • part – the part that is being handled.

  • item_data – the value given to genlist append/prepend.

Returns

state to be used.

Return type

bool or None

text_get(obj, part, item_data)

To be called by Genlist for each row to get its label.

Parameters
  • obj – the Genlist instance

  • part – the part that is being handled.

  • item_data – the value given to genlist append/prepend.

Returns

label to be used.

Return type

str or None

unref()

Decrease the C level reference count.

New in version 1.8.