[gtk/dnd-gestures-2: 183/242] calendar: Use gdk_drag_begin
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/dnd-gestures-2: 183/242] calendar: Use gdk_drag_begin
- Date: Tue, 7 Jan 2020 19:58:46 +0000 (UTC)
commit f14e7cb56734f678a89208b2d04bb1a41d00f83c
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jan 6 16:12:18 2020 -0500
calendar: Use gdk_drag_begin
Use gdk_drag_begin directly for one-off drags.
gtk/gtkcalendar.c | 25 +++++++++++++++++++------
1 file changed, 19 insertions(+), 6 deletions(-)
---
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;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]