Merge branch 'matthiasc/for-master' into 'master'

Matthiasc/for master

See merge request GNOME/gtk!2538
This commit is contained in:
Matthias Clasen 2020-09-06 19:38:56 +00:00
commit 06c866f45e
2 changed files with 35 additions and 5 deletions

View File

@ -2910,6 +2910,16 @@ dnd_finished_cb (GdkDrag *drag,
priv->drag = NULL;
}
static void
dnd_cancel_cb (GdkDrag *drag,
GdkDragCancelReason reason,
GtkText *self)
{
GtkTextPrivate *priv = gtk_text_get_instance_private (self);
priv->drag = NULL;
}
static void
gtk_text_drag_gesture_update (GtkGestureDrag *gesture,
double offset_x,
@ -2973,6 +2983,7 @@ gtk_text_drag_gesture_update (GtkGestureDrag *gesture,
g_object_unref (content);
g_signal_connect (drag, "dnd-finished", G_CALLBACK (dnd_finished_cb), self);
g_signal_connect (drag, "cancel", G_CALLBACK (dnd_cancel_cb), self);
paintable = gtk_text_util_create_drag_icon (widget, text, -1);
gtk_drag_icon_set_from_paintable (drag, paintable, ranges[0], 0);
@ -2986,6 +2997,9 @@ gtk_text_drag_gesture_update (GtkGestureDrag *gesture,
g_free (text);
priv->in_drag = FALSE;
/* Deny the gesture so we don't get further updates */
gtk_gesture_set_state (priv->drag_gesture, GTK_EVENT_SEQUENCE_DENIED);
}
}
else

View File

@ -7262,6 +7262,10 @@ gtk_text_view_drag_gesture_update (GtkGestureDrag *gesture,
gtk_text_view_start_selection_dnd (text_view, &iter, event,
start_x, start_y);
/* Deny the gesture so we don't get further updates */
gtk_gesture_set_state (text_view->priv->drag_gesture,
GTK_EVENT_SEQUENCE_DENIED);
return;
}
else
@ -7275,6 +7279,8 @@ gtk_text_view_drag_gesture_update (GtkGestureDrag *gesture,
return;
}
g_assert (data != NULL);
/* Text selection */
if (data->granularity == SELECT_CHARACTERS)
{
@ -7782,6 +7788,14 @@ dnd_finished_cb (GdkDrag *drag,
self->priv->drag = NULL;
}
static void
dnd_cancel_cb (GdkDrag *drag,
GdkDragCancelReason reason,
GtkTextView *self)
{
self->priv->drag = NULL;
}
static void
gtk_text_view_start_selection_dnd (GtkTextView *text_view,
const GtkTextIter *iter,
@ -7808,9 +7822,11 @@ gtk_text_view_start_selection_dnd (GtkTextView *text_view,
surface = gdk_event_get_surface (event);
device = gdk_event_get_device (event);
drag = gdk_drag_begin (surface, device, content, actions, x, y);
g_object_unref (content);
g_signal_connect (drag, "dnd-finished", G_CALLBACK (dnd_finished_cb), text_view);
g_signal_connect (drag, "cancel", G_CALLBACK (dnd_cancel_cb), text_view);
if (gtk_text_buffer_get_selection_bounds (buffer, &start, &end))
{