<?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="GtkSortListModel">
<refmeta>
<refentrytitle role="top_of_page" id="GtkSortListModel.top_of_page">GtkSortListModel</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GTK4 Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>GtkSortListModel</refname>
<refpurpose>A list model that sorts its items</refpurpose>
</refnamediv>

<refsect1 id="GtkSortListModel.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="GtkSortListModel"><returnvalue>GtkSortListModel</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="gtk-sort-list-model-new">gtk_sort_list_model_new</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GtkSortListModel"><returnvalue>GtkSortListModel</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="gtk-sort-list-model-new-for-type">gtk_sort_list_model_new_for_type</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-sort-list-model-set-sort-func">gtk_sort_list_model_set_sort_func</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
</entry><entry role="function_name"><link linkend="gtk-sort-list-model-has-sort">gtk_sort_list_model_has_sort</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-sort-list-model-set-model">gtk_sort_list_model_set_model</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GListModel"><returnvalue>GListModel</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="gtk-sort-list-model-get-model">gtk_sort_list_model_get_model</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-sort-list-model-resort">gtk_sort_list_model_resort</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 id="GtkSortListModel.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="gboolean"><type>gboolean</type></link></entry><entry role="property_name"><link linkend="GtkSortListModel--has-sort">has-sort</link></entry><entry role="property_flags">Read</entry></row>
<row><entry role="property_type"><link linkend="GType"><type>GType</type></link>&#160;*</entry><entry role="property_name"><link linkend="GtkSortListModel--item-type">item-type</link></entry><entry role="property_flags">Read / Write / Construct&#160;Only</entry></row>
<row><entry role="property_type"><link linkend="GListModel"><type>GListModel</type></link>&#160;*</entry><entry role="property_name"><link linkend="GtkSortListModel--model">model</link></entry><entry role="property_flags">Read / Write / Construct&#160;Only</entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 id="GtkSortListModel.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="GtkSortListModel-struct">GtkSortListModel</link></entry></row>

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

</refsect1>

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

<refsect1 id="GtkSortListModel.description" role="desc">
<title role="desc.title">Description</title>
<para><link linkend="GtkSortListModel"><type>GtkSortListModel</type></link> is a list model that takes a list model and
sorts its elements according to a compare function.</para>
<para><link linkend="GtkSortListModel"><type>GtkSortListModel</type></link> is a generic model and because of that it
cannot take advantage of any external knowledge when sorting.
If you run into performance issues with <link linkend="GtkSortListModel"><type>GtkSortListModel</type></link>, it
is strongly recommended that you write your own sorting list
model.</para>

</refsect1>
<refsect1 id="GtkSortListModel.functions_details" role="details">
<title role="details.title">Functions</title>
<refsect2 id="gtk-sort-list-model-new" role="function">
<title>gtk_sort_list_model_new&#160;()</title>
<indexterm zone="gtk-sort-list-model-new"><primary>gtk_sort_list_model_new</primary></indexterm>
<programlisting language="C"><link linkend="GtkSortListModel"><returnvalue>GtkSortListModel</returnvalue></link>&#160;*
gtk_sort_list_model_new (<parameter><link linkend="GListModel"><type>GListModel</type></link> *model</parameter>,
                         <parameter><link linkend="GCompareDataFunc"><type>GCompareDataFunc</type></link> sort_func</parameter>,
                         <parameter><link linkend="gpointer"><type>gpointer</type></link> user_data</parameter>,
                         <parameter><link linkend="GDestroyNotify"><type>GDestroyNotify</type></link> user_destroy</parameter>);</programlisting>
<para>Creates a new sort list model that uses the <parameter>sort_func</parameter>
 to sort <parameter>model</parameter>
.</para>
<refsect3 id="gtk-sort-list-model-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>model</para></entry>
<entry role="parameter_description"><para>the model to sort</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>sort_func</para></entry>
<entry role="parameter_description"><para>sort function or <link linkend="NULL:CAPS"><literal>NULL</literal></link> to not sort items. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>allow-none</acronym>]</emphasis></entry></row>
<row><entry role="parameter_name"><para>user_data</para></entry>
<entry role="parameter_description"><para>user data passed to <parameter>sort_func</parameter>
. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>closure</acronym>]</emphasis></entry></row>
<row><entry role="parameter_name"><para>user_destroy</para></entry>
<entry role="parameter_description"><para>destroy notifier for <parameter>user_data</parameter>
</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-sort-list-model-new.returns" role="returns">
<title>Returns</title>
<para> a new <link linkend="GtkSortListModel"><type>GtkSortListModel</type></link></para>
</refsect3></refsect2>
<refsect2 id="gtk-sort-list-model-new-for-type" role="function">
<title>gtk_sort_list_model_new_for_type&#160;()</title>
<indexterm zone="gtk-sort-list-model-new-for-type"><primary>gtk_sort_list_model_new_for_type</primary></indexterm>
<programlisting language="C"><link linkend="GtkSortListModel"><returnvalue>GtkSortListModel</returnvalue></link>&#160;*
gtk_sort_list_model_new_for_type (<parameter><link linkend="GType"><type>GType</type></link> item_type</parameter>);</programlisting>
<para>Creates a new empty sort list model set up to return items of type <parameter>item_type</parameter>
.
It is up to the application to set a proper sort function and model to ensure
the item type is matched.</para>
<refsect3 id="gtk-sort-list-model-new-for-type.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>item_type</para></entry>
<entry role="parameter_description"><para>the type of the items that will be returned</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-sort-list-model-new-for-type.returns" role="returns">
<title>Returns</title>
<para> a new <link linkend="GtkSortListModel"><type>GtkSortListModel</type></link></para>
</refsect3></refsect2>
<refsect2 id="gtk-sort-list-model-set-sort-func" role="function">
<title>gtk_sort_list_model_set_sort_func&#160;()</title>
<indexterm zone="gtk-sort-list-model-set-sort-func"><primary>gtk_sort_list_model_set_sort_func</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
gtk_sort_list_model_set_sort_func (<parameter><link linkend="GtkSortListModel"><type>GtkSortListModel</type></link> *self</parameter>,
                                   <parameter><link linkend="GCompareDataFunc"><type>GCompareDataFunc</type></link> sort_func</parameter>,
                                   <parameter><link linkend="gpointer"><type>gpointer</type></link> user_data</parameter>,
                                   <parameter><link linkend="GDestroyNotify"><type>GDestroyNotify</type></link> user_destroy</parameter>);</programlisting>
<para>Sets the function used to sort items. The function will be called for every
item and must return an integer less than, equal to, or greater than zero if
for two items from the model if the first item is considered to be respectively
less than, equal to, or greater than the second.</para>
<refsect3 id="gtk-sort-list-model-set-sort-func.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="GtkSortListModel"><type>GtkSortListModel</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>sort_func</para></entry>
<entry role="parameter_description"><para>sort function or <link linkend="NULL:CAPS"><literal>NULL</literal></link> to not sort items. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>allow-none</acronym>]</emphasis></entry></row>
<row><entry role="parameter_name"><para>user_data</para></entry>
<entry role="parameter_description"><para>user data passed to <parameter>sort_func</parameter>
. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>closure</acronym>]</emphasis></entry></row>
<row><entry role="parameter_name"><para>user_destroy</para></entry>
<entry role="parameter_description"><para>destroy notifier for <parameter>user_data</parameter>
</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="gtk-sort-list-model-has-sort" role="function">
<title>gtk_sort_list_model_has_sort&#160;()</title>
<indexterm zone="gtk-sort-list-model-has-sort"><primary>gtk_sort_list_model_has_sort</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
gtk_sort_list_model_has_sort (<parameter><link linkend="GtkSortListModel"><type>GtkSortListModel</type></link> *self</parameter>);</programlisting>
<para>Checks if a sort function is currently set on <parameter>self</parameter>
</para>
<refsect3 id="gtk-sort-list-model-has-sort.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="GtkSortListModel"><type>GtkSortListModel</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-sort-list-model-has-sort.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if a sort function is set</para>
</refsect3></refsect2>
<refsect2 id="gtk-sort-list-model-set-model" role="function">
<title>gtk_sort_list_model_set_model&#160;()</title>
<indexterm zone="gtk-sort-list-model-set-model"><primary>gtk_sort_list_model_set_model</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
gtk_sort_list_model_set_model (<parameter><link linkend="GtkSortListModel"><type>GtkSortListModel</type></link> *self</parameter>,
                               <parameter><link linkend="GListModel"><type>GListModel</type></link> *model</parameter>);</programlisting>
<para>Sets the model to be sorted. The <parameter>model</parameter>
's item type must conform to
the item type of <parameter>self</parameter>
.</para>
<refsect3 id="gtk-sort-list-model-set-model.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="GtkSortListModel"><type>GtkSortListModel</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>model</para></entry>
<entry role="parameter_description"><para>The model to be sorted. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>allow-none</acronym>]</emphasis></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="gtk-sort-list-model-get-model" role="function">
<title>gtk_sort_list_model_get_model&#160;()</title>
<indexterm zone="gtk-sort-list-model-get-model"><primary>gtk_sort_list_model_get_model</primary></indexterm>
<programlisting language="C"><link linkend="GListModel"><returnvalue>GListModel</returnvalue></link>&#160;*
gtk_sort_list_model_get_model (<parameter><link linkend="GtkSortListModel"><type>GtkSortListModel</type></link> *self</parameter>);</programlisting>
<para>Gets the model currently sorted or <link linkend="NULL:CAPS"><literal>NULL</literal></link> if none.</para>
<refsect3 id="gtk-sort-list-model-get-model.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="GtkSortListModel"><type>GtkSortListModel</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-sort-list-model-get-model.returns" role="returns">
<title>Returns</title>
<para>The model that gets sorted. </para>
<para><emphasis role="annotation">[<acronym>nullable</acronym>][<acronym>transfer none</acronym>]</emphasis></para>
</refsect3></refsect2>
<refsect2 id="gtk-sort-list-model-resort" role="function">
<title>gtk_sort_list_model_resort&#160;()</title>
<indexterm zone="gtk-sort-list-model-resort"><primary>gtk_sort_list_model_resort</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
gtk_sort_list_model_resort (<parameter><link linkend="GtkSortListModel"><type>GtkSortListModel</type></link> *self</parameter>);</programlisting>
<para>Causes <parameter>self</parameter>
 to resort all items in the model.</para>
<para>Calling this function is necessary when data used by the sort
function has changed.</para>
<refsect3 id="gtk-sort-list-model-resort.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="GtkSortListModel"><type>GtkSortListModel</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>

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

</refsect1>
<refsect1 id="GtkSortListModel.property-details" role="property_details">
<title role="property_details.title">Property Details</title>
<refsect2 id="GtkSortListModel--has-sort" role="property"><title>The <literal>“has-sort”</literal> property</title>
<indexterm zone="GtkSortListModel--has-sort"><primary>GtkSortListModel:has-sort</primary></indexterm>
<programlisting>  “has-sort”                 <link linkend="gboolean"><type>gboolean</type></link></programlisting>
<para>If a sort function is set for this model</para>
<para>Owner: GtkSortListModel</para>
<para>Flags: Read</para>
<para>Default value: FALSE</para>
</refsect2>
<refsect2 id="GtkSortListModel--item-type" role="property"><title>The <literal>“item-type”</literal> property</title>
<indexterm zone="GtkSortListModel--item-type"><primary>GtkSortListModel:item-type</primary></indexterm>
<programlisting>  “item-type”                <link linkend="GType"><type>GType</type></link>&#160;*</programlisting>
<para>The <link linkend="GType"><type>GType</type></link> for items of this model</para>
<para>Owner: GtkSortListModel</para>
<para>Flags: Read / Write / Construct&#160;Only</para>
<para>Allowed values: GObject</para>
</refsect2>
<refsect2 id="GtkSortListModel--model" role="property"><title>The <literal>“model”</literal> property</title>
<indexterm zone="GtkSortListModel--model"><primary>GtkSortListModel:model</primary></indexterm>
<programlisting>  “model”                    <link linkend="GListModel"><type>GListModel</type></link>&#160;*</programlisting>
<para>The model being sorted</para>
<para>Owner: GtkSortListModel</para>
<para>Flags: Read / Write / Construct&#160;Only</para>
</refsect2>

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

</refsect1>

</refentry>
