[gtkmm-documentation] Use Gdk::ContentFormats instead of Gtk::TargetList



commit 863e1161e5f5a7d774c803dd4ec06fa70832a1e8
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Fri Nov 24 20:06:25 2017 +0100

    Use Gdk::ContentFormats instead of Gtk::TargetList
    
    Gtk::TargetEntry and Gtk::TargetList have been replaced by
    Gdk::ContentFormats and Gtk::ContentFormatsBuilder.
    Class Gtk::IconSize has been removed, and enum BuiltinIconSize has been
    renamed to IconSize.

 examples/book/actionbar/examplewindow.cc           |    9 +++--
 examples/book/builder/derived/deriveddialog.cc     |    3 +-
 examples/book/buttons/scalebutton/examplewindow.cc |    2 +-
 examples/book/clipboard/ideal/examplewindow.cc     |   32 ++++++++-----------
 examples/book/clipboard/ideal/examplewindow.h      |    2 +-
 examples/book/custom/custom_widget/mywidget.cc     |    3 +-
 examples/book/custom/custom_widget/mywidget2.cc    |    3 +-
 examples/book/drag_and_drop/dndwindow.cc           |   15 +++++----
 examples/book/drag_and_drop/dndwindow.h            |    4 +-
 examples/book/headerbar/examplewindow.cc           |    2 +-
 examples/book/popover/examplewindow.cc             |    6 ++--
 examples/book/searchbar/examplewindow.cc           |    4 +-
 examples/book/toolpalette/canvas.cc                |    4 +-
 examples/book/toolpalette/canvas.h                 |    7 +---
 examples/book/toolpalette/examplewindow.cc         |    4 +--
 examples/book/tooltips/examplewindow.cc            |    2 +-
 examples/others/arrow/arrow.cc                     |    2 +-
 examples/others/cellrenderercustom/popupentry.cc   |    4 +-
 examples/others/dnd/dndwindow.cc                   |   26 ++++++++--------
 examples/others/dnd/dndwindow.h                    |   18 ++--------
 20 files changed, 67 insertions(+), 85 deletions(-)
---
diff --git a/examples/book/actionbar/examplewindow.cc b/examples/book/actionbar/examplewindow.cc
index 0978150..76516ed 100644
--- a/examples/book/actionbar/examplewindow.cc
+++ b/examples/book/actionbar/examplewindow.cc
@@ -31,12 +31,13 @@ ExampleWindow::ExampleWindow()
   settings->property_gtk_application_prefer_dark_theme().set_value(true);
 
   // Face
-  m_face_image.set_from_icon_name("face-cool", Gtk::BuiltinIconSize::DIALOG);
+  m_face_image.set_from_icon_name("face-cool");
+  m_face_image.set_icon_size(Gtk::IconSize::LARGE);
 
   // Center widget layout
-  m_prev_button.set_image_from_icon_name("go-previous-symbolic", Gtk::BuiltinIconSize::BUTTON, true);
-  m_next_button.set_image_from_icon_name("go-next-symbolic", Gtk::BuiltinIconSize::BUTTON, true);
-  m_photo_button.set_image_from_icon_name("media-record-symbolic", Gtk::BuiltinIconSize::BUTTON, true);
+  m_prev_button.set_image_from_icon_name("go-previous-symbolic", Gtk::IconSize::INHERIT, true);
+  m_next_button.set_image_from_icon_name("go-next-symbolic", Gtk::IconSize::INHERIT, true);
+  m_photo_button.set_image_from_icon_name("media-record-symbolic", Gtk::IconSize::INHERIT, true);
   m_photo_box.pack_start(m_prev_button, Gtk::PackOptions::SHRINK);
   m_photo_box.pack_start(m_photo_button, Gtk::PackOptions::SHRINK);
   m_photo_box.pack_start(m_next_button, Gtk::PackOptions::SHRINK);
diff --git a/examples/book/builder/derived/deriveddialog.cc b/examples/book/builder/derived/deriveddialog.cc
index 81db893..2bf7208 100644
--- a/examples/book/builder/derived/deriveddialog.cc
+++ b/examples/book/builder/derived/deriveddialog.cc
@@ -39,7 +39,8 @@ DerivedDialog::DerivedDialog(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Bu
 {
   // Show an icon.
   auto pImage = Gtk::manage(new Gtk::Image());
-  pImage->set_from_icon_name(is_glad ? "face-smile" : "face-sad", Gtk::BuiltinIconSize::DIALOG);
+  pImage->set_from_icon_name(is_glad ? "face-smile" : "face-sad");
+  pImage->set_icon_size(Gtk::IconSize::LARGE);
   get_content_area()->pack_start(*pImage, Gtk::PackOptions::EXPAND_WIDGET);
 }
 
diff --git a/examples/book/buttons/scalebutton/examplewindow.cc 
b/examples/book/buttons/scalebutton/examplewindow.cc
index 755d9f9..0a6080b 100644
--- a/examples/book/buttons/scalebutton/examplewindow.cc
+++ b/examples/book/buttons/scalebutton/examplewindow.cc
@@ -18,7 +18,7 @@
 #include <iostream>
 
 ExampleWindow::ExampleWindow()
-: m_button(Gtk::BuiltinIconSize::BUTTON, 0.0, 100.0, 10.0)
+: m_button(0.0, 100.0, 10.0)
 {
   //Make the window big enough to show the popup scale from the GtkVolumeButton.
   //Otherwise it will be truncated.
diff --git a/examples/book/clipboard/ideal/examplewindow.cc b/examples/book/clipboard/ideal/examplewindow.cc
index 293fe0d..716bd48 100644
--- a/examples/book/clipboard/ideal/examplewindow.cc
+++ b/examples/book/clipboard/ideal/examplewindow.cc
@@ -21,8 +21,8 @@ namespace
 {
 
 //These should usually be MIME types.
-const char example_target_custom[] = "gtkmmclipboardexample";
-const char example_target_text[]   = "UTF8_STRING";
+const char example_format_custom[] = "gtkmmclipboardexample";
+const char example_format_text[]   = "UTF8_STRING";
 
 } // anonymous namespace
 
@@ -88,13 +88,13 @@ void ExampleWindow::on_button_copy()
 
   auto refClipboard = Gtk::Clipboard::get();
 
-  //Targets:
-  std::vector<Gtk::TargetEntry> targets;
+  // Formats:
+  std::vector<Glib::ustring> formats;
 
-  targets.push_back( Gtk::TargetEntry(example_target_custom) );
-  targets.push_back( Gtk::TargetEntry(example_target_text) );
+  formats.push_back(example_format_custom);
+  formats.push_back(example_format_text);
 
-  refClipboard->set(targets,
+  refClipboard->set(Gdk::ContentFormats::create(formats),
     sigc::mem_fun(*this, &ExampleWindow::on_clipboard_get),
     sigc::mem_fun(*this, &ExampleWindow::on_clipboard_clear) );
 
@@ -111,7 +111,7 @@ void ExampleWindow::on_button_paste()
   //Tell the clipboard to call our method when it is ready:
   auto refClipboard = Gtk::Clipboard::get();
 
-  refClipboard->request_contents(example_target_custom,
+  refClipboard->request_contents(example_format_custom,
     sigc::mem_fun(*this, &ExampleWindow::on_clipboard_received) );
 
   update_paste_status();
@@ -122,20 +122,16 @@ void ExampleWindow::on_clipboard_owner_change(const Gdk::EventOwnerChange&)
   update_paste_status();
 }
 
-void ExampleWindow::on_clipboard_get(Gtk::SelectionData& selection_data,
-  guint /* info */)
+void ExampleWindow::on_clipboard_get(Gtk::SelectionData& selection_data)
 {
-  // info corresponds to the optional info parameter in Gtk::TargetEntry's
-  // constructor. We don't use that, so we use selection_data's target instead.
-
   const auto target = selection_data.get_target();
 
-  if(target == example_target_custom)
+  if(target == example_format_custom)
   {
     // This set() override uses an 8-bit text format for the data.
-    selection_data.set(example_target_custom, m_ClipboardStore);
+    selection_data.set(example_format_custom, m_ClipboardStore);
   }
-  else if(target == example_target_text)
+  else if(target == example_format_text)
   {
     //Build some arbitrary text representation of the data,
     //so that people see something when they paste into a text editor:
@@ -168,7 +164,7 @@ void ExampleWindow::on_clipboard_received(
 
   //It should always be this, because that's what we asked for when calling
   //request_contents().
-  if(target == example_target_custom)
+  if(target == example_format_custom)
   {
     auto clipboard_data = selection_data.get_data_as_string();
 
@@ -199,7 +195,7 @@ void ExampleWindow::on_clipboard_received_targets(
 {
   const bool bPasteIsPossible =
     std::find(targets.begin(), targets.end(),
-      example_target_custom) != targets.end();
+      example_format_custom) != targets.end();
 
   // Enable/Disable the Paste button appropriately:
   m_Button_Paste.set_sensitive(bPasteIsPossible);
diff --git a/examples/book/clipboard/ideal/examplewindow.h b/examples/book/clipboard/ideal/examplewindow.h
index 412ea90..71b8198 100644
--- a/examples/book/clipboard/ideal/examplewindow.h
+++ b/examples/book/clipboard/ideal/examplewindow.h
@@ -31,7 +31,7 @@ protected:
   void on_button_paste();
 
   void on_clipboard_owner_change(const Gdk::EventOwnerChange& event);
-  void on_clipboard_get(Gtk::SelectionData& selection_data, guint info);
+  void on_clipboard_get(Gtk::SelectionData& selection_data);
   void on_clipboard_clear();
 
   void on_clipboard_received(const Gtk::SelectionData& selection_data);
diff --git a/examples/book/custom/custom_widget/mywidget.cc b/examples/book/custom/custom_widget/mywidget.cc
index ddba3cc..4375c51 100644
--- a/examples/book/custom/custom_widget/mywidget.cc
+++ b/examples/book/custom/custom_widget/mywidget.cc
@@ -155,8 +155,7 @@ void MyWidget::on_realize()
   if(!m_refGdkWindow)
   {
     //Create the GdkWindow:
-    m_refGdkWindow = Gdk::Window::create_child(get_parent_window(),
-      get_parent_window()->get_events() | Gdk::EventMask::EXPOSURE_MASK, get_allocation());
+    m_refGdkWindow = Gdk::Window::create_child(get_parent_window(), get_allocation());
     set_window(m_refGdkWindow);
 
     //make the widget receive expose events
diff --git a/examples/book/custom/custom_widget/mywidget2.cc b/examples/book/custom/custom_widget/mywidget2.cc
index 0b0e4cb..6d52736 100644
--- a/examples/book/custom/custom_widget/mywidget2.cc
+++ b/examples/book/custom/custom_widget/mywidget2.cc
@@ -154,8 +154,7 @@ void MyWidget2::on_realize()
   if(!m_refGdkWindow)
   {
     //Create the GdkWindow:
-    m_refGdkWindow = Gdk::Window::create_child(get_parent_window(),
-      get_parent_window()->get_events() | Gdk::EventMask::EXPOSURE_MASK, get_allocation());
+    m_refGdkWindow = Gdk::Window::create_child(get_parent_window(), get_allocation());
     set_window(m_refGdkWindow);
 
     //make the widget receive expose events
diff --git a/examples/book/drag_and_drop/dndwindow.cc b/examples/book/drag_and_drop/dndwindow.cc
index 8ba06ed..88e743b 100644
--- a/examples/book/drag_and_drop/dndwindow.cc
+++ b/examples/book/drag_and_drop/dndwindow.cc
@@ -26,14 +26,15 @@ DnDWindow::DnDWindow()
   add(m_HBox);
 
   //Targets:
-  std::vector<Gtk::TargetEntry> listTargets;
-  listTargets.push_back( Gtk::TargetEntry("STRING") );
-  listTargets.push_back( Gtk::TargetEntry("text/plain") );
+  std::vector<Glib::ustring> listFormats;
+  listFormats.push_back("STRING");
+  listFormats.push_back("text/plain");
+  auto targetList = Gdk::ContentFormats::create(listFormats);
 
   //Drag site:
 
   //Make m_Button_Drag a DnD drag source:
-  m_Button_Drag.drag_source_set(listTargets);
+  m_Button_Drag.drag_source_set(targetList);
 
   //Connect signals:
   m_Button_Drag.signal_drag_data_get().connect(sigc::mem_fun(*this,
@@ -44,7 +45,7 @@ DnDWindow::DnDWindow()
   //Drop site:
 
   //Make m_Label_Drop a DnD drop destination:
-  m_Label_Drop.drag_dest_set(listTargets);
+  m_Label_Drop.drag_dest_set(targetList);
 
   //Connect signals:
   m_Label_Drop.signal_drag_data_received().connect(sigc::mem_fun(*this,
@@ -59,7 +60,7 @@ DnDWindow::~DnDWindow()
 
 void DnDWindow::on_button_drag_data_get(
         const Glib::RefPtr<Gdk::DragContext>&,
-        Gtk::SelectionData& selection_data, guint, guint)
+        Gtk::SelectionData& selection_data, guint)
 {
   selection_data.set(selection_data.get_target(), 8 /* 8 bits format */,
           (const guchar*)"I'm Data!",
@@ -68,7 +69,7 @@ void DnDWindow::on_button_drag_data_get(
 
 void DnDWindow::on_label_drop_drag_data_received(
         const Glib::RefPtr<Gdk::DragContext>& context, int, int,
-        const Gtk::SelectionData& selection_data, guint, guint time)
+        const Gtk::SelectionData& selection_data, guint time)
 {
   const int length = selection_data.get_length();
   if((length >= 0) && (selection_data.get_format() == 8))
diff --git a/examples/book/drag_and_drop/dndwindow.h b/examples/book/drag_and_drop/dndwindow.h
index 2d33799..0cbfee2 100644
--- a/examples/book/drag_and_drop/dndwindow.h
+++ b/examples/book/drag_and_drop/dndwindow.h
@@ -35,10 +35,10 @@ protected:
   //Signal handlers:
   void on_button_drag_data_get(
           const Glib::RefPtr<Gdk::DragContext>& context,
-          Gtk::SelectionData& selection_data, guint info, guint time);
+          Gtk::SelectionData& selection_data, guint time);
   void on_label_drop_drag_data_received(
           const Glib::RefPtr<Gdk::DragContext>& context, int x, int y,
-          const Gtk::SelectionData& selection_data, guint info, guint time);
+          const Gtk::SelectionData& selection_data, guint time);
 
   //Member widgets:
   Gtk::Box m_HBox;
diff --git a/examples/book/headerbar/examplewindow.cc b/examples/book/headerbar/examplewindow.cc
index 66e22b4..7c4dee9 100644
--- a/examples/book/headerbar/examplewindow.cc
+++ b/examples/book/headerbar/examplewindow.cc
@@ -25,7 +25,7 @@ ExampleWindow::ExampleWindow()
   set_title("HeaderBar Example");
 
   // Button
-  m_button.set_image_from_icon_name("go-home-symbolic", Gtk::BuiltinIconSize::BUTTON, true);
+  m_button.set_image_from_icon_name("go-home-symbolic", Gtk::IconSize::INHERIT, true);
   m_button.signal_clicked().connect(sigc::mem_fun(*this, &ExampleWindow::on_button_clicked));
 
   // Entries
diff --git a/examples/book/popover/examplewindow.cc b/examples/book/popover/examplewindow.cc
index d7cbdb7..1755663 100644
--- a/examples/book/popover/examplewindow.cc
+++ b/examples/book/popover/examplewindow.cc
@@ -80,9 +80,9 @@ void ExampleWindow::configure_form_popover()
 
 void ExampleWindow::configure_form_buttons()
 {
-  m_toggle_form_buttons[0].set_image_from_icon_name("format-justify-left-symbolic", 
Gtk::BuiltinIconSize::BUTTON, true);
-  m_toggle_form_buttons[1].set_image_from_icon_name("format-justify-center-symbolic", 
Gtk::BuiltinIconSize::BUTTON, true);
-  m_toggle_form_buttons[2].set_image_from_icon_name("format-justify-right-symbolic", 
Gtk::BuiltinIconSize::BUTTON, true);
+  m_toggle_form_buttons[0].set_image_from_icon_name("format-justify-left-symbolic", Gtk::IconSize::INHERIT, 
true);
+  m_toggle_form_buttons[1].set_image_from_icon_name("format-justify-center-symbolic", 
Gtk::IconSize::INHERIT, true);
+  m_toggle_form_buttons[2].set_image_from_icon_name("format-justify-right-symbolic", Gtk::IconSize::INHERIT, 
true);
 
   m_toggle_form_buttons[0].set_draw_indicator(false);
   m_toggle_form_buttons[1].set_draw_indicator(false);
diff --git a/examples/book/searchbar/examplewindow.cc b/examples/book/searchbar/examplewindow.cc
index 3ee9bc3..3a2a245 100644
--- a/examples/book/searchbar/examplewindow.cc
+++ b/examples/book/searchbar/examplewindow.cc
@@ -65,8 +65,8 @@ ExampleWindow::ExampleWindow()
   m_up_down_box.get_style_context()->add_class("linked");
 
   // Buttons
-  m_go_up_button.set_image_from_icon_name("go-up-symbolic", Gtk::BuiltinIconSize::BUTTON, true);
-  m_go_down_button.set_image_from_icon_name("go-down-symbolic", Gtk::BuiltinIconSize::BUTTON, true);
+  m_go_up_button.set_image_from_icon_name("go-up-symbolic", Gtk::IconSize::INHERIT, true);
+  m_go_down_button.set_image_from_icon_name("go-down-symbolic", Gtk::IconSize::INHERIT, true);
 
   m_vbox.set_spacing(6);
   m_vbox.pack_start(m_search_bar, Gtk::PackOptions::SHRINK);
diff --git a/examples/book/toolpalette/canvas.cc b/examples/book/toolpalette/canvas.cc
index 2c85053..efa05eb 100644
--- a/examples/book/toolpalette/canvas.cc
+++ b/examples/book/toolpalette/canvas.cc
@@ -107,7 +107,7 @@ bool Canvas::on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context,
 
 
 void Canvas::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context,
-  int x, int y, const Gtk::SelectionData& selection_data, guint info, guint time)
+  int x, int y, const Gtk::SelectionData& selection_data, guint time)
 {
   // Find the tool button which is the source of this DnD operation.
   auto widget = drag_get_source_widget(context);
@@ -160,7 +160,7 @@ void Canvas::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context
     std::cerr << "IconThemeError: " << ex.what() << std::endl;
   }
 
-  Gtk::DrawingArea::on_drag_data_received(context, x, y, selection_data, info, time);
+  Gtk::DrawingArea::on_drag_data_received(context, x, y, selection_data, time);
 }
 
 
diff --git a/examples/book/toolpalette/canvas.h b/examples/book/toolpalette/canvas.h
index d944b31..2491b6e 100644
--- a/examples/book/toolpalette/canvas.h
+++ b/examples/book/toolpalette/canvas.h
@@ -40,10 +40,7 @@ private:
         icon_name = button->get_label();
 
       auto icon_theme = Gtk::IconTheme::get_for_display(canvas->get_display());
-      int width = 0;
-      int height = 0; //ignored
-      Gtk::IconSize::lookup(Gtk::BuiltinIconSize::DIALOG, width, height);
-      this->m_pixbuf = icon_theme->load_icon(icon_name, width, Gtk::IconLookupFlags::GENERIC_FALLBACK);
+      this->m_pixbuf = icon_theme->load_icon(icon_name, 48, Gtk::IconLookupFlags::GENERIC_FALLBACK);
       this->m_x = x;
       this->m_y = y;
     }
@@ -58,7 +55,7 @@ private:
 
   void on_draw(const Cairo::RefPtr<Cairo::Context>& cr, int width, int height);
   void on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context,
-    int x, int y, const Gtk::SelectionData& selection_data, guint info, guint time) override;
+    int x, int y, const Gtk::SelectionData& selection_data, guint time) override;
   bool on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time) override;
   bool on_drag_drop(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time) override;
   void on_drag_leave(const Glib::RefPtr<Gdk::DragContext>& context, guint time) override;
diff --git a/examples/book/toolpalette/examplewindow.cc b/examples/book/toolpalette/examplewindow.cc
index 6a1919a..de2f164 100644
--- a/examples/book/toolpalette/examplewindow.cc
+++ b/examples/book/toolpalette/examplewindow.cc
@@ -28,9 +28,7 @@ void ExampleWindow::load_icon_items()
   type_stringvec contexts = icon_theme->list_contexts();
   std::sort(contexts.begin(), contexts.end());
 
-  int requested_icon_size = 0;
-  int requested_icon_height = 0; //ignored
-  Gtk::IconSize::lookup(Gtk::BuiltinIconSize::BUTTON, requested_icon_size, requested_icon_height);
+  const int requested_icon_size = 16;
   const guint max_icons_per_group = 10;
 
   for (auto iter = contexts.begin(); iter != contexts.end(); ++iter)
diff --git a/examples/book/tooltips/examplewindow.cc b/examples/book/tooltips/examplewindow.cc
index 24a3682..86a9fd5 100644
--- a/examples/book/tooltips/examplewindow.cc
+++ b/examples/book/tooltips/examplewindow.cc
@@ -154,7 +154,7 @@ bool ExampleWindow::on_textview_query_tooltip(int x, int y, bool keyboard_toolti
   if (iter.has_tag(m_ref_bold_tag))
   {
     tooltip->set_markup("<b>Information</b> attached to a text tag");
-    tooltip->set_icon_from_icon_name("dialog-information", Gtk::BuiltinIconSize::MENU);
+    tooltip->set_icon_from_icon_name("dialog-information");
   }
   else
   {
diff --git a/examples/others/arrow/arrow.cc b/examples/others/arrow/arrow.cc
index 2cea439..c2690c2 100644
--- a/examples/others/arrow/arrow.cc
+++ b/examples/others/arrow/arrow.cc
@@ -31,7 +31,7 @@ ArrowButton::ArrowButton(Gtk::ArrowType arrow_type)
     case Gtk::ArrowType::RIGHT: icon_name = "pan-end-symbolic"; break;
     default:                    icon_name = "dialog-question"; break;
   }
-  set_image_from_icon_name(icon_name, Gtk::BuiltinIconSize::BUTTON, true);
+  set_image_from_icon_name(icon_name, Gtk::IconSize::INHERIT, true);
 }
 
 ArrowButton::~ArrowButton()
diff --git a/examples/others/cellrenderercustom/popupentry.cc 
b/examples/others/cellrenderercustom/popupentry.cc
index b7c347c..acf5124 100644
--- a/examples/others/cellrenderercustom/popupentry.cc
+++ b/examples/others/cellrenderercustom/popupentry.cc
@@ -35,7 +35,7 @@ PopupEntry::PopupEntry(const Glib::ustring& path)
 
   button_ = new Gtk::Button();
   pack_start(*Gtk::manage(button_), Gtk::PackOptions::SHRINK);
-  button_->set_image_from_icon_name("pan-down-symbolic", Gtk::BuiltinIconSize::BUTTON, true);
+  button_->set_image_from_icon_name("pan-down-symbolic", Gtk::IconSize::INHERIT, true);
 
   set_can_focus();
 }
@@ -76,7 +76,7 @@ int PopupEntry::get_button_width()
   Gtk::Button *const button = new Gtk::Button();
   window.add(*Gtk::manage(button));
 
-  button->set_image_from_icon_name("pan-down-symbolic", Gtk::BuiltinIconSize::BUTTON, true);
+  button->set_image_from_icon_name("pan-down-symbolic", Gtk::IconSize::INHERIT, true);
 
   // Urgh.  Hackish :/
   window.move(-500, -500);
diff --git a/examples/others/dnd/dndwindow.cc b/examples/others/dnd/dndwindow.cc
index 0711cef..f96db1a 100644
--- a/examples/others/dnd/dndwindow.cc
+++ b/examples/others/dnd/dndwindow.cc
@@ -35,14 +35,14 @@ DnDWindow::DnDWindow()
   m_trashcan_closed = Gdk::Pixbuf::create_from_xpm_data(trashcan_closed_xpm);
 
   //Targets:
-  m_listTargets.push_back( Gtk::TargetEntry("STRING", Gtk::TargetFlags(0), TARGET_STRING) );
-  m_listTargets.push_back( Gtk::TargetEntry("text/plain", Gtk::TargetFlags(0), TARGET_STRING) );
-  m_listTargets.push_back( Gtk::TargetEntry("application/x-rootwin-drop", Gtk::TargetFlags(0), 
TARGET_ROOTWIN) );
+  m_listTargets.push_back("STRING");
+  m_listTargets.push_back("text/plain");
+  m_listTargets.push_back("application/x-rootwin-drop");
 
   //Targets without rootwin:
   m_listTargetsNoRoot.assign(m_listTargets.begin(), --m_listTargets.end());
 
-  m_Label_Drop.drag_dest_set(m_listTargetsNoRoot, Gtk::DestDefaults::ALL, Gdk::DragAction::COPY | 
Gdk::DragAction::MOVE);
+  m_Label_Drop.drag_dest_set(Gdk::ContentFormats::create(m_listTargetsNoRoot), Gtk::DestDefaults::ALL, 
Gdk::DragAction::COPY | Gdk::DragAction::MOVE);
 
   m_Label_Drop.signal_drag_data_received().connect( sigc::mem_fun(*this, 
&DnDWindow::on_label_drop_drag_data_received) );
 
@@ -50,7 +50,7 @@ DnDWindow::DnDWindow()
   m_Label_Drop.set_hexpand(true);
   m_Label_Drop.set_vexpand(true);
 
-  m_Label_Popup.drag_dest_set(m_listTargetsNoRoot, Gtk::DestDefaults::ALL, Gdk::DragAction::COPY | 
Gdk::DragAction::MOVE);
+  m_Label_Popup.drag_dest_set(Gdk::ContentFormats::create(m_listTargetsNoRoot), Gtk::DestDefaults::ALL, 
Gdk::DragAction::COPY | Gdk::DragAction::MOVE);
 
   m_Grid.attach(m_Label_Popup, 1, 1);
   m_Label_Popup.set_hexpand(true);
@@ -73,7 +73,7 @@ DnDWindow::DnDWindow()
 
   /* Drag site */
 
-  m_Button.drag_source_set(m_listTargets, Gdk::ModifierType::BUTTON1_MASK | Gdk::ModifierType::BUTTON3_MASK,
+  m_Button.drag_source_set(Gdk::ContentFormats::create(m_listTargets), Gdk::ModifierType::BUTTON1_MASK | 
Gdk::ModifierType::BUTTON3_MASK,
                            Gdk::DragAction::COPY | Gdk::DragAction::MOVE);
 
   m_Button.drag_source_set_icon(m_drag_icon);
@@ -93,7 +93,7 @@ DnDWindow::~DnDWindow()
 }
 
 
-void DnDWindow::on_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, 
const Gtk::SelectionData& selection_data, guint, guint time)
+void DnDWindow::on_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, 
const Gtk::SelectionData& selection_data, guint time)
 {
   const int length = selection_data.get_length();
   const guchar* data = selection_data.get_data();
@@ -127,7 +127,7 @@ void DnDWindow::on_label_popup_drag_leave(const Glib::RefPtr<Gdk::DragContext>&,
  }
 }
 
-void DnDWindow::on_image_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const 
Gtk::SelectionData& selection_data, guint, guint time)
+void DnDWindow::on_image_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const 
Gtk::SelectionData& selection_data, guint time)
 {
   const int length = selection_data.get_length();
   const guchar* data = selection_data.get_data();
@@ -153,7 +153,7 @@ bool DnDWindow::on_image_drag_motion(const Glib::RefPtr<Gdk::DragContext>& conte
            G_OBJECT_TYPE_NAME (source_widget) :
            "NULL");
 
-  for(const auto& name : context->list_targets())
+  for(const auto& name : context->get_formats()->get_mime_types())
   {
     g_print ("%s\n", name.c_str());
   }
@@ -176,7 +176,7 @@ bool DnDWindow::on_image_drag_drop(const Glib::RefPtr<Gdk::DragContext>& context
 
   m_Image.set(m_trashcan_closed);
 
-  std::vector<std::string> targets = context->list_targets();
+  const auto targets = context->get_formats()->get_mime_types();
   if(!targets.empty())
   {
     drag_get_data( context, targets[0], time );
@@ -186,9 +186,9 @@ bool DnDWindow::on_image_drag_drop(const Glib::RefPtr<Gdk::DragContext>& context
 }
 
 
-void DnDWindow::on_button_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, Gtk::SelectionData& 
selection_data, guint info, guint)
+void DnDWindow::on_button_drag_data_get(const Glib::RefPtr<Gdk::DragContext>&, Gtk::SelectionData& 
selection_data, guint)
 {
-  if(info == TARGET_ROOTWIN)
+  if(selection_data.get_target() == "application/x-rootwin-drop")
     g_print ("I was dropped on the rootwin\n");
   else
     selection_data.set(selection_data.get_target(),
@@ -242,7 +242,7 @@ void DnDWindow::create_popup()
       auto pButton = Gtk::manage(new Gtk::Button(buffer));
       pGrid->attach(*pButton, i, j, 1, 1);
 
-      pButton->drag_dest_set(m_listTargetsNoRoot, Gtk::DestDefaults::ALL, Gdk::DragAction::COPY | 
Gdk::DragAction::MOVE);
+      pButton->drag_dest_set(Gdk::ContentFormats::create(m_listTargetsNoRoot), Gtk::DestDefaults::ALL, 
Gdk::DragAction::COPY | Gdk::DragAction::MOVE);
       pButton->signal_drag_motion().connect( sigc::mem_fun(*this, &DnDWindow::on_popup_button_drag_motion), 
true );
       pButton->signal_drag_leave().connect( sigc::mem_fun(*this, &DnDWindow::on_popup_button_drag_leave) );
     }
diff --git a/examples/others/dnd/dndwindow.h b/examples/others/dnd/dndwindow.h
index 43807de..9b09334 100644
--- a/examples/others/dnd/dndwindow.h
+++ b/examples/others/dnd/dndwindow.h
@@ -1,5 +1,3 @@
-//$Id: dndwindow.h 114 2004-02-10 14:50:18Z murrayc $ -*- c++ -*-
-
 /* gtkmm example Copyright (C) 2002 gtkmm development team
  *
  * This program is free software; you can redistribute it and/or modify
@@ -33,16 +31,16 @@ protected:
   void create_popup();
 
   //Signal handlers:
-  void on_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const 
Gtk::SelectionData& selection_data, guint info, guint time);
+  void on_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const 
Gtk::SelectionData& selection_data, guint time);
   bool on_label_popup_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time);
   void on_label_popup_drag_leave(const Glib::RefPtr<Gdk::DragContext>& context, guint time);
 
-  void on_image_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const 
Gtk::SelectionData& selection_data, guint info, guint time);
+  void on_image_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const 
Gtk::SelectionData& selection_data, guint time);
   bool on_image_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time);
   void on_image_drag_leave(const Glib::RefPtr<Gdk::DragContext>& context, guint time);
   bool on_image_drag_drop(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time);
 
-  void on_button_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& 
selection_data, guint info, guint time);
+  void on_button_drag_data_get(const Glib::RefPtr<Gdk::DragContext>& context, Gtk::SelectionData& 
selection_data, guint time);
   void on_button_drag_data_delete(const Glib::RefPtr<Gdk::DragContext>& context);
 
   bool on_popdown_timeout();
@@ -70,16 +68,8 @@ protected:
   sigc::connection m_popdown_timer;
   sigc::connection m_popup_timer;
 
-  //Positions in the targets list:
-  enum
-  {
-    TARGET_STRING,
-    TARGET_ROOTWIN
-  };
-
   //Targets:
-  typedef std::vector<Gtk::TargetEntry> type_vecTargets;
-  type_vecTargets m_listTargets, m_listTargetsNoRoot;
+  std::vector<Glib::ustring> m_listTargets, m_listTargetsNoRoot;
 };
 
 #endif // GTKMM_EXAMPLE_DNDWINDOW_H


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