A list model that wraps an array of strings.
The objects in the model are of type [classGtk.StringObject] and have a "string" property that can be used inside expressions.
GtkStringList is well-suited for any place where you would typically use a char*[], but need a list model.
## GtkStringList as GtkBuildable
The GtkStringList implementation of the GtkBuildable interface supports adding items directly using the <items> element and specifying <item> elements for each item. Each <item> element supports the regular translation attributes "translatable", "context" and "comments".
Here is a UI definition fragment specifying a GtkStringList
translatable="yes">Factory</item> <item translatable="yes">Home</item>
<item translatable="yes">Subway</item> </items> </object> ```
function "+"
(Widget : access Gtk_String_List_Record'Class)
return Glib.List_Model.Glist_Model
function "+"
(Widget : access Gtk_String_List_Record'Class)
return Gtk.Buildable.Gtk_Buildable
function "-"
(Interf : Glib.List_Model.Glist_Model)
return Gtk_String_List
function "-"
(Interf : Gtk.Buildable.Gtk_Buildable)
return Gtk_String_List
procedure Append
(Self : not null access Gtk_String_List_Record;
String : UTF8_String)
Appends String to Self. The String will be copied. See [methodGtk.StringList.take] for a way to avoid that.
the string to insert
function Find
(Self : not null access Gtk_String_List_Record;
String : UTF8_String) return Guint
Gets the position of the String in Self. If Self does not contain String item, G_MAXUINT is returned. Since: gtk+ 4.18
the string to find
the position of the string
function Get_Item
(Self : not null access Gtk_String_List_Record;
Position : Guint) return Glib.Object.GObject
function Get_Item_Type
(Self : not null access Gtk_String_List_Record) return GType
function Get_N_Items
(Self : not null access Gtk_String_List_Record) return Guint
function Get_String
(Self : not null access Gtk_String_List_Record;
Position : Guint) return UTF8_String
Gets the string that is at Position in Self. If Self does not contain Position items, null is returned. This function returns the const char *. To get the object wrapping it, use g_list_model_get_item.
the position to get the string for
the string at the given position
function Get_Type return Glib.GType
procedure Gtk_New
(Self : out Gtk_String_List;
Strings : GNAT.Strings.String_List)
Creates a new GtkStringList with the given Strings. Initialize does nothing if the object was already created with another call to Initialize* or G_New.
The strings to put in the model
type Gtk_String_List is access all Gtk_String_List_Record'Class;
function Gtk_String_List_New
(Strings : GNAT.Strings.String_List) return Gtk_String_List
Creates a new GtkStringList with the given Strings.
The strings to put in the model
type Gtk_String_List_Record is new GObject_Record with null record;
package Implements_Glist_Model is new Glib.Types.Implements
(Glib.List_Model.Glist_Model, Gtk_String_List_Record, Gtk_String_List);
package Implements_Gtk_Buildable is new Glib.Types.Implements
(Gtk.Buildable.Gtk_Buildable, Gtk_String_List_Record, Gtk_String_List);
procedure Initialize
(Self : not null access Gtk_String_List_Record'Class;
Strings : GNAT.Strings.String_List)
Creates a new GtkStringList with the given Strings. Initialize does nothing if the object was already created with another call to Initialize* or G_New.
The strings to put in the model
Item_Type_Property : constant Glib.Properties.Property_Boxed;
Type: GType The type of items. See [methodGio.ListModel.get_item_type].
procedure Items_Changed
(Self : not null access Gtk_String_List_Record;
Position : Guint;
Removed : Guint;
Added : Guint)
N_Items_Property : constant Glib.Properties.Property_Uint;
The number of items. See [methodGio.ListModel.get_n_items].
procedure Remove
(Self : not null access Gtk_String_List_Record;
Position : Guint)
Removes the string at Position from Self. Position must be smaller than the current length of the list.
the position of the string that is to be removed
procedure Splice
(Self : not null access Gtk_String_List_Record;
Position : Guint;
N_Removals : Guint;
Additions : GNAT.Strings.String_List)
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).
the position at which to make the change
the number of strings to remove
The strings to add
Strings_Property : constant Glib.Properties.Property_String :=
Glib.Properties.Build ("strings");
Unknown type: unspecified
procedure Take
(Self : not null access Gtk_String_List_Record;
String : UTF8_String)
Adds String to self at the end, and takes ownership of it. This variant of [methodGtk.StringList.append] is convenient for formatting strings:
the string to insert