[nautilus] list-base: Update drag action without holding a DropTarget in priv
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] list-base: Update drag action without holding a DropTarget in priv
- Date: Sun, 3 Jul 2022 13:57:23 +0000 (UTC)
commit ec9a7beceee648cd14fb0bf7cff27fc478caff6d
Author: Corey Berla <corey berla me>
Date: Sat Jul 2 19:50:03 2022 -0700
list-base: Update drag action without holding a DropTarget in priv
This reverts commit e39102ede3e4cf4c9c3a8bc28e268cae6f340838.
Stop holding a GtkDropTarget in priv and unnecessarily loading the
preferred action every time in begin_loading() (even if we aren't
in a drag). In begin_loading() flag the drag_view_action as
invalid and recalculate the preferred action in on_drag_view_motion()
when drag_view_action_invalidated is TRUE;
src/nautilus-list-base.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/src/nautilus-list-base.c b/src/nautilus-list-base.c
index 622ee4eb4..7c193d55f 100644
--- a/src/nautilus-list-base.c
+++ b/src/nautilus-list-base.c
@@ -50,7 +50,7 @@ struct _NautilusListBasePrivate
GdkDragAction drag_item_action;
GdkDragAction drag_view_action;
guint hover_timer_id;
- GtkDropTarget *view_drop_target;
+ gboolean drag_view_action_invalidated;
};
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (NautilusListBase, nautilus_list_base, NAUTILUS_TYPE_FILES_VIEW)
@@ -803,6 +803,16 @@ on_view_drag_motion (GtkDropTarget *target,
NautilusListBase *self = user_data;
NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
+ if (priv->drag_view_action_invalidated)
+ {
+ NautilusFile *dest_file;
+
+ dest_file = nautilus_files_view_get_directory_as_file (NAUTILUS_FILES_VIEW (self));
+ priv->drag_view_action = get_preferred_action (dest_file,
+ gtk_drop_target_get_value (target));
+ priv->drag_view_action_invalidated = FALSE;
+ }
+
return priv->drag_view_action;
}
@@ -934,9 +944,8 @@ real_begin_loading (NautilusFilesView *files_view)
priv->deny_background_click = FALSE;
/* When DnD is used to navigate between directories, the normal callbacks
- * are ignored. Update DnD variables here upon navigating to a directory*/
- priv->drag_view_action = get_preferred_action (nautilus_files_view_get_directory_as_file (files_view),
- gtk_drop_target_get_value (priv->view_drop_target));
+ * are ignored. Invalidate / clear actions when changing directories*/
+ priv->drag_view_action_invalidated = TRUE;
priv->drag_item_action = 0;
}
@@ -1703,7 +1712,6 @@ nautilus_list_base_get_model (NautilusListBase *self)
void
nautilus_list_base_setup_gestures (NautilusListBase *self)
{
- NautilusListBasePrivate *priv = nautilus_list_base_get_instance_private (self);
GtkWidget *view_ui = nautilus_list_base_get_view_ui (self);
GtkEventController *controller;
GtkDropTarget *drop_target;
@@ -1730,5 +1738,4 @@ nautilus_list_base_setup_gestures (NautilusListBase *self)
g_signal_connect (drop_target, "motion", G_CALLBACK (on_view_drag_motion), self);
g_signal_connect (drop_target, "drop", G_CALLBACK (on_view_drop), self);
gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (drop_target));
- priv->view_drop_target = drop_target;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]