From a0f04bdcf368cd789de0407b181bd7c394e642e5 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 21 Dec 2019 19:07:11 -0500 Subject: listbase: Add rubberband selection Implement the typical rubberband selection, including autoscroll. This is only useful with multiselection, and not very compatible with single-click-activate. Therefore, it is not enabled by default, and needs to be turned on explicitly. --- gtk/gtklistitemwidget.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'gtk/gtklistitemwidget.c') diff --git a/gtk/gtklistitemwidget.c b/gtk/gtklistitemwidget.c index 2e6078d704..84e51a166c 100644 --- a/gtk/gtklistitemwidget.c +++ b/gtk/gtklistitemwidget.c @@ -29,6 +29,7 @@ #include "gtkintl.h" #include "gtklistitemfactoryprivate.h" #include "gtklistitemprivate.h" +#include "gtklistbaseprivate.h" #include "gtkmain.h" #include "gtkselectionmodel.h" #include "gtkwidget.h" @@ -309,6 +310,8 @@ gtk_list_item_widget_click_gesture_pressed (GtkGestureClick *gesture, { GtkListItemWidgetPrivate *priv = gtk_list_item_widget_get_instance_private (self); GtkWidget *widget = GTK_WIDGET (self); + GtkWidget * parent = gtk_widget_get_parent (widget); + gboolean rubberband; if (priv->list_item && !priv->list_item->selectable && !priv->list_item->activatable) { @@ -316,7 +319,12 @@ gtk_list_item_widget_click_gesture_pressed (GtkGestureClick *gesture, return; } - if (!priv->list_item || priv->list_item->selectable) + if (GTK_IS_LIST_BASE (parent)) + rubberband = gtk_list_base_get_enable_rubberband (GTK_LIST_BASE (parent)); + else + rubberband = FALSE; + + if (!rubberband && (!priv->list_item || priv->list_item->selectable)) { GdkModifierType state; GdkEvent *event; -- cgit v1.2.1