Commit d0b0be21 authored by Marco Trevisan's avatar Marco Trevisan 🎺

NautilusWindowSlot: allow the location change if selection has been changed

Added nautilus_file_selection_equal function in the file utils.

This makes nautilus -s to work properly.
Added also indentation fixes.

https://bugzilla.gnome.org/show_bug.cgi?id=694034
parent ce4255cf
......@@ -1296,6 +1296,48 @@ nautilus_get_cached_x_content_types_for_mount (GMount *mount)
return NULL;
}
gboolean
nautilus_file_selection_equal (GList *selection_a,
GList *selection_b)
{
GList *al, *bl;
gboolean selection_matches;
if (selection_a == NULL || selection_b == NULL) {
return (selection_a == selection_b);
}
if (g_list_length (selection_a) != g_list_length (selection_b)) {
return FALSE;
}
selection_matches = TRUE;
for (al = selection_a; al; al = al->next) {
GFile *a_location = nautilus_file_get_location (NAUTILUS_FILE (al->data));
gboolean found = FALSE;
for (bl = selection_b; bl; bl = bl->next) {
GFile *b_location = nautilus_file_get_location (NAUTILUS_FILE (bl->data));
found = g_file_equal (b_location, a_location);
g_object_unref (b_location);
if (found) {
break;
}
}
selection_matches = found;
g_object_unref (a_location);
if (!selection_matches) {
break;
}
}
return selection_matches;
}
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
void
......
......@@ -95,4 +95,6 @@ void nautilus_get_x_content_types_for_mount_async (GMount *mount,
GCancellable *cancellable,
gpointer user_data);
gboolean nautilus_file_selection_equal (GList *selection_a, GList *selection_b);
#endif /* NAUTILUS_FILE_UTILITIES_H */
......@@ -792,19 +792,21 @@ nautilus_window_slot_open_location_full (NautilusWindowSlot *slot,
}
}
if (target_window == window && target_slot == slot &&
GList *old_selection = nautilus_view_get_selection (slot->details->content_view);
if (target_window == window && target_slot == slot && !is_desktop &&
old_location && g_file_equal (old_location, location) &&
!is_desktop) {
nautilus_file_selection_equal (old_selection, new_selection)) {
if (callback != NULL) {
callback (window, location, NULL, user_data);
}
goto done;
}
}
slot->details->pending_use_default_location = ((flags & NAUTILUS_WINDOW_OPEN_FLAG_USE_DEFAULT_LOCATION) != 0);
begin_location_change (target_slot, location, old_location, new_selection,
begin_location_change (target_slot, location, old_location, new_selection,
NAUTILUS_LOCATION_CHANGE_STANDARD, 0, NULL, callback, user_data);
done:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment