Gio.ListStore

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 (40), Gio.ListModel (4)
Structs:GObject.ObjectClass (5)
class new (item_type)
  append (item)
  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  

Class Details

class Gio.ListStore(**kwargs)
Bases:GObject.Object, Gio.ListModel
Abstract:No
Structure:Gio.ListStoreClass

Gio.ListStore is a simple implementation of 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:Gio.ListStore

Creates a new Gio.ListStore with 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.

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-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:
Returns:

the position at which item was inserted

Return type:

int

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.

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.

remove_all()[source]

Removes all items from self.

New in version 2.44.

sort(compare_func, *user_data)[source]
Parameters:

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_additions items to it. additions must contain n_additions items of type Gio.ListStore :item-type. None is not permitted.

This function is more efficient than Gio.ListStore.insert() and Gio.ListStore.remove(), because it only emits Gio.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:GObject.GType
Default Value:<GType GObject (80)>
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.