[gtkmm] DragContext: Deprecate create(), adding Window::drag_begin().



commit eb4fa7c430ddc98e0622d955ef8728d6db366f4e
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 |    2 ++
 5 files changed, 56 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c8b661a..6938360 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2011-01-13  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>
+
 	Widget: Make some methods protected.
 
 	* gtk/src/widget.hg: set_window(), set_has_window(), and get_requisition() 
diff --git a/gdk/src/dragcontext.hg b/gdk/src/dragcontext.hg
index cceef3e..7bb38eb 100644
--- a/gdk/src/dragcontext.hg
+++ b/gdk/src/dragcontext.hg
@@ -42,9 +42,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 50517b8..244dee4 100644
--- a/gdk/src/window.ccg
+++ b/gdk/src/window.ccg
@@ -59,4 +59,30 @@ 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 51f617c..630cb2b 100644
--- a/gdk/src/window.hg
+++ b/gdk/src/window.hg
@@ -19,6 +19,7 @@ _CONFIGINCLUDE(gdkmmconfig.h)
 
 #include <glibmm/object.h>
 //#include <gdkmm/cursor.h>
+#include <gdkmm/dragcontext.h>
 #include <gdkmm/types.h>
 #include <cairomm/region.h>
 #include <cairomm/pattern.h>
@@ -247,6 +248,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 e0338fe..bc1a4c0 100644
--- a/tools/m4/convert_gdk.m4
+++ b/tools/m4/convert_gdk.m4
@@ -272,6 +272,8 @@ _CONVERSION(`NativeWindow',`GdkNativeWindow',`($2)($3)')
 _CONVERSION(`GdkEvent*',`const GdkEvent*',`($2)($3)')
 
 
+_CONVERSION(`GdkDragContext*',`Glib::RefPtr<DragContext>',Glib::wrap($3, true))
 _CONVERSION(`GdkDragContext*',`Glib::RefPtr<Gdk::DragContext>',Glib::wrap($3, true))
 
 _CONVERSION(`const Widgetpath&',`GtkWidgetPath*',`const_cast<WidgetPath&>($3).gobj()')
+



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