[nautilus] sidebar: Change location on hover even when not a valid drop target
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] sidebar: Change location on hover even when not a valid drop target
- Date: Thu, 7 Jul 2022 22:43:48 +0000 (UTC)
commit ddbaaec6ae41c725ba58b6b8a4812b30ecf01fac
Author: Corey Berla <corey berla me>
Date: Sun Jul 3 14:36:02 2022 -0700
sidebar: Change location on hover even when not a valid drop target
The "change location on hover" feature should work on any location
you can open, but it currently only works for valid drop targets.
Move the timer to the beginning of the motion handler so the
hover timer begins for locations that aren't valid drop targets.
This may cause hover_timer to receive a NULL row or a row
that doesn't have a valid uri so check for both of those
conditions in hover_timer().
Fixes: https://gitlab.gnome.org/GNOME/nautilus/-/issues/1787
src/gtk/nautilusgtkplacessidebar.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/src/gtk/nautilusgtkplacessidebar.c b/src/gtk/nautilusgtkplacessidebar.c
index d04889f86..6400e6eab 100644
--- a/src/gtk/nautilusgtkplacessidebar.c
+++ b/src/gtk/nautilusgtkplacessidebar.c
@@ -1476,11 +1476,14 @@ hover_timer (gpointer user_data)
NAUTILUS_PREFERENCES_OPEN_FOLDER_ON_DND_HOVER);
sidebar->hover_timer_id = 0;
- if (open_folder_on_hover)
+ if (open_folder_on_hover && sidebar->hover_row != NULL)
{
g_object_get (sidebar->hover_row, "uri", &uri, NULL);
- location = g_file_new_for_uri (uri);
- emit_open_location (sidebar, location, 0);
+ if (uri != NULL)
+ {
+ location = g_file_new_for_uri (uri);
+ emit_open_location (sidebar, location, 0);
+ }
}
return G_SOURCE_REMOVE;
@@ -1675,6 +1678,7 @@ drag_motion_callback (GtkDropTarget *target,
{
g_clear_handle_id (&sidebar->hover_timer_id, g_source_remove);
sidebar->hover_row = row;
+ sidebar->hover_timer_id = g_timeout_add (HOVER_TIMEOUT, hover_timer, sidebar);
}
/* Workaround https://gitlab.gnome.org/GNOME/gtk/-/issues/5023 */
@@ -1767,8 +1771,6 @@ drag_motion_callback (GtkDropTarget *target,
GFile *dest_file = g_file_new_for_uri (drop_target_uri);
action = emit_drag_action_requested (sidebar, file, g_value_get_boxed (value));
- if (sidebar->hover_timer_id == 0)
- sidebar->hover_timer_id = g_timeout_add (HOVER_TIMEOUT, hover_timer, sidebar);
g_object_unref (dest_file);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]