[gtkmm] Add Gtk::TreeExpander
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm] Add Gtk::TreeExpander
- Date: Thu, 3 Dec 2020 14:51:36 +0000 (UTC)
commit c9317c8719be24e7f222ff8c942c7055ed0abb1e
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Thu Dec 3 15:48:54 2020 +0100
Add Gtk::TreeExpander
.gitignore | 2 ++
gtk/gtkmm.h | 1 +
gtk/gtkmm/meson.build | 1 +
gtk/src/filelist.am | 1 +
gtk/src/treeexpander.ccg | 32 +++++++++++++++++++
gtk/src/treeexpander.hg | 81 ++++++++++++++++++++++++++++++++++++++++++++++++
tools/m4/convert_gtk.m4 | 1 +
7 files changed, 119 insertions(+)
---
diff --git a/.gitignore b/.gitignore
index 006119a6..a27e937c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -597,6 +597,8 @@ gtk/gtkmm/treedragdest.cc
gtk/gtkmm/treedragdest.h
gtk/gtkmm/treedragsource.cc
gtk/gtkmm/treedragsource.h
+gtk/gtkmm/treeexpander.cc
+gtk/gtkmm/treeexpander.h
gtk/gtkmm/treeiter.cc
gtk/gtkmm/treeiter.h
gtk/gtkmm/treelistmodel.cc
diff --git a/gtk/gtkmm.h b/gtk/gtkmm.h
index fc946ce9..e5a5dbce 100644
--- a/gtk/gtkmm.h
+++ b/gtk/gtkmm.h
@@ -296,6 +296,7 @@ extern const int gtkmm_micro_version;
#include <gtkmm/textview.h>
#include <gtkmm/togglebutton.h>
#include <gtkmm/tooltip.h>
+#include <gtkmm/treeexpander.h>
#include <gtkmm/treelistmodel.h>
#include <gtkmm/treemodel.h>
#include <gtkmm/treemodelfilter.h>
diff --git a/gtk/gtkmm/meson.build b/gtk/gtkmm/meson.build
index 437a205d..bf6c5804 100644
--- a/gtk/gtkmm/meson.build
+++ b/gtk/gtkmm/meson.build
@@ -249,6 +249,7 @@ gtkmm_any_hg_ccg_basenames = [
'tooltip',
'treedragdest',
'treedragsource',
+ 'treeexpander',
'treeiter',
'treelistmodel',
'treelistrow',
diff --git a/gtk/src/filelist.am b/gtk/src/filelist.am
index 960161a9..00d3edd3 100644
--- a/gtk/src/filelist.am
+++ b/gtk/src/filelist.am
@@ -234,6 +234,7 @@ gtkmm_files_any_hg = \
tooltip.hg \
treedragdest.hg \
treedragsource.hg \
+ treeexpander.hg \
treeiter.hg \
treelistmodel.hg \
treelistrow.hg \
diff --git a/gtk/src/treeexpander.ccg b/gtk/src/treeexpander.ccg
new file mode 100644
index 00000000..01895a06
--- /dev/null
+++ b/gtk/src/treeexpander.ccg
@@ -0,0 +1,32 @@
+/* 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>
+
+namespace Gtk
+{
+
+void TreeExpander::unset_child()
+{
+ gtk_tree_expander_set_child(gobj(), nullptr);
+}
+
+void TreeExpander::unset_list_row()
+{
+ gtk_tree_expander_set_list_row(gobj(), nullptr);
+}
+
+} // namespace Gtk
diff --git a/gtk/src/treeexpander.hg b/gtk/src/treeexpander.hg
new file mode 100644
index 00000000..41fa1bed
--- /dev/null
+++ b/gtk/src/treeexpander.hg
@@ -0,0 +1,81 @@
+/* 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 <gtkmm/widget.h>
+#include <gtkmm/treelistrow.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(gtkmm/private/widget_p.h)
+
+namespace Gtk
+{
+
+/** An indenting expander button for use in a tree list.
+ *
+ * %Gtk::TreeExpander is a widget that provides an expander for a list.
+ *
+ * It is typically placed as a bottommost child into a Gtk::ListView to allow
+ * users to expand and collapse children in a list with a Gtk::TreeListModel.
+ * It will provide the common UI elements, gestures and keybindings for this
+ * purpose.
+ *
+ * On top of this, the "listitem.expand", "listitem.collapse" and
+ * "listitem.toggle-expand" actions are provided to allow adding custom UI
+ * for managing expanded state.
+ *
+ * The Gtk::TreeListModel must be set to not be passthrough. Then it will provide
+ * Gtk::TreeListRow items which can be set via set_list_row()
+ * on the expander. The expander will then watch that row item automatically.
+ * set_child() sets the widget that displays the actual row contents.
+ *
+ * @see Gtk::TreeListModel
+ *
+ * @newin{3,98}
+ */
+class GTKMM_API TreeExpander : public Widget
+{
+ _CLASS_GTKOBJECT(TreeExpander, GtkTreeExpander, GTK_TREE_EXPANDER, Gtk::Widget, GtkWidget, , , GTKMM_API)
+ _STRUCT_NOT_HIDDEN
+
+public:
+ _CTOR_DEFAULT()
+
+ _WRAP_METHOD(Widget* get_child(), gtk_tree_expander_get_child)
+ _WRAP_METHOD(const Widget* get_child() const, gtk_tree_expander_get_child, constversion)
+ _WRAP_METHOD(void set_child(Widget& widget), gtk_tree_expander_set_child)
+ /** Removes the content widget to display.
+ */
+ void unset_child();
+
+#m4 _CONVERSION(`gpointer',`Glib::RefPtr<Glib::ObjectBase>',`Glib::wrap(G_OBJECT($3))')
+ _WRAP_METHOD(Glib::RefPtr<Glib::ObjectBase> get_item(), gtk_tree_expander_get_item)
+ _WRAP_METHOD(Glib::RefPtr<const Glib::ObjectBase> get_item() const, gtk_tree_expander_get_item,
constversion)
+
+ _WRAP_METHOD(Glib::RefPtr<TreeListRow> get_list_row(), gtk_tree_expander_get_list_row, refreturn)
+ _WRAP_METHOD(Glib::RefPtr<const TreeListRow> get_list_row() const, gtk_tree_expander_get_list_row,
refreturn, constversion)
+ _WRAP_METHOD(void set_list_row(const Glib::RefPtr<TreeListRow>& list_row), gtk_tree_expander_set_list_row)
+ /** Removes the tree list row that this expander should manage.
+ */
+ void unset_list_row();
+
+ _WRAP_PROPERTY("child", Widget*)
+ _WRAP_PROPERTY("item", Glib::RefPtr<Glib::ObjectBase>)
+ _WRAP_PROPERTY("list-row", Glib::RefPtr<TreeListRow>)
+};
+
+} // namespace Gtk
diff --git a/tools/m4/convert_gtk.m4 b/tools/m4/convert_gtk.m4
index 57a7bea5..d21fff45 100644
--- a/tools/m4/convert_gtk.m4
+++ b/tools/m4/convert_gtk.m4
@@ -597,6 +597,7 @@ _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<TreeListRow>&', `GtkTreeListRow*', __CONVERT_REFPTR_TO_P)
_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]