1.49 <GListStore>

Class: <GListStore>

It derives from <GObject>.

<GListStore> is a simple implementation of <GListModel> 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.

Properties

Property: list-store:item-type self

The type of items contained in this list store. Items must be subclasses of <GObject>.

Its value is a class, or a GType number.

It can only be set when the object is made, with #:item-type.

Property: list-store:n-items self

The number of items contained in this list store.

Its value is an unsigned 32-bit integer.

It is read only.

Procedures

Method: list-store:append self item
Method: append self item

Appends item to self. item must be of type list-store:item-type.

This function takes a ref on item.

Use list-store:splice to append multiple items at the same time efficiently.

self

Passed: a <GListStore>.

a <GListStore>

item

Passed: a <GObject>.

the new item

Method: list-store:find self item ⇒ %return position
Method: find self item ⇒ %return position

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 #f.

If you need to compare the two items with a custom comparison function, use list-store:find-with-equal-func with a custom GEqualFunc instead.

self

Passed: a <GListStore>.

a <GListStore>

item

Passed: a <GObject>.

an item

%return

Returned: a boolean.

Whether self contains item. If it was found, position will be set to the position where item occurred for the first time.

position

Returned: an unsigned 32-bit integer.

the first position of item, if it was found.

Method: list-store:find-with-equal-func self item equal-func ⇒ %return position
Method: find-with-equal-func self item equal-func ⇒ %return position

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 #f.

item is always passed as second parameter to equal-func.

Since GLib 2.76 it is possible to pass NULL for item.

self

Passed: a <GListStore>.

a <GListStore>

item

Passed: a <GObject>, or #f.

an item

equal-func

Passed: a procedure.

A custom equality check function

See GEqualFunc for how it is called.

%return

Returned: a boolean.

Whether self contains item. If it was found, position will be set to the position where item occurred for the first time.

position

Returned: an unsigned 32-bit integer.

the first position of item, if it was found.

Method: list-store:find-with-equal-func-full self item equal-func ⇒ %return position
Method: find-with-equal-func-full self item equal-func ⇒ %return position

Like list-store:find-with-equal-func but with an additional user-data that 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.

self

Passed: a <GListStore>.

a <GListStore>

item

Passed: a <GObject>, or #f.

an item

equal-func

Passed: a procedure.

A custom equality check function

See GEqualFuncFull for how it is called.

%return

Returned: a boolean.

Whether self contains item. If it was found, position will be set to the position where item occurred for the first time.

position

Returned: an unsigned 32-bit integer.

the first position of item, if it was found.

user-data

Not passed: guile-gi supplies it.

user data for equal-func

Method: list-store:insert self position item
Method: insert self position item

Inserts item into self at position. item must be of type list-store: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 list-store:splice to insert multiple items at the same time efficiently.

self

Passed: a <GListStore>.

a <GListStore>

position

Passed: an unsigned 32-bit integer.

the position at which to insert the new item

item

Passed: a <GObject>.

the new item

Method: list-store:insert-sorted self item compare-func ⇒ %return
Method: insert-sorted self item compare-func ⇒ %return

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.

self

Passed: a <GListStore>.

a <GListStore>

item

Passed: a <GObject>.

the new item

compare-func

Passed: a procedure.

pairwise comparison function for sorting

See GCompareDataFunc for how it is called.

%return

Returned: an unsigned 32-bit integer.

the position at which item was inserted

user-data

Not passed: guile-gi supplies it.

user data for compare-func

Procedure: list-store:new item-type ⇒ %return

Creates a new <GListStore> with items of type item-type. item-type must be a subclass of <GObject>.

item-type

Passed: a class, or a GType number.

the GType of items in the list

%return

Returned: a <GListStore>.

a new <GListStore>

Method: list-store:remove self position
Method: remove self position

Removes the item from self that is at position. position must be smaller than the current length of the list.

Use list-store:splice to remove multiple items at the same time efficiently.

self

Passed: a <GListStore>.

a <GListStore>

position

Passed: an unsigned 32-bit integer.

the position of the item that is to be removed

Method: list-store:remove-all self
Method: remove-all self

Removes all items from self.

self

Passed: a <GListStore>.

a <GListStore>

Method: list-store:sort self compare-func
Method: sort self compare-func

Sort the items in self according to compare-func.

self

Passed: a <GListStore>.

a <GListStore>

compare-func

Passed: a procedure.

pairwise comparison function for sorting

See GCompareDataFunc for how it is called.

user-data

Not passed: guile-gi supplies it.

user data for compare-func

Method: list-store:splice self position n-removals additions
Method: splice self position n-removals additions

Changes self by removing n-removals items and adding n-additions items to it. additions must contain n-additions items of type list-store:item-type. #f is not permitted.

This function is more efficient than list-store:insert and list-store:remove, because it only emits list-model: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).

self

Passed: a <GListStore>.

a <GListStore>

position

Passed: an unsigned 32-bit integer.

the position at which to make the change

n-removals

Passed: an unsigned 32-bit integer.

the number of items to remove

additions

Passed: a list or vector, each a <GObject>.

the items to add

n-additions

Not passed: guile-gi gives the length of additions.

the number of items to add