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 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.
In order to have the ability to add and delete items on the fly, genlist implements a 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 struct (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 delete(). GenlistItemClass contains the following members:
The function pointers inside func are text_get, content_get, state_get and del. The 3 first functions also receive a part parameter described below. A brief description of these functions follows:
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.
A genlist item may be at one of several styles. Elementary provides one by default - “default”, but this can be extended by system or application custom themes/overlays/extensions (see themes) for more details).
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)).
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.
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)
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.
Simple item
The item may be expanded and have child items
An index item of a group of items
Match all fields
Match text fields
Match content fields
Match state fields
No scroll to
Scroll to the nearest viewport
Scroll to the top of viewport
Scroll to the middle of viewport
Bases: efl.elementary.__init__.Object
This is the class that actually implements the widget.
Parameters: |
|
---|
Get the item that is at the x, y canvas coords.
Parameters: |
|
---|---|
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.
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.
Deprecated since version 1.8: You should combine with Scrollable class instead.
Deprecated since version 1.8: You should combine with Scrollable class instead.
Deprecated since version 1.8: You should combine with Scrollable class instead.
The user has right-clicked an item.
New in version 1.13.
When the genlist has received focus.
New in version 1.8.
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.
When the genlist item has received focus.
New in version 1.10.
When the genlist item has lost focus.
New in version 1.10.
When the genlist has lost focus.
New in version 1.8.
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.
Remove all items from a given genlist widget.
Genlist decorate mode for all items.
Type: | bool |
---|
This function returns the item that was activated with a mode, by the function elm_genlist_item_decorate_mode_set().
See also
Type: | GenlistItem |
---|
This returns the first item in the list.
Type: | GenlistItem |
---|
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.
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 |
---|
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
Type: | bool |
---|
Append a new item (add as last row) to this genlist.
Parameters: |
|
---|---|
Return type: |
Insert a new item after another item to this genlist.
Parameters: |
|
---|---|
Return type: |
Insert a new item before another item to this genlist.
Parameters: |
|
---|---|
Return type: |
Prepend a new item (add as first row) to this genlist.
Parameters: |
|
---|---|
Return type: |
This inserts a new item in the genlist based on a user defined comparison function.
Parameters: |
|
---|---|
Return type: |
Return how many items are currently in a list
Type: | int |
---|
This returns the last item in the list.
Type: | GenlistItem |
---|
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.
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”.
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.
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 |
---|
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.
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.
See also
Type: | tuple of GenlistItem |
---|
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
Reorder mode.
Type: | bool |
---|
Deprecated since version 1.8: You should combine with Scrollable class instead.
Deprecated since version 1.8: You should combine with Scrollable class instead.
Deprecated since version 1.8: You should combine with Scrollable class instead.
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: |
|
---|---|
Returns: | The first item found |
Return type: |
New in version 1.11.
Selection mode of the Genlist widget.
selection func and callback when first becoming selected. Any further clicks will do nothing, unless you set always select mode.
every click will make the selected callbacks be called.
select items entirely and they will neither appear selected nor call selected callback functions.
Type: | Selection modes |
---|
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
Type: | GenlistItem |
---|
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.
See also
Type: | tuple of GenlistItem |
---|
Genlist tree effect.
Type: | bool |
---|
Bases: efl.elementary.__init__.ObjectItem
An item for the Genlist widget.
Parameters: |
|
---|
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.
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 |
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.
Type: | Genlist items’ scroll-to types |
---|
See also
User data for the item.
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:
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
Demote an item to the end of the list
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 |
---|
Get the depth of expanded item.
Type: | int |
---|
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
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 |
---|
Get the index of the item. It is only valid once displayed.
Type: | int |
---|
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 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 |
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.
This returns the item placed after the item, on the container genlist.
See also
Type: | GenlistItem |
---|
This returns the item that was specified as parent of the item on elm_genlist_item_append() and insertion related functions.
Type: | GenlistItem |
---|
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 |
This returns the item placed before the item, on the container genlist.
See also
Type: | GenlistItem |
---|
Promote an item to the top of the list
Item’s select mode. Possible values are:
Type: | Selection modes |
---|
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 |
---|
This causes genlist to jump to the item and show it (by jumping to that position), if it is not fully visible.
Type: | Genlist items’ scroll-to types |
---|
See also
Insert a new item into the sorted genlist object
Parameters: |
|
---|---|
Return type: |
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.
This removes all items that are children (and their descendants) of the item.
Get the number of subitems.
Returns: | The number of subitems, 0 on error. |
---|---|
Return type: | int |
New in version 1.9.
Get the list of subitems.
Returns: | The list of subitems. |
---|---|
Rype: | list of GenlistItem |
New in version 1.9.
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 |
---|
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.
See also
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: |
|
---|
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.
To be called by Genlist for each row to get its icon.
Parameters: |
|
---|---|
Returns: | icon object to be used and swallowed. |
Return type: | evas Object or None |
Decorate all style of this item class.
The decoration style of this item class.
Free the C level struct.
New in version 1.8.
The style of this item class.
Increase the C level reference count.
New in version 1.8.
To be called by Genlist for each row to get its state.
Parameters: |
|
---|---|
Returns: | state to be used. |
Return type: | bool or None |
To be called by Genlist for each row to get its label.
Parameters: |
|
---|---|
Returns: | label to be used. |
Return type: | str or None |
Decrease the C level reference count.
New in version 1.8.