[gtk/listview-dnd: 7/15] columnview: Autoscroll during DND
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/listview-dnd: 7/15] columnview: Autoscroll during DND
- Date: Fri, 19 Jun 2020 19:28:09 +0000 (UTC)
commit 470a1aabddaf508550bf04e5d03e72b09da8bd16
Author: Matthias Clasen <mclasen redhat com>
Date: Fri Jun 19 12:22:25 2020 -0400
columnview: Autoscroll during DND
Use a drop motion controller to autoscroll horizontally
while a drag operation is hovering over the list. The
vertical scrolling is handled by the listview.
gtk/gtkcolumnview.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
---
diff --git a/gtk/gtkcolumnview.c b/gtk/gtkcolumnview.c
index 614f82e5d4..1b6be13a44 100644
--- a/gtk/gtkcolumnview.c
+++ b/gtk/gtkcolumnview.c
@@ -28,6 +28,7 @@
#include "gtkcolumnviewlayoutprivate.h"
#include "gtkcolumnviewsorterprivate.h"
#include "gtkcssnodeprivate.h"
+#include "gtkdropcontrollermotion.h"
#include "gtkintl.h"
#include "gtklistview.h"
#include "gtkmain.h"
@@ -1102,6 +1103,29 @@ header_key_pressed (GtkEventControllerKey *controller,
return FALSE;
}
+static void
+gtk_column_view_drag_motion (GtkDropControllerMotion *motion,
+ double x,
+ double y,
+ gpointer unused)
+{
+ GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (motion));
+ GtkColumnView *self = GTK_COLUMN_VIEW (widget);
+ double hx, hy;
+
+ gtk_widget_translate_coordinates (widget, self->header, x, 0, &hx, &hy);
+ update_autoscroll (GTK_COLUMN_VIEW (widget), hx);
+}
+
+static void
+gtk_column_view_drag_leave (GtkDropControllerMotion *motion,
+ gpointer unused)
+{
+ GtkWidget *widget = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (motion));
+
+ remove_autoscroll (GTK_COLUMN_VIEW (widget));
+}
+
static void
gtk_column_view_init (GtkColumnView *self)
{
@@ -1130,6 +1154,11 @@ gtk_column_view_init (GtkColumnView *self)
g_signal_connect (controller, "key-pressed", G_CALLBACK (header_key_pressed), self);
gtk_widget_add_controller (GTK_WIDGET (self), controller);
+ controller = gtk_drop_controller_motion_new ();
+ g_signal_connect (controller, "motion", G_CALLBACK (gtk_column_view_drag_motion), NULL);
+ g_signal_connect (controller, "leave", G_CALLBACK (gtk_column_view_drag_leave), NULL);
+ gtk_widget_add_controller (GTK_WIDGET (self), controller);
+
self->sorter = gtk_column_view_sorter_new ();
self->factory = gtk_column_list_item_factory_new (self);
self->listview = GTK_LIST_VIEW (gtk_list_view_new_with_factory (
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]