<?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="GtkFilter">
<refmeta>
<refentrytitle role="top_of_page" id="GtkFilter.top_of_page">GtkFilter</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GTK4 Library</refmiscinfo>
</refmeta>
<refnamediv>
<refname>GtkFilter</refname>
<refpurpose>Filtering items</refpurpose>
</refnamediv>

<refsect1 id="GtkFilter.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-filter-match">gtk_filter_match</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>
<row><entry role="function_type"><link linkend="GtkFilterMatch"><returnvalue>GtkFilterMatch</returnvalue></link>
</entry><entry role="function_name"><link linkend="gtk-filter-get-strictness">gtk_filter_get_strictness</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-filter-changed">gtk_filter_changed</link>&#160;<phrase role="c_punctuation">()</phrase></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 id="GtkFilter.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="GtkFilter-changed">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="GtkFilter.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="GtkFilter-struct">GtkFilter</link></entry></row>
<row><entry role="datatype_keyword">enum</entry><entry role="function_name"><link linkend="GtkFilterMatch">GtkFilterMatch</link></entry></row>

<row><entry role="datatype_keyword">enum</entry><entry role="function_name"><link linkend="GtkFilterChange">GtkFilterChange</link></entry></row>

</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 id="GtkFilter.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> GtkFilter
        <phrase role="lineart">&#9500;&#9472;&#9472;</phrase> <link linkend="GtkMultiFilter">GtkMultiFilter</link>
        <phrase role="lineart">&#9500;&#9472;&#9472;</phrase> <link linkend="GtkBoolFilter">GtkBoolFilter</link>
        <phrase role="lineart">&#9500;&#9472;&#9472;</phrase> <link linkend="GtkCustomFilter">GtkCustomFilter</link>
        <phrase role="lineart">&#9500;&#9472;&#9472;</phrase> <link linkend="GtkFileFilter">GtkFileFilter</link>
        <phrase role="lineart">&#9584;&#9472;&#9472;</phrase> <link linkend="GtkStringFilter">GtkStringFilter</link>
</screen>
</refsect1>

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

<refsect1 id="GtkFilter.description" role="desc">
<title role="desc.title">Description</title>
<para>A <link linkend="GtkFilter"><type>GtkFilter</type></link> object describes the filtering to be performed by a
<link linkend="GtkFilterListModel"><type>GtkFilterListModel</type></link>.</para>
<para>The model will use the filter to determine if it should include items
or not by calling <link linkend="gtk-filter-match"><function>gtk_filter_match()</function></link> for each item and only keeping the
ones that the function returns <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> for.</para>
<para>Filters may change what items they match through their lifetime. In that
case, they will emit the <link linkend="GtkFilter-changed"><type>“changed”</type></link> signal to notify that previous
filter results are no longer valid and that items should be checked again
via <link linkend="gtk-filter-match"><function>gtk_filter_match()</function></link>.</para>
<para>GTK provides various pre-made filter implementations for common filtering
operations. These filters often include properties that can be linked to
various widgets to easily allow searches.</para>
<para>However, in particular for large lists or complex search methods, it is
also possible to subclass <link linkend="GtkFilter"><type>GtkFilter</type></link> and provide one's own filter.</para>

</refsect1>
<refsect1 id="GtkFilter.functions_details" role="details">
<title role="details.title">Functions</title>
<refsect2 id="gtk-filter-match" role="function">
<title>gtk_filter_match&#160;()</title>
<indexterm zone="gtk-filter-match"><primary>gtk_filter_match</primary></indexterm>
<programlisting language="C"><link linkend="gboolean"><returnvalue>gboolean</returnvalue></link>
gtk_filter_match (<parameter><link linkend="GtkFilter"><type>GtkFilter</type></link> *self</parameter>,
                  <parameter><link linkend="gpointer"><type>gpointer</type></link> item</parameter>);</programlisting>
<para>Checks if the given <parameter>item</parameter>
 is matched by the filter or not.</para>
<refsect3 id="gtk-filter-match.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="GtkFilter"><type>GtkFilter</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>item</para></entry>
<entry role="parameter_description"><para>The item to check. </para></entry>
<entry role="parameter_annotations"><emphasis role="annotation">[<acronym>type</acronym> GObject][<acronym>transfer none</acronym>]</emphasis></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-filter-match.returns" role="returns">
<title>Returns</title>
<para> <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> if the filter matches the item and a filter model should
keep it, <link linkend="FALSE:CAPS"><literal>FALSE</literal></link> if not.</para>
</refsect3></refsect2>
<refsect2 id="gtk-filter-get-strictness" role="function">
<title>gtk_filter_get_strictness&#160;()</title>
<indexterm zone="gtk-filter-get-strictness"><primary>gtk_filter_get_strictness</primary></indexterm>
<programlisting language="C"><link linkend="GtkFilterMatch"><returnvalue>GtkFilterMatch</returnvalue></link>
gtk_filter_get_strictness (<parameter><link linkend="GtkFilter"><type>GtkFilter</type></link> *self</parameter>);</programlisting>
<para>Gets the known strictness of <parameter>filters</parameter>
. If the strictness is not known,
<link linkend="GTK-FILTER-MATCH-SOME:CAPS"><literal>GTK_FILTER_MATCH_SOME</literal></link> is returned.</para>
<para>This value may change after emission of the <link linkend="GtkFilter-changed"><type>“changed”</type></link> signal.</para>
<para>This function is meant purely for optimization purposes, filters can
choose to omit implementing it, but <link linkend="GtkFilterListModel"><type>GtkFilterListModel</type></link> uses it.</para>
<refsect3 id="gtk-filter-get-strictness.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="GtkFilter"><type>GtkFilter</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3><refsect3 id="gtk-filter-get-strictness.returns" role="returns">
<title>Returns</title>
<para> the strictness of <parameter>self</parameter>
</para>
</refsect3></refsect2>
<refsect2 id="gtk-filter-changed" role="function">
<title>gtk_filter_changed&#160;()</title>
<indexterm zone="gtk-filter-changed"><primary>gtk_filter_changed</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
gtk_filter_changed (<parameter><link linkend="GtkFilter"><type>GtkFilter</type></link> *self</parameter>,
                    <parameter><link linkend="GtkFilterChange"><type>GtkFilterChange</type></link> change</parameter>);</programlisting>
<para>Emits the <link linkend="GtkFilter-changed"><type>“changed”</type></link> signal to notify all users of the filter that
the filter changed. Users of the filter should then check items again via
<link linkend="gtk-filter-match"><function>gtk_filter_match()</function></link>.</para>
<para>Depending on the <parameter>change</parameter>
 parameter, not all items need to be changed, but
only some. Refer to the <link linkend="GtkFilterChange"><type>GtkFilterChange</type></link> documentation for details.</para>
<para>This function is intended for implementors of <link linkend="GtkFilter"><type>GtkFilter</type></link> subclasses and
should not be called from other functions.</para>
<refsect3 id="gtk-filter-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>self</para></entry>
<entry role="parameter_description"><para>a <link linkend="GtkFilter"><type>GtkFilter</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>change</para></entry>
<entry role="parameter_description"><para>How the filter changed</para></entry>
<entry role="parameter_annotations"></entry></row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>

</refsect1>
<refsect1 id="GtkFilter.other_details" role="details">
<title role="details.title">Types and Values</title>
<refsect2 id="GtkFilter-struct" role="struct">
<title>GtkFilter</title>
<indexterm zone="GtkFilter-struct"><primary>GtkFilter</primary></indexterm>
<programlisting language="C">typedef struct _GtkFilter GtkFilter;</programlisting>
<para>The object describing a filter.</para>
</refsect2>
<refsect2 id="GtkFilterMatch" role="enum">
<title>enum GtkFilterMatch</title>
<indexterm zone="GtkFilterMatch"><primary>GtkFilterMatch</primary></indexterm>
<para>Describes the known strictness of a filter.</para>
<para>Note that for filters where the strictness is not known,
<link linkend="GTK-FILTER-MATCH-SOME:CAPS"><literal>GTK_FILTER_MATCH_SOME</literal></link> is always an acceptable value,
even if a filter does match all or no items.</para>
<refsect3 id="GtkFilterMatch.members" role="enum_members">
<title>Members</title>
<informaltable role="enum_members_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="enum_members_name" colwidth="300px"/>
<colspec colname="enum_members_description"/>
<colspec colname="enum_members_annotations" colwidth="200px"/>
<tbody>
<row role="constant"><entry role="enum_member_name"><para id="GTK-FILTER-MATCH-SOME:CAPS">GTK_FILTER_MATCH_SOME</para></entry>
<entry role="enum_member_description"><para>The filter matches some items,
<link linkend="gtk-filter-match"><function>gtk_filter_match()</function></link> may return <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> or <link linkend="FALSE:CAPS"><literal>FALSE</literal></link></para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="GTK-FILTER-MATCH-NONE:CAPS">GTK_FILTER_MATCH_NONE</para></entry>
<entry role="enum_member_description"><para>The filter does not match any item,
<link linkend="gtk-filter-match"><function>gtk_filter_match()</function></link> will always return <link linkend="FALSE:CAPS"><literal>FALSE</literal></link>.</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="GTK-FILTER-MATCH-ALL:CAPS">GTK_FILTER_MATCH_ALL</para></entry>
<entry role="enum_member_description"><para>The filter matches all items,
<link linkend="gtk-filter-match"><function>gtk_filter_match()</function></link> will alays return <link linkend="TRUE:CAPS"><literal>TRUE</literal></link>.</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>
<refsect2 id="GtkFilterChange" role="enum">
<title>enum GtkFilterChange</title>
<indexterm zone="GtkFilterChange"><primary>GtkFilterChange</primary></indexterm>
<para>Describes changes in a filter in more detail and allows objects
using the filter to optimize refiltering items.</para>
<para>If you are writing an implementation and are not sure which
value to pass, <link linkend="GTK-FILTER-CHANGE-DIFFERENT:CAPS"><literal>GTK_FILTER_CHANGE_DIFFERENT</literal></link> is always a correct
choice.</para>
<refsect3 id="GtkFilterChange.members" role="enum_members">
<title>Members</title>
<informaltable role="enum_members_table" pgwide="1" frame="none">
<tgroup cols="3">
<colspec colname="enum_members_name" colwidth="300px"/>
<colspec colname="enum_members_description"/>
<colspec colname="enum_members_annotations" colwidth="200px"/>
<tbody>
<row role="constant"><entry role="enum_member_name"><para id="GTK-FILTER-CHANGE-DIFFERENT:CAPS">GTK_FILTER_CHANGE_DIFFERENT</para></entry>
<entry role="enum_member_description"><para>The filter change cannot be
described with any of the other enumeration values.</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="GTK-FILTER-CHANGE-LESS-STRICT:CAPS">GTK_FILTER_CHANGE_LESS_STRICT</para></entry>
<entry role="enum_member_description"><para>The filter is less strict than
it was before: All items that it used to return <link linkend="TRUE:CAPS"><literal>TRUE</literal></link> for
still return <link linkend="TRUE:CAPS"><literal>TRUE</literal></link>, others now may, too.</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
<row role="constant"><entry role="enum_member_name"><para id="GTK-FILTER-CHANGE-MORE-STRICT:CAPS">GTK_FILTER_CHANGE_MORE_STRICT</para></entry>
<entry role="enum_member_description"><para>The filter is more strict than
it was before: All items that it used to return <link linkend="FALSE:CAPS"><literal>FALSE</literal></link> for
still return <link linkend="FALSE:CAPS"><literal>FALSE</literal></link>, others now may, too.</para>
</entry>
<entry role="enum_member_annotations"></entry>
</row>
</tbody></tgroup></informaltable>
</refsect3></refsect2>

</refsect1>
<refsect1 id="GtkFilter.signal-details" role="signals">
<title role="signals.title">Signal Details</title>
<refsect2 id="GtkFilter-changed" role="signal"><title>The <literal>“changed”</literal> signal</title>
<indexterm zone="GtkFilter-changed"><primary>GtkFilter::changed</primary></indexterm>
<programlisting language="C"><link linkend="void"><returnvalue>void</returnvalue></link>
user_function (<link linkend="GtkFilter"><type>GtkFilter</type></link>      *self,
               <link linkend="GtkFilterChange"><type>GtkFilterChange</type></link> change,
               <link linkend="gpointer"><type>gpointer</type></link>        user_data)</programlisting>
<para>This signal is emitted whenever the filter changed. Users of the filter
should then check items again via <link linkend="gtk-filter-match"><function>gtk_filter_match()</function></link>.</para>
<para><link linkend="GtkFilterListModel"><type>GtkFilterListModel</type></link> handles this signal automatically.</para>
<para>Depending on the <parameter>change</parameter>
 parameter, not all items need to be changed, but
only some. Refer to the <link linkend="GtkFilterChange"><type>GtkFilterChange</type></link> documentation for details.</para>
<refsect3 id="GtkFilter-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>self</para></entry>
<entry role="parameter_description"><para>The <link linkend="GtkFilter"><type>GtkFilter</type></link></para></entry>
<entry role="parameter_annotations"></entry></row>
<row><entry role="parameter_name"><para>change</para></entry>
<entry role="parameter_description"><para>how the filter changed</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="GtkFilter.see-also">
<title>See Also</title>
<para><link linkend="GtkFilterListModel"><type>GtkFilterListModel</type></link></para>

</refsect1>

</refentry>
