From: Christian Heller Date: Mon, 23 Sep 2024 04:17:55 +0000 (+0200) Subject: To browser.py directory loading, add some progress messages. X-Git-Url: https://plomlompom.com/repos/te"st.html?a=commitdiff_plain;h=014741191fa8040b87c284ea7b3e05729c37d41a;p=stable_plom To browser.py directory loading, add some progress messages. --- 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 = []