Gio.ListStore¶
| Subclasses: | None | 
|---|
Methods¶
| Inherited: | GObject.Object (37), Gio.ListModel (4) | 
|---|---|
| Structs: | GObject.ObjectClass (5) | 
| class | new(item_type) | 
| append(item) | |
| find(item) | |
| find_with_equal_func(item, equal_func) | |
| insert(position, item) | |
| insert_sorted(item, compare_func, *user_data) | |
| remove(position) | |
| remove_all() | |
| sort(compare_func, *user_data) | |
| splice(position, n_removals, additions) | 
Virtual Methods¶
| Inherited: | GObject.Object (7), Gio.ListModel (3) | 
|---|
Properties¶
| Name | Type | Flags | Short Description | 
|---|---|---|---|
| item-type | GObject.GType | r/w/co | 
Signals¶
| Inherited: | GObject.Object (1), Gio.ListModel (1) | 
|---|
Fields¶
| Inherited: | GObject.Object (1), Gio.ListModel (1) | 
|---|
Class Details¶
- 
class Gio.ListStore(**kwargs)¶
- Bases: - GObject.Object,- Gio.ListModel- Abstract: - No - Structure: - Gio.ListStoreClass- Gio.ListStoreis a simple implementation of- Gio.ListModelthat stores all items in memory.- It provides insertions, deletions, and lookups in logarithmic time with a fast path for the common case of iterating the list linearly. - 
classmethod new(item_type)[source]¶
- Parameters: - item_type ( - GObject.GType) – the- GObject.GTypeof items in the list- Returns: - a new - Gio.ListStore- Return type: - Gio.ListStore- Creates a new - Gio.ListStorewith items of type item_type. item_type must be a subclass of- GObject.Object.- New in version 2.44. 
 - 
append(item)[source]¶
- Parameters: - item ( - GObject.Object) – the new item- Appends item to self. item must be of type - Gio.ListStore- :item-type.- This function takes a ref on item. - Use - Gio.ListStore.splice() to append multiple items at the same time efficiently.- New in version 2.44. 
 - 
find(item)[source]¶
- Parameters: - item ( - GObject.Object) – an item- Returns: - Whether self contains item. If it was found, position will be set to the position where item occurred for the first time. - position: - the first position of item, if it was found. - Return type: - ( - bool, position:- int)- Looks up the given item in the list store by looping over the items until the first occurrence of item. If item was not found, then position will not be set, and this method will return - False.- If you need to compare the two items with a custom comparison function, use - Gio.ListStore.find_with_equal_func() with a custom- GLib.EqualFuncinstead.- New in version 2.64. 
 - 
find_with_equal_func(item, equal_func)[source]¶
- Parameters: - item (GObject.Object) – an item
- equal_func (GLib.EqualFunc) – A custom equality check function
 - Returns: - Whether self contains item. If it was found, position will be set to the position where item occurred for the first time. - position: - the first position of item, if it was found. - Return type: - Looks up the given item in the list store by looping over the items and comparing them with compare_func until the first occurrence of item which matches. If item was not found, then position will not be set, and this method will return - False.- New in version 2.64. 
- item (
 - 
insert(position, item)[source]¶
- Parameters: - position (int) – the position at which to insert the new item
- item (GObject.Object) – the new item
 - Inserts item into self at position. item must be of type - Gio.ListStore- :item-typeor derived from it. position must be smaller than the length of the list, or equal to it to append.- This function takes a ref on item. - Use - Gio.ListStore.splice() to insert multiple items at the same time efficiently.- New in version 2.44. 
- position (
 - 
insert_sorted(item, compare_func, *user_data)[source]¶
- Parameters: - item (GObject.Object) – the new item
- compare_func (GLib.CompareDataFunc) – pairwise comparison function for sorting
- user_data (objectorNone) – user data for compare_func
 - Returns: - the position at which item was inserted - Return type: - Inserts item into self at a position to be determined by the compare_func. - The list must already be sorted before calling this function or the result is undefined. Usually you would approach this by only ever inserting items by way of this function. - This function takes a ref on item. - New in version 2.44. 
- item (
 - 
remove(position)[source]¶
- Parameters: - position ( - int) – the position of the item that is to be removed- Removes the item from self that is at position. position must be smaller than the current length of the list. - Use - Gio.ListStore.splice() to remove multiple items at the same time efficiently.- New in version 2.44. 
 - 
sort(compare_func, *user_data)[source]¶
- Parameters: - compare_func (GLib.CompareDataFunc) – pairwise comparison function for sorting
- user_data (objectorNone) – user data for compare_func
 - Sort the items in self according to compare_func. - New in version 2.46. 
- compare_func (
 - 
splice(position, n_removals, additions)[source]¶
- Parameters: - position (int) – the position at which to make the change
- n_removals (int) – the number of items to remove
- additions ([GObject.Object]) – the items to add
 - Changes self by removing n_removals items and adding n_additions items to it. additions must contain n_additions items of type - Gio.ListStore- :item-type.- Noneis not permitted.- This function is more efficient than - Gio.ListStore.insert() and- Gio.ListStore.remove(), because it only emits- Gio.ListModel- ::items-changedonce for the change.- This function takes a ref on each item in additions. - The parameters position and n_removals must be correct (ie: position + n_removals must be less than or equal to the length of the list at the time this function is called). - New in version 2.44. 
- position (
 
- 
classmethod 
Property Details¶
- 
Gio.ListStore.props.item_type¶
- Name: - item-type- Type: - GObject.GType- Default Value: - <GType GObject>- Flags: - READABLE,- WRITABLE,- CONSTRUCT_ONLY- The type of items contained in this list store. Items must be subclasses of - GObject.Object.- New in version 2.44.