/* Copyright (C) 2020 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
 */

_CONFIGINCLUDE(gtkmmconfig.h)

#include <glibmm/object.h>
#include <gtk/gtk.h>

_DEFS(gtkmm,gtk)
_PINCLUDE(glibmm/private/object_p.h)

namespace Gtk
{

/** Filtering items.
 *
 * A %Gtk::Filter object describes the filtering to be performed by a
 * Gtk::FilterListModel.
 *
 * The model will use the filter to determine if it should include items
 * or not by calling match() for each item and only keeping the
 * ones that the function returns <tt>true</tt> for.
 *
 * Filters may change what items they match through their lifetime. In that
 * case, they will emit the signal_changed() signal to notify that previous
 * filter results are no longer valid and that items should be checked again
 * via match().
 *
 * 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.
 *
 * However, in particular for large lists or complex search methods, it is
 * also possible to subclass %Gtk::Filter and provide one's own filter.
 *
 * @see Gtk::FilterListModel
 * @newin{3,98}
 */
class GTKMM_API Filter : public Glib::Object
{
  _CLASS_GOBJECT(Filter, GtkFilter, GTK_FILTER, Glib::Object, GObject, , , GTKMM_API)
  _STRUCT_NOT_HIDDEN

protected:
  _CTOR_DEFAULT

public: 
  _WRAP_ENUM(Match, GtkFilterMatch, decl_prefix GTKMM_API)
  _WRAP_ENUM(Change, GtkFilterChange, decl_prefix GTKMM_API)

#m4 _CONVERSION(`const Glib::RefPtr<Glib::ObjectBase>&',`gpointer',`($3)->gobj()')
  _WRAP_METHOD(bool match(const Glib::RefPtr<Glib::ObjectBase>& item), gtk_filter_match)
  _WRAP_METHOD(Match get_strictness(), gtk_filter_get_strictness)

  _WRAP_SIGNAL(void changed(Change change), "changed", no_default_handler)

protected:
  // for filter implementations
  _WRAP_METHOD(void changed(Change change = Change::DIFFERENT), gtk_filter_changed)

#m4 _CONVERSION(`gpointer',`const Glib::RefPtr<Glib::ObjectBase>&',`Glib::wrap(G_OBJECT($3), true)')
  _WRAP_VFUNC(bool match(const Glib::RefPtr<Glib::ObjectBase>& item), match)
  _WRAP_VFUNC(Match get_strictness(), get_strictness)
};

} // namespace Gtk
