]> Pileus Git - ~andy/gtk/commitdiff
Implement gdk_drag_context_{get,set}_device in Quartz backend
authorKristian Rietveld <kris@gtk.org>
Tue, 29 Jun 2010 11:10:44 +0000 (13:10 +0200)
committerKristian Rietveld <kris@gtk.org>
Wed, 30 Jun 2010 08:56:44 +0000 (10:56 +0200)
gdk/quartz/gdkdnd-quartz.c
gdk/quartz/gdkprivate-quartz.h

index 2292d1fbb1018b7ec0c02a750f29a5d0a49f66e0..a330300448b23b506f76af2c1b8f1a4368290d8c 100644 (file)
@@ -87,6 +87,56 @@ gdk_drag_context_new (void)
   return (GdkDragContext *)g_object_new (gdk_drag_context_get_type (), NULL);
 }
 
+/**
+ * gdk_drag_context_set_device:
+ * @context: a #GdkDragContext
+ * @device: a #GdkDevice
+ *
+ * Associates a #GdkDevice to @context, so all Drag and Drop events
+ * for @context are emitted as if they came from this device.
+ **/
+void
+gdk_drag_context_set_device (GdkDragContext *context,
+                             GdkDevice      *device)
+{
+  GdkDragContextPrivate *private;
+
+  g_return_if_fail (GDK_IS_DRAG_CONTEXT (context));
+  g_return_if_fail (GDK_IS_DEVICE (device));
+
+  private = GDK_DRAG_CONTEXT_PRIVATE (context);
+
+  if (private->device)
+    {
+      g_object_unref (private->device);
+      private->device = NULL;
+    }
+
+  if (device)
+    private->device = g_object_ref (device);
+}
+
+/**
+ * gdk_drag_context_get_device:
+ * @context: a #GdkDragContext
+ *
+ * Returns the #GdkDevice associated to the drag context.
+ *
+ * Returns: The #GdkDevice associated to @context.
+ **/
+GdkDevice *
+gdk_drag_context_get_device (GdkDragContext *context)
+{
+  GdkDragContextPrivate *private;
+
+  g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL);
+
+  private = GDK_DRAG_CONTEXT_PRIVATE (context);
+
+  return private->device;
+}
+
+
 GdkDragContext *_gdk_quartz_drag_source_context = NULL;
 
 GdkDragContext *
index b1421fd74967c6fab4d19341b6f886c225069152..dc747e47919463a29e59aabb2059320107aee44d 100644 (file)
@@ -94,6 +94,7 @@ struct _GdkCursorPrivate
 struct _GdkDragContextPrivate
 {
   id <NSDraggingInfo> dragging_info;
+  GdkDevice *device;
 };
 
 extern GdkDisplay *_gdk_display;