home · contact · privacy
To browser.py directory loading, add some progress messages.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 23 Sep 2024 04:17:55 +0000 (06:17 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 23 Sep 2024 04:17:55 +0000 (06:17 +0200)
browser.py

index e1463d689aa2c6e47671221f89e8144552ea9443..f2183730e83cb77a1967f06e2cf53766cdf31e52 100755 (executable)
@@ -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 = []