def reload(self, thumb, index, reload_image=True): """Reload the thumbnails of manipulated images. Args: thumb: Thumbnail to reload. index: Position of the thumbnail to be reloaded. reload_image: If True reload the image of the thumbnail. Else only the name (useful for marking). """ # Remember position old_path = self.iconview.get_cursor()[1] liststore_iter = self.liststore.get_iter(index) self.liststore.remove(liststore_iter) try: if reload_image: thumbnails = Thumbnails([thumb], self.sizes[-1]) new_thumb = thumbnails.thumbnails_create()[0] self.elements[index] = new_thumb pixbuf_max = self.pixbuf_max[index] pixbuf = self.scale_thumb(pixbuf_max) name = os.path.basename(self.elements[index]) name = name.split(".")[0] if thumb in self.vimiv.mark.marked: name = name + " [*]" elif index in self.vimiv.commandline.search_positions: name = self.markup + '<b>' + name + '</b></span>' self.liststore.insert(index, [pixbuf, name]) self.iconview.select_path(old_path) cell_renderer = self.iconview.get_cells()[0] self.iconview.set_cursor(old_path, cell_renderer, False) except: message = "Reload of manipulated thumbnails failed" self.vimiv.statusbar.err_message(message)
def reload(self, thumb, index, reload_image=True): """Reload the thumbnails of manipulated images. Args: thumb: Thumbnail to reload. index: Position of the thumbnail to be reloaded. reload_image: If True reload the image of the thumbnail. Else only the name (useful for marking). """ # Remember position old_path = self.iconview.get_cursor()[1] liststore_iter = self.liststore.get_iter(index) self.liststore.remove(liststore_iter) try: if reload_image: thumbnails = Thumbnails([thumb], self.sizes[-1], self.directory) new_thumb = thumbnails.thumbnails_create()[0] self.elements[index] = new_thumb pixbuf_max = self.pixbuf_max[index] pixbuf = self.scale_thumb(pixbuf_max) name = os.path.basename(self.elements[index]) name = name.split(".")[0] if thumb in self.app["mark"].marked: name = name + " [*]" elif index in self.app["commandline"].search_positions: name = self.markup + '<b>' + name + '</b></span>' self.liststore.insert(index, [pixbuf, name]) self.iconview.select_path(old_path) cell_renderer = self.iconview.get_cells()[0] self.iconview.set_cursor(old_path, cell_renderer, False) except: message = "Reload of manipulated thumbnails failed" self.app["statusbar"].err_message(message)
def show(self, toggled=False): """Show thumbnails when called from toggle. Args: toggled: If True thumbnail mode is already toggled. """ # Clean liststore self.liststore.clear() self.pixbuf_max = [] # Create thumbnails thumbnails = Thumbnails(self.vimiv.paths, self.sizes[-1]) self.elements = thumbnails.thumbnails_create() # Draw the icon view instead of the image if not toggled: self.vimiv.image.scrolled_win.remove(self.vimiv.image.viewport) self.vimiv.image.scrolled_win.add(self.iconview) # Show the window self.iconview.show() self.toggled = True # Add all thumbnails to the liststore for i, thumb in enumerate(self.elements): pixbuf_max = GdkPixbuf.Pixbuf.new_from_file(thumb) self.pixbuf_max.append(pixbuf_max) pixbuf = self.scale_thumb(pixbuf_max) name = os.path.basename(thumb) name = name.split(".")[0] if self.vimiv.paths[i] in self.vimiv.mark.marked: name = name + " [*]" self.liststore.append([pixbuf, name]) # Set columns self.calculate_columns() # Focus the current image self.iconview.grab_focus() pos = (self.vimiv.index) % len(self.vimiv.paths) self.move_to_pos(pos) # Remove the files again if the thumbnails should not be cached if not self.cache: for thumb in self.elements: os.remove(thumb)
def show(self, toggled=False): """Show thumbnails when called from toggle. Args: toggled: If True thumbnail mode is already toggled. """ # Clean liststore self.liststore.clear() self.pixbuf_max = [] # Create thumbnails thumbnails = Thumbnails(self.app.paths, self.sizes[-1], self.directory) self.elements = thumbnails.thumbnails_create() # Draw the icon view instead of the image if not toggled: self.app["image"].scrolled_win.remove(self.app["image"].viewport) self.app["image"].scrolled_win.add(self.iconview) # Show the window self.iconview.show() self.toggled = True # Add all thumbnails to the liststore for i, thumb in enumerate(self.elements): pixbuf_max = GdkPixbuf.Pixbuf.new_from_file(thumb) self.pixbuf_max.append(pixbuf_max) pixbuf = self.scale_thumb(pixbuf_max) name = os.path.basename(thumb) name = name.split(".")[0] if self.app.paths[i] in self.app["mark"].marked: name = name + " [*]" self.liststore.append([pixbuf, name]) # Set columns self.calculate_columns() # Focus the current image self.iconview.grab_focus() pos = (self.app.index) % len(self.app.paths) self.move_to_pos(pos) # Remove the files again if the thumbnails should not be cached if not self.cache: for thumb in self.elements: os.remove(thumb)