diff options
author | António Fernandes <antoniof@gnome.org> | 2020-09-17 18:29:03 +0100 |
---|---|---|
committer | António Fernandes <antoniof@gnome.org> | 2020-09-19 13:50:41 +0100 |
commit | f2237185a37e617e375474e3d28d200774f1b752 (patch) | |
tree | 21ebd52e9b76d47da3128b768e5081aa0b2702be | |
parent | 3cdc56c44bf497a7ba91251b26c4685469e7dbba (diff) | |
download | nautilus-f2237185a37e617e375474e3d28d200774f1b752.tar.gz |
starred-directory: Actually implement ::force_reload
The code created to handle the NautilusTagManager::files-changed signal
has been reused for implemeting the NautilusDirectory::force_reload
virtual function.
This is conceptually wrong, because the update_files function doesn't
actually reload the file list. Also, as a side effect, it causes gone
files to reappear as "ghost files" (files without any attributes).
Instead, let's follow what NautilusSearchDirectory does: clear the
current file list after unmonitoring the files, and set the file list
anew the same way it's done on ::init.
Fixes:
https://gitlab.gnome.org/GNOME/nautilus/-/issues/162
https://gitlab.gnome.org/GNOME/nautilus/-/issues/167
-rw-r--r-- | src/nautilus-starred-directory.c | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/src/nautilus-starred-directory.c b/src/nautilus-starred-directory.c index da00a579b..bed4725bf 100644 --- a/src/nautilus-starred-directory.c +++ b/src/nautilus-starred-directory.c @@ -223,12 +223,6 @@ real_is_editable (NautilusDirectory *directory) } static void -real_force_reload (NautilusDirectory *directory) -{ - nautilus_starred_directory_update_files (NAUTILUS_STARRED_DIRECTORY (directory)); -} - -static void real_call_when_ready (NautilusDirectory *directory, NautilusFileAttributes file_attributes, gboolean wait_for_file_list, @@ -478,6 +472,31 @@ nautilus_starred_directory_set_files (NautilusFavoriteDirectory *self) } static void +real_force_reload (NautilusDirectory *directory) +{ + NautilusFavoriteDirectory *self = NAUTILUS_STARRED_DIRECTORY (directory); + + /* Unset current file list */ + for (GList *l = self->files; l != NULL; l = l->next) + { + NautilusFile *file = l->data; + + /* Disconnect change handler */ + g_signal_handlers_disconnect_by_func (file, file_changed, self); + + /* Remove monitors */ + for (GList *m = self->monitor_list; m != NULL; m = m->next) + { + nautilus_file_monitor_remove (file, m->data); + } + } + g_clear_list (&self->files, g_object_unref); + + /* Set a fresh file list */ + nautilus_starred_directory_set_files (self); +} + +static void nautilus_starred_directory_finalize (GObject *object) { NautilusFavoriteDirectory *self; |