Gio.ListStore - Classes - Gio 2.0 (original) (raw)
g GObject.GInterface GObject.GInterface Gio.ListModel Gio.ListModel GObject.GInterface->Gio.ListModel GObject.Object GObject.Object Gio.ListStore Gio.ListStore GObject.Object->Gio.ListStore Gio.ListModel->Gio.ListStore
Subclasses:
None
Methods¶
Inherited:
GObject.Object (37), Gio.ListModel (4)
Structs:
class | new (item_type) |
---|---|
append (item) | |
find (item) | |
find_with_equal_func (item, equal_func) | |
find_with_equal_func_full (item, equal_func, *user_data) | |
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 | |
n-items | int | r |
Signals¶
Inherited:
GObject.Object (1), Gio.ListModel (1)
Fields¶
Inherited:
GObject.Object (1), Gio.ListModel (1)
Class Details¶
class Gio.ListStore(**kwargs)¶
Bases:
Abstract:
No
Structure:
GListStore
is a simple implementation of [iface`Gio`.ListModel] that 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.GType of items in the list
Returns:
a new Gio.ListStore
Return type:
Creates a new Gio.ListStore with items of type item_type. item_typemust be a subclass of GObject.Object.
New in version 2.44.
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.
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:
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, useGio.ListStore.find_with_equal_func() with a custom GLib.EqualFunc instead.
New in version 2.64.
find_with_equal_func(item, equal_func)[source]¶
Parameters:
- item (GObject.Object or None) – 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 equal_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.
item is always passed as second parameter to equal_func.
Since GLib 2.76 it is possible to pass NULL
for item.
New in version 2.64.
find_with_equal_func_full(item, equal_func, *user_data)[source]¶
Parameters:
- item (GObject.Object or None) – an item
- equal_func (GLib.EqualFuncFull) – A custom equality check function
- user_data (object or None) – user data for equal_func
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:
Like Gio.ListStore.find_with_equal_func() but with an additional user_datathat is passed to equal_func.
item is always passed as second parameter to equal_func.
Since GLib 2.76 it is possible to pass NULL
for item.
New in version 2.74.
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 typeGio.ListStore :item-type or 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.
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 (object or None) – 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 thecompare_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.
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.
Removes all items from self.
New in version 2.44.
sort(compare_func, *user_data)[source]¶
Parameters:
- compare_func (GLib.CompareDataFunc) – pairwise comparison function for sorting
- user_data (object or None) – user data for compare_func
Sort the items in self according to compare_func.
New in version 2.46.
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_additionsitems to it. additions must contain n_additions items of typeGio.ListStore :item-type. None is not permitted.
This function is more efficient than Gio.ListStore.insert() andGio.ListStore.remove(), because it only emitsGio.ListModel ::items-changed once 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.
Property Details¶
Gio.ListStore.props.item_type¶
Name:
item-type
Type:
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.
Gio.ListStore.props.n_items¶
Name:
n-items
Type:
Default Value:
0
Flags:
The number of items contained in this list store.
New in version 2.74.