From 014741191fa8040b87c284ea7b3e05729c37d41a Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Mon, 23 Sep 2024 06:17:55 +0200
Subject: [PATCH] To browser.py directory loading, add some progress messages.

---
 browser.py | 25 ++++++++++++++++++++-----
 1 file changed, 20 insertions(+), 5 deletions(-)

diff --git a/browser.py b/browser.py
index e1463d6..f218373 100755
--- a/browser.py
+++ b/browser.py
@@ -738,13 +738,16 @@ class MainWindow(Gtk.Window):
                                      UPPER_DIR, is_parent=True)
                 self.gallery.dir_entries += [parent_dir]
             to_set_metadata_on = []
-            for fn in list(listdir(dir_path)):
+            dir_entries = list(listdir(dir_path))
+            dirs_to_enter = []
+            for i, fn in enumerate(dir_entries):
+                msg = f'loading {dir_path}: entry {i+1}/{len(dir_entries)}'
+                print(msg, end='\r')
                 full_path = path_join(dir_path, fn)
                 if isdir(full_path):
                     if self.gallery.show_dirs:
                         self.gallery.dir_entries += [DirItem(dir_path, fn)]
-                    if self.recurse_dirs:
-                        read_directory_into_gallery_items(full_path)
+                    dirs_to_enter += [full_path]
                     continue
                 _, ext = splitext(fn)
                 if ext not in {'.png', '.PNG'}:
@@ -759,8 +762,20 @@ class MainWindow(Gtk.Window):
                 if '' == item.model:
                     to_set_metadata_on += [item]
                 self.gallery.dir_entries += [item]
-            for item in to_set_metadata_on:
-                item.set_metadata(cache)
+            print('')
+            if len(to_set_metadata_on):
+                for i, item in enumerate(to_set_metadata_on):
+                    msg = f'setting metadata: {i+1}/{len(to_set_metadata_on)}'
+                    print(msg, end='\r')
+                    item.set_metadata(cache)
+                print('')
+            else:
+                print('no metadata to set')
+            if dirs_to_enter and self.recurse_dirs:
+                prefix = f'entering directories below {dir_path}: directory '
+                for i, path in enumerate(dirs_to_enter):
+                    print(f'{prefix}{i+1}/{len(dirs_to_enter)}')
+                    read_directory_into_gallery_items(path)
 
         old_selection = self.gallery.selected_item
         self.gallery.dir_entries = []
-- 
2.30.2