<?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 index-Objects-Grouped SYSTEM "objects_grouped.sgml"-->
<refentry id="GtkTreeSelection">
<refmeta>
<refentrytitle role="top_of_page" id="GtkTreeSelection.top_of_page">GtkTreeSelection</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GTK Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>GtkTreeSelection</refname>
<refpurpose>The selection object for GtkTreeView</refpurpose>
</refnamediv>

<refsynopsisdiv id="GtkTreeSelection.synopsis" role="synopsis">
<title role="synopsis.title">Synopsis</title>

<synopsis>

#include &lt;gtk/gtk.h&gt;

                    <link linkend="GtkTreeSelection-struct">GtkTreeSelection</link>;
<link linkend="gboolean">gboolean</link>            (<link linkend="GtkTreeSelectionFunc">*GtkTreeSelectionFunc</link>)             (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreeModel">GtkTreeModel</link> *model,
                                                         <link linkend="GtkTreePath">GtkTreePath</link> *path,
                                                         <link linkend="gboolean">gboolean</link> path_currently_selected,
                                                         <link linkend="gpointer">gpointer</link> data);
<link linkend="void">void</link>                (<link linkend="GtkTreeSelectionForeachFunc">*GtkTreeSelectionForeachFunc</link>)      (<link linkend="GtkTreeModel">GtkTreeModel</link> *model,
                                                         <link linkend="GtkTreePath">GtkTreePath</link> *path,
                                                         <link linkend="GtkTreeIter">GtkTreeIter</link> *iter,
                                                         <link linkend="gpointer">gpointer</link> data);
<link linkend="void">void</link>                <link linkend="gtk-tree-selection-set-mode">gtk_tree_selection_set_mode</link>         (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkSelectionMode">GtkSelectionMode</link> type);
<link linkend="GtkSelectionMode">GtkSelectionMode</link>    <link linkend="gtk-tree-selection-get-mode">gtk_tree_selection_get_mode</link>         (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection);
<link linkend="void">void</link>                <link linkend="gtk-tree-selection-set-select-function">gtk_tree_selection_set_select_function</link>
                                                        (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreeSelectionFunc">GtkTreeSelectionFunc</link> func,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GDestroyNotify">GDestroyNotify</link> destroy);
<link linkend="GtkTreeSelectionFunc">GtkTreeSelectionFunc</link>  <link linkend="gtk-tree-selection-get-select-function">gtk_tree_selection_get_select_function</link>
                                                        (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection);
<link linkend="gpointer">gpointer</link>            <link linkend="gtk-tree-selection-get-user-data">gtk_tree_selection_get_user_data</link>    (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection);
<link linkend="GtkTreeView">GtkTreeView</link>*        <link linkend="gtk-tree-selection-get-tree-view">gtk_tree_selection_get_tree_view</link>    (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection);
<link linkend="gboolean">gboolean</link>            <link linkend="gtk-tree-selection-get-selected">gtk_tree_selection_get_selected</link>     (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreeModel">GtkTreeModel</link> **model,
                                                         <link linkend="GtkTreeIter">GtkTreeIter</link> *iter);
<link linkend="void">void</link>                <link linkend="gtk-tree-selection-selected-foreach">gtk_tree_selection_selected_foreach</link> (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreeSelectionForeachFunc">GtkTreeSelectionForeachFunc</link> func,
                                                         <link linkend="gpointer">gpointer</link> data);
<link linkend="GList">GList</link> *             <link linkend="gtk-tree-selection-get-selected-rows">gtk_tree_selection_get_selected_rows</link>
                                                        (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreeModel">GtkTreeModel</link> **model);
<link linkend="gint">gint</link>                <link linkend="gtk-tree-selection-count-selected-rows">gtk_tree_selection_count_selected_rows</link>
                                                        (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection);
<link linkend="void">void</link>                <link linkend="gtk-tree-selection-select-path">gtk_tree_selection_select_path</link>      (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreePath">GtkTreePath</link> *path);
<link linkend="void">void</link>                <link linkend="gtk-tree-selection-unselect-path">gtk_tree_selection_unselect_path</link>    (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreePath">GtkTreePath</link> *path);
<link linkend="gboolean">gboolean</link>            <link linkend="gtk-tree-selection-path-is-selected">gtk_tree_selection_path_is_selected</link> (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreePath">GtkTreePath</link> *path);
<link linkend="void">void</link>                <link linkend="gtk-tree-selection-select-iter">gtk_tree_selection_select_iter</link>      (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreeIter">GtkTreeIter</link> *iter);
<link linkend="void">void</link>                <link linkend="gtk-tree-selection-unselect-iter">gtk_tree_selection_unselect_iter</link>    (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreeIter">GtkTreeIter</link> *iter);
<link linkend="gboolean">gboolean</link>            <link linkend="gtk-tree-selection-iter-is-selected">gtk_tree_selection_iter_is_selected</link> (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreeIter">GtkTreeIter</link> *iter);
<link linkend="void">void</link>                <link linkend="gtk-tree-selection-select-all">gtk_tree_selection_select_all</link>       (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection);
<link linkend="void">void</link>                <link linkend="gtk-tree-selection-unselect-all">gtk_tree_selection_unselect_all</link>     (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection);
<link linkend="void">void</link>                <link linkend="gtk-tree-selection-select-range">gtk_tree_selection_select_range</link>     (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreePath">GtkTreePath</link> *start_path,
                                                         <link linkend="GtkTreePath">GtkTreePath</link> *end_path);
<link linkend="void">void</link>                <link linkend="gtk-tree-selection-unselect-range">gtk_tree_selection_unselect_range</link>   (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreePath">GtkTreePath</link> *start_path,
                                                         <link linkend="GtkTreePath">GtkTreePath</link> *end_path);
</synopsis>
</refsynopsisdiv>

<refsect1 id="GtkTreeSelection.object-hierarchy" role="object_hierarchy">
<title role="object_hierarchy.title">Object Hierarchy</title>
<synopsis>
  <link linkend="GObject">GObject</link>
   +----GtkTreeSelection
</synopsis>
</refsect1>






<refsect1 id="GtkTreeSelection.signals" role="signal_proto">
<title role="signal_proto.title">Signals</title>
<synopsis>
  &quot;<link linkend="GtkTreeSelection-changed">changed</link>&quot;                                        : Run First
</synopsis>
</refsect1>


<refsect1 id="GtkTreeSelection.description" role="desc">
<title role="desc.title">Description</title>
<para>
The <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link> object is a helper object to manage the selection
for a <link linkend="GtkTreeView"><type>GtkTreeView</type></link> widget.  The <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link> object is
automatically created when a new <link linkend="GtkTreeView"><type>GtkTreeView</type></link> widget is created, and
cannot exist independentally of this widget.  The primary reason the
<link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link> objects exists is for cleanliness of code and API.
That is, there is no conceptual reason all these functions could not be
methods on the <link linkend="GtkTreeView"><type>GtkTreeView</type></link> widget instead of a separate function.
</para>
<para>
The <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link> object is gotten from a <link linkend="GtkTreeView"><type>GtkTreeView</type></link> by calling
<link linkend="gtk-tree-view-get-selection"><function>gtk_tree_view_get_selection()</function></link>.  It can be manipulated to check the
selection status of the tree, as well as select and deselect individual
rows.  Selection is done completely view side.  As a result, multiple
views of the same model can have completely different selections.
Additionally, you cannot change the selection of a row on the model that
is not currently displayed by the view without expanding its parents
first.
</para>
<para>
One of the important things to remember when monitoring the selection of
a view is that the <link linkend="GtkTreeSelection-changed"><type>"changed"</type></link> signal is mostly a hint.  That is, it may
only emit one signal when a range of rows is selected.  Additionally, it
may on occasion emit a ::changed signal when nothing has happened
(mostly as a result of programmers calling select_row on an already
selected row).
</para>
</refsect1>

<refsect1 id="GtkTreeSelection.details" role="details">
<title role="details.title">Details</title>
<refsect2 id="GtkTreeSelection-struct" role="struct">
<title>GtkTreeSelection</title>
<indexterm zone="GtkTreeSelection-struct"><primary sortas="TreeSelection">GtkTreeSelection</primary></indexterm><programlisting>typedef struct _GtkTreeSelection GtkTreeSelection;</programlisting>
<para>
</para></refsect2>
<refsect2 id="GtkTreeSelectionFunc" role="function">
<title>GtkTreeSelectionFunc ()</title>
<indexterm zone="GtkTreeSelectionFunc"><primary sortas="TreeSelectionFunc">GtkTreeSelectionFunc</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            (*GtkTreeSelectionFunc)             (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreeModel">GtkTreeModel</link> *model,
                                                         <link linkend="GtkTreePath">GtkTreePath</link> *path,
                                                         <link linkend="gboolean">gboolean</link> path_currently_selected,
                                                         <link linkend="gpointer">gpointer</link> data);</programlisting>
<para>
A function used by <link linkend="gtk-tree-selection-set-select-function"><function>gtk_tree_selection_set_select_function()</function></link> to filter
whether or not a row may be selected.  It is called whenever a row's
state might change.  A return value of <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> indicates to <parameter>selection</parameter>
that it is okay to change the selection.
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara>A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>model</parameter>&#160;:</term>
<listitem><simpara>A <link linkend="GtkTreeModel"><type>GtkTreeModel</type></link> being viewed
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>path</parameter>&#160;:</term>
<listitem><simpara>The <link linkend="GtkTreePath"><type>GtkTreePath</type></link> of the row in question
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>path_currently_selected</parameter>&#160;:</term>
<listitem><simpara>%TRUE, if the path is currently selected
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara>user data
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara>%TRUE, if the selection state of the row can be toggled
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="GtkTreeSelectionForeachFunc" role="function">
<title>GtkTreeSelectionForeachFunc ()</title>
<indexterm zone="GtkTreeSelectionForeachFunc"><primary sortas="TreeSelectionForeachFunc">GtkTreeSelectionForeachFunc</primary></indexterm><programlisting><link linkend="void">void</link>                (*GtkTreeSelectionForeachFunc)      (<link linkend="GtkTreeModel">GtkTreeModel</link> *model,
                                                         <link linkend="GtkTreePath">GtkTreePath</link> *path,
                                                         <link linkend="GtkTreeIter">GtkTreeIter</link> *iter,
                                                         <link linkend="gpointer">gpointer</link> data);</programlisting>
<para>
A function used by <link linkend="gtk-tree-selection-selected-foreach"><function>gtk_tree_selection_selected_foreach()</function></link> to map all
selected rows.  It will be called on every selected row in the view.
</para><variablelist role="params">
<varlistentry><term><parameter>model</parameter>&#160;:</term>
<listitem><simpara>The <link linkend="GtkTreeModel"><type>GtkTreeModel</type></link> being viewed
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>path</parameter>&#160;:</term>
<listitem><simpara>The <link linkend="GtkTreePath"><type>GtkTreePath</type></link> of a selected row
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>iter</parameter>&#160;:</term>
<listitem><simpara>A <link linkend="GtkTreeIter"><type>GtkTreeIter</type></link> pointing to a selected row
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara>user data
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-tree-selection-set-mode" role="function">
<title>gtk_tree_selection_set_mode ()</title>
<indexterm zone="gtk-tree-selection-set-mode"><primary sortas="tree_selection_set_mode">gtk_tree_selection_set_mode</primary></indexterm><programlisting><link linkend="void">void</link>                gtk_tree_selection_set_mode         (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkSelectionMode">GtkSelectionMode</link> type);</programlisting>
<para>
Sets the selection mode of the <parameter>selection</parameter>.  If the previous type was
<link linkend="GTK-SELECTION-MULTIPLE--CAPS"><type>GTK_SELECTION_MULTIPLE</type></link>, then the anchor is kept selected, if it was
previously selected.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>type</parameter>&#160;:</term>
<listitem><simpara> The selection mode
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-tree-selection-get-mode" role="function">
<title>gtk_tree_selection_get_mode ()</title>
<indexterm zone="gtk-tree-selection-get-mode"><primary sortas="tree_selection_get_mode">gtk_tree_selection_get_mode</primary></indexterm><programlisting><link linkend="GtkSelectionMode">GtkSelectionMode</link>    gtk_tree_selection_get_mode         (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection);</programlisting>
<para>
Gets the selection mode for <parameter>selection</parameter>. See
<link linkend="gtk-tree-selection-set-mode"><function>gtk_tree_selection_set_mode()</function></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> a <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> the current selection mode
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-tree-selection-set-select-function" role="function">
<title>gtk_tree_selection_set_select_function ()</title>
<indexterm zone="gtk-tree-selection-set-select-function"><primary sortas="tree_selection_set_select_function">gtk_tree_selection_set_select_function</primary></indexterm><programlisting><link linkend="void">void</link>                gtk_tree_selection_set_select_function
                                                        (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreeSelectionFunc">GtkTreeSelectionFunc</link> func,
                                                         <link linkend="gpointer">gpointer</link> data,
                                                         <link linkend="GDestroyNotify">GDestroyNotify</link> destroy);</programlisting>
<para>
Sets the selection function.  If set, this function is called before any node
is selected or unselected, giving some control over which nodes are selected.
The select function should return <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if the state of the node may be toggled,
and <link linkend="FALSE--CAPS"><literal>FALSE</literal></link> if the state of the node should be left unchanged.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>func</parameter>&#160;:</term>
<listitem><simpara> The selection function.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara> The selection function's data.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>destroy</parameter>&#160;:</term>
<listitem><simpara> The destroy function for user data.  May be NULL.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-tree-selection-get-select-function" role="function" condition="since:2.14">
<title>gtk_tree_selection_get_select_function ()</title>
<indexterm zone="gtk-tree-selection-get-select-function" role="2.14"><primary sortas="tree_selection_get_select_function">gtk_tree_selection_get_select_function</primary></indexterm><programlisting><link linkend="GtkTreeSelectionFunc">GtkTreeSelectionFunc</link>  gtk_tree_selection_get_select_function
                                                        (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection);</programlisting>
<para>
Returns the current selection function.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The function.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.14</para></refsect2>
<refsect2 id="gtk-tree-selection-get-user-data" role="function">
<title>gtk_tree_selection_get_user_data ()</title>
<indexterm zone="gtk-tree-selection-get-user-data"><primary sortas="tree_selection_get_user_data">gtk_tree_selection_get_user_data</primary></indexterm><programlisting><link linkend="gpointer">gpointer</link>            gtk_tree_selection_get_user_data    (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection);</programlisting>
<para>
Returns the user data for the selection function.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The user data.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-tree-selection-get-tree-view" role="function">
<title>gtk_tree_selection_get_tree_view ()</title>
<indexterm zone="gtk-tree-selection-get-tree-view"><primary sortas="tree_selection_get_tree_view">gtk_tree_selection_get_tree_view</primary></indexterm><programlisting><link linkend="GtkTreeView">GtkTreeView</link>*        gtk_tree_selection_get_tree_view    (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection);</programlisting>
<para>
Returns the tree view associated with <parameter>selection</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> A <link linkend="GtkTreeView"><type>GtkTreeView</type></link>
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-tree-selection-get-selected" role="function">
<title>gtk_tree_selection_get_selected ()</title>
<indexterm zone="gtk-tree-selection-get-selected"><primary sortas="tree_selection_get_selected">gtk_tree_selection_get_selected</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            gtk_tree_selection_get_selected     (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreeModel">GtkTreeModel</link> **model,
                                                         <link linkend="GtkTreeIter">GtkTreeIter</link> *iter);</programlisting>
<para>
Sets <parameter>iter</parameter> to the currently selected node if <parameter>selection</parameter> is set to
<link linkend="GTK-SELECTION-SINGLE--CAPS"><type>GTK_SELECTION_SINGLE</type></link> or <link linkend="GTK-SELECTION-BROWSE--CAPS"><type>GTK_SELECTION_BROWSE</type></link>.  <parameter>iter</parameter> may be NULL if you
just want to test if <parameter>selection</parameter> has any selected nodes.  <parameter>model</parameter> is filled
with the current model as a convenience.  This function will not work if you
use <parameter>selection</parameter> is <link linkend="GTK-SELECTION-MULTIPLE--CAPS"><type>GTK_SELECTION_MULTIPLE</type></link>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>model</parameter>&#160;:</term>
<listitem><simpara> A pointer to set to the <link linkend="GtkTreeModel"><type>GtkTreeModel</type></link>, or NULL.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>iter</parameter>&#160;:</term>
<listitem><simpara> The <link linkend="GtkTreeIter"><type>GtkTreeIter</type></link>, or NULL.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> TRUE, if there is a selected node.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-tree-selection-selected-foreach" role="function">
<title>gtk_tree_selection_selected_foreach ()</title>
<indexterm zone="gtk-tree-selection-selected-foreach"><primary sortas="tree_selection_selected_foreach">gtk_tree_selection_selected_foreach</primary></indexterm><programlisting><link linkend="void">void</link>                gtk_tree_selection_selected_foreach (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreeSelectionForeachFunc">GtkTreeSelectionForeachFunc</link> func,
                                                         <link linkend="gpointer">gpointer</link> data);</programlisting>
<para>
Calls a function for each selected node. Note that you cannot modify
the tree or selection from within this function. As a result,
<link linkend="gtk-tree-selection-get-selected-rows"><function>gtk_tree_selection_get_selected_rows()</function></link> might be more useful.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>func</parameter>&#160;:</term>
<listitem><simpara> The function to call for each selected node.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>data</parameter>&#160;:</term>
<listitem><simpara> user data to pass to the function.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-tree-selection-get-selected-rows" role="function" condition="since:2.2">
<title>gtk_tree_selection_get_selected_rows ()</title>
<indexterm zone="gtk-tree-selection-get-selected-rows" role="2.2"><primary sortas="tree_selection_get_selected_rows">gtk_tree_selection_get_selected_rows</primary></indexterm><programlisting><link linkend="GList">GList</link> *             gtk_tree_selection_get_selected_rows
                                                        (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreeModel">GtkTreeModel</link> **model);</programlisting>
<para>
Creates a list of path of all selected rows. Additionally, if you are
planning on modifying the model after calling this function, you may
want to convert the returned list into a list of <link linkend="GtkTreeRowReference"><type>GtkTreeRowReference</type></link><!-- -->s.
To do this, you can use <link linkend="gtk-tree-row-reference-new"><function>gtk_tree_row_reference_new()</function></link>.
</para>
<para>
To free the return value, use:
<informalexample><programlisting>
g_list_foreach (list, gtk_tree_path_free, NULL);
g_list_free (list);
</programlisting></informalexample></para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>model</parameter>&#160;:</term>
<listitem><simpara> A pointer to set to the <link linkend="GtkTreeModel"><type>GtkTreeModel</type></link>, or NULL.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> A <link linkend="GList"><type>GList</type></link> containing a <link linkend="GtkTreePath"><type>GtkTreePath</type></link> for each selected row.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.2</para></refsect2>
<refsect2 id="gtk-tree-selection-count-selected-rows" role="function" condition="since:2.2">
<title>gtk_tree_selection_count_selected_rows ()</title>
<indexterm zone="gtk-tree-selection-count-selected-rows" role="2.2"><primary sortas="tree_selection_count_selected_rows">gtk_tree_selection_count_selected_rows</primary></indexterm><programlisting><link linkend="gint">gint</link>                gtk_tree_selection_count_selected_rows
                                                        (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection);</programlisting>
<para>
Returns the number of rows that have been selected in <parameter>tree</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> The number of rows selected.

</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.2</para></refsect2>
<refsect2 id="gtk-tree-selection-select-path" role="function">
<title>gtk_tree_selection_select_path ()</title>
<indexterm zone="gtk-tree-selection-select-path"><primary sortas="tree_selection_select_path">gtk_tree_selection_select_path</primary></indexterm><programlisting><link linkend="void">void</link>                gtk_tree_selection_select_path      (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreePath">GtkTreePath</link> *path);</programlisting>
<para>
Select the row at <parameter>path</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>path</parameter>&#160;:</term>
<listitem><simpara> The <link linkend="GtkTreePath"><type>GtkTreePath</type></link> to be selected.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-tree-selection-unselect-path" role="function">
<title>gtk_tree_selection_unselect_path ()</title>
<indexterm zone="gtk-tree-selection-unselect-path"><primary sortas="tree_selection_unselect_path">gtk_tree_selection_unselect_path</primary></indexterm><programlisting><link linkend="void">void</link>                gtk_tree_selection_unselect_path    (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreePath">GtkTreePath</link> *path);</programlisting>
<para>
Unselects the row at <parameter>path</parameter>.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>path</parameter>&#160;:</term>
<listitem><simpara> The <link linkend="GtkTreePath"><type>GtkTreePath</type></link> to be unselected.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-tree-selection-path-is-selected" role="function">
<title>gtk_tree_selection_path_is_selected ()</title>
<indexterm zone="gtk-tree-selection-path-is-selected"><primary sortas="tree_selection_path_is_selected">gtk_tree_selection_path_is_selected</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            gtk_tree_selection_path_is_selected (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreePath">GtkTreePath</link> *path);</programlisting>
<para>
Returns <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if the row pointed to by <parameter>path</parameter> is currently selected.  If <parameter>path</parameter>
does not point to a valid location, <link linkend="FALSE--CAPS"><literal>FALSE</literal></link> is returned</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>path</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreePath"><type>GtkTreePath</type></link> to check selection on.
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if <parameter>path</parameter> is selected.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-tree-selection-select-iter" role="function">
<title>gtk_tree_selection_select_iter ()</title>
<indexterm zone="gtk-tree-selection-select-iter"><primary sortas="tree_selection_select_iter">gtk_tree_selection_select_iter</primary></indexterm><programlisting><link linkend="void">void</link>                gtk_tree_selection_select_iter      (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreeIter">GtkTreeIter</link> *iter);</programlisting>
<para>
Selects the specified iterator.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>iter</parameter>&#160;:</term>
<listitem><simpara> The <link linkend="GtkTreeIter"><type>GtkTreeIter</type></link> to be selected.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-tree-selection-unselect-iter" role="function">
<title>gtk_tree_selection_unselect_iter ()</title>
<indexterm zone="gtk-tree-selection-unselect-iter"><primary sortas="tree_selection_unselect_iter">gtk_tree_selection_unselect_iter</primary></indexterm><programlisting><link linkend="void">void</link>                gtk_tree_selection_unselect_iter    (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreeIter">GtkTreeIter</link> *iter);</programlisting>
<para>
Unselects the specified iterator.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>iter</parameter>&#160;:</term>
<listitem><simpara> The <link linkend="GtkTreeIter"><type>GtkTreeIter</type></link> to be unselected.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-tree-selection-iter-is-selected" role="function">
<title>gtk_tree_selection_iter_is_selected ()</title>
<indexterm zone="gtk-tree-selection-iter-is-selected"><primary sortas="tree_selection_iter_is_selected">gtk_tree_selection_iter_is_selected</primary></indexterm><programlisting><link linkend="gboolean">gboolean</link>            gtk_tree_selection_iter_is_selected (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreeIter">GtkTreeIter</link> *iter);</programlisting>
<para>
Returns <link linkend="TRUE--CAPS"><literal>TRUE</literal></link> if the row at <parameter>iter</parameter> is currently selected.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>iter</parameter>&#160;:</term>
<listitem><simpara> A valid <link linkend="GtkTreeIter"><type>GtkTreeIter</type></link>
</simpara></listitem></varlistentry>
<varlistentry><term><emphasis>Returns</emphasis>&#160;:</term><listitem><simpara> <link linkend="TRUE--CAPS"><literal>TRUE</literal></link>, if <parameter>iter</parameter> is selected
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-tree-selection-select-all" role="function">
<title>gtk_tree_selection_select_all ()</title>
<indexterm zone="gtk-tree-selection-select-all"><primary sortas="tree_selection_select_all">gtk_tree_selection_select_all</primary></indexterm><programlisting><link linkend="void">void</link>                gtk_tree_selection_select_all       (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection);</programlisting>
<para>
Selects all the nodes. <parameter>selection</parameter> must be set to <link linkend="GTK-SELECTION-MULTIPLE--CAPS"><type>GTK_SELECTION_MULTIPLE</type></link>
mode.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-tree-selection-unselect-all" role="function">
<title>gtk_tree_selection_unselect_all ()</title>
<indexterm zone="gtk-tree-selection-unselect-all"><primary sortas="tree_selection_unselect_all">gtk_tree_selection_unselect_all</primary></indexterm><programlisting><link linkend="void">void</link>                gtk_tree_selection_unselect_all     (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection);</programlisting>
<para>
Unselects all the nodes.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-tree-selection-select-range" role="function">
<title>gtk_tree_selection_select_range ()</title>
<indexterm zone="gtk-tree-selection-select-range"><primary sortas="tree_selection_select_range">gtk_tree_selection_select_range</primary></indexterm><programlisting><link linkend="void">void</link>                gtk_tree_selection_select_range     (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreePath">GtkTreePath</link> *start_path,
                                                         <link linkend="GtkTreePath">GtkTreePath</link> *end_path);</programlisting>
<para>
Selects a range of nodes, determined by <parameter>start_path</parameter> and <parameter>end_path</parameter> inclusive.
<parameter>selection</parameter> must be set to <link linkend="GTK-SELECTION-MULTIPLE--CAPS"><type>GTK_SELECTION_MULTIPLE</type></link> mode.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>start_path</parameter>&#160;:</term>
<listitem><simpara> The initial node of the range.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>end_path</parameter>&#160;:</term>
<listitem><simpara> The final node of the range.
</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2 id="gtk-tree-selection-unselect-range" role="function" condition="since:2.2">
<title>gtk_tree_selection_unselect_range ()</title>
<indexterm zone="gtk-tree-selection-unselect-range" role="2.2"><primary sortas="tree_selection_unselect_range">gtk_tree_selection_unselect_range</primary></indexterm><programlisting><link linkend="void">void</link>                gtk_tree_selection_unselect_range   (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *selection,
                                                         <link linkend="GtkTreePath">GtkTreePath</link> *start_path,
                                                         <link linkend="GtkTreePath">GtkTreePath</link> *end_path);</programlisting>
<para>
Unselects a range of nodes, determined by <parameter>start_path</parameter> and <parameter>end_path</parameter>
inclusive.</para>
<para>
</para><variablelist role="params">
<varlistentry><term><parameter>selection</parameter>&#160;:</term>
<listitem><simpara> A <link linkend="GtkTreeSelection"><type>GtkTreeSelection</type></link>.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>start_path</parameter>&#160;:</term>
<listitem><simpara> The initial node of the range.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>end_path</parameter>&#160;:</term>
<listitem><simpara> The initial node of the range.
</simpara></listitem></varlistentry>
</variablelist><para role="since">Since 2.2</para></refsect2>

</refsect1>

<refsect1 id="GtkTreeSelection.signal-details" role="signals">
<title role="signals.title">Signal Details</title>
<refsect2 id="GtkTreeSelection-changed" role="signal"><title>The <literal>&quot;changed&quot;</literal> signal</title>
<indexterm zone="GtkTreeSelection-changed"><primary sortas="TreeSelection::changed">GtkTreeSelection::changed</primary></indexterm><programlisting><link linkend="void">void</link>                user_function                      (<link linkend="GtkTreeSelection">GtkTreeSelection</link> *treeselection,
                                                        <link linkend="gpointer">gpointer</link>          user_data)          : Run First</programlisting>
<para>
Emitted whenever the selection has (possibly) changed.  Please note that
this signal is mostly a hint.  It may only be emitted once when a range
of rows are selected, and it may occasionally be emitted when nothing
has happened.
</para><variablelist role="params">
<varlistentry><term><parameter>treeselection</parameter>&#160;:</term>
<listitem><simpara>the object which received the signal.
</simpara></listitem></varlistentry>
<varlistentry><term><parameter>user_data</parameter>&#160;:</term>
<listitem><simpara>user data set when the signal handler was connected.</simpara></listitem></varlistentry>
</variablelist></refsect2>
</refsect1>


<refsect1 id="GtkTreeSelection.see-also">
<title>See Also</title>
<para>
<link linkend="GtkTreeView"><type>GtkTreeView</type></link>, <link linkend="GtkTreeViewColumn"><type>GtkTreeViewColumn</type></link>, <link linkend="GtkTreeDnd"><type>GtkTreeDnd</type></link>, <link linkend="GtkTreeMode"><type>GtkTreeMode</type></link>, <link linkend="GtkTreeSortable"><type>GtkTreeSortable</type></link>, <link linkend="GtkTreeModelSort"><type>GtkTreeModelSort</type></link>, <link linkend="GtkListStore"><type>GtkListStore</type></link>, <link linkend="GtkTreeStore"><type>GtkTreeStore</type></link>, <link linkend="GtkCellRenderer"><type>GtkCellRenderer</type></link>, <link linkend="GtkCellEditable"><type>GtkCellEditable</type></link>, <link linkend="GtkCellRendererPixbuf"><type>GtkCellRendererPixbuf</type></link>, <link linkend="GtkCellRendererText"><type>GtkCellRendererText</type></link>, <link linkend="GtkCellRendererToggle"><type>GtkCellRendererToggle</type></link>
</para>
</refsect1>

</refentry>
