+ def switchToFileList(self):
+ if not self.userMode:
+ self.currList = "filelist"
+ self["filelist"].selectionEnabled(1)
+ self["booklist"].selectionEnabled(0)
+ self["key_blue"].text = _("Add Bookmark")
+ self.updateTarget()
+
+ def switchToBookList(self):
+ self.currList = "booklist"
+ self["filelist"].selectionEnabled(0)
+ self["booklist"].selectionEnabled(1)
+ self["key_blue"].text = _("Remove Bookmark")
+ self.updateTarget()
+
+ def addRemoveBookmark(self):
+ if self.currList == "filelist":
+ # add bookmark
+ folder = self["filelist"].getSelection()[0]
+ if folder is not None and not folder in self.bookmarks:
+ self.bookmarks.append(folder)
+ self.bookmarks.sort()
+ self["booklist"].setList(self.bookmarks)
+ else:
+ # remove bookmark
+ if not self.userMode:
+ name = self["booklist"].getCurrent()
+ self.session.openWithCallback(
+ boundFunction(self.removeBookmark, name),
+ MessageBox,
+ _("Do you really want to remove your bookmark of %s?") % (name),
+ )
+
+ def removeBookmark(self, name, ret):
+ if not ret:
+ return
+ if name in self.bookmarks:
+ self.bookmarks.remove(name)
+ self["booklist"].setList(self.bookmarks)
+
+ def createDir(self):
+ if self["filelist"].current_directory != None:
+ self.session.openWithCallback(
+ self.createDirCallback,
+ InputBox,
+ title = _("Please enter name of the new directory"),
+ text = ""
+ )
+
+ def createDirCallback(self, res):
+ if res:
+ path = os.path.join(self["filelist"].current_directory, res)
+ if not pathExists(path):
+ if not createDir(path):
+ self.session.open(
+ MessageBox,
+ _("Creating directory %s failed.") % (path),
+ type = MessageBox.TYPE_ERROR,
+ timeout = 5
+ )
+ self["filelist"].refresh()
+ else:
+ self.session.open(
+ MessageBox,
+ _("The path %s already exists.") % (path),
+ type = MessageBox.TYPE_ERROR,
+ timeout = 5
+ )
+
+ def removeDir(self):
+ sel = self["filelist"].getSelection()
+ if sel and pathExists(sel[0]):
+ self.session.openWithCallback(
+ boundFunction(self.removeDirCallback, sel[0]),
+ MessageBox,
+ _("Do you really want to remove directory %s from the disk?") % (sel[0]),
+ type = MessageBox.TYPE_YESNO
+ )
+ else:
+ self.session.open(
+ MessageBox,
+ _("Invalid directory selected: %s") % (sel[0]),
+ type = MessageBox.TYPE_ERROR,
+ timeout = 5
+ )
+
+ def removeDirCallback(self, name, res):
+ if res:
+ if not removeDir(name):
+ self.session.open(
+ MessageBox,
+ _("Removing directory %s failed. (Maybe not empty.)") % (name),
+ type = MessageBox.TYPE_ERROR,
+ timeout = 5
+ )
+ else:
+ self["filelist"].refresh()
+ self.removeBookmark(name, True)
+