<?xml version="1.0"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
<!ENTITY % local.common.attrib "xmlns:xi  CDATA  #FIXED 'http://www.w3.org/2003/XInclude'">
<!ENTITY version SYSTEM "version.xml">
<!ENTITY pi "&#960;">
<!ENTITY solidus "&#8260;">
]>
<refentry id="GtkStringList">
<refmeta>
<refentrytitle role="top_of_page" id="GtkStringList.top_of_page">GtkStringList</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GTK4 Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>GtkStringList</refname>
<refpurpose>A list model for strings</refpurpose>
</refnamediv>

<refsect1 id="GtkStringList.functions" role="functions_proto">
<title role="functions_proto.title">Functions</title>
<informaltable pgwide="1" frame="none">
<tgroup cols="2">
<colspec colname="functions_proto_type" colwidth="150px"/>
<colspec colname="functions_proto_name"/>
<tbody>
<row><entry role="function_type"><link linkend="GtkStringList"><returnvalue>GtkStringList</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="gtk-string-list-new">gtk_string_list_new</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="gtk-string-list-append">gtk_string_list_append</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="gtk-string-list-take">gtk_string_list_take</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="gtk-string-list-remove">gtk_string_list_remove</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="void"><returnvalue>void</returnvalue></link>
</entry><entry role="function_name"><link linkend="gtk-string-list-splice">gtk_string_list_splice</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type">const <link linkend="char"><returnvalue>char</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="gtk-string-list-get-string">gtk_string_list_get_string</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>

<row><entry role="function_type"><link linkend="GtkStringObject"><returnvalue>GtkStringObject</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="gtk-string-object-new">gtk_string_object_new</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type">const <link linkend="char"><returnvalue>char</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="gtk-string-object-get-string">gtk_string_object_get_string</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 id="GtkStringList.properties" role="properties">
<title role="properties.title">Properties</title>
<informaltable frame="none">
<tgroup cols="3">
<colspec colname="properties_type" colwidth="150px"/>
<colspec colname="properties_name" colwidth="300px"/>
<colspec colname="properties_flags" colwidth="200px"/>
<tbody>
<row><entry role="property_type"><link linkend="char"><type>char</type></link>&#160;*</entry><entry role="property_name"><link linkend="GtkStringObject--string">string</link></entry><entry role="property_flags">Read</entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>
<anchor id="GtkStringObject"/><refsect1 id="GtkStringList.other" role="other_proto">
<title role="other_proto.title">Types and Values</title>
<informaltable pgwide="1" frame="none">
<tgroup cols="2">
<colspec colname="other_proto_type" colwidth="150px"/>
<colspec colname="other_proto_name"/>
<tbody>
<row><entry role="datatype_keyword"></entry><entry role="function_name"><link linkend="GtkStringList-struct">GtkStringList</link></entry></row>

<row><entry role="datatype_keyword"></entry><entry role="function_name"><link linkend="GtkStringObject-struct">GtkStringObject</link></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 id="GtkStringList.object-hierarchy" role="object_hierarchy">
<title role="object_hierarchy.title">Object Hierarchy</title>
<screen>    <link linkend="GObject">GObject</link>
    <phrase role="lineart">&#9500;&#9472;&#9472;</phrase> GtkStringList
    <phrase role="lineart">&#9584;&#9472;&#9472;</phrase> GtkStringObject
</screen>
</refsect1>
<refsect1 id="GtkStringList.implemented-interfaces" role="impl_interfaces">
<title role="impl_interfaces.title">Implemented Interfaces</title>
<para>
GtkStringList implements
 <link linkend="GtkBuildable">GtkBuildable</link> and  <link linkend="GListModel">GListModel</link>.</para>

</refsect1>

<refsect1 id="GtkStringList.includes"><title>Includes</title><synopsis>#include &lt;gtk/gtk.h&gt;
</synopsis></refsect1>

<refsect1 id="GtkStringList.description" role="desc">
<title role="desc.title">Description</title>
<para><link linkend="GtkStringList"><type>GtkStringList</type></link> is a list model that wraps an array of strings.</para>
<para>The objects in the model have a "string" property.</para>
<para>GtkStringList is well-suited for any place where you would
typically use a <literal>char*[]</literal>, but need a list model.</para>
<refsect2><title>GtkStringList as GtkBuildable</title><para>The GtkStringList implementation of the GtkBuildable interface
supports adding items directly using the &lt;items> element and
specifying &lt;item> elements for each item. Each &lt;item> element
supports the regular translation attributes “translatable”,
“context” and “comments”.</para>
<para>Here is a UI definition fragment specifying a GtkStringList</para>
<informalexample><programlisting role="example"><![CDATA[
<object class="GtkStringList">
  <items>
    <item translatable="yes">Factory</item>
    <item translatable="yes">Home</item>
    <item translatable="yes">Subway</item>
  </items>
</object>
]]></programlisting></informalexample>
<para></para>
</refsect2>

</refsect1>
<refsect1 id="GtkStringList.functions_details" role="details">
<title role="details.title">Functions</title>
<refsect2 id="gtk-string-list-new" role="function">
<title>gtk_string_list_new&#160;()</title>
<indexterm zone="gtk-string-list-new"><primary>gtk_string_list_new</primary></indexterm>
<programlisting language="C"><link linkend="GtkStringList"><returnvalue>GtkStringList</returnvalue></link>&#160;*
gtk_string_list_new (<parameter>const <link linkend="char"><type>char</type></link> * const *strings</parameter>);</programlisting>
<para>Creates a new <link linkend="GtkStringList"><type>GtkStringList</type></link> with the given <parameter>strings</parameter>
.</para>
<refsect3 id="gtk-string-list-new.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>strings</para></entry>
<entry role="parameter_description"><para>The strings to put in the model. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>array</acronym> zero-terminated=1][<acronym>nullable</acronym>]</emphasis></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-string-list-new.returns" role="returns">
<title>Returns</title>
<para> a new <link linkend="GtkStringList"><type>GtkStringList</type></link></para>
</refsect3></refsect2>
<refsect2 id="gtk-string-list-append" role="function">
<title>gtk_string_list_append&#160;()</title>
<indexterm zone="gtk-string-list-append"><primary>gtk_string_list_append</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
gtk_string_list_append (<parameter><link linkend="GtkStringList"><type>GtkStringList</type></link> *self</parameter>,
                        <parameter>const <link linkend="char"><type>char</type></link> *string</parameter>);</programlisting>
<para>Appends <parameter>string</parameter>
 to <parameter>self</parameter>
.</para>
<para>The <parameter>string</parameter>
 will be copied. See <link linkend="gtk-string-list-take"><function>gtk_string_list_take()</function></link>
for a way to avoid that.</para>
<refsect3 id="gtk-string-list-append.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>self</para></entry>
<entry role="parameter_description"><para>a <link linkend="GtkStringList"><type>GtkStringList</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>string</para></entry>
<entry role="parameter_description"><para>the string to insert</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="gtk-string-list-take" role="function">
<title>gtk_string_list_take&#160;()</title>
<indexterm zone="gtk-string-list-take"><primary>gtk_string_list_take</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
gtk_string_list_take (<parameter><link linkend="GtkStringList"><type>GtkStringList</type></link> *self</parameter>,
                      <parameter><link linkend="char"><type>char</type></link> *string</parameter>);</programlisting>
<para>Adds <parameter>string</parameter>
 to self at the end, and takes
ownership of it.</para>
<para>This variant of <link linkend="gtk-string-list-append"><function>gtk_string_list_append()</function></link> is
convenient for formatting strings:</para>
<informalexample><programlisting role="example"><![CDATA[
gtk_string_list_take (self, g_strdup_print ("%d dollars", lots));
]]></programlisting></informalexample>
<para></para>
<refsect3 id="gtk-string-list-take.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>self</para></entry>
<entry role="parameter_description"><para>a <link linkend="GtkStringList"><type>GtkStringList</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>string</para></entry>
<entry role="parameter_description"><para>the string to insert. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>transfer full</acronym>]</emphasis></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="gtk-string-list-remove" role="function">
<title>gtk_string_list_remove&#160;()</title>
<indexterm zone="gtk-string-list-remove"><primary>gtk_string_list_remove</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
gtk_string_list_remove (<parameter><link linkend="GtkStringList"><type>GtkStringList</type></link> *self</parameter>,
                        <parameter><link linkend="guint"><type>guint</type></link> position</parameter>);</programlisting>
<para>Removes the string at <parameter>position</parameter>
 from <parameter>self</parameter>
. <parameter>position</parameter>
 must
be smaller than the current length of the list.</para>
<refsect3 id="gtk-string-list-remove.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>self</para></entry>
<entry role="parameter_description"><para>a <link linkend="GtkStringList"><type>GtkStringList</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>position</para></entry>
<entry role="parameter_description"><para>the position of the string that is to be removed</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="gtk-string-list-splice" role="function">
<title>gtk_string_list_splice&#160;()</title>
<indexterm zone="gtk-string-list-splice"><primary>gtk_string_list_splice</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
gtk_string_list_splice (<parameter><link linkend="GtkStringList"><type>GtkStringList</type></link> *self</parameter>,
                        <parameter><link linkend="guint"><type>guint</type></link> position</parameter>,
                        <parameter><link linkend="guint"><type>guint</type></link> n_removals</parameter>,
                        <parameter>const <link linkend="char"><type>char</type></link> * const *additions</parameter>);</programlisting>
<para>Changes <parameter>self</parameter>
 by removing <parameter>n_removals</parameter>
 strings and adding <parameter>additions</parameter>

to it.</para>
<para>This function is more efficient than <link linkend="gtk-string-list-append"><function>gtk_string_list_append()</function></link> and
<link linkend="gtk-string-list-remove"><function>gtk_string_list_remove()</function></link>, because it only emits
<link linkend="GListModel-items-changed"><type>“items-changed”</type></link> once for the change.</para>
<para>This function copies the strings in <parameter>additions</parameter>
.</para>
<para>The parameters <parameter>position</parameter>
 and <parameter>n_removals</parameter>
 must be correct (ie:
<parameter>position</parameter>
 + <parameter>n_removals</parameter>
 must be less than or equal to the length
of the list at the time this function is called).</para>
<refsect3 id="gtk-string-list-splice.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>self</para></entry>
<entry role="parameter_description"><para>a <link linkend="GtkStringList"><type>GtkStringList</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>position</para></entry>
<entry role="parameter_description"><para>the position at which to make the change</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>n_removals</para></entry>
<entry role="parameter_description"><para>the number of strings to remove</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>additions</para></entry>
<entry role="parameter_description"><para>The strings to add. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>array</acronym> zero-terminated=1][<acronym>nullable</acronym>]</emphasis></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="gtk-string-list-get-string" role="function">
<title>gtk_string_list_get_string&#160;()</title>
<indexterm zone="gtk-string-list-get-string"><primary>gtk_string_list_get_string</primary></indexterm>
<programlisting language="C">const <link linkend="char"><returnvalue>char</returnvalue></link>&#160;*
gtk_string_list_get_string (<parameter><link linkend="GtkStringList"><type>GtkStringList</type></link> *self</parameter>,
                            <parameter><link linkend="guint"><type>guint</type></link> position</parameter>);</programlisting>
<para>Gets the string that is at <parameter>position</parameter>
 in <parameter>self</parameter>
. If <parameter>self</parameter>

does not contain <parameter>position</parameter>
 items, <link linkend="NULL:CAPS"><literal>NULL</literal></link> is returned.</para>
<para>This function returns the const char *. To get the
object wrapping it, use <link linkend="g-list-model-get-item"><function>g_list_model_get_item()</function></link>.</para>
<refsect3 id="gtk-string-list-get-string.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>self</para></entry>
<entry role="parameter_description"><para>a <link linkend="GtkStringList"><type>GtkStringList</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>position</para></entry>
<entry role="parameter_description"><para>the position to get the string for</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-string-list-get-string.returns" role="returns">
<title>Returns</title>
<para> the string at the given position</para>
</refsect3></refsect2>
<refsect2 id="gtk-string-object-new" role="function">
<title>gtk_string_object_new&#160;()</title>
<indexterm zone="gtk-string-object-new"><primary>gtk_string_object_new</primary></indexterm>
<programlisting language="C"><link linkend="GtkStringObject"><returnvalue>GtkStringObject</returnvalue></link>&#160;*
gtk_string_object_new (<parameter>const <link linkend="char"><type>char</type></link> *string</parameter>);</programlisting>
<para>Wraps a string in an object for use with <link linkend="GListModel"><type>GListModel</type></link></para>
<refsect3 id="gtk-string-object-new.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>string</para></entry>
<entry role="parameter_description"><para>The string to wrap. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>not nullable</acronym>]</emphasis></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-string-object-new.returns" role="returns">
<title>Returns</title>
<para> a new <link linkend="GtkStringObject"><type>GtkStringObject</type></link></para>
</refsect3></refsect2>
<refsect2 id="gtk-string-object-get-string" role="function">
<title>gtk_string_object_get_string&#160;()</title>
<indexterm zone="gtk-string-object-get-string"><primary>gtk_string_object_get_string</primary></indexterm>
<programlisting language="C">const <link linkend="char"><returnvalue>char</returnvalue></link>&#160;*
gtk_string_object_get_string (<parameter><link linkend="GtkStringObject"><type>GtkStringObject</type></link> *self</parameter>);</programlisting>
<para>Returns the string contained in a <link linkend="GtkStringObject"><type>GtkStringObject</type></link>.</para>
<refsect3 id="gtk-string-object-get-string.parameters" role="parameters">
<title>Parameters</title>
<informaltable role="parameters_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="parameters_name" colwidth="150px"/>
<colspec colname="parameters_description"/>
<colspec colname="parameters_annotations" colwidth="200px"/>
<tbody>
<row><entry role="parameter_name"><para>self</para></entry>
<entry role="parameter_description"><para>a <link linkend="GtkStringObject"><type>GtkStringObject</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-string-object-get-string.returns" role="returns">
<title>Returns</title>
<para> the string of <parameter>self</parameter>
</para>
</refsect3></refsect2>

</refsect1>
<refsect1 id="GtkStringList.other_details" role="details">
<title role="details.title">Types and Values</title>
<refsect2 id="GtkStringList-struct" role="struct">
<title>GtkStringList</title>
<indexterm zone="GtkStringList-struct"><primary>GtkStringList</primary></indexterm>
<programlisting language="C">typedef struct _GtkStringList GtkStringList;</programlisting>
</refsect2>
<refsect2 id="GtkStringObject-struct" role="struct">
<title>GtkStringObject</title>
<indexterm zone="GtkStringObject-struct"><primary>GtkStringObject</primary></indexterm>
<programlisting language="C">typedef struct _GtkStringObject GtkStringObject;</programlisting>
</refsect2>

</refsect1>
<refsect1 id="GtkStringList.property-details" role="property_details">
<title role="property_details.title">Property Details</title>
<refsect2 id="GtkStringObject--string" role="property"><title>The <literal>“string”</literal> property</title>
<indexterm zone="GtkStringObject--string"><primary>GtkStringObject:string</primary></indexterm>
<programlisting>  “string”                   <link linkend="char"><type>char</type></link>&#160;*</programlisting>
<para>String.</para><para>Owner: GtkStringObject</para>
<para>Flags: Read</para>
<para>Default value: NULL</para>
</refsect2>

</refsect1>
<refsect1 id="GtkStringList.see-also">
<title>See Also</title>
<para><link linkend="GListModel"><type>GListModel</type></link></para>

</refsect1>

</refentry>
