[nautilus] NautilusWindowSlot: allow the location change if selection has been changed
- From: Marco Trevisan <marcotrevi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] NautilusWindowSlot: allow the location change if selection has been changed
- Date: Mon, 4 Mar 2013 09:51:19 +0000 (UTC)
commit d0b0be2184e0d32536138c4b128a206bf46356ad
Author: Marco Trevisan (TreviƱo) <mail 3v1n0 net>
Date: Sun Mar 3 19:33:19 2013 +0100
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
libnautilus-private/nautilus-file-utilities.c | 42 +++++++++++++++++++++++++
libnautilus-private/nautilus-file-utilities.h | 2 +
src/nautilus-window-slot.c | 10 +++--
3 files changed, 50 insertions(+), 4 deletions(-)
---
diff --git a/libnautilus-private/nautilus-file-utilities.c b/libnautilus-private/nautilus-file-utilities.c
index 8f02c2d..0e44685 100644
--- a/libnautilus-private/nautilus-file-utilities.c
+++ b/libnautilus-private/nautilus-file-utilities.c
@@ -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
diff --git a/libnautilus-private/nautilus-file-utilities.h b/libnautilus-private/nautilus-file-utilities.h
index 0c3b3c8..10b368e 100644
--- a/libnautilus-private/nautilus-file-utilities.h
+++ b/libnautilus-private/nautilus-file-utilities.h
@@ -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 */
diff --git a/src/nautilus-window-slot.c b/src/nautilus-window-slot.c
index 1e1fbeb..a8d50ed 100644
--- a/src/nautilus-window-slot.c
+++ b/src/nautilus-window-slot.c
@@ -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:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]