[gtk/dnd-gestures-2: 98/175] label: Use gdk_drag_begin



commit 72e933e45b9b77691b1021db5bd3c9260cfefdec
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jan 6 16:00:32 2020 -0500

    label: Use gdk_drag_begin
    
    Use gdk_drag_begin directly for one-off drags.

 gtk/gtklabel.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 6b56dfcfdc..dbaab2545d 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -54,6 +54,7 @@
 #include "gtkpopovermenu.h"
 #include "gtknative.h"
 #include "gtkdragsource.h"
+#include "gtkdragicon.h"
 
 #include "a11y/gtklabelaccessibleprivate.h"
 
@@ -4716,19 +4717,24 @@ gtk_label_drag_gesture_update (GtkGestureDrag *gesture,
     {
       if (gtk_drag_check_threshold (widget, info->drag_start_x, info->drag_start_y, x, y))
        {
-          GtkDragSource *source;
-          GdkPaintable *paintable;
+          GdkDrag *drag;
+          GdkSurface *surface;
           GdkDevice *device;
 
-          source = gtk_drag_source_new ();
-          gtk_drag_source_set_content (source, info->provider);
-          paintable = get_selection_paintable (label);
-          gtk_drag_source_set_icon (source, paintable, 9, 0);
-          g_clear_object (&paintable); 
+          surface = gtk_native_get_surface (gtk_widget_get_native (widget));
           device = gtk_gesture_get_device (GTK_GESTURE (gesture));
-          gtk_drag_source_drag_begin (source, widget, device, info->drag_start_x, info->drag_start_y);
-          g_object_unref (source);
 
+          drag = gdk_drag_begin (surface,
+                                 device,
+                                 info->provider,
+                                 GDK_ACTION_COPY,
+                                 info->drag_start_x,
+                                 info->drag_start_y);
+
+          gtk_drag_icon_set_from_paintable (drag, get_selection_paintable (label), 0, 0);
+
+          g_object_unref (drag);
+          
          info->in_drag = FALSE;
        }
     }


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