[gtkmm] Add Gtk::AssistantPage and Gtk::StackPage



commit a9e7dcc9e6b8507dacfc0739c4800c3753fb3353
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Wed Feb 13 10:30:17 2019 +0100

    Add Gtk::AssistantPage and Gtk::StackPage
    
    They replace child properties in Assistant and Stack.

 .gitignore                      |  4 ++++
 demos/gtk-demo/example_stack.cc |  2 +-
 gtk/src/assistant.ccg           |  2 --
 gtk/src/assistant.hg            | 19 ++++++++-------
 gtk/src/assistantpage.ccg       | 20 ++++++++++++++++
 gtk/src/assistantpage.hg        | 53 +++++++++++++++++++++++++++++++++++++++++
 gtk/src/enums.hg                |  1 +
 gtk/src/filelist.am             |  2 ++
 gtk/src/stack.hg                | 19 ++++++++-------
 gtk/src/stackpage.ccg           | 18 ++++++++++++++
 gtk/src/stackpage.hg            | 52 ++++++++++++++++++++++++++++++++++++++++
 gtk/src/widget.hg               |  4 ++++
 tools/m4/convert_gtk.m4         |  8 ++++++-
 13 files changed, 182 insertions(+), 22 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 7420ebbc..3b5eef8f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -155,6 +155,8 @@ gtk/gtkmm/aspectframe.cc
 gtk/gtkmm/aspectframe.h
 gtk/gtkmm/assistant.cc
 gtk/gtkmm/assistant.h
+gtk/gtkmm/assistantpage.cc
+gtk/gtkmm/assistantpage.h
 gtk/gtkmm/bin.cc
 gtk/gtkmm/bin.h
 gtk/gtkmm/border.cc
@@ -447,6 +449,8 @@ gtk/gtkmm/spinner.cc
 gtk/gtkmm/spinner.h
 gtk/gtkmm/stack.cc
 gtk/gtkmm/stack.h
+gtk/gtkmm/stackpage.cc
+gtk/gtkmm/stackpage.h
 gtk/gtkmm/stacksidebar.cc
 gtk/gtkmm/stacksidebar.h
 gtk/gtkmm/stackswitcher.cc
diff --git a/demos/gtk-demo/example_stack.cc b/demos/gtk-demo/example_stack.cc
index 953e43ce..2242fbfa 100644
--- a/demos/gtk-demo/example_stack.cc
+++ b/demos/gtk-demo/example_stack.cc
@@ -54,7 +54,7 @@ Example_Stack::Example_Stack()
   m_check_button.set_halign(Gtk::Align::CENTER);
 
   // Page 3
-  m_stack.child_property_icon_name(m_spinner) = "face-laugh-symbolic";
+  m_stack.get_page(m_spinner)->property_icon_name() = "face-laugh-symbolic";
   m_spinner.property_active() = true;
 
   // Stack transition
diff --git a/gtk/src/assistant.ccg b/gtk/src/assistant.ccg
index bd60ab2e..54315814 100644
--- a/gtk/src/assistant.ccg
+++ b/gtk/src/assistant.ccg
@@ -18,8 +18,6 @@
 
 #include <gtk/gtk.h>
 
-using PageType = Gtk::Assistant::PageType;
-
 static gint SignalProxy_SlotForwardPage_gtk_callback(gint current_page, gpointer data)
 {
   auto the_slot = static_cast<Gtk::Assistant::SlotForwardPage*>(data);
diff --git a/gtk/src/assistant.hg b/gtk/src/assistant.hg
index 98667eea..d5472b29 100644
--- a/gtk/src/assistant.hg
+++ b/gtk/src/assistant.hg
@@ -17,6 +17,7 @@
  */
 
 #include <gtkmm/window.h>
+#include <gtkmm/assistantpage.h>
 #include <gdkmm/pixbuf.h>
 
 _DEFS(gtkmm,gtk)
@@ -31,6 +32,10 @@ namespace Gtk
  * operation split into several steps, guiding the user through its
  * pages and controlling the page flow to collect the necessary data.
  *
+ * %Gtk::Assistant maintains a Gtk::AssistantPage object for each added
+ * child, which holds additional per-child properties. You
+ * obtain the Gtk::AssistantPage for a child with get_page().
+ *
  * @newin{2,10}
  * @ingroup Dialogs
  */
@@ -39,8 +44,6 @@ class Assistant : public Window
   _CLASS_GTKOBJECT(Assistant, GtkAssistant, GTK_ASSISTANT, Gtk::Window, GtkWindow)
   _UNMANAGEABLE
 public:
-  _WRAP_ENUM(PageType, GtkAssistantPageType)
-
   _CTOR_DEFAULT()
 
   /** Constructor.
@@ -70,8 +73,8 @@ public:
   void set_forward_page_func(const SlotForwardPage& slot);
   _IGNORE(gtk_assistant_set_forward_page_func)
 
-  _WRAP_METHOD(void set_page_type(const Widget& page, PageType type), gtk_assistant_set_page_type)
-  _WRAP_METHOD(PageType  get_page_type(const Widget& page) const, gtk_assistant_get_page_type)
+  _WRAP_METHOD(void set_page_type(const Widget& page, AssistantPage::Type type), gtk_assistant_set_page_type)
+  _WRAP_METHOD(AssistantPage::Type  get_page_type(const Widget& page) const, gtk_assistant_get_page_type)
   _WRAP_METHOD(void set_page_title(const Widget& page, const Glib::ustring& title), 
gtk_assistant_set_page_title)
   _WRAP_METHOD(Glib::ustring get_page_title(const Widget& page) const, gtk_assistant_get_page_title)
 
@@ -85,6 +88,9 @@ public:
   _WRAP_METHOD(void set_page_has_padding(const Widget& page, bool has_padding = true), 
gtk_assistant_set_page_has_padding)
   _WRAP_METHOD(bool get_page_has_padding(const Widget& page) const, gtk_assistant_get_page_has_padding)
 
+  _WRAP_METHOD(Glib::RefPtr<AssistantPage> get_page(Widget& child), gtk_assistant_get_page, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const AssistantPage> get_page(const Widget& child) const, 
gtk_assistant_get_page, refreturn, constversion)
+
   _WRAP_SIGNAL(void prepare(Gtk::Widget* page), "prepare")
   _WRAP_SIGNAL(void apply(), "apply")
   _WRAP_SIGNAL(void close(), "close")
@@ -94,11 +100,6 @@ public:
   _IGNORE_SIGNAL("escape")
 
   _WRAP_PROPERTY("use-header-bar", bool)
-
-  _WRAP_CHILD_PROPERTY("page-type", PageType, newin "3,90")
-  _WRAP_CHILD_PROPERTY("title", Glib::ustring, newin "3,90")
-  _WRAP_CHILD_PROPERTY("complete", bool, newin "3,90")
-  _WRAP_CHILD_PROPERTY("has-padding", bool, newin "3,90")
 };
 
 } // namespace Gtk
diff --git a/gtk/src/assistantpage.ccg b/gtk/src/assistantpage.ccg
new file mode 100644
index 00000000..24d929ab
--- /dev/null
+++ b/gtk/src/assistantpage.ccg
@@ -0,0 +1,20 @@
+/* Copyright (C) 2019 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/widget.h>
+#include <gtk/gtk.h>
+
+using Type = Gtk::AssistantPage::Type;
diff --git a/gtk/src/assistantpage.hg b/gtk/src/assistantpage.hg
new file mode 100644
index 00000000..8fe622c7
--- /dev/null
+++ b/gtk/src/assistantpage.hg
@@ -0,0 +1,53 @@
+/* Copyright (C) 2019 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 <glibmm/object.h>
+#include <glibmm/refptr.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gtk
+{
+class Widget;
+
+/** Holds properties of a Gtk::Assistant page.
+ *
+ * Use Gtk::Assistant::get_page() to get a pointer to an %AssistantPage object.
+ *
+ * @see Assistant
+ * @newin{3,96}
+ */
+class AssistantPage : public Glib::Object
+{
+  _CLASS_GOBJECT(AssistantPage, GtkAssistantPage, GTK_ASSISTANT_PAGE, Glib::Object, GObject)
+
+public:
+  _WRAP_ENUM(Type, GtkAssistantPageType)
+
+  _WRAP_METHOD(Widget* get_child(), gtk_assistant_page_get_child)
+  _WRAP_METHOD(const Widget* get_child() const, gtk_assistant_page_get_child, constversion)
+
+  _WRAP_PROPERTY("page-type", Type)
+  _WRAP_PROPERTY("title", Glib::ustring)
+  _WRAP_PROPERTY("complete", bool)
+  _WRAP_PROPERTY("has-padding", bool)
+  _WRAP_PROPERTY("child", Widget*)
+
+  // There are no signals or vfuncs.
+};
+
+} // namespace Gtk
diff --git a/gtk/src/enums.hg b/gtk/src/enums.hg
index dbe1853f..09b8a262 100644
--- a/gtk/src/enums.hg
+++ b/gtk/src/enums.hg
@@ -38,6 +38,7 @@ _WRAP_ENUM(MenuDirectionType, GtkMenuDirectionType)
 _WRAP_ENUM(MessageType, GtkMessageType)
 _WRAP_ENUM(MovementStep, GtkMovementStep)
 _WRAP_ENUM(Orientation, GtkOrientation)
+_WRAP_ENUM(Overflow, GtkOverflow)
 _WRAP_ENUM(CornerType, GtkCornerType)
 _WRAP_ENUM(PackType, GtkPackType)
 _WRAP_ENUM(PlacesOpenFlags, GtkPlacesOpenFlags)
diff --git a/gtk/src/filelist.am b/gtk/src/filelist.am
index f45484d1..7a20dce2 100644
--- a/gtk/src/filelist.am
+++ b/gtk/src/filelist.am
@@ -25,6 +25,7 @@ gtkmm_files_any_hg =          \
        applicationwindow.hg    \
        aspectframe.hg          \
        assistant.hg            \
+       assistantpage.hg \
        bin.hg                  \
        border.hg               \
        box.hg                  \
@@ -167,6 +168,7 @@ gtkmm_files_any_hg =                \
        spinbutton.hg           \
        spinner.hg              \
        stack.hg                \
+       stackpage.hg \
        stacksidebar.hg         \
        stackswitcher.hg        \
        statusbar.hg            \
diff --git a/gtk/src/stack.hg b/gtk/src/stack.hg
index 31fc2f9f..40c1828c 100644
--- a/gtk/src/stack.hg
+++ b/gtk/src/stack.hg
@@ -17,6 +17,7 @@
  */
 
 #include <gtkmm/container.h>
+#include <gtkmm/stackpage.h>
 #include <gtkmm/enums.h>
 
 _DEFS(gtkmm,gtk)
@@ -28,9 +29,13 @@ _CC_INCLUDE(gtk/gtk.h)
 
 /** A container that shows only one child at a time.
  *
- * Gtk::Stack does not provide a means for users to change the visible
+ * %Gtk::Stack does not provide a means for users to change the visible
  * child. Instead, the Gtk::StackSwitcher or Gtk::StackSidebar widget can be used with
- * Gtk::Stack to provide this functionality.
+ * %Gtk::Stack to provide this functionality.
+ *
+ * %Gtk::Stack maintains a Gtk::StackPage object for each added
+ * child, which holds additional per-child properties. You
+ * obtain the Gtk::StackPage for a child with get_page().
  *
  * @ingroup Widgets
  * @ingroup Containers
@@ -46,8 +51,10 @@ public:
   _WRAP_METHOD(void add(Widget& child, const Glib::ustring& name), gtk_stack_add_named)
   _WRAP_METHOD(void add(Widget& child, const Glib::ustring& name, const Glib::ustring& title), 
gtk_stack_add_titled)
 
-  _WRAP_METHOD(void set_visible_child(Widget& child), gtk_stack_set_visible_child)
+  _WRAP_METHOD(Glib::RefPtr<StackPage> get_page(Widget& child), gtk_stack_get_page, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const StackPage> get_page(const Widget& child) const, gtk_stack_get_page, 
refreturn, constversion)
 
+  _WRAP_METHOD(void set_visible_child(Widget& child), gtk_stack_set_visible_child)
   _WRAP_METHOD(Widget* get_visible_child(), gtk_stack_get_visible_child)
   _WRAP_METHOD(const Widget* get_visible_child() const, gtk_stack_get_visible_child, constversion)
 
@@ -88,12 +95,6 @@ public:
   _WRAP_PROPERTY("visible-child-name", Glib::ustring)
   _WRAP_PROPERTY("interpolate-size", bool, newin "3,20")
 
-  _WRAP_CHILD_PROPERTY("name", Glib::ustring)
-  _WRAP_CHILD_PROPERTY("title", Glib::ustring)
-  _WRAP_CHILD_PROPERTY("icon-name", Glib::ustring)
-  _WRAP_CHILD_PROPERTY("position", int)
-  _WRAP_CHILD_PROPERTY("needs-attention", bool)
-
   // There are no signals or vfuncs.
 };
 
diff --git a/gtk/src/stackpage.ccg b/gtk/src/stackpage.ccg
new file mode 100644
index 00000000..2b01d5aa
--- /dev/null
+++ b/gtk/src/stackpage.ccg
@@ -0,0 +1,18 @@
+/* Copyright (C) 2019 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/widget.h>
+#include <gtk/gtk.h>
diff --git a/gtk/src/stackpage.hg b/gtk/src/stackpage.hg
new file mode 100644
index 00000000..7258d2cf
--- /dev/null
+++ b/gtk/src/stackpage.hg
@@ -0,0 +1,52 @@
+/* Copyright (C) 2019 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 <glibmm/object.h>
+#include <glibmm/refptr.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(glibmm/private/object_p.h)
+
+namespace Gtk
+{
+class Widget;
+
+/** Holds properties of a Gtk::Stack page.
+ *
+ * Use Gtk::Stack::get_page() to get a pointer to an %StackPage object.
+ *
+ * @see Stack
+ * @newin{3,96}
+ */
+class StackPage : public Glib::Object
+{
+  _CLASS_GOBJECT(StackPage, GtkStackPage, GTK_STACK_PAGE, Glib::Object, GObject)
+
+public:
+  _WRAP_METHOD(Widget* get_child(), gtk_stack_page_get_child)
+  _WRAP_METHOD(const Widget* get_child() const, gtk_stack_page_get_child, constversion)
+
+  _WRAP_PROPERTY("child", Widget*)
+  _WRAP_PROPERTY("name", Glib::ustring)
+  _WRAP_PROPERTY("title", Glib::ustring)
+  _WRAP_PROPERTY("icon-name", Glib::ustring)
+  _WRAP_PROPERTY("needs-attention", bool)
+  _WRAP_PROPERTY("visible", bool)
+
+  // There are no signals or vfuncs.
+};
+
+} // namespace Gtk
diff --git a/gtk/src/widget.hg b/gtk/src/widget.hg
index 4d408daf..d73cc556 100644
--- a/gtk/src/widget.hg
+++ b/gtk/src/widget.hg
@@ -273,6 +273,9 @@ public:
   _WRAP_METHOD(void set_opacity(double opacity), gtk_widget_set_opacity)
   _WRAP_METHOD(double get_opacity() const, gtk_widget_get_opacity)
 
+  _WRAP_METHOD(void set_overflow(Overflow overflow), gtk_widget_set_overflow, newin "3,96")
+  _WRAP_METHOD(Overflow get_overflow() const, gtk_widget_get_overflow, newin "3,96")
+
   _WRAP_METHOD(Container* get_toplevel(), gtk_widget_get_toplevel)
   _WRAP_METHOD(const Container* get_toplevel() const, gtk_widget_get_toplevel, constversion)
 
@@ -750,6 +753,7 @@ dnl
   _WRAP_PROPERTY("vexpand-set", bool)
   _WRAP_PROPERTY("expand", bool)
   _WRAP_PROPERTY("opacity", double)
+  _WRAP_PROPERTY("overflow", Overflow, newin "3,96")
   _WRAP_PROPERTY("scale-factor", int)
   _WRAP_PROPERTY("css-name", Glib::ustring)
 
diff --git a/tools/m4/convert_gtk.m4 b/tools/m4/convert_gtk.m4
index b1f55e23..c5c2d2ee 100644
--- a/tools/m4/convert_gtk.m4
+++ b/tools/m4/convert_gtk.m4
@@ -32,6 +32,7 @@ _CONVERSION(`guint',`ui_merge_id',`$3')
 _CONV_ENUM(Gtk,AccelFlags)
 _CONV_ENUM(Gtk,Align)
 _CONV_ENUM(Gtk,ArrowType)
+_CONV_INCLASS_ENUM(Gtk,AssistantPage,Type)
 _CONV_ENUM(Gtk,ButtonRole)
 _CONV_ENUM(Gtk,ButtonsType)
 _CONV_INCLASS_ENUM(Gtk,Calendar,DisplayOptions)
@@ -56,6 +57,7 @@ _CONV_ENUM(Gtk,MessageType)
 _CONV_ENUM(Gtk,MovementStep)
 _CONV_ENUM(Gtk,NotebookTab)
 _CONV_ENUM(Gtk,Orientation)
+_CONV_ENUM(Gtk,Overflow)
 _CONV_ENUM(Gtk,PackType)
 _CONV_ENUM(Gtk,PackDirection)
 _CONV_ENUM(Gtk,PanDirection)
@@ -99,7 +101,6 @@ _CONV_INCLASS_ENUM(Gtk,FileFilter,Flags)
 _CONV_ENUM(Gtk,IconLookupFlags)
 _CONV_ENUM(Gtk,IconThemeError)
 _CONV_ENUM(Gtk,SensitivityType)
-_CONV_INCLASS_ENUM(Gtk,Assistant,PageType)
 _CONV_INCLASS_ENUM(Gtk,IconView,DropPosition)
 _CONV_INCLASS_ENUM(Gtk,RecentFilter,Flags)
 _CONV_ENUM(Gtk,RecentManagerError)
@@ -160,6 +161,8 @@ _CONVERSION(`GtkPopover*',`Popover*',__RP2P)
 _CONVERSION(`GtkToolItem*',`ToolItem*',__RP2P)
 _CONVERSION(`GtkToolItemGroup*',`ToolItemGroup*',__RP2P)
 _CONVERSION(`GtkStack*',`Stack*',__RP2P)
+_CONVERSION(`GtkStackPage*',`Glib::RefPtr<StackPage>',`Glib::wrap($3)')
+_CONVERSION(`GtkStackPage*',`Glib::RefPtr<const StackPage>',`Glib::wrap($3)')
 
 # Ptr (gtk+) -> const Ptr (gtkmm)
 _CONVERSION(`GtkWidget*',`const Gtk::Widget*',__RP2P)
@@ -182,6 +185,9 @@ _CONVERSION(`GtkAccelGroup*',`Glib::RefPtr<const AccelGroup>',`Glib::wrap($3)')
 _CONVERSION(`const Glib::RefPtr<AccelGroup>&',`GtkAccelGroup*',__CONVERT_REFPTR_TO_P)
 _CONVERSION(`Gtk::Object&',`GObject*', `($3).Glib::Object::gobj()')
 
+_CONVERSION(`GtkAssistantPage*',`Glib::RefPtr<AssistantPage>',`Glib::wrap($3)')
+_CONVERSION(`GtkAssistantPage*',`Glib::RefPtr<const AssistantPage>',`Glib::wrap($3)')
+
 _CONVERSION(`GtkCellArea*',`Glib::RefPtr<CellArea>',`Glib::wrap($3)')
 _CONVERSION(`GtkCellArea*',`Glib::RefPtr<const CellArea>',`Glib::wrap($3)')
 _CONVERSION(`const Glib::RefPtr<CellArea>&',`GtkCellArea*',__CONVERT_REFPTR_TO_P)


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