def __get_search_path_from(self, uri): self.__manager.response() from gio import File path = File(uri).get_parse_name() path = path.replace(self.__home_folder, "").strip("/\\") self.__manager.response() return path
def __set_label(self): from gio import File uri = self.__editor.uri if uri: folder = File(uri).get_parent().get_parse_name() if not uri: folder = self.__editor.desktop_folder folder = folder.replace(self.__editor.home_folder.rstrip("/"), "~") self.__label.set_label(message % folder) return False
def __get_display_path_from(self, uri): self.__manager.response() from gio import File path = File(uri).get_parent().get_parse_name() path = path.replace(self.__home_folder, "").strip("/\\") from os.path import split self.__manager.response() if not path: return split(self.__home_folder)[-1].strip("/\\") return path
def __set_label(self, fileinfo): try: if not self.__editor.uri: raise AssertionError from gio import File path = File(self.__editor.uri).get_parent().get_parse_name() folder = path.replace(self.__editor.home_folder.rstrip("/"), "~") self.__label.set_text(folder) except AssertionError: self.__label.set_text("Unknown") return False
def __get_dictionary(self, uri): from gio import File title = File(uri).get_basename() if uri else _("Unnamed Document") ellipsize = self.__ellipsize if uri: parent_path = File(uri).get_parent().get_parse_name() if uri: parent_path = ellipsize(parent_path.replace(self.__editor.home_folder, "~").strip("/\\")) fulltitle = "%s - (%s)" % (title, parent_path) if uri else title fulltitle = title if len(title) > 30 else fulltitle dictionary = { "normal": fulltitle, "modified": "*" + fulltitle, "readonly": fulltitle + _(" [READONLY]"), "loading": _("Loading %s ...") % title, } return dictionary
def __replace(self, _file): from gio import File __file = File(_file).get_path() return __file.replace(self.__path, "").lstrip("/"), File(_file).get_uri()
def __update_names(self, uri): from gio import File filename = File(uri).get_parse_name() filename = filename.replace(self.__editor.home_folder.rstrip("/"), "~") self.__default_name = filename return False