[nautilus/wip/antoniof/gtk4-preparation-step-event-controllers: 20/35] list-view: Cleanup long press gesture at ::finalize
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/gtk4-preparation-step-event-controllers: 20/35] list-view: Cleanup long press gesture at ::finalize
- Date: Wed, 22 Dec 2021 01:38:49 +0000 (UTC)
commit 2ea3697563d9504e862894c92216345b980d51e0
Author: António Fernandes <antoniof gnome org>
Date: Fri Aug 6 02:01:57 2021 +0100
list-view: Cleanup long press gesture at ::finalize
Also, restyle code to make it more readable.
src/nautilus-list-view-private.h | 1 +
src/nautilus-list-view.c | 36 ++++++++++++++++++++----------------
2 files changed, 21 insertions(+), 16 deletions(-)
---
diff --git a/src/nautilus-list-view-private.h b/src/nautilus-list-view-private.h
index 0ca8b70b3..5ec3b9f5a 100644
--- a/src/nautilus-list-view-private.h
+++ b/src/nautilus-list-view-private.h
@@ -76,5 +76,6 @@ struct NautilusListViewDetails {
GtkGesture *tree_view_multi_press_gesture;
GtkEventController *motion_controller;
GtkEventController *key_controller;
+ GtkGesture *long_press_gesture;
};
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index c0fb18644..b8248e0bc 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -2000,7 +2000,7 @@ create_and_set_up_tree_view (NautilusListView *view)
GList *l;
gchar **default_column_order, **default_visible_columns;
GtkWidget *content_widget;
- GtkGesture *longpress_gesture;
+ GtkGesture *gesture;
GtkEventController *controller;
content_widget = nautilus_files_view_get_content_widget (NAUTILUS_FILES_VIEW (view));
@@ -2046,26 +2046,28 @@ create_and_set_up_tree_view (NautilusListView *view)
"changed",
G_CALLBACK (list_selection_changed_callback), view, 0);
- view->details->tree_view_drag_gesture = gtk_gesture_drag_new (GTK_WIDGET (view->details->tree_view));
+ gesture = gtk_gesture_drag_new (GTK_WIDGET (view->details->tree_view));
+ view->details->tree_view_drag_gesture = gesture;
- gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (view->details->tree_view_drag_gesture),
+ gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
GTK_PHASE_CAPTURE);
- gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (view->details->tree_view_drag_gesture), 0);
+ gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
- g_signal_connect (view->details->tree_view_drag_gesture, "drag-begin",
+ g_signal_connect (gesture, "drag-begin",
G_CALLBACK (on_tree_view_drag_gesture_drag_begin), view);
- g_signal_connect (view->details->tree_view_drag_gesture, "drag-update",
+ g_signal_connect (gesture, "drag-update",
G_CALLBACK (on_tree_view_drag_gesture_drag_update), view);
- view->details->tree_view_multi_press_gesture = gtk_gesture_multi_press_new (GTK_WIDGET
(view->details->tree_view));
+ gesture = gtk_gesture_multi_press_new (GTK_WIDGET (view->details->tree_view));
+ view->details->tree_view_multi_press_gesture = gesture;
- gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER
(view->details->tree_view_multi_press_gesture),
+ gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
GTK_PHASE_CAPTURE);
- gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (view->details->tree_view_multi_press_gesture), 0);
+ gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (gesture), 0);
- g_signal_connect (view->details->tree_view_multi_press_gesture, "pressed",
+ g_signal_connect (gesture, "pressed",
G_CALLBACK (on_tree_view_multi_press_gesture_pressed), view);
- g_signal_connect (view->details->tree_view_multi_press_gesture, "released",
+ g_signal_connect (gesture, "released",
G_CALLBACK (on_tree_view_multi_press_gesture_released), view);
controller = gtk_event_controller_motion_new (GTK_WIDGET (view->details->tree_view));
@@ -2118,12 +2120,13 @@ create_and_set_up_tree_view (NautilusListView *view)
g_signal_connect_object (view->details->model, "get-icon-scale",
G_CALLBACK (get_icon_scale_callback), view, 0);
- longpress_gesture = gtk_gesture_long_press_new (GTK_WIDGET (content_widget));
- gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (longpress_gesture),
+ gesture = gtk_gesture_long_press_new (GTK_WIDGET (content_widget));
+ view->details->long_press_gesture = gesture;
+
+ gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (gesture),
GTK_PHASE_CAPTURE);
- gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (longpress_gesture),
- TRUE);
- g_signal_connect (longpress_gesture,
+ gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (gesture), TRUE);
+ g_signal_connect (gesture,
"pressed",
(GCallback) on_longpress_gesture_pressed_event,
view);
@@ -3576,6 +3579,7 @@ nautilus_list_view_dispose (GObject *object)
g_clear_object (&list_view->details->tree_view_multi_press_gesture);
g_clear_object (&list_view->details->motion_controller);
g_clear_object (&list_view->details->key_controller);
+ g_clear_object (&list_view->details->long_press_gesture);
G_OBJECT_CLASS (nautilus_list_view_parent_class)->dispose (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]