def thread_for_simple_manipulations(self): """Rotate and flip image file in an extra thread.""" to_remove = list(self.simple_manipulations.keys()) for f in self.simple_manipulations: if self.simple_manipulations[f][0]: imageactions.rotate_file([f], self.simple_manipulations[f][0]) if self.simple_manipulations[f][1]: imageactions.flip_file([f], True) if self.simple_manipulations[f][2]: imageactions.flip_file([f], False) if self.app["thumbnail"].toggled: self.app["thumbnail"].reload(f) for key in to_remove: del self.simple_manipulations[key]
def _thread_for_apply(self): """Rotate and flip image file in an extra thread.""" self.threads_running = True to_remove = list(self._changes.keys()) for f in self._changes: if self._changes[f][0]: imageactions.rotate_file(f, self._changes[f][0]) if self._changes[f][1]: imageactions.flip_file(f, True) if self._changes[f][2]: imageactions.flip_file(f, False) for key in to_remove: del self._changes[key] self.emit("applied-to-file", to_remove) self.threads_running = False
def thread_for_flip(self, images, horizontal): """Flip all image files in an extra thread. Args: images: List of images to rotate. horizontal: If 1 flip horizontally. Else vertically. """ try: # Finish older manipulate threads first while len(self.running_threads) > 1: self.running_threads[0].join() imageactions.flip_file(images, horizontal) if self.app["thumbnail"].toggled: for image in images: self.app["thumbnail"].reload( image, self.app.paths.index(image)) except: self.app["statusbar"].err_message("Error: Flipping of file failed") self.running_threads.pop(0)
def thread_for_flip(self, images, horizontal): """Flip all image files in an extra thread. Args: images: List of images to rotate. horizontal: If 1 flip horizontally. Else vertically. """ try: # Finish older manipulate threads first while len(self.running_threads) > 1: self.running_threads[0].join() imageactions.flip_file(images, horizontal) if self.vimiv.thumbnail.toggled: for image in images: self.vimiv.thumbnail.reload(image, self.vimiv.paths.index(image)) except: self.vimiv.statusbar.err_message("Error: Flipping of file failed") self.running_threads.pop(0)
def test_flip(self): """Flipping of files.""" # Images equal before the flip self.assertTrue(compare_images(self.orig, self.filename)) # Images differ after the flip imageactions.flip_file(self.files, False) self.assertFalse(compare_images(self.orig, self.filename)) # Images equal after flipping again imageactions.flip_file(self.files, False) self.assertTrue(compare_images(self.orig, self.filename)) # Same for horizontal flip # Images equal before the flip self.assertTrue(compare_images(self.orig, self.filename)) # Images differ after the flip imageactions.flip_file(self.files, True) self.assertFalse(compare_images(self.orig, self.filename)) # Images equal after flipping again imageactions.flip_file(self.files, True) self.assertTrue(compare_images(self.orig, self.filename))
def test_flip(self): """Flipping of files.""" # Currently only runs through # TODO find a way to check if the image was flipped imageactions.flip_file(self.files, False) imageactions.flip_file(self.files, True)