[gtkmm/gtkmm-2-24] DragContext: Deprecate create(), adding Window::drag_begin().



commit f4292fcae7e93c8f8ce99a5af6a7a50b3d1623f6
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Jan 14 15:37:54 2011 +0100

    DragContext: Deprecate create(), adding Window::drag_begin().
    
    * gdk/src/dragcontext.hg: Deprecate the constructor and create(), because
    the equivalent gdk_drag_context_new() is deprecated.
    * gdk/src/window.[hg|ccg]: Added begin_drag(), wrapping gdk_drag_begin(),
    mentioned in the deprecation comment.
    * tools/m4/convert_gdk.m4: Added a DragContext conversion.

 ChangeLog               |   10 ++++++++++
 gdk/src/dragcontext.hg  |    5 +++++
 gdk/src/window.ccg      |   26 ++++++++++++++++++++++++++
 gdk/src/window.hg       |   13 +++++++++++++
 tools/m4/convert_gdk.m4 |    1 +
 5 files changed, 55 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b21d6ab..1a9c3c1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2011-01-14  Murray Cumming  <murrayc murrayc com>
 
+	DragContext: Deprecate create(), adding Window::drag_begin().
+
+	* gdk/src/dragcontext.hg: Deprecate the constructor and create(), because 
+	the equivalent gdk_drag_context_new() is deprecated.
+	* gdk/src/window.[hg|ccg]: Added begin_drag(), wrapping gdk_drag_begin(), 
+	mentioned in the deprecation comment.
+	* tools/m4/convert_gdk.m4: Added a DragContext conversion.
+
+2011-01-14  Murray Cumming  <murrayc murrayc com>
+
 	Fix the make check build.
 
 	* demos/gtk-demo/example_treeview_editable_cells.cc:
diff --git a/gdk/src/dragcontext.hg b/gdk/src/dragcontext.hg
index 1b41b14..26dafb0 100644
--- a/gdk/src/dragcontext.hg
+++ b/gdk/src/dragcontext.hg
@@ -45,9 +45,14 @@ class DragContext : public Glib::Object
   _CLASS_GOBJECT(DragContext, GdkDragContext, GDK_DRAG_CONTEXT, Glib::Object,GObject)
   _IGNORE(gdk_drag_context_ref, gdk_drag_context_unref)
 protected:
+
+  /** @deprecated This method is not useful, you always obtain drag contexts by Gdk::Window::drag_begin() or similar.
+   */
   _CTOR_DEFAULT
 
 public:
+  /** @deprecated This method is not useful, you always obtain drag contexts by Gdk::Window::drag_begin() or similar.
+   */
   _WRAP_CREATE()
 
   _WRAP_METHOD(void drag_status(DragAction action, guint32 time), gdk_drag_status)
diff --git a/gdk/src/window.ccg b/gdk/src/window.ccg
index 0170653..eff082f 100644
--- a/gdk/src/window.ccg
+++ b/gdk/src/window.ccg
@@ -92,5 +92,31 @@ void Window::restack(bool above)
   gdk_window_restack(gobj(), NULL, above);
 }
 
+Glib::RefPtr<DragContext> Window::drag_begin(const Glib::StringArrayHandle& targets))
+{
+  Glib::RefPtr<DragContext> result;
+  
+  //Put it into a real container that we can use:
+  std::vector<Glib::ustring> targets_copy = targets;
+   
+  //Create array of target GdkAtoms from target strings:
+  if(!targets_copy.empty())
+  {
+    GdkAtom* pAtoms = new GdkAtom[targets_copy.size()];
+
+    for(guint i = 0; i < targets_copy.size(); ++i)
+    {
+      *pAtoms = Gdk::AtomString::to_c_type(targets_copy[i]);
+    }
+
+    result = Glib::wrap(gdk_drag_begin(gobj(), targets), true);
+
+    delete[] pAtoms;
+  }
+
+  return result;
+}
+
+
 } // namespace Gdk
 
diff --git a/gdk/src/window.hg b/gdk/src/window.hg
index 8096235..c834559 100644
--- a/gdk/src/window.hg
+++ b/gdk/src/window.hg
@@ -24,6 +24,7 @@ _CONFIGINCLUDE(gdkmmconfig.h)
 #include <gdkmm/drawable.h>
 #include <gdkmm/bitmap.h>
 //#include <gdkmm/cursor.h>
+#include <gdkmm/dragcontext.h>
 #include <gdkmm/types.h>
 
 _DEFS(gdkmm,gdk)
@@ -248,6 +249,18 @@ public:
   _WRAP_METHOD(void begin_resize_drag(WindowEdge  edge, int button, int root_x, int root_y, guint32 timestamp), gdk_window_begin_resize_drag)
   _WRAP_METHOD(void begin_move_drag(int button, int root_x, int root_y, guint32 timestamp), gdk_window_begin_move_drag)
 
+  /** Starts a drag and creates a new drag context for it.
+   * 
+   * This method is called by the drag source.
+   * @param window The source window for this drag.
+   * @param targets A list of the offered targets names.
+   * @return A newly created Gdk::DragContext.
+   *
+   * @newin{2,24}
+   */
+  Glib::RefPtr<DragContext> drag_begin(const Glib::StringArrayHandle& targets);
+  _IGNORE(gdk_drag_begin)
+
   _WRAP_METHOD(void invalidate_rect(const Rectangle& rect, bool invalidate_children), gdk_window_invalidate_rect)
 
   /** A convenience wrapper around invalidate_region() which
diff --git a/tools/m4/convert_gdk.m4 b/tools/m4/convert_gdk.m4
index 5dd2bf0..4dcf37a 100644
--- a/tools/m4/convert_gdk.m4
+++ b/tools/m4/convert_gdk.m4
@@ -277,3 +277,4 @@ _CONVERSION(`GdkEvent*',`const GdkEvent*',`($2)($3)')
 
 
 _CONVERSION(`GdkDragContext*',`Glib::RefPtr<Gdk::DragContext>',Glib::wrap($3, true))
+_CONVERSION(`GdkDragContext*',`Glib::RefPtr<DragContext>',Glib::wrap($3, true))



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