<?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="GtkSelectionModel">
<refmeta>
<refentrytitle role="top_of_page" id="GtkSelectionModel.top_of_page">GtkSelectionModel</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GTK4 Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>GtkSelectionModel</refname>
<refpurpose>An extension of the list model interface that handles selections</refpurpose>
</refnamediv>

<refsect1 id="GtkSelectionModel.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="gboolean"><returnvalue>gboolean</returnvalue></link>
</entry><entry role="function_name"><link linkend="gtk-selection-model-is-selected">gtk_selection_model_is_selected</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GtkBitset"><returnvalue>GtkBitset</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="gtk-selection-model-get-selection">gtk_selection_model_get_selection</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GtkBitset"><returnvalue>GtkBitset</returnvalue></link>&#160;*
</entry><entry role="function_name"><link linkend="gtk-selection-model-get-selection-in-range">gtk_selection_model_get_selection_in_range</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-selection-model-select-item">gtk_selection_model_select_item</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-selection-model-unselect-item">gtk_selection_model_unselect_item</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-selection-model-select-range">gtk_selection_model_select_range</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-selection-model-unselect-range">gtk_selection_model_unselect_range</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-selection-model-select-all">gtk_selection_model_select_all</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-selection-model-unselect-all">gtk_selection_model_unselect_all</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-selection-model-set-selection">gtk_selection_model_set_selection</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-selection-model-selection-changed">gtk_selection_model_selection_changed</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 id="GtkSelectionModel.signals" role="signal_proto">
<title role="signal_proto.title">Signals</title>
<informaltable frame="none">
<tgroup cols="3">
<colspec colname="signal_proto_type" colwidth="150px"/>
<colspec colname="signal_proto_name" colwidth="300px"/>
<colspec colname="signal_proto_flags" colwidth="200px"/>
<tbody>
<row><entry role="signal_type"><link linkend="void"><returnvalue>void</returnvalue></link></entry><entry role="signal_name"><link linkend="GtkSelectionModel-selection-changed">selection-changed</link></entry><entry role="signal_flags"><link linkend="G-SIGNAL-RUN-LAST:CAPS">Run Last</link></entry></row>

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

</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 id="GtkSelectionModel.object-hierarchy" role="object_hierarchy">
<title role="object_hierarchy.title">Object Hierarchy</title>
<screen>    <link linkend="GInterface">GInterface</link>
    <phrase role="lineart">&#9584;&#9472;&#9472;</phrase> GtkSelectionModel
</screen>
</refsect1>
<refsect1 id="GtkSelectionModel.prerequisites" role="prerequisites">
<title role="prerequisites.title">Prerequisites</title>
<para>
GtkSelectionModel requires
 <link linkend="GListModel">GListModel</link> and  <link linkend="GObject">GObject</link>.</para>

</refsect1>
<refsect1 id="GtkSelectionModel.implementations" role="implementations">
<title role="implementations.title">Known Implementations</title>
<para>
GtkSelectionModel is implemented by
 <link linkend="GtkMultiSelection">GtkMultiSelection</link>,  <link linkend="GtkNoSelection">GtkNoSelection</link> and  <link linkend="GtkSingleSelection">GtkSingleSelection</link>.</para>

</refsect1>

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

<refsect1 id="GtkSelectionModel.description" role="desc">
<title role="desc.title">Description</title>
<para><link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link> is an interface that extends the <link linkend="GListModel"><type>GListModel</type></link> interface by
adding support for selections. This support is then used by widgets using list
models to add the ability to select and unselect various items.</para>
<para>GTK provides default implementations of the most common selection modes such
as <link linkend="GtkSingleSelection"><type>GtkSingleSelection</type></link>, so you will only need to implement this interface if
you want detailed control about how selections should be handled.</para>
<para>A <link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link> supports a single boolean per item indicating if an item
is selected or not. This can be queried via <link linkend="gtk-selection-model-is-selected"><function>gtk_selection_model_is_selected()</function></link>.
When the selected state of one or more items changes, the model will emit the
<link linkend="GtkSelectionModel-selection-changed"><type>“selection-changed”</type></link> signal by calling the
<link linkend="gtk-selection-model-selection-changed"><function>gtk_selection_model_selection_changed()</function></link> function. The positions given in that
signal may have their selection state changed, though that is not a requirement.
If new items added to the model via the <link linkend="GListModel-items-changed"><type>“items-changed”</type></link> signal are
selected or not is up to the implementation.</para>
<para>Note that items added via <link linkend="GListModel-items-changed"><type>“items-changed”</type></link> may already be selected
and no <link linkend="GtkSelectionModel-selection-changed"><type>“selection-changed”</type></link> will be emitted for them. So to
track which items are selected, it is necessary to listen to both signals.</para>
<para>Additionally, the interface can expose functionality to select and unselect
items. If these functions are implemented, GTK's list widgets will allow users
to select and unselect items. However, <link linkend="GtkSelectionModels"><type>GtkSelectionModels</type></link> are free to only
implement them partially or not at all. In that case the widgets will not
support the unimplemented operations.</para>
<para>When selecting or unselecting is supported by a model, the return values of
the selection functions do *not* indicate if selection or unselection happened.
They are only meant to indicate complete failure, like when this mode of
selecting is not supported by the model.</para>
<para>Selections may happen asynchronously, so the only reliable way to find out
when an item was selected is to listen to the signals that indicate selection.</para>

</refsect1>
<refsect1 id="GtkSelectionModel.functions_details" role="details">
<title role="details.title">Functions</title>
<refsect2 id="gtk-selection-model-is-selected" role="function">
<title>gtk_selection_model_is_selected&#160;()</title>
<indexterm zone="gtk-selection-model-is-selected"><primary>gtk_selection_model_is_selected</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
gtk_selection_model_is_selected (<parameter><link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link> *model</parameter>,
                                 <parameter><link linkend="guint"><type>guint</type></link> position</parameter>);</programlisting>
<para>Checks if the given item is selected.</para>
<refsect3 id="gtk-selection-model-is-selected.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>a <link linkend="GtkSelectionModel"><type>GtkSelectionModel</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 item to query</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-selection-model-is-selected.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if the item is selected</para>
</refsect3></refsect2>
<refsect2 id="gtk-selection-model-get-selection" role="function">
<title>gtk_selection_model_get_selection&#160;()</title>
<indexterm zone="gtk-selection-model-get-selection"><primary>gtk_selection_model_get_selection</primary></indexterm>
<programlisting language="C"><link linkend="GtkBitset"><returnvalue>GtkBitset</returnvalue></link>&#160;*
gtk_selection_model_get_selection (<parameter><link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link> *model</parameter>);</programlisting>
<para>Gets the set containing all currently selected items in the model.</para>
<para>This function may be slow, so if you are only interested in single item,
consider using <link linkend="gtk-selection-model-is-selected"><function>gtk_selection_model_is_selected()</function></link> or if you are only
interested in a few consider <link linkend="gtk-selection-model-get-selection-in-range"><function>gtk_selection_model_get_selection_in_range()</function></link>.</para>
<refsect3 id="gtk-selection-model-get-selection.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>a <link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-selection-model-get-selection.returns" role="returns">
<title>Returns</title>
<para>a <link linkend="GtkBitset"><type>GtkBitset</type></link> containing all the values currently
selected in <parameter>model</parameter>
. If no items are selected, the bitset is empty.
The bitset must not be modified. </para>
<para><emphasis role="annotation">[<acronym>transfer full</acronym>]</emphasis></para>
</refsect3></refsect2>
<refsect2 id="gtk-selection-model-get-selection-in-range" role="function">
<title>gtk_selection_model_get_selection_in_range&#160;()</title>
<indexterm zone="gtk-selection-model-get-selection-in-range"><primary>gtk_selection_model_get_selection_in_range</primary></indexterm>
<programlisting language="C"><link linkend="GtkBitset"><returnvalue>GtkBitset</returnvalue></link>&#160;*
gtk_selection_model_get_selection_in_range
                               (<parameter><link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link> *model</parameter>,
                                <parameter><link linkend="guint"><type>guint</type></link> position</parameter>,
                                <parameter><link linkend="guint"><type>guint</type></link> n_items</parameter>);</programlisting>
<para>Gets a set containing a set where the values in the range <literal>[position,
position + n_items)</literal> match the selected state of the items in that range.
All values outside that range are undefined.</para>
<para>This function is an optimization for <link linkend="gtk-selection-model-get-selection"><function>gtk_selection_model_get_selection()</function></link> when
you are only interested in part of the model's selected state. A common use
case is in response to the <link linkend="GtkSelectionModel-selection-changed"><type>“selection-changed”</type></link> signal.</para>
<refsect3 id="gtk-selection-model-get-selection-in-range.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>a <link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>position</para></entry>
<entry role="parameter_description"><para>start of the queired range</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>n_items</para></entry>
<entry role="parameter_description"><para>number of items in the queried range</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-selection-model-get-selection-in-range.returns" role="returns">
<title>Returns</title>
<para> A <link linkend="GtkBitset"><type>GtkBitset</type></link> that matches the selection state for the given state
with all other values being undefined.
The bitset must not be modified.</para>
</refsect3></refsect2>
<refsect2 id="gtk-selection-model-select-item" role="function">
<title>gtk_selection_model_select_item&#160;()</title>
<indexterm zone="gtk-selection-model-select-item"><primary>gtk_selection_model_select_item</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
gtk_selection_model_select_item (<parameter><link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link> *model</parameter>,
                                 <parameter><link linkend="guint"><type>guint</type></link> position</parameter>,
                                 <parameter><link linkend="gboolean"><type>gboolean</type></link> unselect_rest</parameter>);</programlisting>
<para>Requests to select an item in the model.</para>
<refsect3 id="gtk-selection-model-select-item.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>a <link linkend="GtkSelectionModel"><type>GtkSelectionModel</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 item to select</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>unselect_rest</para></entry>
<entry role="parameter_description"><para>whether previously selected items should be unselected</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-selection-model-select-item.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if this action was supported and no fallback should be
tried. This does not mean the item was selected.</para>
</refsect3></refsect2>
<refsect2 id="gtk-selection-model-unselect-item" role="function">
<title>gtk_selection_model_unselect_item&#160;()</title>
<indexterm zone="gtk-selection-model-unselect-item"><primary>gtk_selection_model_unselect_item</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
gtk_selection_model_unselect_item (<parameter><link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link> *model</parameter>,
                                   <parameter><link linkend="guint"><type>guint</type></link> position</parameter>);</programlisting>
<para>Requests to unselect an item in the model.</para>
<refsect3 id="gtk-selection-model-unselect-item.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>a <link linkend="GtkSelectionModel"><type>GtkSelectionModel</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 item to unselect</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-selection-model-unselect-item.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if this action was supported and no fallback should be
tried. This does not mean the item was unselected.</para>
</refsect3></refsect2>
<refsect2 id="gtk-selection-model-select-range" role="function">
<title>gtk_selection_model_select_range&#160;()</title>
<indexterm zone="gtk-selection-model-select-range"><primary>gtk_selection_model_select_range</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
gtk_selection_model_select_range (<parameter><link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link> *model</parameter>,
                                  <parameter><link linkend="guint"><type>guint</type></link> position</parameter>,
                                  <parameter><link linkend="guint"><type>guint</type></link> n_items</parameter>,
                                  <parameter><link linkend="gboolean"><type>gboolean</type></link> unselect_rest</parameter>);</programlisting>
<para>Requests to select a range of items in the model.</para>
<refsect3 id="gtk-selection-model-select-range.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>a <link linkend="GtkSelectionModel"><type>GtkSelectionModel</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 first item to select</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>n_items</para></entry>
<entry role="parameter_description"><para>the number of items to select</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>unselect_rest</para></entry>
<entry role="parameter_description"><para>whether previously selected items should be unselected</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-selection-model-select-range.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if this action was supported and no fallback should be
tried. This does not mean the range was selected.</para>
</refsect3></refsect2>
<refsect2 id="gtk-selection-model-unselect-range" role="function">
<title>gtk_selection_model_unselect_range&#160;()</title>
<indexterm zone="gtk-selection-model-unselect-range"><primary>gtk_selection_model_unselect_range</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
gtk_selection_model_unselect_range (<parameter><link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link> *model</parameter>,
                                    <parameter><link linkend="guint"><type>guint</type></link> position</parameter>,
                                    <parameter><link linkend="guint"><type>guint</type></link> n_items</parameter>);</programlisting>
<para>Requests to unselect a range of items in the model.</para>
<refsect3 id="gtk-selection-model-unselect-range.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>a <link linkend="GtkSelectionModel"><type>GtkSelectionModel</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 first item to unselect</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>n_items</para></entry>
<entry role="parameter_description"><para>the number of items to unselect</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-selection-model-unselect-range.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if this action was supported and no fallback should be
tried. This does not mean the range was unselected.</para>
</refsect3></refsect2>
<refsect2 id="gtk-selection-model-select-all" role="function">
<title>gtk_selection_model_select_all&#160;()</title>
<indexterm zone="gtk-selection-model-select-all"><primary>gtk_selection_model_select_all</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
gtk_selection_model_select_all (<parameter><link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link> *model</parameter>);</programlisting>
<para>Requests to select all items in the model.</para>
<refsect3 id="gtk-selection-model-select-all.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>a <link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-selection-model-select-all.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if this action was supported and no fallback should be
tried. This does not mean that all items are now selected.</para>
</refsect3></refsect2>
<refsect2 id="gtk-selection-model-unselect-all" role="function">
<title>gtk_selection_model_unselect_all&#160;()</title>
<indexterm zone="gtk-selection-model-unselect-all"><primary>gtk_selection_model_unselect_all</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
gtk_selection_model_unselect_all (<parameter><link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link> *model</parameter>);</programlisting>
<para>Requests to unselect all items in the model.</para>
<refsect3 id="gtk-selection-model-unselect-all.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>a <link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-selection-model-unselect-all.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if this action was supported and no fallback should be
tried. This does not mean that all items are now unselected.</para>
</refsect3></refsect2>
<refsect2 id="gtk-selection-model-set-selection" role="function">
<title>gtk_selection_model_set_selection&#160;()</title>
<indexterm zone="gtk-selection-model-set-selection"><primary>gtk_selection_model_set_selection</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
gtk_selection_model_set_selection (<parameter><link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link> *model</parameter>,
                                   <parameter><link linkend="GtkBitset"><type>GtkBitset</type></link> *selected</parameter>,
                                   <parameter><link linkend="GtkBitset"><type>GtkBitset</type></link> *mask</parameter>);</programlisting>
<para>This is the most advanced selection updating method that allows
the most fine-grained control over selection changes.
If you can, you should try the simpler versions, as implementations
are more likely to implement support for those.</para>
<para>Requests that the selection state of all positions set in <parameter>mask</parameter>
 be
updated to the respective value in the <parameter>selected</parameter>
 bitmask.</para>
<para>In pseudocode, it would look something like this:</para>
<informalexample><programlisting role="example"><![CDATA[
for (i = 0; i < n_items; i++)
  {
    // don't change values not in the mask
    if (!gtk_bitset_contains (mask, i))
      continue;

    if (gtk_bitset_contains (selected, i))
      select_item (i);
    else
      unselect_item (i);
  }

gtk_selection_model_selection_changed (model, first_changed_item, n_changed_items);
]]></programlisting></informalexample>
<para></para>
<para><parameter>mask</parameter>
 and <parameter>selected</parameter>
 must not be modified. They may refer to the same bitset,
which would mean that every item in the set should be selected.</para>
<refsect3 id="gtk-selection-model-set-selection.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>a <link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>selected</para></entry>
<entry role="parameter_description"><para>bitmask specifying if items should be selected or
unselected</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>mask</para></entry>
<entry role="parameter_description"><para>bitmask specifying which items should be updated</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-selection-model-set-selection.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if this action was supported and no fallback should be
tried. This does not mean that all items were updated according
to the inputs.</para>
</refsect3></refsect2>
<refsect2 id="gtk-selection-model-selection-changed" role="function">
<title>gtk_selection_model_selection_changed&#160;()</title>
<indexterm zone="gtk-selection-model-selection-changed"><primary>gtk_selection_model_selection_changed</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
gtk_selection_model_selection_changed (<parameter><link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link> *model</parameter>,
                                       <parameter><link linkend="guint"><type>guint</type></link> position</parameter>,
                                       <parameter><link linkend="guint"><type>guint</type></link> n_items</parameter>);</programlisting>
<para>Helper function for implementations of <link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link>.
Call this when a the selection changes to emit the
<link linkend="GtkSelectionModel-selection-changed"><type>“selection-changed”</type></link> signal.</para>
<refsect3 id="gtk-selection-model-selection-changed.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>a <link linkend="GtkSelectionModel"><type>GtkSelectionModel</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 first changed item</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>n_items</para></entry>
<entry role="parameter_description"><para>the number of changed items</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>

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

</refsect1>
<refsect1 id="GtkSelectionModel.signal-details" role="signals">
<title role="signals.title">Signal Details</title>
<refsect2 id="GtkSelectionModel-selection-changed" role="signal"><title>The <literal>“selection-changed”</literal> signal</title>
<indexterm zone="GtkSelectionModel-selection-changed"><primary>GtkSelectionModel::selection-changed</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
user_function (<link linkend="GtkSelectionModel"><type>GtkSelectionModel</type></link> *model,
               <link linkend="guint"><type>guint</type></link>              position,
               <link linkend="guint"><type>guint</type></link>              n_items,
               <link linkend="gpointer"><type>gpointer</type></link>           user_data)</programlisting>
<para>Emitted when the selection state of some of the items in <parameter>model</parameter>
 changes.</para>
<para>Note that this signal does not specify the new selection state of the items,
they need to be queried manually.
It is also not necessary for a model to change the selection state of any of
the items in the selection model, though it would be rather useless to emit
such a signal.</para>
<refsect3 id="GtkSelectionModel-selection-changed.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>a <link linkend="GtkSelectionModel"><type>GtkSelectionModel</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 first item that may have changed</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>n_items</para></entry>
<entry role="parameter_description"><para>number of items with changes</para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><simpara>user_data</simpara></entry>
<entry role="parameter_description"><simpara>user data set when the signal handler was connected.</simpara></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><para>Flags: <link linkend="G-SIGNAL-RUN-LAST:CAPS">Run Last</link></para>
</refsect2>
</refsect1>
<refsect1 id="GtkSelectionModel.see-also">
<title>See Also</title>
<para><link linkend="GListModel"><type>GListModel</type></link>, <link linkend="GtkSingleSelection"><type>GtkSingleSelection</type></link></para>

</refsect1>

</refentry>
