text = entry.get_buffer().get_text()
if '' != text.rstrip():
self.filter_inputs[item.props.item.name] = text
- else:
+ elif item.props.item.name in self.filter_inputs.keys():
del self.filter_inputs[item.props.item.name]
self.update_gallery()
to_select.activate()
else:
self.counter.set_text(' (nothing) ')
- with open(BOOKMARKS_PATH, 'r', encoding='utf8') as f:
- bookmarks = json_load(f)
- for i in range(self.gallery_store_filtered.get_n_items()):
- slot = self.gallery_store.get_item(i)
- if slot.full_path in bookmarks:
- slot.bookmarked = True
self.update_gallery_view()
def update_gallery_view(self, refocus=False):
elif slot_bottom > vp_bottom:
vp_scroll.set_value(slot_bottom - vp_height)
vp_scroll.emit('value-changed')
- # # DEBUG: mere statistics
- # from datetime import datetime
- # n_imgs, n_buttons, n_others = 0, 0, 0
- # for i in range(self.gallery_store_filtered.props.n_items):
- # child = self.gallery.get_child_at_index(i).props.child
- # grandchild = child.get_first_child()
- # if isinstance(grandchild, Gtk.Image):
- # n_imgs += 1
- # elif isinstance(grandchild, Gtk.Button):
- # n_buttons += 1
- # else:
- # n_others += 1
- # print(datetime.now(), "DEBUG", n_imgs, n_buttons, n_others)
def hit_file_selection(self):
"""If current file selection is directory, reload into that one."""
def load_directory(self, update_gallery=True):
"""Load into gallery directory at .app.img_dir_absolute."""
- def read_directory_into_gallery_items(cache, dir_path,
- make_parent=False):
+ def read_directory_into_gallery_items(dir_path, make_parent=False):
directory = Gio.File.new_for_path(dir_path)
query_attrs = 'standard::name,time::*'
if make_parent:
self.gallery_store.append(DirItem(dir_path, info))
if self.recurse_dirs:
read_directory_into_gallery_items(
- cache, path_join(dir_path, info.get_name()))
+ path_join(dir_path, info.get_name()))
elif info.get_content_type()\
and info.get_content_type().startswith('image/'):
item = ImgItem(dir_path, info, cache)
+ if item.full_path in bookmarks:
+ item.bookmarked = True
if '' == item.model:
to_set_metadata_on += [item]
self.gallery_store.append(item)
self.block_file_selection_updates = True
self.gallery_store.remove_all()
self.block_file_selection_updates = False
+ with open(BOOKMARKS_PATH, 'r', encoding='utf8') as f:
+ bookmarks = json_load(f)
with open(CACHE_PATH, 'r', encoding='utf8') as f:
cache = json_load(f)
- read_directory_into_gallery_items(cache, self.app.img_dir_absolute,
- True)
+ read_directory_into_gallery_items(self.app.img_dir_absolute, True)
with open(CACHE_PATH, 'w', encoding='utf8') as f:
json_dump(cache, f)
if update_gallery: