Class: Gio::ListStore

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#append(item) ⇒ nil

Appends item to store. item must be of type GList::Store:item-type.

This function takes a ref on item.

Use g_list_store_splice() to append multiple items at the same time efficiently.

Parameters:

  • item (GObject::Object)

    the new item

Returns:

  • (nil)

#find(item, position) ⇒ TrueClass

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 g_list_store_find_with_equal_func() with a custom GEqual::Func instead. set to the position where item occurred for the first time.

Parameters:

  • item (GObject::Object)

    an item

  • position (Integer)

    the first position of item, if it was found.

Returns:

  • (TrueClass)

    Whether store contains item. If it was found, position will be

#find_with_equal_func(item, equal_func, position) ⇒ TrueClass

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. set to the position where item occurred for the first time.

Parameters:

  • item (GObject::Object)

    an item

  • equal_func (GLib::EqualFunc)

    A custom equality check function

  • position (Integer)

    the first position of item, if it was found.

Returns:

  • (TrueClass)

    Whether store contains item. If it was found, position will be

#insert(position, item) ⇒ nil

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

Parameters:

  • position (Integer)

    the position at which to insert the new item

  • item (GObject::Object)

    the new item

Returns:

  • (nil)

#insert_sorted(item, compare_func, user_data) ⇒ Integer

Inserts item into store 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.

Parameters:

  • item (GObject::Object)

    the new item

  • compare_func (GLib::CompareDataFunc)

    pairwise comparison function for sorting

  • user_data (GObject)

    user data for compare_func

Returns:

  • (Integer)

    the position at which item was inserted

#item_typeGLib::Type

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

Returns:

#item_type=(item_type) ⇒ GLib::Type

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

Parameters:

Returns:

#new(item_type) ⇒ Gio::ListStore

Creates a new GList::Store with items of type item_type. item_type must be a subclass of #GObject.

Parameters:

  • item_type (GLib::Type)

    the #GType of items in the list

Returns:

#remove(position) ⇒ nil

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

Use g_list_store_splice() to remove multiple items at the same time efficiently.

Parameters:

  • position (Integer)

    the position of the item that is to be removed

Returns:

  • (nil)

#remove_allnil

Removes all items from store.

Returns:

  • (nil)

#sort(compare_func, user_data) ⇒ nil

Sort the items in store according to compare_func.

Parameters:

  • compare_func (GLib::CompareDataFunc)

    pairwise comparison function for sorting

  • user_data (GObject)

    user data for compare_func

Returns:

  • (nil)

#splice(position, n_removals, additions, n_additions) ⇒ nil

Changes store by removing n_removals items and adding n_additions items to it. additions must contain n_additions items of type GList::Store:item-type. nil is not permitted.

This function is more efficient than g_list_store_insert() and g_list_store_remove(), because it only emits GList::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).

Parameters:

  • position (Integer)

    the position at which to make the change

  • n_removals (Integer)

    the number of items to remove

  • additions (Array<GObject::Object>)

    the items to add

  • n_additions (Integer)

    the number of items to add

Returns:

  • (nil)