[nautilus/wip/antoniof/new-list-view-continuation: 140/141] list-view: Hide expander if subdirectory is empty
- From: Corey Berla <coreyberla src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/wip/antoniof/new-list-view-continuation: 140/141] list-view: Hide expander if subdirectory is empty
- Date: Fri, 5 Aug 2022 16:45:26 +0000 (UTC)
commit aeaf4b00186ec405920ab98e6db0600fb0bcc5eb
Author: António Fernandes <antoniof gnome org>
Date: Fri Apr 15 12:15:58 2022 +0100
list-view: Hide expander if subdirectory is empty
The old list view used to add a dummy row with the "(empty)" label.
That solution required a lot of code gymnastics to special case
the dummy row everywhere, which was error-prone.
So, for the new list view, I wanted to avoid that solution. For
now, the simplest solution is to follow the example of other
file managers and hide the expander if the folder is found to be
empty after trying to expand it.
src/nautilus-list-view.c | 7 +++++++
src/nautilus-view-model.c | 11 +++++++++++
2 files changed, 18 insertions(+)
---
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index ff80169a8..28a19cd7b 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -970,6 +970,13 @@ on_subdirectory_done_loading (NautilusDirectory *directory,
item = NAUTILUS_VIEW_ITEM (gtk_tree_list_row_get_item (row));
nautilus_view_item_set_loading (item, FALSE);
+
+ if (!nautilus_directory_is_not_empty (directory))
+ {
+ /* Collapse to trigger a reassessment of the tree in order to make the
+ * expander disappear. */
+ gtk_tree_list_row_set_expanded (row, FALSE);
+ }
}
static void
diff --git a/src/nautilus-view-model.c b/src/nautilus-view-model.c
index 82692ccdd..f3ff42f1d 100644
--- a/src/nautilus-view-model.c
+++ b/src/nautilus-view-model.c
@@ -1,5 +1,6 @@
#include "nautilus-view-model.h"
#include "nautilus-view-item.h"
+#include "nautilus-directory.h"
#include "nautilus-global-preferences.h"
struct _NautilusViewModel
@@ -258,6 +259,16 @@ create_model_func (GObject *item,
{
return NULL;
}
+ else /* Check whether we already know it to be empty. */
+ {
+ g_autoptr (NautilusDirectory) directory = NULL;
+ directory = nautilus_directory_get_for_file (file);
+ if (nautilus_directory_are_all_files_seen (directory) &&
+ !nautilus_directory_is_not_empty (directory))
+ {
+ return NULL;
+ }
+ }
store = g_hash_table_lookup (self->directory_reverse_map, file);
if (store == NULL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]