[gtkmm] Gtk: Update for the latest gtk4 (drag-and-drop)



commit ff72a8428449e6c166f19bdb6ecef8969249fe38
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Thu Jan 16 11:13:54 2020 +0100

    Gtk: Update for the latest gtk4 (drag-and-drop)
    
    Remove old drag-and-drop API.
    Add Gtk::DragSource, DropTarget.
    
    DnD does not yet work in the icon browser demo.

 .gitignore                            |   4 +
 demos/gtk-demo/example_iconbrowser.cc |  18 +++--
 gtk/gtkmm.h                           |   3 +-
 gtk/gtkmm/dnd_ns.cc                   |  66 ----------------
 gtk/gtkmm/dnd_ns.h                    | 140 ----------------------------------
 gtk/gtkmm/filelist.am                 |   2 -
 gtk/src/dragsource.ccg                |  17 +++++
 gtk/src/dragsource.hg                 |  94 +++++++++++++++++++++++
 gtk/src/droptarget.ccg                |  26 +++++++
 gtk/src/droptarget.hg                 | 110 ++++++++++++++++++++++++++
 gtk/src/entry.hg                      |   2 +-
 gtk/src/eventcontrollermotion.hg      |   4 +-
 gtk/src/filelist.am                   |   4 +-
 gtk/src/iconview.hg                   |   8 +-
 gtk/src/selectionmodel.hg             |   2 +-
 gtk/src/textbuffer.hg                 |   4 +
 gtk/src/widget.ccg                    |  67 ----------------
 gtk/src/widget.hg                     |  81 --------------------
 tools/m4/convert_gdk.m4               |   6 +-
 tools/m4/convert_gtk.m4               |   4 +-
 20 files changed, 285 insertions(+), 377 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 292a5f25..02783759 100644
--- a/.gitignore
+++ b/.gitignore
@@ -240,8 +240,12 @@ gtk/gtkmm/csssection.cc
 gtk/gtkmm/csssection.h
 gtk/gtkmm/dialog.cc
 gtk/gtkmm/dialog.h
+gtk/gtkmm/dragsource.cc
+gtk/gtkmm/dragsource.h
 gtk/gtkmm/drawingarea.cc
 gtk/gtkmm/drawingarea.h
+gtk/gtkmm/droptarget.cc
+gtk/gtkmm/droptarget.h
 gtk/gtkmm/editable.cc
 gtk/gtkmm/editable.h
 gtk/gtkmm/entry.cc
diff --git a/demos/gtk-demo/example_iconbrowser.cc b/demos/gtk-demo/example_iconbrowser.cc
index 0da67114..dfda8216 100644
--- a/demos/gtk-demo/example_iconbrowser.cc
+++ b/demos/gtk-demo/example_iconbrowser.cc
@@ -238,9 +238,11 @@ Example_IconBrowser::Example_IconBrowser()
   m_text_cell.set_alignment(0.5, 0.5);
 
   // Enable dragging an icon name, and copying it to another program.
+  const std::vector<Glib::ustring> mime_types{"UTF8_STRING", "TEXT", "text/plain",
+    "text/plain;charset=utf-8"}; // mime types copied from gtkselection.c.
+  auto content_formats = Gdk::ContentFormats::create(mime_types);
   m_icon_view.enable_model_drag_source(
-    Gdk::ContentFormats::create(), Gdk::ModifierType::BUTTON1_MASK, Gdk::DragAction::COPY);
-  m_icon_view.drag_source_add_text_targets();
+    content_formats, Gdk::ModifierType::BUTTON1_MASK, Gdk::DragAction::COPY);
 
   m_icon_view.set_has_tooltip(true);
   m_filter_model->set_visible_func(
@@ -906,11 +908,11 @@ DetailDialog::DetailDialog(Gtk::Window& parent)
     m_image[i].set_valign(Gtk::Align::END);
 
     // Enable dragging an image, and copying it to another program.
-    m_image[i].drag_source_set(
-      Gdk::ContentFormats::create(), Gdk::ModifierType::BUTTON1_MASK, Gdk::DragAction::COPY);
-    m_image[i].drag_source_add_image_targets();
-    m_image[i].signal_drag_data_get().connect(
-      sigc::bind(sigc::mem_fun(*this, &DetailDialog::on_image_drag_data_get), i));
+    //??m_image[i].drag_source_set(
+    //??  Gdk::ContentFormats::create(), Gdk::ModifierType::BUTTON1_MASK, Gdk::DragAction::COPY);
+    //??m_image[i].drag_source_add_image_targets();
+    //??m_image[i].signal_drag_data_get().connect(
+    //??  sigc::bind(sigc::mem_fun(*this, &DetailDialog::on_image_drag_data_get), i));
 
     m_grid.attach(m_label[i], i, 1);
     m_label[i].set_margin(4);
@@ -940,7 +942,7 @@ void DetailDialog::set_image(
   {
     m_image[i].set_from_icon_name(icon_name);
     m_image[i].set_pixel_size(m_icon_size[i]);
-    m_image[i].drag_source_set_icon(icon_name);
+    //??m_image[i].drag_source_set_icon(icon_name);
   }
   if (description.empty())
     m_description.hide();
diff --git a/gtk/gtkmm.h b/gtk/gtkmm.h
index 5242910e..97ce59ca 100644
--- a/gtk/gtkmm.h
+++ b/gtk/gtkmm.h
@@ -137,8 +137,9 @@ extern const int gtkmm_micro_version;
 #include <gtkmm/cssprovider.h>
 #include <gtkmm/csssection.h>
 #include <gtkmm/dialog.h>
-#include <gtkmm/dnd_ns.h>
+#include <gtkmm/dragsource.h>
 #include <gtkmm/drawingarea.h>
+#include <gtkmm/droptarget.h>
 #include <gtkmm/editable.h>
 #include <gtkmm/entry.h>
 #include <gtkmm/expander.h>
diff --git a/gtk/gtkmm/filelist.am b/gtk/gtkmm/filelist.am
index 670c6e33..23bd02ed 100644
--- a/gtk/gtkmm/filelist.am
+++ b/gtk/gtkmm/filelist.am
@@ -7,7 +7,6 @@ gtkmm_files_extra_any_cc =              \
        accelkey.cc                     \
        accelmap.cc                     \
        cellrenderer_generation.cc      \
-       dnd_ns.cc \
        listviewtext.cc                 \
        object.cc \
        radiobuttongroup.cc             \
@@ -22,7 +21,6 @@ gtkmm_files_extra_any_h =                     \
        accelmap.h                      \
        border.h                        \
        cellrenderer_generation.h       \
-       dnd_ns.h \
        listviewtext.h                  \
        object.h \
        radiobuttongroup.h              \
diff --git a/gtk/src/dragsource.ccg b/gtk/src/dragsource.ccg
new file mode 100644
index 00000000..57b87fdc
--- /dev/null
+++ b/gtk/src/dragsource.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/dragsource.hg b/gtk/src/dragsource.hg
new file mode 100644
index 00000000..8f7a723b
--- /dev/null
+++ b/gtk/src/dragsource.hg
@@ -0,0 +1,94 @@
+/* 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 <gdkmm/contentprovider.h>
+#include <gdkmm/drag.h>
+#include <gdkmm/enums.h>
+#include <gdkmm/paintable.h>
+#include <gtkmm/gesturesingle.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(gtkmm/private/gesturesingle_p.h)
+
+namespace Gtk
+{
+/** Event controller to initiate DND operations.
+ *
+ * %Gtk::DragSource is an auxiliary object that is used to initiate
+ * Drag-And-Drop operations. It can be set up with the necessary
+ * ingredients for a DND operation ahead of time. This includes
+ * the source for the data that is being transferred, in the form
+ * of a Gdk::ContentProvider, the desired action, and the icon to
+ * use during the drag operation. After setting it up, the drag
+ * source must be added to a widget as an event controller, using
+ * Gtk::Widget::add_controller().
+ *
+ * Setting up the content provider and icon ahead of time only
+ * makes sense when the data does not change. More commonly, you
+ * will want to set them up just in time. To do so, %Gtk::DragSource
+ * has signal_prepare() and signal_drag_begin().
+ * The prepare signal is emitted before a drag is started, and
+ * can be used to set the content provider and actions that the
+ * drag should be started with. The drag-begin signal is emitted
+ * after the Gdk::Drag object has been created, and can be used
+ * to set up the drag icon.
+ *
+ * During the DND operation, %Gtk::DragSource emits signals that
+ * can be used to obtain updates about the status of the operation,
+ * but it is not normally necessary to connect to any signals,
+ * except for one case: when the supported actions include
+ * Gdk::DragAction::MOVE, you need to listen for signal_drag_end() and
+ * delete the data after it has been transferred.
+ *
+ * @newin{3,96}
+ *
+ * @ingroup Gestures
+ */
+class DragSource : public GestureSingle
+{
+  _CLASS_GOBJECT(DragSource, GtkDragSource, GTK_DRAG_SOURCE, GestureSingle, GtkGestureSingle)
+
+protected:
+  _CTOR_DEFAULT
+
+public:
+  _WRAP_CREATE()
+
+  _WRAP_METHOD(void set_content(const Glib::RefPtr<Gdk::ContentProvider>& content), 
gtk_drag_source_set_content)
+  _WRAP_METHOD(Glib::RefPtr<Gdk::ContentProvider> get_content(), gtk_drag_source_get_content, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const Gdk::ContentProvider> get_content() const, gtk_drag_source_get_content, 
refreturn, constversion)
+
+  _WRAP_METHOD(void set_actions(Gdk::DragAction actions), gtk_drag_source_set_actions)
+  _WRAP_METHOD(Gdk::DragAction get_actions() const, gtk_drag_source_get_actions)
+
+  _WRAP_METHOD(void set_icon(const Glib::RefPtr<Gdk::Paintable>& paintable, int hot_x, int hot_y), 
gtk_drag_source_set_icon)
+  _WRAP_METHOD(void drag_cancel(), gtk_drag_source_drag_cancel)
+  _WRAP_METHOD(Glib::RefPtr<Gdk::Drag> get_drag(), gtk_drag_source_get_drag, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const Gdk::Drag> get_drag() const, gtk_drag_source_get_drag, refreturn, 
constversion)
+
+  _WRAP_PROPERTY("content", Glib::RefPtr<Gdk::ContentProvider>)
+  _WRAP_PROPERTY("actions", Gdk::DragAction)
+
+#m4 _CONVERSION(`Glib::RefPtr<Gdk::ContentProvider>',`GdkContentProvider*',`Glib::unwrap_copy($3)')
+#m4 _CONVERSION(`GdkDrag*',`const Glib::RefPtr<Gdk::Drag>&',`Glib::wrap($3, true)')
+  // no_default_handler because GtkDragSourceClass is private.
+  _WRAP_SIGNAL(Glib::RefPtr<Gdk::ContentProvider> prepare(double x, double y), "prepare", no_default_handler)
+  _WRAP_SIGNAL(void drag_begin(const Glib::RefPtr<Gdk::Drag>& drag), "drag-begin", no_default_handler)
+  _WRAP_SIGNAL(void drag_end(const Glib::RefPtr<Gdk::Drag>& drag, bool delete_data), "drag-end", 
no_default_handler)
+  _WRAP_SIGNAL(bool drag_cancel(const Glib::RefPtr<Gdk::Drag>& drag, Gdk::DragCancelReason reason), 
"drag-cancel", no_default_handler)
+};
+
+} // namespace Gtk
diff --git a/gtk/src/droptarget.ccg b/gtk/src/droptarget.ccg
new file mode 100644
index 00000000..ee2e7d5e
--- /dev/null
+++ b/gtk/src/droptarget.ccg
@@ -0,0 +1,26 @@
+/* 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 <giomm/slot_async.h>
+#include <gtk/gtk.h>
+
+namespace Gtk
+{
+  Glib::RefPtr<DropTarget> DropTarget::create(Gdk::DragAction actions)
+  {
+    return Glib::make_refptr_for_instance<DropTarget>(new DropTarget(nullptr, actions));
+  }
+}
diff --git a/gtk/src/droptarget.hg b/gtk/src/droptarget.hg
new file mode 100644
index 00000000..0a366932
--- /dev/null
+++ b/gtk/src/droptarget.hg
@@ -0,0 +1,110 @@
+/* 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 <gdkmm/contentformats.h>
+#include <gdkmm/drop.h>
+#include <gdkmm/enums.h>
+#include <gtkmm/eventcontroller.h>
+
+_DEFS(gtkmm,gtk)
+_PINCLUDE(gtkmm/private/eventcontroller_p.h)
+
+// The underlying C code can be found in gtkdragdest.h,.c
+
+namespace Gtk
+{
+/** Event controller to receive DND drops.
+ *
+ * %Gtk::DropTarget is an auxiliary object that is used to receive
+ * Drag-and-Drop operations.
+ *
+ * To use a %Gtk::DropTarget to receive drops on a widget, you create
+ * a %Gtk::DropTarget object, configure which data formats and actions
+ * you support, connect to its signals, and then attach
+ * it to the widget with Gtk::Widget::add_controller().
+ *
+ * During a drag operation, the first signal that a %Gtk::DropTarget
+ * emits is signal_accept(), which is meant to determine
+ * whether the target is a possible drop site for the ongoing drag.
+ * The default handler for the accept signal accepts the drag
+ * if it finds a compatible data format and an action that is supported
+ * on both sides.
+ *
+ * If it is, and the widget becomes the current target, you will
+ * receive a signal_drag_enter(), followed by
+ * signal_drag_motion() signals as the pointer moves, and
+ * finally either a signal_drag_leave() when the pointer
+ * move off the widget, or a signal_drag_drop() when a drop happens.
+ *
+ * The signal_drag_enter() and signal_drag_motion() handler can call Gdk::Drop::status()
+ * to update the status of the ongoing operation. The signal_drag_drop() handler
+ * should initiate the data transfer and finish the operation by calling
+ * Gdk::Drop::finish().
+ *
+ * Between the drag-enter and drag-leave signals the widget is the
+ * current drop target, and will receive the Gtk::StateFlags::DROP_ACTIVE
+ * state, which can be used to style the widget as a drop target.
+ *
+ * @newin{3,96}
+ *
+ * @ingroup Gestures
+ */
+class DropTarget : public EventController
+{
+  _CLASS_GOBJECT(DropTarget, GtkDropTarget, GTK_DROP_TARGET, EventController, GtkEventController)
+
+protected:
+  _WRAP_CTOR(DropTarget(const Glib::RefPtr<Gdk::ContentFormats>& formats, Gdk::DragAction actions), 
gtk_drop_target_new)
+
+public:
+  _WRAP_CREATE(const Glib::RefPtr<Gdk::ContentFormats>& formats, Gdk::DragAction actions)
+  Glib::RefPtr<DropTarget> create(Gdk::DragAction actions);
+
+  _WRAP_METHOD(void set_formats(const Glib::RefPtr<Gdk::ContentFormats>& formats), 
gtk_drop_target_set_formats)
+  _WRAP_METHOD(Glib::RefPtr<Gdk::ContentFormats> get_formats(), gtk_drop_target_get_formats, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const Gdk::ContentFormats> get_formats() const, gtk_drop_target_get_formats, 
refreturn, constversion)
+
+  _WRAP_METHOD(void set_actions(Gdk::DragAction actions), gtk_drop_target_set_actions)
+  _WRAP_METHOD(Gdk::DragAction get_actions() const, gtk_drop_target_get_actions)
+
+  _WRAP_METHOD(Glib::RefPtr<Gdk::Drop> get_drop(), gtk_drop_target_get_drop, refreturn)
+  _WRAP_METHOD(Glib::RefPtr<const Gdk::Drop> get_drop() const, gtk_drop_target_get_drop, refreturn, 
constversion)
+
+  _WRAP_METHOD(Glib::ustring find_mimetype() const, gtk_drop_target_find_mimetype)
+
+  _WRAP_METHOD(void read_selection_async(const std::string& target, const Gio::SlotAsyncReady& 
slot{callback},
+    const Glib::RefPtr<Gio::Cancellable>& cancellable{.?}),
+    gtk_drop_target_read_selection, slot_name slot, slot_callback Gio::SignalProxy_async_callback)
+#m4 _CONVERSION(`GtkSelectionData*',`SelectionData', `Gtk::SelectionData(($3), false)')
+  _WRAP_METHOD(SelectionData read_selection_finish(const Glib::RefPtr<Gio::AsyncResult>& result),
+    gtk_drop_target_read_selection_finish, errthrow)
+
+  _WRAP_METHOD(void deny_drop(const Glib::RefPtr<Gdk::Drop>& drop), gtk_drop_target_deny_drop)
+
+  _WRAP_PROPERTY("formats", Glib::RefPtr<Gdk::ContentFormats>)
+  _WRAP_PROPERTY("actions", Gdk::DragAction)
+  _WRAP_PROPERTY("contains", bool)
+
+#m4 _CONVERSION(`GdkDrop*',`const Glib::RefPtr<Gdk::Drop>&',`Glib::wrap($3, true)')
+  // no_default_handler because GtkDropTargetClass is private.
+  _WRAP_SIGNAL(bool accept(const Glib::RefPtr<Gdk::Drop>& drop), "accept", no_default_handler)
+  _WRAP_SIGNAL(void drag_enter(const Glib::RefPtr<Gdk::Drop>& drop), "drag-enter", no_default_handler)
+  _WRAP_SIGNAL(void drag_motion(const Glib::RefPtr<Gdk::Drop>& drop, int x, int y), "drag-motion", 
no_default_handler)
+  _WRAP_SIGNAL(void drag_leave(const Glib::RefPtr<Gdk::Drop>& drop), "drag-leave", no_default_handler)
+  _WRAP_SIGNAL(bool drag_drop(const Glib::RefPtr<Gdk::Drop>& drop, int x, int y), "drag-drop", 
no_default_handler)
+};
+
+} // namespace Gtk
diff --git a/gtk/src/entry.hg b/gtk/src/entry.hg
index a963246d..11db8373 100644
--- a/gtk/src/entry.hg
+++ b/gtk/src/entry.hg
@@ -143,7 +143,7 @@ public:
 
   _WRAP_METHOD(Glib::ustring get_icon_tooltip_markup(IconPosition icon_pos = IconPosition::PRIMARY) const, 
gtk_entry_get_icon_tooltip_markup)
 
-  _WRAP_METHOD(void set_icon_drag_source(const Glib::RefPtr<Gdk::ContentFormats>& formats{.},
+  _WRAP_METHOD(void set_icon_drag_source(const Glib::RefPtr<Gdk::ContentProvider>& provider{.},
     Gdk::DragAction actions{.} = Gdk::DragAction::COPY,
     IconPosition icon_pos{.} = IconPosition::PRIMARY), gtk_entry_set_icon_drag_source)
 
diff --git a/gtk/src/eventcontrollermotion.hg b/gtk/src/eventcontrollermotion.hg
index 2462072d..c5a8d949 100644
--- a/gtk/src/eventcontrollermotion.hg
+++ b/gtk/src/eventcontrollermotion.hg
@@ -51,9 +51,9 @@ public:
   _WRAP_METHOD(bool is_pointer() const, gtk_event_controller_motion_is_pointer)
 
   // no_default_handler because GtkEventControllerMotionClass is private.
-  _WRAP_SIGNAL(void enter(double x, double y, Gdk::CrossingMode mode, Gdk::NotifyType detail),
+  _WRAP_SIGNAL(void enter(double x, double y, Gdk::CrossingMode crossing_mode, Gdk::NotifyType notify_type),
     "enter", no_default_handler)
-  _WRAP_SIGNAL(void leave(Gdk::CrossingMode mode, Gdk::NotifyType detail),
+  _WRAP_SIGNAL(void leave(Gdk::CrossingMode crossing_mode, Gdk::NotifyType notify_type),
     "leave", no_default_handler)
   _WRAP_SIGNAL(void motion(double x, double y), "motion", no_default_handler)
 
diff --git a/gtk/src/filelist.am b/gtk/src/filelist.am
index afe7c7a9..20d1695c 100644
--- a/gtk/src/filelist.am
+++ b/gtk/src/filelist.am
@@ -67,7 +67,9 @@ gtkmm_files_any_hg =          \
        cssprovider.hg          \
        csssection.hg           \
        dialog.hg               \
-       drawingarea.hg          \
+       dragsource.hg \
+       drawingarea.hg \
+       droptarget.hg \
        editable.hg             \
        entry.hg                \
        entrycompletion.hg      \
diff --git a/gtk/src/iconview.hg b/gtk/src/iconview.hg
index 8cf371df..79001a7d 100644
--- a/gtk/src/iconview.hg
+++ b/gtk/src/iconview.hg
@@ -24,6 +24,7 @@
 #include <gtkmm/celllayout.h>
 #include <gtkmm/cellarea.h>
 #include <gtkmm/cellrenderer.h>
+#include <gtkmm/droptarget.h>
 #include <gtkmm/scrollable.h>
 #include <gtkmm/tooltip.h>
 
@@ -229,9 +230,10 @@ public:
      Gdk::DragAction actions{.} = Gdk::DragAction::COPY | Gdk::DragAction::MOVE),
      gtk_icon_view_enable_model_drag_source)
 
-  _WRAP_METHOD(void enable_model_drag_dest(const Glib::RefPtr<Gdk::ContentFormats>& formats,
-     Gdk::DragAction actions = Gdk::DragAction::COPY | Gdk::DragAction::MOVE),
-     gtk_icon_view_enable_model_drag_dest)
+  _WRAP_METHOD(Glib::RefPtr<DropTarget> enable_model_drag_dest(
+    const Glib::RefPtr<Gdk::ContentFormats>& formats,
+    Gdk::DragAction actions = Gdk::DragAction::COPY | Gdk::DragAction::MOVE),
+    gtk_icon_view_enable_model_drag_dest, refreturn)
 
   _WRAP_METHOD(void unset_model_drag_source(), gtk_icon_view_unset_model_drag_source)
   _WRAP_METHOD(void unset_model_drag_dest(), gtk_icon_view_unset_model_drag_dest)
diff --git a/gtk/src/selectionmodel.hg b/gtk/src/selectionmodel.hg
index 3435a013..72a616a3 100644
--- a/gtk/src/selectionmodel.hg
+++ b/gtk/src/selectionmodel.hg
@@ -69,7 +69,7 @@ class SelectionModel : public Glib::Interface
   _CLASS_INTERFACE(SelectionModel, GtkSelectionModel, GTK_SELECTION_MODEL, GtkSelectionModelInterface)
 
 public:
-  _WRAP_METHOD(bool is_slected(guint position) const, gtk_selection_model_is_selected)
+  _WRAP_METHOD(bool is_selected(guint position) const, gtk_selection_model_is_selected)
   _WRAP_METHOD(bool select_item(guint position, bool exclusive), gtk_selection_model_select_item)
   _WRAP_METHOD(bool unselect_item(guint position), gtk_selection_model_unselect_item)
   _WRAP_METHOD(bool select_range(guint position, guint n_items, bool exclusive), 
gtk_selection_model_select_range)
diff --git a/gtk/src/textbuffer.hg b/gtk/src/textbuffer.hg
index 0cd5cfe6..fc5d9dbf 100644
--- a/gtk/src/textbuffer.hg
+++ b/gtk/src/textbuffer.hg
@@ -21,6 +21,7 @@ _CONFIGINCLUDE(gtkmmconfig.h)
 
 #include <vector>
 
+#include <gdkmm/contentprovider.h>
 #include <gtkmm/texttagtable.h>
 #include <gtkmm/textchildanchor.h>
 #include <gtkmm/textmark.h>
@@ -492,6 +493,9 @@ public:
   _WRAP_METHOD(bool get_selection_bounds(const_iterator& range_start, const_iterator& range_end) const, 
gtk_text_buffer_get_selection_bounds)
   _WRAP_METHOD(bool erase_selection(bool interactive = true, bool default_editable = true), 
gtk_text_buffer_delete_selection)
 
+  // gtk_text_buffer_get_selection_content() gives us a ref. Don't add refreturn.
+  _WRAP_METHOD(Glib::RefPtr<Gdk::ContentProvider> get_selection_content(), 
gtk_text_buffer_get_selection_content)
+
   _WRAP_METHOD(void select_range(const iterator& ins, const iterator& bound), gtk_text_buffer_select_range)
 
   _WRAP_METHOD(bool get_can_undo() const, gtk_text_buffer_get_can_undo)
diff --git a/gtk/src/widget.ccg b/gtk/src/widget.ccg
index f578b35b..ea00665b 100644
--- a/gtk/src/widget.ccg
+++ b/gtk/src/widget.ccg
@@ -64,31 +64,6 @@ void Widget_signal_hide_callback(GObject* self, void* data)
   }
 }
 
-//These signal callbacks are custom implemented, so that we can create a temporary SelectionData instance.
-//To do this, we used the optional custom_c_callback paramater to _WRAP_SIGNAL() in the .hg file.
-static void Widget_signal_drag_data_get_callback(GtkWidget* self, GdkDrag* p0,GtkSelectionData* p1,void* 
data)
-{
-  using namespace Gtk;
-  typedef sigc::slot<void(const Glib::RefPtr<Gdk::Drag>&,SelectionData&)> SlotType;
-
-  // Do not try to call a signal on a disassociated wrapper.
-  if(Glib::ObjectBase::_get_current_wrapper((GObject*) self))
-  {
-    try
-    {
-      if(sigc::slot_base *const slot = Glib::SignalProxyNormal::data_to_slot(data))
-      {
-        SelectionData_WithoutOwnership temp_instance(p1);
-        (*static_cast<SlotType*>(slot))(Glib::wrap(p0, true), temp_instance);
-      }
-    }
-    catch(...)
-    {
-      Glib::exception_handlers_invoke();
-    }
-  }
-}
-
 gboolean SlotTick_gtk_callback(GtkWidget* self, GdkFrameClock* frame_clock, void* data)
 {
   // Do not try to call a signal on a disassociated wrapper.
@@ -156,43 +131,6 @@ void Widget_Class::hide_callback(GtkWidget* self)
     (*base->hide)(self);
 }
 
-//This default handler callback is custom implemented, so that we can create a temporary SelectionData 
instance.
-//To do this, we used the optional custom_c_callback paramater to _WRAP_SIGNAL() in the .hg file.
-void Widget_Class::drag_data_get_callback(GtkWidget* self, GdkDrag* p0, GtkSelectionData* p1)
-{
-  const auto obj = dynamic_cast<CppObjectType*>(
-      Glib::ObjectBase::_get_current_wrapper((GObject*)self));
-
-  // Non-gtkmmproc-generated custom classes implicitly call the default
-  // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
-  // generated classes can use this optimisation, which avoids the unnecessary
-  // parameter conversions if there is no possibility of the virtual function
-  // being overridden:
-  if(obj && obj->is_derived_())
-  {
-    try // Trap C++ exceptions which would normally be lost because this is a C callback.
-    {
-      // Call the virtual member method, which derived classes might override.
-      SelectionData_WithoutOwnership temp_instance(p1);
-      obj->on_drag_data_get(Glib::wrap(p0, true), temp_instance);
-    }
-    catch(...)
-    {
-      Glib::exception_handlers_invoke();
-    }
-  }
-  else
-  {
-    const auto base = static_cast<BaseClassType*>(
-        g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The 
original underlying C class).
-    );
-
-    // Call the original underlying C function:
-    if(base && base->drag_data_get)
-      (*base->drag_data_get)(self, p0, p1);
-  }
-}
-
 // This vfunc callback is custom implemented because we want the output
 // arguments of the C++ vfunc to be int& (not int*), and the vfunc_callback
 // function may be called from gtk+ with NULL pointers.
@@ -385,11 +323,6 @@ Allocation Widget::get_allocation() const
   return allocation;
 }
 
-void Widget::drag_dest_set(DestDefaults flags, Gdk::DragAction actions)
-{
-  gtk_drag_dest_set(gobj(), (GtkDestDefaults)flags, nullptr, (GdkDragAction)actions);
-}
-
 void Widget_Class::dispose_vfunc_callback(GObject* self)
 {
   //Avoid disposal. See also Window_Class::dispose_vfunc_callback().
diff --git a/gtk/src/widget.hg b/gtk/src/widget.hg
index 673ab561..b479f66e 100644
--- a/gtk/src/widget.hg
+++ b/gtk/src/widget.hg
@@ -32,8 +32,6 @@ _CONFIGINCLUDE(gtkmmconfig.h)
 #include <gtkmm/constrainttarget.h>
 #include <gdkmm/events.h>
 #include <gdkmm/types.h>
-#include <gdkmm/drag.h>
-#include <gdkmm/drop.h>
 #include <gtkmm/enums.h>
 #include <gdkmm/display.h>
 #include <gdkmm/clipboard.h>
@@ -62,8 +60,6 @@ namespace Gtk
 {
 
 _CC_INCLUDE(gtk/gtk.h)
-_WRAP_ENUM(DestDefaults, GtkDestDefaults)
-_WRAP_ENUM(DragResult, GtkDragResult)
 
 class AccelGroup;
 class Adjustment;
@@ -411,69 +407,6 @@ public:
  _WRAP_METHOD(void add_mnemonic_label(Widget& label), gtk_widget_add_mnemonic_label)
  _WRAP_METHOD(void remove_mnemonic_label(Widget& label), gtk_widget_remove_mnemonic_label)
 
-  //TODO: Should drag_get_data() be const?
-  _WRAP_METHOD(void drag_get_data(const Glib::RefPtr<Gdk::Drop>& drop, const Glib::ustring& target), 
gtk_drag_get_data)
-
-  _WRAP_METHOD(void drag_highlight(), gtk_drag_highlight)
-  _WRAP_METHOD(void drag_unhighlight(), gtk_drag_unhighlight)
-
-  /** Sets a widget as a potential drop destination, and adds default behaviors.
-   *
-   * This %drag_dest_set() overload, with its default values of @a flags and
-   * @a actions, is useful if you provide your own signal handlers for
-   * signal_drag_motion() and signal_drag_drop() and let the signal handlers
-   * decide if a drop is possible.
-   *
-   * @see drag_dest_set(const Glib::RefPtr<Gdk::ContentFormats>&, DestDefaults, Gdk::DragAction)
-   *
-   * @param flags Which types of default drag behavior to use.
-   * @param actions A bitmask of possible actions for a drop onto this widget.
-   */
-  void drag_dest_set(DestDefaults flags = DestDefaults(0), Gdk::DragAction actions = Gdk::DragAction(0));
-
-  // I've used Gdk::DragAction::COPY as the default, because Gdk::DragAction::DEFAULT means that
-  // it's never a drag destination, so it would seem like this method didn't work. murrayc.
-  _WRAP_METHOD(void drag_dest_set(const Glib::RefPtr<Gdk::ContentFormats>& targets{.},
-    DestDefaults flags{.} = DestDefaults::ALL,
-    Gdk::DragAction actions{.} = Gdk::DragAction::COPY), gtk_drag_dest_set)
-
-  _WRAP_METHOD(void drag_dest_unset(), gtk_drag_dest_unset)
-  _WRAP_METHOD(Glib::ustring drag_dest_find_target(const Glib::RefPtr<Gdk::Drop>& drop,
-    const Glib::RefPtr<Gdk::ContentFormats>& target_list = {}) const, gtk_drag_dest_find_target)
-
-  _WRAP_METHOD(Glib::RefPtr<Gdk::ContentFormats> drag_dest_get_target_list(), gtk_drag_dest_get_target_list, 
refreturn)
-  _WRAP_METHOD(Glib::RefPtr<const Gdk::ContentFormats> drag_dest_get_target_list() const, 
gtk_drag_dest_get_target_list, refreturn, constversion)
-  _WRAP_METHOD(void drag_dest_set_target_list(const Glib::RefPtr<Gdk::ContentFormats>& target_list), 
gtk_drag_dest_set_target_list)
-
-  _WRAP_METHOD(void drag_dest_add_text_targets(), gtk_drag_dest_add_text_targets)
-  _WRAP_METHOD(void drag_dest_add_image_targets(), gtk_drag_dest_add_image_targets)
-  _WRAP_METHOD(void drag_dest_add_uri_targets(), gtk_drag_dest_add_uri_targets)
-
-  _WRAP_METHOD(void drag_dest_set_track_motion(bool track_motion = true), gtk_drag_dest_set_track_motion)
-  _WRAP_METHOD(bool drag_dest_get_track_motion() const, gtk_drag_dest_get_track_motion)
-
-  // I've used Gdk::ModifierType::MODIFIER_MASK as the default, because it seems
-  // to mean 'whatever is possible in the context'. murrayc.
-  _WRAP_METHOD(void drag_source_set(const Glib::RefPtr<Gdk::ContentFormats>& targets{.},
-    Gdk::ModifierType start_button_mask{.} = Gdk::ModifierType::MODIFIER_MASK,
-    Gdk::DragAction actions{.} = Gdk::DragAction::COPY), gtk_drag_source_set)
-  _WRAP_METHOD(void drag_source_unset(), gtk_drag_source_unset)
-
-  _WRAP_METHOD(Glib::RefPtr<Gdk::ContentFormats> drag_source_get_target_list(), 
gtk_drag_source_get_target_list, refreturn)
-  _WRAP_METHOD(Glib::RefPtr<const Gdk::ContentFormats> drag_source_get_target_list() const, 
gtk_drag_source_get_target_list, refreturn, constversion)
-  _WRAP_METHOD(void drag_source_set_target_list(const Glib::RefPtr<Gdk::ContentFormats>& target_list), 
gtk_drag_source_set_target_list)
-
-  _WRAP_METHOD(void drag_source_set_icon(const Glib::ustring& icon_name), gtk_drag_source_set_icon_name)
-  _WRAP_METHOD(void drag_source_set_icon(const Glib::RefPtr<Gio::Icon>& icon), 
gtk_drag_source_set_icon_gicon)
-  _WRAP_METHOD(void drag_source_set_icon(const Glib::RefPtr<Gdk::Paintable>& paintable), 
gtk_drag_source_set_icon_paintable)
-
-  _WRAP_METHOD(void drag_source_add_text_targets(), gtk_drag_source_add_text_targets)
-  _WRAP_METHOD(void drag_source_add_uri_targets(), gtk_drag_source_add_uri_targets)
-  _WRAP_METHOD(void drag_source_add_image_targets(), gtk_drag_source_add_image_targets)
-
-  _WRAP_METHOD(Glib::RefPtr<Gdk::Drag> drag_begin(const Glib::RefPtr<Gdk::Device>& device,
-    const Glib::RefPtr<Gdk::ContentFormats>& targets, Gdk::DragAction actions, int x, int y),
-    gtk_drag_begin, refreturn)
   _WRAP_METHOD(bool drag_check_threshold(int start_x, int start_y, int current_x, int current_y), 
gtk_drag_check_threshold)
 
   _WRAP_METHOD(Glib::RefPtr<Gdk::FrameClock> get_frame_clock(), gtk_widget_get_frame_clock, refreturn, newin 
"3,24")
@@ -699,20 +632,6 @@ dnl
   _POP()
 #m4end
 
-#m4 _CONVERSION(`GdkDrag*',`const Glib::RefPtr<Gdk::Drag>&',Glib::wrap($3, true))
-#m4 _CONVERSION(`GdkDrop*',`const Glib::RefPtr<Gdk::Drop>&',Glib::wrap($3, true))
-  _WRAP_SIGNAL(void drag_begin(const Glib::RefPtr<Gdk::Drag>& drag), "drag_begin")
-  _WRAP_SIGNAL(void drag_end(const Glib::RefPtr<Gdk::Drag>& drag), "drag_end")
-  //We use the optional custom_c_callback parameter with _WRAP_SIGNAL(),
-  //so that we can write special code to wrap the non-const SelectionData& output parameter:
-  _WRAP_SIGNAL(void drag_data_get(const Glib::RefPtr<Gdk::Drag>& drag, SelectionData& selection_data), 
"drag_data_get", custom_c_callback)
-  _WRAP_SIGNAL(void drag_data_delete(const Glib::RefPtr<Gdk::Drag>& drag), "drag_data_delete")
-  _WRAP_SIGNAL(bool drag_failed(const Glib::RefPtr<Gdk::Drag>& drag, DragResult result), "drag_failed")
-  _WRAP_SIGNAL(void drag_leave(const Glib::RefPtr<Gdk::Drop>& drop), "drag_leave")
-  _WRAP_SIGNAL(bool drag_motion(const Glib::RefPtr<Gdk::Drop>& drop, int x, int y), "drag_motion")
-  _WRAP_SIGNAL(bool drag_drop(const Glib::RefPtr<Gdk::Drop>& drop, int x, int y), "drag_drop")
-  _WRAP_SIGNAL(void drag_data_received(const Glib::RefPtr<Gdk::Drop>& drop, const SelectionData& 
selection_data), "drag_data_received")
-
   // The accel_closures_changed signal can't have a default handler because the wrapped C signal has no 
default handler.
   _WRAP_SIGNAL(void accel_closures_changed(), "accel_closures_changed", no_default_handler)
 
diff --git a/tools/m4/convert_gdk.m4 b/tools/m4/convert_gdk.m4
index 7cf1de6f..b119678a 100644
--- a/tools/m4/convert_gdk.m4
+++ b/tools/m4/convert_gdk.m4
@@ -260,8 +260,10 @@ _CONVERSION(`GdkContentFormatsBuilder*',`Glib::RefPtr<ContentFormatsBuilder>',`G
 
 # ContentProvider
 _CONVERSION(`const Glib::RefPtr<ContentProvider>&',`GdkContentProvider*',__CONVERT_REFPTR_TO_P)
+_CONVERSION(`const Glib::RefPtr<Gdk::ContentProvider>&',`GdkContentProvider*',__CONVERT_REFPTR_TO_P)
 _CONVERSION(`const Glib::RefPtr<const ContentProvider>&',`GdkContentProvider*',__CONVERT_CONST_REFPTR_TO_P)
 _CONVERSION(`GdkContentProvider*',`Glib::RefPtr<ContentProvider>',`Glib::wrap($3)')
+_CONVERSION(`GdkContentProvider*',`Glib::RefPtr<Gdk::ContentProvider>',`Glib::wrap($3)')
 
 # FrameClock, FrameTimings
 _CONVERSION(`GdkFrameClock*',`Glib::RefPtr<FrameClock>',`Glib::wrap($3)')
@@ -277,10 +279,11 @@ _CONVERSION(`GdkTimeCoord**&',`GdkTimeCoord***',`&($3)')
 
 dnl _CONVERSION(GdkBitmap*,Gdk::Bitmap&,`Glib::unwrap_boxed($3)',`$3')
 
-dnl GdkAtom -> Glib::ustring and vice versa
+dnl GdkAtom -> Glib::ustring and std::string and vice versa
 _CONVERSION(`GdkAtom',`Glib::ustring',`Gdk::AtomUstring::to_cpp_type($3)')
 _CONVERSION(`const Glib::ustring&', `GdkAtom', `Gdk::AtomUstring::to_c_type($3)')
 _CONVERSION(`Glib::ustring&',`GdkAtom',`Gdk::AtomUstring::to_c_type($3)')
+_CONVERSION(`const std::string&', `GdkAtom', `Gdk::AtomString::to_c_type($3)')
 
 dnl GdkEvent and GdkEventSequence
 _CONVERSION(`GdkEvent*',`Glib::RefPtr<Event>',`Glib::wrap($3)')
@@ -298,4 +301,5 @@ _CONVERSION(`GdkEventSequence*',`Gdk::EventSequence*',`reinterpret_cast<$2>($3)'
 
 _CONVERSION(`GdkDrag*',`Glib::RefPtr<Drag>',Glib::wrap($3))
 _CONVERSION(`GdkDrag*',`Glib::RefPtr<Gdk::Drag>',Glib::wrap($3))
+_CONVERSION(`GdkDrop*',`Glib::RefPtr<Gdk::Drop>',Glib::wrap($3))
 
diff --git a/tools/m4/convert_gtk.m4 b/tools/m4/convert_gtk.m4
index 1e2c13bc..72921e91 100644
--- a/tools/m4/convert_gtk.m4
+++ b/tools/m4/convert_gtk.m4
@@ -46,7 +46,6 @@ _CONV_ENUM(Gtk,CssParserError)
 _CONV_ENUM(Gtk,CssParserWarning)
 _CONV_ENUM(Gtk,CurveType)
 _CONV_ENUM(Gtk,DeleteType)
-_CONV_ENUM(Gtk,DestDefaults)
 _CONV_ENUM(Gtk,DirectionType)
 _CONV_INCLASS_ENUM(Gtk,EventControllerScroll,Flags)
 _CONV_ENUM(Gtk,EventSequenceState)
@@ -90,7 +89,6 @@ _CONV_ENUM(Gtk,TextSearchFlags)
 _CONV_ENUM(Gtk,TextWindowType)
 _CONV_ENUM(Gtk,ToolbarChildType)
 _CONV_ENUM(Gtk,ToolbarStyle)
-_CONV_ENUM(Gtk,ToolPaletteDragTargets)
 _CONV_INCLASS_ENUM(Gtk,TreeModel,Flags)
 _CONV_INCLASS_ENUM(Gtk,TreeViewColumn,Sizing)
 _CONV_INCLASS_ENUM(Gtk,TreeView,DropPosition)
@@ -121,7 +119,6 @@ _CONV_INCLASS_ENUM(Gtk,PrintOperation,Result)
 _CONV_INCLASS_ENUM(Gtk,PrintOperation,Action)
 _CONV_ENUM(Gtk,PrintError)
 _CONV_ENUM(Gtk,PrintCapabilities)
-_CONV_ENUM(Gtk,DragResult)
 _CONV_ENUM(Gtk,NumberUpLayout)
 _CONV_INCLASS_ENUM(Gtk,Entry,IconPosition)
 _CONV_ENUM(Gtk,WrapAllocationMode)
@@ -574,6 +571,7 @@ _CONVERSION(`GActionGroup*',`Glib::RefPtr<Gio::ActionGroup>',`Glib::wrap($3)')
 _CONVERSION(`GActionGroup*',`Glib::RefPtr<const Gio::ActionGroup>',`Glib::wrap($3)')
 
 _CONVERSION(`GtkDragResult',`DragResult',`static_cast<$2>($3)')
+_CONVERSION(`GtkDropTarget*',`Glib::RefPtr<DropTarget>',`Glib::wrap($3)')
 
 _CONVERSION(`GtkWidgetPath*',`WidgetPath',`Glib::wrap($3, true)')
 _CONVERSION(`const GtkWidgetPath*',`WidgetPath',`Glib::wrap(const_cast<GtkWidgetPath*>($3), true)')


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