def test_use_trash_is_false_on_non_posix(self): old_os_name = os.name try: os.name = 'not posix' self.assertFalse(use_trash()) finally: os.name = old_os_name
def test_use_trash_is_true_by_default_on_posix(self): old_os_name = os.name old_sys_platform = sys.platform try: os.name = 'posix' sys.platform = 'linux' self.assertTrue(use_trash()) finally: os.name = old_os_name sys.platform = old_sys_platform
def test_use_trash_is_false_on_darwin(self): old_os_name = os.name old_sys_platform = sys.platform try: os.name = 'posix' sys.platform = 'darwin' self.assertFalse(use_trash()) finally: os.name = old_os_name sys.platform = old_sys_platform
def test_use_trash_is_false_when_bypassed(self): old_os_name = os.name old_sys_platform = sys.platform try: config.set('settings', 'bypass_trash', "true") os.name = 'posix' sys.platform = 'linux' self.assertFalse(use_trash()) finally: os.name = old_os_name sys.platform = old_sys_platform
def test_use_trash_is_false_when_bypassed(self): old_os_name = os.name old_sys_platform = sys.platform try: config.set("settings", "bypass_trash", "true") os.name = "posix" sys.platform = "linux" self.assertFalse(use_trash()) finally: os.name = old_os_name sys.platform = old_sys_platform
def trash_files(parent, paths): """Will try to move the files to the trash, or if not possible, delete them permanently. Will ask for confirmation in each case. """ if not paths: return # depends on the platform if we can if trash.use_trash(): _do_trash_files(parent, paths) else: _do_delete_files(parent, paths)
def trash_songs(parent, songs, librarian): """Will try to move the files associated with the songs to the trash, or if not possible, delete them permanently. Will ask for confirmation in each case. The deleted songs will be removed from the librarian. """ if not songs: return # depends on the platform if we can if trash.use_trash(): _do_trash_songs(parent, songs, librarian) else: _do_delete_songs(parent, songs, librarian)
def TrashMenuItem(): if trash.use_trash(): return MenuItem(_("_Move to Trash"), Icons.USER_TRASH) else: return MenuItem(_("_Delete"), Icons.EDIT_DELETE)
def TrashMenuItem(): return (MenuItem(_("_Move to Trash"), "user-trash") if trash.use_trash() else Gtk.ImageMenuItem(Gtk.STOCK_DELETE, use_stock=True))