From: Matthias Clasen Date: Mon, 6 Jan 2020 21:12:18 +0000 (-0500) Subject: calendar: Use gdk_drag_begin X-Git-Tag: archive/raspbian/4.4.1+ds1-2+rpi1^2~18^2~20^2~354^2~89 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5144d151682a504d4d18cd001153c3fd94ea89e8;p=gtk4.git calendar: Use gdk_drag_begin Use gdk_drag_begin directly for one-off drags. --- diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c index 9892f99e22..91259b6922 100644 --- a/gtk/gtkcalendar.c +++ b/gtk/gtkcalendar.c @@ -87,6 +87,9 @@ #include "gtkeventcontrollerscroll.h" #include "gtkeventcontrollerkey.h" #include "gtkdragsource.h" +#include "gtknative.h" +#include "gtkicontheme.h" +#include "gtkdragicon.h" #define TIMEOUT_INITIAL 500 #define TIMEOUT_REPEAT 50 @@ -2697,9 +2700,12 @@ gtk_calendar_drag_update (GtkGestureDrag *gesture, GtkCalendar *calendar = GTK_CALENDAR (widget); GtkCalendarPrivate *priv = gtk_calendar_get_instance_private (calendar); gdouble start_x, start_y; - GtkDragSource *source; GdkContentProvider *content; GdkDevice *device; + GdkDrag *drag; + GtkIconTheme *theme; + GdkPaintable *paintable; + GdkSurface *surface; if (!priv->in_drag) return; @@ -2709,13 +2715,20 @@ gtk_calendar_drag_update (GtkGestureDrag *gesture, gtk_gesture_drag_get_start_point (gesture, &start_x, &start_y); - source = gtk_drag_source_new (); + surface = gtk_native_get_surface (gtk_widget_get_native (widget)); + device = gtk_gesture_get_device (GTK_GESTURE (gesture)); + content = get_calendar_content (calendar); - gtk_drag_source_set_content (source, content); + + drag = gdk_drag_begin (surface, device, content, GDK_ACTION_COPY, start_x, start_y); + + theme = gtk_icon_theme_get_for_display (gtk_widget_get_display (widget)); + paintable = gtk_icon_theme_load_icon (theme, "text-x-generic", 32, 0, NULL); + gtk_drag_icon_set_from_paintable (drag, paintable, 0, 0); + g_clear_object (&paintable); + g_object_unref (content); - device = gtk_gesture_get_device (GTK_GESTURE (gesture)); - gtk_drag_source_drag_begin (source, widget, device, start_x, start_y); - g_object_unref (source); + g_object_unref (drag); priv->in_drag = 0; }