示例#1
0
    def delete(self):
        """Delete all marked images or the current one."""
        # Get all images
        images = self.get_manipulated_images("Deleted")
        self.app["mark"].marked = []
        # Delete all images
        for i, im in enumerate(images):
            message = ""
            if not os.path.exists(im):
                message = "Image %s does not exist" % (im)
            elif os.path.isdir(im):
                message = "Deleting directories is not supported"
            if message:
                self.app["statusbar"].err_message(message)
                images.remove(i)
        move_to_trash(images, self.app["image"].trashdir)

        # Reload stuff if needed
        if self.app["library"].grid.is_visible():
            if self.app.get_pos():
                self.app["library"].remember_pos(os.getcwd(),
                                                 self.app.get_pos() - 1)
            self.app["library"].reload(os.getcwd())
        if self.app["image"].scrolled_win.is_focus():
            del self.app.paths[self.app.index]
            if self.app.paths:
                self.app["image"].load_image()
            else:
                # No more images in this directory -> focus parent in library
                self.app["library"].move_up()
                self.app["library"].focus(True)
                self.app["statusbar"].err_message("No more images")
示例#2
0
    def delete(self):
        """Delete all marked images or the current one."""
        # Get all images
        images = self.get_manipulated_images("Deleted")
        self.app["mark"].marked = []
        # Delete all images
        for im in images:
            message = ""
            if not os.path.exists(im):
                message = "Image %s does not exist" % (im)
            elif os.path.isdir(im):
                message = "Deleting directories is not supported"
            if message:
                self.app["statusbar"].message(message, "error")
                return
        move_to_trash(images, self.app["image"].trashdir)

        # Reload stuff if needed
        if self.app["library"].grid.is_visible():
            if self.app.get_pos():
                self.app["library"].remember_pos(os.getcwd(),
                                                 self.app.get_pos() - 1)
            self.app["library"].reload(os.getcwd())
        if self.app["image"].scrolled_win.is_focus():
            del self.app.paths[self.app.index]
            if self.app.paths:
                self.app["image"].load_image()
            else:
                # No more images in this directory -> focus parent in library
                self.app["library"].move_up()
                self.app["library"].focus(True)
                self.app["statusbar"].message("No more images", "info")
示例#3
0
    def delete(self):
        """Delete all marked images or the current one."""
        # Get all images
        images = self.get_manipulated_images("Deleted")
        self.vimiv.mark.marked = []
        # Delete all images
        for i, im in enumerate(images):
            message = ""
            if not os.path.exists(im):
                message = "Image %s does not exist" % (im)
            elif os.path.isdir(im):
                message = "Deleting directories is not supported"
            if message:
                self.vimiv.statusbar.err_message(message)
                images.remove(i)
        move_to_trash(images)

        # Reload stuff if needed
        if self.vimiv.library.grid.is_visible():
            if self.vimiv.get_pos():
                self.vimiv.library.remember_pos(os.getcwd(),
                                                self.vimiv.get_pos() - 1)
            self.vimiv.library.reload(os.getcwd())
        if self.vimiv.image.scrolled_win.is_focus():
            del self.vimiv.paths[self.vimiv.index]
            if self.vimiv.paths:
                self.vimiv.image.move_index(delta=0)
            else:
                # No more images in this directory -> focus parent in library
                self.vimiv.library.move_up()
                self.vimiv.library.focus(True)
                self.vimiv.statusbar.err_message("No more images")
示例#4
0
 def test_move_to_trash(self):
     """Move file to trash."""
     os.chdir("testimages/")
     shutil.copyfile("arch_001.jpg", "image_to_edit.jpg")
     filename = os.path.abspath("image_to_edit.jpg")
     files = [filename]
     fileactions.move_to_trash(files, self.trashdir)
     trashed_file = os.path.join(self.trashdir, "image_to_edit.jpg")
     self.assertTrue(os.path.isfile(trashed_file))
     # Repeat, to check if backing up works
     shutil.copyfile("arch_001.jpg", "image_to_edit.jpg")
     fileactions.move_to_trash(files, self.trashdir)
     trashed_file1 = os.path.join(self.trashdir, "image_to_edit.jpg.1")
     self.assertTrue(os.path.isfile(trashed_file1))
     shutil.copyfile("arch_001.jpg", "image_to_edit.jpg")
     fileactions.move_to_trash(files, self.trashdir)
     trashed_file2 = os.path.join(self.trashdir, "image_to_edit.jpg.2")
     self.assertTrue(os.path.isfile(trashed_file2))
     # Clear the files
     os.remove(trashed_file)
     os.remove(trashed_file1)
示例#5
0
 def test_move_to_trash(self):
     """Move file to trash."""
     os.chdir("testimages/")
     shutil.copyfile("arch_001.jpg", "image_to_edit.jpg")
     filename = os.path.abspath("image_to_edit.jpg")
     files = [filename]
     fileactions.move_to_trash(files, self.trashdir)
     trashed_file = os.path.join(self.trashdir, "image_to_edit.jpg")
     self.assertTrue(os.path.isfile(trashed_file))
     # Repeat, to check if backing up works
     shutil.copyfile("arch_001.jpg", "image_to_edit.jpg")
     fileactions.move_to_trash(files, self.trashdir)
     trashed_file1 = os.path.join(self.trashdir, "image_to_edit.jpg.1")
     self.assertTrue(os.path.isfile(trashed_file1))
     shutil.copyfile("arch_001.jpg", "image_to_edit.jpg")
     fileactions.move_to_trash(files, self.trashdir)
     trashed_file2 = os.path.join(self.trashdir, "image_to_edit.jpg.2")
     self.assertTrue(os.path.isfile(trashed_file2))
     # Clear the files
     os.remove(trashed_file)
     os.remove(trashed_file1)