[gtkmm] Gdk, Gtk: Update for the latest gtk4 (Add Gtk::CenterLayout, etc.)



commit 092daea80e262946f74b16140b96c72f54f9c26b
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Sun Sep 15 15:29:00 2019 +0200

    Gdk, Gtk: Update for the latest gtk4 (Add Gtk::CenterLayout, etc.)

 .gitignore                            |  2 +
 demos/gtk-demo/example_iconbrowser.cc | 17 +++++----
 gdk/src/pixbuf.hg                     |  4 +-
 gtk/gtkmm.h                           |  1 +
 gtk/src/buildable.ccg                 |  2 +-
 gtk/src/buildable.hg                  |  5 ++-
 gtk/src/centerlayout.ccg              | 18 +++++++++
 gtk/src/centerlayout.hg               | 69 +++++++++++++++++++++++++++++++++++
 gtk/src/filelist.am                   |  1 +
 gtk/src/headerbar.hg                  |  1 -
 gtk/src/iconinfo.ccg                  |  1 -
 gtk/src/iconinfo.hg                   | 19 ++++------
 gtk/src/icontheme.hg                  |  6 +--
 gtk/src/label.hg                      |  8 ++--
 gtk/src/menubutton.ccg                | 38 +++++++++++++++++++
 gtk/src/menubutton.hg                 | 32 ++++++++++++++++
 gtk/src/modelbutton.hg                |  2 +
 gtk/src/popovermenu.ccg               | 13 ++++---
 gtk/src/popovermenu.hg                | 20 ++++++++--
 tools/m4/convert_gdk.m4               |  1 +
 tools/m4/convert_gtk.m4               |  1 +
 21 files changed, 220 insertions(+), 41 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 4d0551a8..93b6f689 100644
--- a/.gitignore
+++ b/.gitignore
@@ -208,6 +208,8 @@ gtk/gtkmm/cellview.cc
 gtk/gtkmm/cellview.h
 gtk/gtkmm/centerbox.cc
 gtk/gtkmm/centerbox.h
+gtk/gtkmm/centerlayout.cc
+gtk/gtkmm/centerlayout.h
 gtk/gtkmm/checkbutton.cc
 gtk/gtkmm/checkbutton.h
 gtk/gtkmm/checkmenuitem.cc
diff --git a/demos/gtk-demo/example_iconbrowser.cc b/demos/gtk-demo/example_iconbrowser.cc
index 6f05bb6a..13fb92b0 100644
--- a/demos/gtk-demo/example_iconbrowser.cc
+++ b/demos/gtk-demo/example_iconbrowser.cc
@@ -95,7 +95,7 @@ protected:
   void on_image_drag_data_get(const Glib::RefPtr<Gdk::Drag>& drag,
     Gtk::SelectionData& selection_data, int size_index);
 
-  Glib::RefPtr<const Gdk::Pixbuf> get_icon(int size_index);
+  Glib::RefPtr<const Gdk::Texture> get_icon(int size_index);
 
   static const int n_icon_sizes = 5;
   static const int m_icon_size[n_icon_sizes];
@@ -921,7 +921,7 @@ DetailDialog::DetailDialog(Gtk::Window& parent)
     m_label[i].set_text(ostr.str());
   }
   m_grid.attach(m_description, 0, 2, n_icon_sizes, 1);
-  m_description.set_line_wrap(true);
+  m_description.set_wrap(true);
   m_description.set_max_width_chars(60);
   m_description.set_halign(Gtk::Align::START);
   m_description.set_valign(Gtk::Align::START);
@@ -954,25 +954,28 @@ void DetailDialog::set_image(
 void DetailDialog::on_image_drag_data_get(const Glib::RefPtr<Gdk::Drag>& /* drag */,
   Gtk::SelectionData& selection_data, int size_index)
 {
-  selection_data.set_pixbuf(get_icon(size_index));
+  selection_data.set_texture(get_icon(size_index));
 }
 
-Glib::RefPtr<const Gdk::Pixbuf> DetailDialog::get_icon(int size_index)
+Glib::RefPtr<const Gdk::Texture> DetailDialog::get_icon(int size_index)
 {
   auto context = m_image[size_index].get_style_context();
   auto info = Gtk::IconTheme::get_default()->lookup_icon(
     m_icon_name, m_icon_size[size_index]);
-  Glib::RefPtr<const Gdk::Pixbuf> pixbuf;
+  Glib::RefPtr<const Gdk::Texture> texture;
   try
   {
+    // Gtk::IconInfo::load_symbolic_for_context() returns a Glib::RefPtr<const Gdk::Paintable>
+    // which is actually a Glib::RefPtr<const Gdk::Texture>
     bool is_symbolic = false;
-    pixbuf = info->load_symbolic_for_context(context, is_symbolic);
+    texture = std::dynamic_pointer_cast<const Gdk::Texture>(
+      info->load_symbolic_for_context(context, is_symbolic));
   }
   catch (const Glib::Error& err)
   {
     std::cout << "Error in DetailDialog::get_icon(): " << err.what() << std::endl;
   }
-  return pixbuf;
+  return texture;
 }
 
 IconInfoStore::IconInfoStore()
diff --git a/gdk/src/pixbuf.hg b/gdk/src/pixbuf.hg
index 8afbaa7f..2fb2692e 100644
--- a/gdk/src/pixbuf.hg
+++ b/gdk/src/pixbuf.hg
@@ -78,8 +78,8 @@ protected:
    */
   Pixbuf(const ::Cairo::RefPtr< ::Cairo::Surface>& src,
          int src_x, int src_y, int width, int height);
-   _IGNORE(gdk_pixbuf_get_from_surface)
-
+  _IGNORE(gdk_pixbuf_get_from_surface)
+  _IGNORE(gdk_pixbuf_get_from_texture)dnl// should not be used in newly written code
 
 public:
   // Used only internally in gdk-pixbuf: _WRAP_ENUM(AlphaMode, GdkPixbufAlphaMode)
diff --git a/gtk/gtkmm.h b/gtk/gtkmm.h
index ae4d700f..7ee1548f 100644
--- a/gtk/gtkmm.h
+++ b/gtk/gtkmm.h
@@ -127,6 +127,7 @@ extern const int gtkmm_micro_version;
 #include <gtkmm/cellrenderertext.h>
 #include <gtkmm/cellrenderertoggle.h>
 #include <gtkmm/centerbox.h>
+#include <gtkmm/centerlayout.h>
 #include <gtkmm/colorbutton.h>
 #include <gtkmm/colorchooser.h>
 #include <gtkmm/colorchooserdialog.h>
diff --git a/gtk/src/buildable.ccg b/gtk/src/buildable.ccg
index 984025a8..2eaf52a3 100644
--- a/gtk/src/buildable.ccg
+++ b/gtk/src/buildable.ccg
@@ -28,7 +28,7 @@ gboolean Buildable_Class::custom_tag_start_vfunc_callback(
   GtkBuilder* builder,
   GObject* child,
   const gchar* tagname,
-  GMarkupParser* parser,
+  GtkBuildableParser* parser,
   gpointer* data)
 {
   // If it's a TreeModel (such as ListStore or TreeStore) and it's the start
diff --git a/gtk/src/buildable.hg b/gtk/src/buildable.hg
index c989f6df..ba6ce5c4 100644
--- a/gtk/src/buildable.hg
+++ b/gtk/src/buildable.hg
@@ -63,7 +63,7 @@ public:
                                                GtkBuilder          *builder,
                                                GObject             *child,
                                                const Glib::ustring& tagname,
-                                               GMarkupParser       *parser,
+                                               GtkBuildableParser  *parser,
                                                gpointer            *data);
   _WRAP_METHOD(void      gtk_buildable_custom_tag_end         (
                                                GtkBuilder          *builder,
@@ -90,6 +90,7 @@ dnl
   _PUSH(SECTION_CC_PRE_INCLUDES)
     // Needed before gtkmm/private/buildable_p.h is included.
     typedef struct _GtkBuilder GtkBuilder;
+    typedef struct _GtkBuildableParser GtkBuildableParser;
   _SECTION(SECTION_PCC_CLASS_INIT_VFUNCS)
     klass->custom_tag_start = &custom_tag_start_vfunc_callback;
     klass->custom_tag_end = &custom_tag_end_vfunc_callback;
@@ -99,7 +100,7 @@ dnl
       GtkBuilder* builder,
       GObject* child,
       const gchar* tagname,
-      GMarkupParser* parser,
+      GtkBuildableParser* parser,
       gpointer* data);
     static void custom_tag_end_vfunc_callback(
       GtkBuildable* buildable,
diff --git a/gtk/src/centerlayout.ccg b/gtk/src/centerlayout.ccg
new file mode 100644
index 00000000..90a31c64
--- /dev/null
+++ b/gtk/src/centerlayout.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 <gtk/gtk.h>
+#include <gtkmm/widget.h>
diff --git a/gtk/src/centerlayout.hg b/gtk/src/centerlayout.hg
new file mode 100644
index 00000000..7f8e7956
--- /dev/null
+++ b/gtk/src/centerlayout.hg
@@ -0,0 +1,69 @@
+/* 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/layoutmanager.h>
+#include <gtkmm/enums.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(gtkmm/private/layoutmanager_p.h)
+
+namespace Gtk
+{
+class Widget;
+
+/** A centering layout.
+ *
+ * A %Gtk::CenterLayout is a layout manager that manages up to three children.
+ * The start widget is allocated at the start of the layout (left in LRT
+ * layouts and right in RTL ones), and the end widget at the end.
+ *
+ * The center widget is centered regarding the full width of the layout.
+ *
+ * @newin{3,96}
+ */
+class CenterLayout : public LayoutManager
+{
+  _CLASS_GOBJECT(CenterLayout, GtkCenterLayout, GTK_CENTER_LAYOUT, LayoutManager, GtkLayoutManager)
+  _STRUCT_NOT_HIDDEN
+
+protected:
+  _CTOR_DEFAULT
+
+public:
+  _WRAP_CREATE()
+
+  _WRAP_METHOD(void set_orientation(Orientation orientation), gtk_center_layout_set_orientation)
+  _WRAP_METHOD(Orientation get_orientation() const, gtk_center_layout_get_orientation)
+
+  _WRAP_METHOD(void set_baseline_position(BaselinePosition baseline_position), 
gtk_center_layout_set_baseline_position)
+  _WRAP_METHOD(BaselinePosition get_baseline_position() const, gtk_center_layout_get_baseline_position)
+
+  _WRAP_METHOD(void set_start_widget(Widget* widget), gtk_center_layout_set_start_widget)
+  _WRAP_METHOD(Widget* get_start_widget(), gtk_center_layout_get_start_widget)
+  _WRAP_METHOD(const Widget* get_start_widget() const, gtk_center_layout_get_start_widget, constversion)
+
+  _WRAP_METHOD(void set_center_widget(Widget* widget), gtk_center_layout_set_center_widget)
+  _WRAP_METHOD(Widget* get_center_widget(), gtk_center_layout_get_center_widget)
+  _WRAP_METHOD(const Widget* get_center_widget() const, gtk_center_layout_get_center_widget, constversion)
+
+  _WRAP_METHOD(void set_end_widget(Widget* widget), gtk_center_layout_set_end_widget)
+  _WRAP_METHOD(Widget* get_end_widget(), gtk_center_layout_get_end_widget)
+  _WRAP_METHOD(const Widget* get_end_widget() const, gtk_center_layout_get_end_widget, constversion)
+
+  // There are no signals, properties or vfuncs.
+};
+
+} // namespace Gtk
diff --git a/gtk/src/filelist.am b/gtk/src/filelist.am
index 56013cca..d24ecf5c 100644
--- a/gtk/src/filelist.am
+++ b/gtk/src/filelist.am
@@ -51,6 +51,7 @@ gtkmm_files_any_hg =          \
        cellrenderertoggle.hg   \
        cellview.hg             \
        centerbox.hg            \
+       centerlayout.hg \
        checkbutton.hg          \
        checkmenuitem.hg        \
        colorbutton.hg          \
diff --git a/gtk/src/headerbar.hg b/gtk/src/headerbar.hg
index 41314ebc..3d5e8cdf 100644
--- a/gtk/src/headerbar.hg
+++ b/gtk/src/headerbar.hg
@@ -75,7 +75,6 @@ public:
 
   _WRAP_PROPERTY("custom-title", Gtk::Widget*)
   _WRAP_PROPERTY("show-title-buttons", bool)
-  _WRAP_PROPERTY("spacing", int)
   _WRAP_PROPERTY("subtitle", Glib::ustring)
   _WRAP_PROPERTY("title", Glib::ustring)
   _WRAP_PROPERTY("decoration-layout", Glib::ustring)
diff --git a/gtk/src/iconinfo.ccg b/gtk/src/iconinfo.ccg
index ee83e8fc..15b2f555 100644
--- a/gtk/src/iconinfo.ccg
+++ b/gtk/src/iconinfo.ccg
@@ -19,7 +19,6 @@
 #include <giomm/slot_async.h>
 
 #include <gtk/gtk.h>
-#include <gdkmm/texture.h>
 #include <gtkmm/icontheme.h>
 
 namespace Gtk
diff --git a/gtk/src/iconinfo.hg b/gtk/src/iconinfo.hg
index f45dc11a..f24999b1 100644
--- a/gtk/src/iconinfo.hg
+++ b/gtk/src/iconinfo.hg
@@ -19,6 +19,7 @@
 
 #include <gtkmm/stylecontext.h>
 #include <gdkmm/rectangle.h>
+#include <gdkmm/paintable.h>
 #include <gdkmm/pixbuf.h>
 #include <gdkmm/rgba.h>
 #include <gdkmm/types.h>
@@ -28,11 +29,6 @@
 _DEFS(gtkmm,gtk)
 _PINCLUDE(glibmm/private/object_p.h)
 
-namespace Gdk
-{
-class Texture;
-}
-
 namespace Gtk
 {
 
@@ -65,16 +61,15 @@ public:
   _WRAP_METHOD(Glib::ustring get_filename() const, gtk_icon_info_get_filename)
   _WRAP_METHOD(bool is_symbolic() const, gtk_icon_info_is_symbolic)
 
-  _WRAP_METHOD(Glib::RefPtr<const Gdk::Pixbuf> load_icon() const, gtk_icon_info_load_icon, errthrow)
-  _WRAP_METHOD(Glib::RefPtr<const Gdk::Texture> load_texture() const, gtk_icon_info_load_texture)
+  _WRAP_METHOD(Glib::RefPtr<const Gdk::Paintable> load_icon() const, gtk_icon_info_load_icon, errthrow)
 
   _WRAP_METHOD(void load_icon_async(const Gio::SlotAsyncReady& slot{callback}, const 
Glib::RefPtr<Gio::Cancellable>& cancellable{.?}) const,
     gtk_icon_info_load_icon_async, slot_name slot, slot_callback Gio::SignalProxy_async_callback)
-  _WRAP_METHOD(Glib::RefPtr<const Gdk::Pixbuf> load_icon_finish(const Glib::RefPtr<Gio::AsyncResult>& 
result) const,
+  _WRAP_METHOD(Glib::RefPtr<const Gdk::Paintable> load_icon_finish(const Glib::RefPtr<Gio::AsyncResult>& 
result) const,
     gtk_icon_info_load_icon_finish, errthrow)
 
 
-  _WRAP_METHOD(Glib::RefPtr<const Gdk::Pixbuf> load_symbolic(const Gdk::RGBA& fg, const Gdk::RGBA& 
success_color,
+  _WRAP_METHOD(Glib::RefPtr<const Gdk::Paintable> load_symbolic(const Gdk::RGBA& fg, const Gdk::RGBA& 
success_color,
     const Gdk::RGBA& warning_color, const Gdk::RGBA& error_color, bool& was_symbolic{>>}) const,
     gtk_icon_info_load_symbolic, errthrow)
 
@@ -83,17 +78,17 @@ public:
     const Gdk::RGBA& warning_color, const Gdk::RGBA& error_color, const Gio::SlotAsyncReady& slot{callback},
     const Glib::RefPtr<Gio::Cancellable>& cancellable{.?}) const,
     gtk_icon_info_load_symbolic_async, slot_name slot, slot_callback Gio::SignalProxy_async_callback)
-  _WRAP_METHOD(Glib::RefPtr<const Gdk::Pixbuf> load_symbolic_finish(const Glib::RefPtr<Gio::AsyncResult>& 
result,
+  _WRAP_METHOD(Glib::RefPtr<const Gdk::Paintable> load_symbolic_finish(const Glib::RefPtr<Gio::AsyncResult>& 
result,
     bool& was_symbolic{>>}) const, gtk_icon_info_load_symbolic_finish, errthrow)
 
 
-  _WRAP_METHOD(Glib::RefPtr<const Gdk::Pixbuf> load_symbolic_for_context(const Glib::RefPtr<StyleContext>& 
context,
+  _WRAP_METHOD(Glib::RefPtr<const Gdk::Paintable> load_symbolic_for_context(const 
Glib::RefPtr<StyleContext>& context,
     bool& was_symbolic{>>}) const, gtk_icon_info_load_symbolic_for_context, errthrow)
 
   _WRAP_METHOD(void load_symbolic_for_context_async(const Glib::RefPtr<StyleContext>& context,
     const Gio::SlotAsyncReady& slot{callback}, const Glib::RefPtr<Gio::Cancellable>& cancellable{.?}) const,
     gtk_icon_info_load_symbolic_for_context_async, slot_name slot, slot_callback 
Gio::SignalProxy_async_callback)
- _WRAP_METHOD(Glib::RefPtr<const Gdk::Pixbuf> load_symbolic_for_context_finish(const 
Glib::RefPtr<Gio::AsyncResult>& result,
+ _WRAP_METHOD(Glib::RefPtr<const Gdk::Paintable> load_symbolic_for_context_finish(const 
Glib::RefPtr<Gio::AsyncResult>& result,
    bool& was_symbolic{>>}) const, gtk_icon_info_load_symbolic_for_context_finish, errthrow)
 };
 
diff --git a/gtk/src/icontheme.hg b/gtk/src/icontheme.hg
index fce33fec..81b6a602 100644
--- a/gtk/src/icontheme.hg
+++ b/gtk/src/icontheme.hg
@@ -17,7 +17,7 @@
 
 #include <vector>
 
-#include <gdkmm/pixbuf.h>
+#include <gdkmm/paintable.h>
 #include <gdkmm/display.h>
 
 #include <gtkmm/iconinfo.h>
@@ -101,9 +101,9 @@ public:
   _WRAP_METHOD(Glib::RefPtr<IconInfo> choose_icon(const std::vector<Glib::ustring>& icon_names, int size, 
int scale, IconLookupFlags flags = (IconLookupFlags)0), gtk_icon_theme_choose_icon_for_scale)
   _WRAP_METHOD(Glib::RefPtr<const IconInfo> choose_icon(const std::vector<Glib::ustring>& icon_names, int 
size, int scale, IconLookupFlags flags = (IconLookupFlags)0) const, gtk_icon_theme_choose_icon_for_scale, 
constversion)
 
-  _WRAP_METHOD(Glib::RefPtr<const Gdk::Pixbuf> load_icon(const Glib::ustring& icon_name, int size,
+  _WRAP_METHOD(Glib::RefPtr<const Gdk::Paintable> load_icon(const Glib::ustring& icon_name, int size,
     IconLookupFlags flags = (IconLookupFlags)0) const, gtk_icon_theme_load_icon, errthrow)
-  _WRAP_METHOD(Glib::RefPtr<const Gdk::Pixbuf> load_icon(const Glib::ustring& icon_name, int size,
+  _WRAP_METHOD(Glib::RefPtr<const Gdk::Paintable> load_icon(const Glib::ustring& icon_name, int size,
     int scale, IconLookupFlags flags = (IconLookupFlags)0) const, gtk_icon_theme_load_icon_for_scale, 
errthrow)
 
 #m4 _CONVERSION(`GList*',`std::vector<Glib::ustring>',`Glib::ListHandler<Glib::ustring>::list_to_vector($3, 
Glib::OWNERSHIP_DEEP)')
diff --git a/gtk/src/label.hg b/gtk/src/label.hg
index dfb2ebfd..eaf0510c 100644
--- a/gtk/src/label.hg
+++ b/gtk/src/label.hg
@@ -97,10 +97,10 @@ public:
   _WRAP_METHOD(int get_lines() const, gtk_label_get_lines)
 
   _WRAP_METHOD(void set_pattern(const Glib::ustring& pattern), gtk_label_set_pattern)
-  _WRAP_METHOD(void set_line_wrap(bool wrap = true), gtk_label_set_line_wrap)
-  _WRAP_METHOD(bool get_line_wrap() const, gtk_label_get_line_wrap)
-  _WRAP_METHOD(void set_line_wrap_mode(Pango::WrapMode wrap_mode), gtk_label_set_line_wrap_mode)
-  _WRAP_METHOD(Pango::WrapMode get_line_wrap_mode() const, gtk_label_get_line_wrap_mode)
+  _WRAP_METHOD(void set_wrap(bool wrap = true), gtk_label_set_wrap)
+  _WRAP_METHOD(bool get_wrap() const, gtk_label_get_wrap)
+  _WRAP_METHOD(void set_wrap_mode(Pango::WrapMode wrap_mode), gtk_label_set_wrap_mode)
+  _WRAP_METHOD(Pango::WrapMode get_wrap_mode() const, gtk_label_get_wrap_mode)
   _WRAP_METHOD(void set_selectable(bool setting = true), gtk_label_set_selectable)
   _WRAP_METHOD(bool get_selectable() const, gtk_label_get_selectable)
   _WRAP_METHOD(void select_region(int start_offset, int end_offset), gtk_label_select_region)
diff --git a/gtk/src/menubutton.ccg b/gtk/src/menubutton.ccg
index cde0b927..01da7c61 100644
--- a/gtk/src/menubutton.ccg
+++ b/gtk/src/menubutton.ccg
@@ -17,6 +17,27 @@
 
 #include <gtk/gtk.h>
 
+namespace
+{
+
+void SignalProxy_MenuButton_create_popup_callback(
+  GtkMenuButton* /* menu_button */, gpointer user_data)
+{
+  auto the_slot = static_cast<Gtk::MenuButton::SlotCreatePopup*>(user_data);
+
+  try
+  {
+    (*the_slot)();
+  }
+  catch (...)
+  {
+    Glib::exception_handlers_invoke();
+  }
+  return;
+}
+
+} // anonymous namespace
+
 namespace Gtk
 {
 
@@ -35,4 +56,21 @@ void MenuButton::unset_menu_model()
   gtk_menu_button_set_menu_model(gobj(), nullptr);
 }
 
+void MenuButton::set_create_popup_func(const SlotCreatePopup& slot)
+{
+  // Create a copy of the slot object. A pointer to this will be passed
+  // through the callback's user_data parameter. It will be deleted
+  // when Glib::destroy_notify_delete<SlotCreatePopup> is called.
+  auto slot_copy = new SlotCreatePopup(slot);
+
+  gtk_menu_button_set_create_popup_func(gobj(),
+    &SignalProxy_MenuButton_create_popup_callback, slot_copy,
+    &Glib::destroy_notify_delete<SlotCreatePopup>);
+}
+
+void MenuButton::unset_create_popup_func()
+{
+  gtk_menu_button_set_create_popup_func(gobj(), nullptr, nullptr, nullptr);
+}
+
 } //namespace Gtk
diff --git a/gtk/src/menubutton.hg b/gtk/src/menubutton.hg
index aa4be68f..8641c78c 100644
--- a/gtk/src/menubutton.hg
+++ b/gtk/src/menubutton.hg
@@ -94,6 +94,38 @@ public:
   _WRAP_METHOD(void popup(), gtk_menu_button_popup)
   _WRAP_METHOD(void popdown(), gtk_menu_button_popdown)
 
+  /** Slot to create a popup for the %MenuButton on demand.
+   *
+   * This slot is called when the popoup of the %MenuButton is shown, but none has
+   * been provided via set_popup(), set_popover() or set_menu_model().
+   */
+  using SlotCreatePopup = sigc::slot<void()>;
+
+  /** Sets @a slot to be called when a popup is about to be shown.
+   *
+   *  @a slot should use one of
+   *
+   * - set_popup()
+   * - set_popover()
+   * - set_menu_model()
+   *
+   * to set a popup for the %MenuButton.
+   * The %MenuButton will always be sensitive.
+   *
+   * Using this method will NOT reset the menu widget attached to the %MenuButton.
+   * Instead, this can be done manually in @a slot.
+   *
+   * @param slot Slot to call when a popup is about to be shown, but none
+   *             has been provided via other means.
+   * @newin{3,96}
+   */
+  void set_create_popup_func(const SlotCreatePopup& slot);
+  _IGNORE(gtk_menu_button_set_create_popup_func)
+
+  /** Undoes the effect of a previous call to set_create_popup_func().
+   */
+  void unset_create_popup_func();
+
   _WRAP_PROPERTY("popup", Menu*)
   _WRAP_PROPERTY("menu-model", Glib::RefPtr<Gio::MenuModel>)
   _WRAP_PROPERTY("align-widget", Widget*)
diff --git a/gtk/src/modelbutton.hg b/gtk/src/modelbutton.hg
index d516c602..314bc49b 100644
--- a/gtk/src/modelbutton.hg
+++ b/gtk/src/modelbutton.hg
@@ -15,6 +15,7 @@
  */
 
 #include <gtkmm/button.h>
+#include <gtkmm/popover.h>
 #include <gtkmm/sizegroup.h>
 #include <giomm/icon.h>
 
@@ -70,6 +71,7 @@ public:
   _WRAP_PROPERTY("use-markup", bool, newin "3,96")
   _WRAP_PROPERTY("active", bool)
   _WRAP_PROPERTY("menu-name", Glib::ustring)
+  _WRAP_PROPERTY("popover", Popover*)
   _WRAP_PROPERTY("iconic", bool)
   _WRAP_PROPERTY("accel", Glib::ustring)
   _WRAP_PROPERTY("indicator-size-group", Glib::RefPtr<SizeGroup>)
diff --git a/gtk/src/popovermenu.ccg b/gtk/src/popovermenu.ccg
index cc85e3fc..272ef9f9 100644
--- a/gtk/src/popovermenu.ccg
+++ b/gtk/src/popovermenu.ccg
@@ -19,16 +19,19 @@
 namespace Gtk
 {
 // Delegating constructors.
-PopoverMenu::PopoverMenu(const Widget& relative_to, const Glib::RefPtr<Gio::MenuModel>& model)
+PopoverMenu::PopoverMenu(const Widget& relative_to,
+  const Glib::RefPtr<Gio::MenuModel>& model, Flags flags)
 :
-  PopoverMenu((GtkPopoverMenu*)gtk_popover_menu_new_from_model(
-    const_cast<GtkWidget*>(relative_to.gobj()), Glib::unwrap(model)))
+  PopoverMenu((GtkPopoverMenu*)gtk_popover_menu_new_from_model_full(
+    const_cast<GtkWidget*>(relative_to.gobj()), Glib::unwrap(model),
+    static_cast<GtkPopoverMenuFlags>(flags)))
 {
 }
 
-PopoverMenu::PopoverMenu(const Glib::RefPtr<Gio::MenuModel>& model)
+PopoverMenu::PopoverMenu(const Glib::RefPtr<Gio::MenuModel>& model, Flags flags)
 :
-  PopoverMenu((GtkPopoverMenu*)gtk_popover_menu_new_from_model(nullptr, Glib::unwrap(model)))
+  PopoverMenu((GtkPopoverMenu*)gtk_popover_menu_new_from_model_full(
+    nullptr, Glib::unwrap(model), static_cast<GtkPopoverMenuFlags>(flags)))
 {
 }
 
diff --git a/gtk/src/popovermenu.hg b/gtk/src/popovermenu.hg
index c9ec57be..cc38ff91 100644
--- a/gtk/src/popovermenu.hg
+++ b/gtk/src/popovermenu.hg
@@ -57,6 +57,8 @@ class PopoverMenu : public Popover
   _CLASS_GTKOBJECT(PopoverMenu, GtkPopoverMenu, GTK_POPOVER_MENU, Gtk::Popover, GtkPopover)
 
 public:
+  _WRAP_ENUM(Flags, GtkPopoverMenuFlags)
+
   /** Creates a new popover menu to point to @a relative_to.
    *
    * @param relative_to The Gtk::Widget the popover menu is related to.
@@ -77,10 +79,16 @@ public:
    * Actions can also be added using Widget::insert_action_group()
    * on the menu's attached widget or on any of its parent widgets.
    *
+   * The only flag that is supported currently is
+   * Gtk::PopoverMenu::Flags::NESTED, which makes GTK create traditional,
+   * nested submenus instead of the default sliding submenus.
+   *
    * @param relative_to Widget the popover menu is related to
    * @param model A Gio::MenuModel
+   * @param flags Flags that affect how the menu is created
    */
-  explicit PopoverMenu(const Widget& relative_to, const Glib::RefPtr<Gio::MenuModel>& model);
+  explicit PopoverMenu(const Widget& relative_to,
+    const Glib::RefPtr<Gio::MenuModel>& model, Flags flags = static_cast<Flags>(0));
 
   /** Creates a %PopoverMenu and populates it according to @a model.
    *
@@ -92,10 +100,16 @@ public:
    * Actions can also be added using Widget::insert_action_group()
    * on the menu's attached widget or on any of its parent widgets.
    *
+   * The only flag that is supported currently is
+   * Gtk::PopoverMenu::Flags::NESTED, which makes GTK create traditional,
+   * nested submenus instead of the default sliding submenus.
+   *
    * @param model A Gio::MenuModel
+   * @param flags Flags that affect how the menu is created
    */
-  explicit PopoverMenu(const Glib::RefPtr<Gio::MenuModel>& model);
-  _IGNORE(gtk_popover_menu_new_from_model)
+  explicit PopoverMenu(const Glib::RefPtr<Gio::MenuModel>& model,
+    Flags flags = static_cast<Flags>(0));
+  _IGNORE(gtk_popover_menu_new_from_model, gtk_popover_menu_new_from_model_full)
 
   _WRAP_METHOD(void add_submenu(Widget& submenu, const Glib::ustring& name), gtk_popover_menu_add_submenu)
   _WRAP_METHOD(void open_submenu(const Glib::ustring& name), gtk_popover_menu_open_submenu)
diff --git a/tools/m4/convert_gdk.m4 b/tools/m4/convert_gdk.m4
index d3b6accd..2aafa8ae 100644
--- a/tools/m4/convert_gdk.m4
+++ b/tools/m4/convert_gdk.m4
@@ -222,6 +222,7 @@ _CONVERSION(`GdkDeviceTool*',`Glib::RefPtr<Gdk::DeviceTool>', `Glib::wrap($3)')
 _CONVERSION(`GdkPaintable*',`Glib::RefPtr<Paintable>', `Glib::wrap($3)')
 _CONVERSION(`GdkPaintable*',`Glib::RefPtr<const Paintable>', `Glib::wrap($3)')
 _CONVERSION(`GdkPaintable*',`Glib::RefPtr<Gdk::Paintable>', `Glib::wrap($3)')
+_CONVERSION(`GdkPaintable*',`Glib::RefPtr<const Gdk::Paintable>', `Glib::wrap($3)')
 
 _CONVERSION(`GdkSeat*',`Glib::RefPtr<Seat>', `Glib::wrap($3)')
 _CONVERSION(`GdkSeat*',`Glib::RefPtr<Gdk::Seat>', `Glib::wrap($3)')
diff --git a/tools/m4/convert_gtk.m4 b/tools/m4/convert_gtk.m4
index 79df5b57..cb15ae2a 100644
--- a/tools/m4/convert_gtk.m4
+++ b/tools/m4/convert_gtk.m4
@@ -67,6 +67,7 @@ _CONV_ENUM(Gtk,PickFlags)
 _CONV_ENUM(Gtk,PlacesOpenFlags)
 _CONV_ENUM(Gtk,PolicyType)
 _CONV_INCLASS_ENUM(Gtk,Popover,Constraint)
+_CONV_INCLASS_ENUM(Gtk,PopoverMenu,Flags)
 _CONV_ENUM(Gtk,PositionType)
 _CONV_ENUM(Gtk,PreviewType)
 _CONV_ENUM(Gtk,ProgressBarOrientation)


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