[gtkmm: 1/5] Add Gtk::SortListModel and Gtk::FilterListModel




commit e738d28fd8f6133bca4eaa64135eda58d7473103
Author: Andreas Persson <andreasp56 outlook com>
Date:   Fri Aug 7 17:46:11 2020 +0200

    Add Gtk::SortListModel and Gtk::FilterListModel
    
    Add bindings for SortListModel, StringSorter, FilterListModel, Filter
    and StringFilter.
    
    GtkExpression* is used for now, as GtkExpression is not yet wrapped.

 .gitignore                                |  10 ++
 gtk/gtkmm.h                               |   4 +
 gtk/gtkmm/meson.build                     |   5 +
 gtk/src/filelist.am                       |   5 +
 gtk/src/filter.ccg                        |  20 ++++
 gtk/src/filter.hg                         |  79 +++++++++++++++
 gtk/src/filterlistmodel.ccg               |  17 ++++
 gtk/src/filterlistmodel.hg                |  73 ++++++++++++++
 gtk/src/gtk_docs_override.xml             |   2 +
 gtk/src/gtk_extra_objects.defs            |  24 +++++
 gtk/src/gtk_signals.defs                  | 153 ++++++++++++++++++++++++++++++
 gtk/src/gtk_vfuncs.defs                   |  15 +++
 gtk/src/sortlistmodel.ccg                 |  17 ++++
 gtk/src/sortlistmodel.hg                  |  74 +++++++++++++++
 gtk/src/stringfilter.ccg                  |  19 ++++
 gtk/src/stringfilter.hg                   |  65 +++++++++++++
 gtk/src/stringsorter.ccg                  |  17 ++++
 gtk/src/stringsorter.hg                   |  58 +++++++++++
 tools/extra_defs_gen/generate_defs_gtk.cc |   5 +
 tools/m4/convert_gtk.m4                   |   5 +
 20 files changed, 667 insertions(+)
---
diff --git a/.gitignore b/.gitignore
index af5b23f4..d15f4f4c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -305,6 +305,10 @@ gtk/gtkmm/filechooserwidget.cc
 gtk/gtkmm/filechooserwidget.h
 gtk/gtkmm/filefilter.cc
 gtk/gtkmm/filefilter.h
+gtk/gtkmm/filter.cc
+gtk/gtkmm/filter.h
+gtk/gtkmm/filterlistmodel.cc
+gtk/gtkmm/filterlistmodel.h
 gtk/gtkmm/fixed.cc
 gtk/gtkmm/fixed.h
 gtk/gtkmm/flowbox.cc
@@ -513,6 +517,8 @@ gtk/gtkmm/snapshot.cc
 gtk/gtkmm/snapshot.h
 gtk/gtkmm/sorter.cc
 gtk/gtkmm/sorter.h
+gtk/gtkmm/sortlistmodel.cc
+gtk/gtkmm/sortlistmodel.h
 gtk/gtkmm/spinbutton.cc
 gtk/gtkmm/spinbutton.h
 gtk/gtkmm/spinner.cc
@@ -527,10 +533,14 @@ gtk/gtkmm/stackswitcher.cc
 gtk/gtkmm/stackswitcher.h
 gtk/gtkmm/statusbar.cc
 gtk/gtkmm/statusbar.h
+gtk/gtkmm/stringfilter.cc
+gtk/gtkmm/stringfilter.h
 gtk/gtkmm/stringlist.cc
 gtk/gtkmm/stringlist.h
 gtk/gtkmm/stringobject.cc
 gtk/gtkmm/stringobject.h
+gtk/gtkmm/stringsorter.cc
+gtk/gtkmm/stringsorter.h
 gtk/gtkmm/stylecontext.cc
 gtk/gtkmm/stylecontext.h
 gtk/gtkmm/styleprovider.cc
diff --git a/gtk/gtkmm.h b/gtk/gtkmm.h
index c0bac01e..bddffbea 100644
--- a/gtk/gtkmm.h
+++ b/gtk/gtkmm.h
@@ -158,6 +158,7 @@ extern const int gtkmm_micro_version;
 #include <gtkmm/filechoosernative.h>
 #include <gtkmm/filechooserwidget.h>
 #include <gtkmm/filefilter.h>
+#include <gtkmm/filterlistmodel.h>
 #include <gtkmm/fixed.h>
 #include <gtkmm/flowbox.h>
 #include <gtkmm/flowboxchild.h>
@@ -252,14 +253,17 @@ extern const int gtkmm_micro_version;
 #include <gtkmm/singleselection.h>
 #include <gtkmm/sizegroup.h>
 #include <gtkmm/snapshot.h>
+#include <gtkmm/sortlistmodel.h>
 #include <gtkmm/spinbutton.h>
 #include <gtkmm/spinner.h>
 #include <gtkmm/stack.h>
 #include <gtkmm/stacksidebar.h>
 #include <gtkmm/stackswitcher.h>
 #include <gtkmm/statusbar.h>
+#include <gtkmm/stringfilter.h>
 #include <gtkmm/stringlist.h>
 #include <gtkmm/stringobject.h>
+#include <gtkmm/stringsorter.h>
 #include <gtkmm/stylecontext.h>
 #include <gtkmm/switch.h>
 #include <gtkmm/text.h>
diff --git a/gtk/gtkmm/meson.build b/gtk/gtkmm/meson.build
index 45eaf5e3..c336e2fb 100644
--- a/gtk/gtkmm/meson.build
+++ b/gtk/gtkmm/meson.build
@@ -110,6 +110,8 @@ gtkmm_any_hg_ccg_basenames = [
   'filechoosernative',
   'filechooserwidget',
   'filefilter',
+  'filter',
+  'filterlistmodel',
   'fixed',
   'flowbox',
   'flowboxchild',
@@ -208,6 +210,7 @@ gtkmm_any_hg_ccg_basenames = [
   'sizegroup',
   'snapshot',
   'sorter',
+  'sortlistmodel',
   'spinbutton',
   'spinner',
   'stack',
@@ -215,8 +218,10 @@ gtkmm_any_hg_ccg_basenames = [
   'stacksidebar',
   'stackswitcher',
   'statusbar',
+  'stringfilter',
   'stringlist',
   'stringobject',
+  'stringsorter',
   'stylecontext',
   'styleprovider',
   'switch',
diff --git a/gtk/src/filelist.am b/gtk/src/filelist.am
index 4555b9f7..c7a376c3 100644
--- a/gtk/src/filelist.am
+++ b/gtk/src/filelist.am
@@ -95,6 +95,8 @@ gtkmm_files_any_hg =          \
        filechoosernative.hg    \
        filechooserwidget.hg    \
        filefilter.hg           \
+       filter.hg \
+       filterlistmodel.hg \
        fixed.hg                \
        flowbox.hg              \
        flowboxchild.hg         \
@@ -193,6 +195,7 @@ gtkmm_files_any_hg =                \
        sizegroup.hg            \
        snapshot.hg             \
        sorter.hg \
+       sortlistmodel.hg \
        spinbutton.hg           \
        spinner.hg              \
        stack.hg                \
@@ -200,8 +203,10 @@ gtkmm_files_any_hg =               \
        stacksidebar.hg         \
        stackswitcher.hg        \
        statusbar.hg            \
+       stringfilter.hg \
        stringlist.hg \
        stringobject.hg \
+       stringsorter.hg \
        stylecontext.hg         \
        styleprovider.hg        \
        switch.hg               \
diff --git a/gtk/src/filter.ccg b/gtk/src/filter.ccg
new file mode 100644
index 00000000..ba3e08e5
--- /dev/null
+++ b/gtk/src/filter.ccg
@@ -0,0 +1,20 @@
+/* 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/>.
+ */
+
+#include <gtk/gtk.h>
+
+using Change = Gtk::Filter::Change;
+using Match = Gtk::Filter::Match;
diff --git a/gtk/src/filter.hg b/gtk/src/filter.hg
new file mode 100644
index 00000000..a52b365d
--- /dev/null
+++ b/gtk/src/filter.hg
@@ -0,0 +1,79 @@
+/* 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_copy()')
+  _WRAP_METHOD(bool match(const Glib::RefPtr<Glib::ObjectBase>& item), gtk_filter_match)
+  _WRAP_METHOD(Match get_strictness(), gtk_filter_get_strictness)
+
+  // for filter implementations
+  _WRAP_METHOD(void changed(Change change = Change::DIFFERENT), gtk_filter_changed)
+ 
+  _WRAP_SIGNAL(void changed(Change change), "changed", no_default_handler)
+
+protected:
+#m4 _CONVERSION(`gpointer',`const Glib::RefPtr<Glib::ObjectBase>&',`Glib::wrap(G_OBJECT($3))')
+  _WRAP_VFUNC(bool match(const Glib::RefPtr<Glib::ObjectBase>& item), match)
+  _WRAP_VFUNC(Match get_strictness(), get_strictness)
+};
+
+} // namespace Gtk
diff --git a/gtk/src/filterlistmodel.ccg b/gtk/src/filterlistmodel.ccg
new file mode 100644
index 00000000..57b87fdc
--- /dev/null
+++ b/gtk/src/filterlistmodel.ccg
@@ -0,0 +1,17 @@
+/* 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/>.
+ */
+
+#include <gtk/gtk.h>
diff --git a/gtk/src/filterlistmodel.hg b/gtk/src/filterlistmodel.hg
new file mode 100644
index 00000000..135b6a23
--- /dev/null
+++ b/gtk/src/filterlistmodel.hg
@@ -0,0 +1,73 @@
+/* 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 <giomm/listmodel.h>
+#include <gtkmm/filter.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gtk
+{
+
+/** A list model that filters its items.
+ *
+ * %Gtk::FilterListModel is a list model that filters a given other
+ * listmodel.
+ * It hides some elements from the other model according to
+ * criteria given by a Gtk::Filter.
+ *
+ * The model can be set up to do incremental searching, so that
+ * filtering long lists doesn't block the UI. See set_incremental()
+ * for details.
+ *
+ * @see Gio::ListModel, Gtk::Filter
+ * @newin{3,98}
+ */
+class GTKMM_API FilterListModel : public Glib::Object, public Gio::ListModel
+{
+  _CLASS_GOBJECT(FilterListModel, GtkFilterListModel, GTK_FILTER_LIST_MODEL, Glib::Object, GObject, , , 
GTKMM_API)
+  _IMPLEMENTS_INTERFACE(Gio::ListModel)
+  _STRUCT_NOT_HIDDEN
+
+protected:
+  _WRAP_CTOR(FilterListModel(const Glib::RefPtr<Gio::ListModel>& model, const Glib::RefPtr<Filter>& filter), 
gtk_filter_list_model_new)
+
+public:
+  _WRAP_CREATE(const Glib::RefPtr<Gio::ListModel>& model, const Glib::RefPtr<Filter>& filter)
+
+  _WRAP_METHOD(void set_filter(const Glib::RefPtr<Filter>& filter), gtk_filter_list_model_set_filter)
+  _WRAP_METHOD(Glib::RefPtr<Filter> get_filter(), gtk_filter_list_model_get_filter, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const Filter> get_filter() const, gtk_filter_list_model_get_filter, refreturn, 
constversion)
+
+  _WRAP_METHOD(void set_model(const Glib::RefPtr<Gio::ListModel>& model), gtk_filter_list_model_set_model)
+  _WRAP_METHOD(Glib::RefPtr<Gio::ListModel> get_model(), gtk_filter_list_model_get_model, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const Gio::ListModel> get_model() const, gtk_filter_list_model_get_model, 
refreturn, constversion)
+
+  _WRAP_METHOD(void set_incremental(bool incremental = true), gtk_filter_list_model_set_incremental)
+  _WRAP_METHOD(bool get_incremental() const, gtk_filter_list_model_get_incremental)
+
+  _WRAP_METHOD(guint get_pending() const, gtk_filter_list_model_get_pending)
+
+  _WRAP_PROPERTY("filter", Glib::RefPtr<Filter>)
+  _WRAP_PROPERTY("incremental", bool)
+  _WRAP_PROPERTY("model", Glib::RefPtr<Gio::ListModel>)
+  _WRAP_PROPERTY("pending", guint)
+};
+
+} // namespace Gtk
diff --git a/gtk/src/gtk_docs_override.xml b/gtk/src/gtk_docs_override.xml
index d72f5738..e5b7fe53 100644
--- a/gtk/src/gtk_docs_override.xml
+++ b/gtk/src/gtk_docs_override.xml
@@ -132,6 +132,8 @@
 <substitute_enumerator_name from_prefix="GTK_ORDERING_" to_prefix="Gtk::Ordering::" />
 <substitute_enumerator_name from_prefix="GTK_ACCESSIBLE_STATE_" to_prefix="Gtk::Accessible::State::" />
 <substitute_enumerator_name from_prefix="GTK_ACCESSIBLE_ROLE_" to_prefix="Gtk::Accessible::Role::" />
+<substitute_enumerator_name from_prefix="GTK_FILTER_MATCH_" to_prefix="Gtk::Filter::Match::" />
+<substitute_enumerator_name from_prefix="GTK_STRING_FILTER_MATCH_MODE_" 
to_prefix="Gtk::StringFilter::MatchMode::" />
 <!-- GdkWindowWindowClass is not wrapped in gtkmm. Don't substitute its enumerator names. -->
 <substitute_enumerator_name from="GDK_INPUT_ONLY" to="GDK_INPUT_ONLY" />
 <substitute_enumerator_name from="GDK_INPUT_OUTPUT" to="GDK_INPUT_OUTPUT" />
diff --git a/gtk/src/gtk_extra_objects.defs b/gtk/src/gtk_extra_objects.defs
index 63f11612..76815b18 100644
--- a/gtk/src/gtk_extra_objects.defs
+++ b/gtk/src/gtk_extra_objects.defs
@@ -181,6 +181,18 @@
   (gtype-id "GTK_TYPE_FILE_FILTER")
 )
 
+(define-object Filter
+  (in-module "Gtk")
+  (c-name "GtkFilter")
+  (gtype-id "GTK_TYPE_FILTER")
+)
+
+(define-object FilterListModel
+  (in-module "Gtk")
+  (c-name "GtkFilterListModel")
+  (gtype-id "GTK_TYPE_FILTER_LIST_MODEL")
+)
+
 (define-object FlowBox
   (in-module "Gtk")
   (c-name "GtkFlowBox")
@@ -508,6 +520,12 @@
   (gtype-id "GTK_TYPE_SORTER")
 )
 
+(define-object SortListModel
+  (in-module "Gtk")
+  (c-name "GtkSortListModel")
+  (gtype-id "GTK_TYPE_SORT_LIST_MODEL")
+)
+
 (define-object SpinButton
   (in-module "Gtk")
   (c-name "GtkSpinButton")
@@ -538,6 +556,12 @@
   (gtype-id "GTK_TYPE_STACK_SWITCHER")
 )
 
+(define-object StringFilter
+  (in-module "Gtk")
+  (c-name "GtkStringFilter")
+  (gtype-id "GTK_TYPE_STRING_FILTER")
+)
+
 (define-object StringList
   (in-module "Gtk")
   (c-name "GtkStringList")
diff --git a/gtk/src/gtk_signals.defs b/gtk/src/gtk_signals.defs
index 45c102b0..531950c7 100644
--- a/gtk/src/gtk_signals.defs
+++ b/gtk/src/gtk_signals.defs
@@ -4472,6 +4472,57 @@
   (default-value "")
 )
 
+;; From GtkFilter
+
+(define-signal changed
+  (of-object "GtkFilter")
+  (return-type "void")
+  (flags "Run Last")
+  (parameters
+    '("GtkFilterChange" "p0")
+  )
+)
+
+;; From GtkFilterListModel
+
+(define-property filter
+  (of-object "GtkFilterListModel")
+  (prop-type "GParamObject")
+  (docs "The filter set for this model")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
+(define-property incremental
+  (of-object "GtkFilterListModel")
+  (prop-type "GParamBoolean")
+  (docs "Filter items incrementally")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+  (default-value "FALSE")
+)
+
+(define-property model
+  (of-object "GtkFilterListModel")
+  (prop-type "GParamObject")
+  (docs "The model being filtered")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
+(define-property pending
+  (of-object "GtkFilterListModel")
+  (prop-type "GParamUInt")
+  (docs "Number of items not yet filtered")
+  (readable #t)
+  (writable #f)
+  (construct-only #f)
+  (default-value "0")
+)
+
 ;; From GtkFixed
 
 ;; From GtkFlowBox
@@ -9708,6 +9759,46 @@
   )
 )
 
+;; From GtkSortListModel
+
+(define-property incremental
+  (of-object "GtkSortListModel")
+  (prop-type "GParamBoolean")
+  (docs "Sort items incrementally")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+  (default-value "FALSE")
+)
+
+(define-property model
+  (of-object "GtkSortListModel")
+  (prop-type "GParamObject")
+  (docs "The model being sorted")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
+(define-property pending
+  (of-object "GtkSortListModel")
+  (prop-type "GParamUInt")
+  (docs "Estimate of unsorted items remaining")
+  (readable #t)
+  (writable #f)
+  (construct-only #f)
+  (default-value "0")
+)
+
+(define-property sorter
+  (of-object "GtkSortListModel")
+  (prop-type "GParamObject")
+  (docs "The sorter for this model")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
 ;; From GtkSpinner
 
 (define-property spinning
@@ -10042,6 +10133,47 @@
   )
 )
 
+;; From GtkStringFilter
+
+(define-property expression
+  (of-object "GtkStringFilter")
+  (prop-type "GtkParamSpecExpression")
+  (docs "Expression to compare with")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
+(define-property ignore-case
+  (of-object "GtkStringFilter")
+  (prop-type "GParamBoolean")
+  (docs "If matching is case sensitive")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+  (default-value "TRUE")
+)
+
+(define-property match-mode
+  (of-object "GtkStringFilter")
+  (prop-type "GParamEnum")
+  (docs "If exact matches are necessary or if substrings are allowed")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+  (default-value "GTK_STRING_FILTER_MATCH_MODE_SUBSTRING")
+)
+
+(define-property search
+  (of-object "GtkStringFilter")
+  (prop-type "GParamString")
+  (docs "The search term")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+  (default-value "")
+)
+
 ;; From GtkStringObject
 
 (define-property string
@@ -10054,6 +10186,27 @@
   (default-value "")
 )
 
+;; From GtkStringSorter
+
+(define-property expression
+  (of-object "GtkStringSorter")
+  (prop-type "GtkParamSpecExpression")
+  (docs "Expression to compare with")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+)
+
+(define-property ignore-case
+  (of-object "GtkStringSorter")
+  (prop-type "GParamBoolean")
+  (docs "If matching is case sensitive")
+  (readable #t)
+  (writable #t)
+  (construct-only #f)
+  (default-value "TRUE")
+)
+
 ;; From GtkStyleContext
 
 (define-property display
diff --git a/gtk/src/gtk_vfuncs.defs b/gtk/src/gtk_vfuncs.defs
index f82d1427..02f4b433 100644
--- a/gtk/src/gtk_vfuncs.defs
+++ b/gtk/src/gtk_vfuncs.defs
@@ -313,6 +313,21 @@
   (return-type "GtkEditable*")
 )
 
+; GtkFilter
+
+(define-vfunc match
+  (of-object "GtkFilter")
+  (return-type "gboolean")
+  (parameters
+    '("gpointer" "item")
+  )
+)
+
+(define-vfunc get_strictness
+  (of-object "GtkFilter")
+  (return-type "GtkFilterMatch")
+)
+
 ; GtkFrame
 
 (define-vfunc compute_child_allocation
diff --git a/gtk/src/sortlistmodel.ccg b/gtk/src/sortlistmodel.ccg
new file mode 100644
index 00000000..57b87fdc
--- /dev/null
+++ b/gtk/src/sortlistmodel.ccg
@@ -0,0 +1,17 @@
+/* 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/>.
+ */
+
+#include <gtk/gtk.h>
diff --git a/gtk/src/sortlistmodel.hg b/gtk/src/sortlistmodel.hg
new file mode 100644
index 00000000..0c6b4187
--- /dev/null
+++ b/gtk/src/sortlistmodel.hg
@@ -0,0 +1,74 @@
+/* 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 <giomm/listmodel.h>
+#include <gtkmm/sorter.h>
+#include <gtk/gtk.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gtk
+{
+
+/** A list model that sorts its items.
+ *
+ * %Gtk::SortListModel is a list model that takes a list model and
+ * sorts its elements according to a Gtk::Sorter.
+ *
+ * %Gtk::SortListModel is a generic model and because of that it
+ * cannot take advantage of any external knowledge when sorting.
+ * If you run into performance issues with %Gtk::SortListModel, it
+ * is strongly recommended that you write your own sorting list
+ * model.
+ *
+ * @see Gio::ListModel, Gtk::Sorter
+ * @newin{3,98}
+ */
+class GTKMM_API SortListModel : public Glib::Object, public Gio::ListModel
+{
+  _CLASS_GOBJECT(SortListModel, GtkSortListModel, GTK_SORT_LIST_MODEL, Glib::Object, GObject, , , GTKMM_API)
+  _IMPLEMENTS_INTERFACE(Gio::ListModel)
+  _STRUCT_NOT_HIDDEN
+
+protected:
+  _WRAP_CTOR(SortListModel(const Glib::RefPtr<Gio::ListModel>& model, const Glib::RefPtr<Sorter>& sorter), 
gtk_sort_list_model_new)
+
+public:
+  _WRAP_CREATE(const Glib::RefPtr<Gio::ListModel>& model, const Glib::RefPtr<Sorter>& sorter)
+
+  _WRAP_METHOD(void set_sorter(const Glib::RefPtr<Sorter>& sorter), gtk_sort_list_model_set_sorter)
+  _WRAP_METHOD(Glib::RefPtr<Sorter> get_sorter(), gtk_sort_list_model_get_sorter, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const Sorter> get_sorter() const, gtk_sort_list_model_get_sorter, refreturn, 
constversion)
+
+  _WRAP_METHOD(void set_model(const Glib::RefPtr<Gio::ListModel>& model), gtk_sort_list_model_set_model)
+  _WRAP_METHOD(Glib::RefPtr<Gio::ListModel> get_model(), gtk_sort_list_model_get_model, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const Gio::ListModel> get_model() const, gtk_sort_list_model_get_model, 
refreturn, constversion)
+
+  _WRAP_METHOD(void set_incremental(bool incremental = true), gtk_sort_list_model_set_incremental)
+  _WRAP_METHOD(bool get_incremental() const, gtk_sort_list_model_get_incremental)
+
+  _WRAP_METHOD(guint get_pending() const, gtk_sort_list_model_get_pending)
+
+  _WRAP_PROPERTY("incremental", bool)
+  _WRAP_PROPERTY("model", Glib::RefPtr<Gio::ListModel>)
+  _WRAP_PROPERTY("pending", guint)
+  _WRAP_PROPERTY("sorter", Glib::RefPtr<Sorter>)
+};
+
+} // namespace Gtk
diff --git a/gtk/src/stringfilter.ccg b/gtk/src/stringfilter.ccg
new file mode 100644
index 00000000..810dd853
--- /dev/null
+++ b/gtk/src/stringfilter.ccg
@@ -0,0 +1,19 @@
+/* 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/>.
+ */
+
+#include <gtk/gtk.h>
+
+using MatchMode = Gtk::StringFilter::MatchMode;
diff --git a/gtk/src/stringfilter.hg b/gtk/src/stringfilter.hg
new file mode 100644
index 00000000..53493bd8
--- /dev/null
+++ b/gtk/src/stringfilter.hg
@@ -0,0 +1,65 @@
+/* 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/>.
+ */
+
+#include <gtkmm/filter.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(gtkmm/private/filter_p.h)
+
+namespace Gtk
+{
+
+/** Filtering by strings.
+ *
+ * %Gtk::StringFilter determines whether to include items by looking
+ * at strings and comparing them to a fixed search term. The strings
+ * are obtained from the items by evaluating a Gtk::Expression.
+ *
+ * %Gtk::StringFilter has several different modes of comparison - it
+ * can match the whole string, just a prefix, or any substring.
+ *
+ * @newin{3,98}
+ */
+class GTKMM_API StringFilter : public Filter
+{
+  _CLASS_GOBJECT(StringFilter, GtkStringFilter, GTK_STRING_FILTER, Gtk::Filter, GtkFilter, , , GTKMM_API)
+  _STRUCT_NOT_HIDDEN
+
+protected:
+  //TODO: change this when GtkExpression has been wrapped
+  _WRAP_CTOR(StringFilter(GtkExpression* expression), gtk_string_filter_new)
+
+public:
+  _WRAP_ENUM(MatchMode, GtkStringFilterMatchMode, decl_prefix GTKMM_API)
+
+  _WRAP_CREATE(GtkExpression* expression)
+
+  _WRAP_METHOD(Glib::ustring get_search() const, gtk_string_filter_get_search)
+  _WRAP_METHOD(void set_search(const Glib::ustring& search), gtk_string_filter_set_search)
+  _WRAP_METHOD(GtkExpression* get_expression() const, gtk_string_filter_get_expression)
+  _WRAP_METHOD(void set_expression(GtkExpression* expression), gtk_string_filter_set_expression)
+  _WRAP_METHOD(bool get_ignore_case() const, gtk_string_filter_get_ignore_case)
+  _WRAP_METHOD(void set_ignore_case(bool ignore_case = true), gtk_string_filter_set_ignore_case)
+  _WRAP_METHOD(MatchMode get_match_mode() const, gtk_string_filter_get_match_mode)
+  _WRAP_METHOD(void set_match_mode(MatchMode mode), gtk_string_filter_set_match_mode)
+
+  _WRAP_PROPERTY("expression", GtkExpression*)
+  _WRAP_PROPERTY("ignore-case", bool)
+  _WRAP_PROPERTY("match-mode", MatchMode)
+  _WRAP_PROPERTY("search", Glib::ustring)
+};
+
+} // namespace Gtk
diff --git a/gtk/src/stringsorter.ccg b/gtk/src/stringsorter.ccg
new file mode 100644
index 00000000..57b87fdc
--- /dev/null
+++ b/gtk/src/stringsorter.ccg
@@ -0,0 +1,17 @@
+/* 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/>.
+ */
+
+#include <gtk/gtk.h>
diff --git a/gtk/src/stringsorter.hg b/gtk/src/stringsorter.hg
new file mode 100644
index 00000000..13254d0b
--- /dev/null
+++ b/gtk/src/stringsorter.hg
@@ -0,0 +1,58 @@
+/* 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/>.
+ */
+
+#include <gtkmm/sorter.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(gtkmm/private/sorter_p.h)
+
+namespace Gtk
+{
+
+/** Sort by comparing strings
+ *
+ * %Gtk::StringSorter is a Gtk::Sorter that compares strings. It does the
+ * comparison in a linguistically correct way using the current locale by
+ * normalizing Unicode strings and possibly case-folding them before
+ * performing the comparison.
+ *
+ * To obtain the strings to compare, this sorter evaluates a Gtk::Expression.
+ *
+ * @see Gtk::Expression
+ * @newin{3,98}
+ */
+class GTKMM_API StringSorter : public Sorter
+{
+  _CLASS_GOBJECT(StringSorter, GtkStringSorter, GTK_STRING_SORTER, Gtk::Sorter, GtkSorter, , , GTKMM_API)
+  _STRUCT_NOT_HIDDEN
+
+protected:
+  //TODO: change this when GtkExpression has been wrapped
+  _WRAP_CTOR(StringSorter(GtkExpression* expression), gtk_string_sorter_new)
+
+public:
+  _WRAP_CREATE(GtkExpression* expression)
+
+  _WRAP_METHOD(GtkExpression* get_expression() const, gtk_string_sorter_get_expression)
+  _WRAP_METHOD(void set_expression(GtkExpression* expression), gtk_string_sorter_set_expression)
+  _WRAP_METHOD(bool get_ignore_case() const, gtk_string_sorter_get_ignore_case)
+  _WRAP_METHOD(void set_ignore_case(bool ignore_case = true), gtk_string_sorter_set_ignore_case)
+
+  _WRAP_PROPERTY("expression", GtkExpression*)
+  _WRAP_PROPERTY("ignore-case", bool)
+};
+
+} // namespace Gtk
diff --git a/tools/extra_defs_gen/generate_defs_gtk.cc b/tools/extra_defs_gen/generate_defs_gtk.cc
index f311a609..aa13026c 100644
--- a/tools/extra_defs_gen/generate_defs_gtk.cc
+++ b/tools/extra_defs_gen/generate_defs_gtk.cc
@@ -114,6 +114,8 @@ int main(int /* argc */, char** /* argv */)
             << get_defs( GTK_TYPE_FILE_CHOOSER_DIALOG )
             << get_defs( GTK_TYPE_FILE_CHOOSER_NATIVE )
             << get_defs( GTK_TYPE_FILE_CHOOSER_WIDGET )
+            << get_defs( GTK_TYPE_FILTER )
+            << get_defs( GTK_TYPE_FILTER_LIST_MODEL )
             << get_defs( GTK_TYPE_FIXED )
             << get_defs( GTK_TYPE_FLOW_BOX )
             << get_defs( GTK_TYPE_FLOW_BOX_CHILD )
@@ -210,6 +212,7 @@ int main(int /* argc */, char** /* argv */)
             << get_defs( GTK_TYPE_SINGLE_SELECTION )
             << get_defs( GTK_TYPE_SIZE_GROUP )
             << get_defs( GTK_TYPE_SORTER )
+            << get_defs( GTK_TYPE_SORT_LIST_MODEL )
             << get_defs( GTK_TYPE_SPINNER )
             << get_defs( GTK_TYPE_SPIN_BUTTON )
             << get_defs( GTK_TYPE_STACK )
@@ -217,7 +220,9 @@ int main(int /* argc */, char** /* argv */)
             << get_defs( GTK_TYPE_STACK_SIDEBAR )
             << get_defs( GTK_TYPE_STACK_SWITCHER )
             << get_defs( GTK_TYPE_STATUSBAR )
+            << get_defs( GTK_TYPE_STRING_FILTER )
             << get_defs( GTK_TYPE_STRING_OBJECT )
+            << get_defs( GTK_TYPE_STRING_SORTER )
             << get_defs( GTK_TYPE_STYLE_CONTEXT )
             << get_defs( GTK_TYPE_STYLE_PROVIDER )
             << get_defs( GTK_TYPE_SWITCH )
diff --git a/tools/m4/convert_gtk.m4 b/tools/m4/convert_gtk.m4
index c3c1a5f5..7f1c20c7 100644
--- a/tools/m4/convert_gtk.m4
+++ b/tools/m4/convert_gtk.m4
@@ -52,6 +52,8 @@ _CONV_ENUM(Gtk,DeleteType)
 _CONV_ENUM(Gtk,DirectionType)
 _CONV_INCLASS_ENUM(Gtk,EventControllerScroll,Flags)
 _CONV_ENUM(Gtk,EventSequenceState)
+_CONV_INCLASS_ENUM(Gtk,Filter,Change)
+_CONV_INCLASS_ENUM(Gtk,Filter,Match)
 _CONV_INCLASS_ENUM(Gtk,FontChooser,Level)
 _CONV_INCLASS_ENUM(Gtk,Image,Type)
 _CONV_ENUM(Gtk,IconSize)
@@ -89,6 +91,7 @@ _CONV_ENUM(Gtk,SortType)
 _CONV_INCLASS_ENUM(Gtk,SpinButton,UpdatePolicy)
 _CONV_ENUM(Gtk,SpinType)
 _CONV_ENUM(Gtk,StackTransitionType)
+_CONV_INCLASS_ENUM(Gtk,StringFilter,MatchMode)
 _CONV_INCLASS_ENUM(Gtk,StyleContext,PrintFlags)
 _CONV_ENUM(Gtk,TextDirection)
 _CONV_ENUM(Gtk,TextSearchFlags)
@@ -593,3 +596,5 @@ _CONVERSION(`GtkStringObject*',`Glib::RefPtr<StringObject>',`Glib::wrap($3)')
 _CONVERSION(`const Glib::RefPtr<Sorter>&', `GtkSorter*', __CONVERT_REFPTR_TO_P)
 _CONVERSION(`GtkSorter*',`Glib::RefPtr<Sorter>',`Glib::wrap($3)')
 _CONVERSION(`GtkTreeListRow*',`Glib::RefPtr<TreeListRow>',`Glib::wrap($3)')
+_CONVERSION(`const Glib::RefPtr<Filter>&', `GtkFilter*', __CONVERT_REFPTR_TO_P)
+_CONVERSION(`GtkFilter*',`Glib::RefPtr<Filter>',`Glib::wrap($3)')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]