[gtkmm/flatten_slice_models] Add Gtk::FlattenListModel and Gtk::SliceListModel
- From: Andreas Persson <andreasp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm/flatten_slice_models] Add Gtk::FlattenListModel and Gtk::SliceListModel
- Date: Fri, 11 Sep 2020 17:42:43 +0000 (UTC)
commit 2cdd790f832b1c4db907b020ee5abc3d7cd9e3fa
Author: Andreas Persson <andreasp56 outlook com>
Date: Fri Sep 11 19:42:07 2020 +0200
Add Gtk::FlattenListModel and Gtk::SliceListModel
Add bindings for two simple list model classes.
.gitignore | 4 ++
gtk/gtkmm.h | 2 +
gtk/gtkmm/meson.build | 2 +
gtk/src/filelist.am | 2 +
gtk/src/flattenlistmodel.ccg | 17 ++++++++
gtk/src/flattenlistmodel.hg | 60 ++++++++++++++++++++++++++++
gtk/src/gtk_extra_objects.defs | 12 ++++++
gtk/src/gtk_signals.defs | 42 ++++++++++++++++++++
gtk/src/slicelistmodel.ccg | 17 ++++++++
gtk/src/slicelistmodel.hg | 65 +++++++++++++++++++++++++++++++
tools/extra_defs_gen/generate_defs_gtk.cc | 2 +
11 files changed, 225 insertions(+)
---
diff --git a/.gitignore b/.gitignore
index 0eae73fc..1dd182d3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -313,6 +313,8 @@ gtk/gtkmm/filterlistmodel.cc
gtk/gtkmm/filterlistmodel.h
gtk/gtkmm/fixed.cc
gtk/gtkmm/fixed.h
+gtk/gtkmm/flattenlistmodel.cc
+gtk/gtkmm/flattenlistmodel.h
gtk/gtkmm/flowbox.cc
gtk/gtkmm/flowbox.h
gtk/gtkmm/flowboxchild.cc
@@ -521,6 +523,8 @@ gtk/gtkmm/singleselection.cc
gtk/gtkmm/singleselection.h
gtk/gtkmm/sizegroup.cc
gtk/gtkmm/sizegroup.h
+gtk/gtkmm/slicelistmodel.cc
+gtk/gtkmm/slicelistmodel.h
gtk/gtkmm/snapshot.cc
gtk/gtkmm/snapshot.h
gtk/gtkmm/sorter.cc
diff --git a/gtk/gtkmm.h b/gtk/gtkmm.h
index 8881ed42..520ddac1 100644
--- a/gtk/gtkmm.h
+++ b/gtk/gtkmm.h
@@ -160,6 +160,7 @@ extern const int gtkmm_micro_version;
#include <gtkmm/filefilter.h>
#include <gtkmm/filterlistmodel.h>
#include <gtkmm/fixed.h>
+#include <gtkmm/flattenlistmodel.h>
#include <gtkmm/flowbox.h>
#include <gtkmm/flowboxchild.h>
#include <gtkmm/fontbutton.h>
@@ -252,6 +253,7 @@ extern const int gtkmm_micro_version;
#include <gtkmm/signallistitemfactory.h>
#include <gtkmm/singleselection.h>
#include <gtkmm/sizegroup.h>
+#include <gtkmm/slicelistmodel.h>
#include <gtkmm/snapshot.h>
#include <gtkmm/sortlistmodel.h>
#include <gtkmm/spinbutton.h>
diff --git a/gtk/gtkmm/meson.build b/gtk/gtkmm/meson.build
index 98ce3558..2bade12e 100644
--- a/gtk/gtkmm/meson.build
+++ b/gtk/gtkmm/meson.build
@@ -113,6 +113,7 @@ gtkmm_any_hg_ccg_basenames = [
'filter',
'filterlistmodel',
'fixed',
+ 'flattenlistmodel',
'flowbox',
'flowboxchild',
'fontbutton',
@@ -211,6 +212,7 @@ gtkmm_any_hg_ccg_basenames = [
'shortcuttrigger',
'singleselection',
'sizegroup',
+ 'slicelistmodel',
'snapshot',
'sorter',
'sortlistmodel',
diff --git a/gtk/src/filelist.am b/gtk/src/filelist.am
index 587ed1e7..816a091c 100644
--- a/gtk/src/filelist.am
+++ b/gtk/src/filelist.am
@@ -98,6 +98,7 @@ gtkmm_files_any_hg = \
filter.hg \
filterlistmodel.hg \
fixed.hg \
+ flattenlistmodel.hg \
flowbox.hg \
flowboxchild.hg \
fontbutton.hg \
@@ -196,6 +197,7 @@ gtkmm_files_any_hg = \
signallistitemfactory.hg \
singleselection.hg \
sizegroup.hg \
+ slicelistmodel.hg \
snapshot.hg \
sorter.hg \
sortlistmodel.hg \
diff --git a/gtk/src/flattenlistmodel.ccg b/gtk/src/flattenlistmodel.ccg
new file mode 100644
index 00000000..57b87fdc
--- /dev/null
+++ b/gtk/src/flattenlistmodel.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/flattenlistmodel.hg b/gtk/src/flattenlistmodel.hg
new file mode 100644
index 00000000..113500c4
--- /dev/null
+++ b/gtk/src/flattenlistmodel.hg
@@ -0,0 +1,60 @@
+/* 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 <gtk/gtk.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gtk
+{
+
+/** A list model that flattens a list of lists.
+ *
+ * %Gtk::FlattenListModel is a list model that takes a list model containing
+ * list models and flattens it into a single model.
+ *
+ * Another term for this is concatenation: %Gtk::FlattenListModel takes a
+ * list of lists and concatenates them into a single list.
+ *
+ * @see Gio::ListModel
+ * @newin{3,98}
+ */
+class GTKMM_API FlattenListModel : public Glib::Object, public Gio::ListModel
+{
+ _CLASS_GOBJECT(FlattenListModel, GtkFlattenListModel, GTK_FLATTEN_LIST_MODEL, Glib::Object, GObject, , ,
GTKMM_API)
+ _IMPLEMENTS_INTERFACE(Gio::ListModel)
+ _STRUCT_NOT_HIDDEN
+
+protected:
+ _WRAP_CTOR(FlattenListModel(const Glib::RefPtr<Gio::ListModel>& model), gtk_flatten_list_model_new)
+
+public:
+ _WRAP_CREATE(const Glib::RefPtr<Gio::ListModel>& model)
+
+ _WRAP_METHOD(void set_model(const Glib::RefPtr<Gio::ListModel>& model), gtk_flatten_list_model_set_model)
+ _WRAP_METHOD(Glib::RefPtr<Gio::ListModel> get_model(), gtk_flatten_list_model_get_model, refreturn)
+ _WRAP_METHOD(Glib::RefPtr<const Gio::ListModel> get_model() const, gtk_flatten_list_model_get_model,
refreturn, constversion)
+
+ _WRAP_METHOD(Glib::RefPtr<Gio::ListModel> get_model_for_item(guint position),
gtk_flatten_list_model_get_model_for_item, refreturn)
+
+ _WRAP_PROPERTY("model", Glib::RefPtr<Gio::ListModel>)
+};
+
+} // namespace Gtk
diff --git a/gtk/src/gtk_extra_objects.defs b/gtk/src/gtk_extra_objects.defs
index 218500f7..4ac9dc95 100644
--- a/gtk/src/gtk_extra_objects.defs
+++ b/gtk/src/gtk_extra_objects.defs
@@ -205,6 +205,12 @@
(gtype-id "GTK_TYPE_FILTER_LIST_MODEL")
)
+(define-object FlattenListModel
+ (in-module "Gtk")
+ (c-name "GtkFlattenListModel")
+ (gtype-id "GTK_TYPE_FLATTEN_LIST_MODEL")
+)
+
(define-object FlowBox
(in-module "Gtk")
(c-name "GtkFlowBox")
@@ -526,6 +532,12 @@
(gtype-id "GTK_TYPE_SHORTCUT_CONTROLLER")
)
+(define-object SliceListModel
+ (in-module "Gtk")
+ (c-name "GtkSliceListModel")
+ (gtype-id "GTK_TYPE_SLICE_LIST_MODEL")
+)
+
(define-object Snapshot
(in-module "Gtk")
(c-name "GtkSnapshot")
diff --git a/gtk/src/gtk_signals.defs b/gtk/src/gtk_signals.defs
index 6f25ec52..19d61b20 100644
--- a/gtk/src/gtk_signals.defs
+++ b/gtk/src/gtk_signals.defs
@@ -4580,6 +4580,17 @@
;; From GtkFixed
+;; From GtkFlattenListModel
+
+(define-property model
+ (of-object "GtkFlattenListModel")
+ (prop-type "GParamObject")
+ (docs "The model being flattened")
+ (readable #t)
+ (writable #t)
+ (construct-only #f)
+)
+
;; From GtkFlowBox
(define-signal child-activated
@@ -9913,6 +9924,37 @@
(default-value "GTK_SIZE_GROUP_HORIZONTAL")
)
+;; From GtkSliceListModel
+
+(define-property model
+ (of-object "GtkSliceListModel")
+ (prop-type "GParamObject")
+ (docs "Child model to take slice from")
+ (readable #t)
+ (writable #t)
+ (construct-only #f)
+)
+
+(define-property offset
+ (of-object "GtkSliceListModel")
+ (prop-type "GParamUInt")
+ (docs "Offset of slice")
+ (readable #t)
+ (writable #t)
+ (construct-only #f)
+ (default-value "0")
+)
+
+(define-property size
+ (of-object "GtkSliceListModel")
+ (prop-type "GParamUInt")
+ (docs "Maximum size of slice")
+ (readable #t)
+ (writable #t)
+ (construct-only #f)
+ (default-value "10")
+)
+
;; From GtkSorter
(define-signal changed
diff --git a/gtk/src/slicelistmodel.ccg b/gtk/src/slicelistmodel.ccg
new file mode 100644
index 00000000..57b87fdc
--- /dev/null
+++ b/gtk/src/slicelistmodel.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/slicelistmodel.hg b/gtk/src/slicelistmodel.hg
new file mode 100644
index 00000000..e75f633a
--- /dev/null
+++ b/gtk/src/slicelistmodel.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/>.
+ */
+
+_CONFIGINCLUDE(gtkmmconfig.h)
+
+#include <giomm/listmodel.h>
+#include <gtk/gtk.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gtk
+{
+
+/** A list model that presents a slice out of a larger list.
+ *
+ * %Gtk::SliceListModel is a list model that takes a list model and presents a
+ * slice of that model.
+ *
+ * This is useful when implementing paging by setting the size to the number
+ * of elements per page and updating the offset whenever a different page is
+ * opened.
+ *
+ * @see Gio::ListModel
+ * @newin{3,98}
+ */
+class GTKMM_API SliceListModel : public Glib::Object, public Gio::ListModel
+{
+ _CLASS_GOBJECT(SliceListModel, GtkSliceListModel, GTK_SLICE_LIST_MODEL, Glib::Object, GObject, , ,
GTKMM_API)
+ _IMPLEMENTS_INTERFACE(Gio::ListModel)
+ _STRUCT_NOT_HIDDEN
+
+protected:
+ _WRAP_CTOR(SliceListModel(const Glib::RefPtr<Gio::ListModel>& model, guint offset, guint size),
gtk_slice_list_model_new)
+
+public:
+ _WRAP_CREATE(const Glib::RefPtr<Gio::ListModel>& model, guint offset, guint size)
+
+ _WRAP_METHOD(void set_model(const Glib::RefPtr<Gio::ListModel>& model), gtk_slice_list_model_set_model)
+ _WRAP_METHOD(Glib::RefPtr<Gio::ListModel> get_model(), gtk_slice_list_model_get_model, refreturn)
+ _WRAP_METHOD(Glib::RefPtr<const Gio::ListModel> get_model() const, gtk_slice_list_model_get_model,
refreturn, constversion)
+ _WRAP_METHOD(void set_offset(guint offset), gtk_slice_list_model_set_offset)
+ _WRAP_METHOD(guint get_offset() const, gtk_slice_list_model_get_offset)
+ _WRAP_METHOD(void set_size(guint size), gtk_slice_list_model_set_size)
+ _WRAP_METHOD(guint get_size() const, gtk_slice_list_model_get_size)
+
+ _WRAP_PROPERTY("model", Glib::RefPtr<Gio::ListModel>)
+ _WRAP_PROPERTY("offset", guint)
+ _WRAP_PROPERTY("size", guint)
+};
+
+} // namespace Gtk
diff --git a/tools/extra_defs_gen/generate_defs_gtk.cc b/tools/extra_defs_gen/generate_defs_gtk.cc
index 2d97b014..a7b5b83b 100644
--- a/tools/extra_defs_gen/generate_defs_gtk.cc
+++ b/tools/extra_defs_gen/generate_defs_gtk.cc
@@ -118,6 +118,7 @@ int main(int /* argc */, char** /* argv */)
<< get_defs( GTK_TYPE_FILTER )
<< get_defs( GTK_TYPE_FILTER_LIST_MODEL )
<< get_defs( GTK_TYPE_FIXED )
+ << get_defs( GTK_TYPE_FLATTEN_LIST_MODEL )
<< get_defs( GTK_TYPE_FLOW_BOX )
<< get_defs( GTK_TYPE_FLOW_BOX_CHILD )
<< get_defs( GTK_TYPE_FONT_BUTTON )
@@ -216,6 +217,7 @@ int main(int /* argc */, char** /* argv */)
<< get_defs( GTK_TYPE_SIGNAL_LIST_ITEM_FACTORY )
<< get_defs( GTK_TYPE_SINGLE_SELECTION )
<< get_defs( GTK_TYPE_SIZE_GROUP )
+ << get_defs( GTK_TYPE_SLICE_LIST_MODEL )
<< get_defs( GTK_TYPE_SORTER )
<< get_defs( GTK_TYPE_SORT_LIST_MODEL )
<< get_defs( GTK_TYPE_SPINNER )
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]