Class: Gtk::StringList

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

Instance Method Summary collapse

Constructor Details

#initialize(strings) ⇒ Gtk::StringList

Creates a new GtkStringList with the given strings.

Parameters:

  • strings (Array<String>)

    The strings to put in the model

Instance Method Details

#append(string) ⇒ nil

Appends string to self.

The string will be copied. See [methodGtk.StringList.take] for a way to avoid that.

Parameters:

  • string (String)

    the string to insert

Returns:

  • (nil)

#get_string(position) ⇒ String

Gets the string that is at position in self.

If self does not contain position items, nil is returned.

This function returns the const char *. To get the object wrapping it, use g_list_model_get_item().

Parameters:

  • position (Integer)

    the position to get the string for

Returns:

  • (String)

    the string at the given position

#item_typeGLib::Type

The type of items. See [methodGio.ListModel.get_item_type].

Returns:

  • (GLib::Type)

    item-type

#item_type=(item_type) ⇒ GLib::Type

The type of items. See [methodGio.ListModel.get_item_type].

Parameters:

  • item_type (GLib::Type)

Returns:

  • (GLib::Type)

    item-type

  • (GLib::Type)

    item-type

#n_itemsInteger

The number of items. See [methodGio.ListModel.get_n_items].

Returns:

  • (Integer)

    n-items

#n_items=(n_items) ⇒ Integer

The number of items. See [methodGio.ListModel.get_n_items].

Parameters:

  • n_items (Integer)

Returns:

  • (Integer)

    n-items

  • (Integer)

    n-items

#remove(position) ⇒ nil

Removes the string at position from self.

position must be smaller than the current length of the list.

Parameters:

  • position (Integer)

    the position of the string that is to be removed

Returns:

  • (nil)

#splice(position, n_removals, additions) ⇒ nil

Changes self by removing n_removals strings and adding additions to it.

This function is more efficient than [methodGtk.StringList.append] and [methodGtk.StringList.remove], because it only emits the ::items-changed signal once for the change.

This function copies the strings 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 strings to remove

  • additions (Array<String>)

    The strings to add

Returns:

  • (nil)

#strings=(strings) ⇒ Gtk::

Returns strings.

Parameters:

Returns:

#take(string) ⇒ nil

Adds string to self at the end, and takes ownership of it.

This variant of [methodGtk.StringList.append] is convenient for formatting strings:

gtk_string_list_take (self, g_strdup_print ("%d dollars", lots));

Parameters:

  • string (String)

    the string to insert

Returns:

  • (nil)