def set_current_directory(self, uri): self.file_model.clear() self.uri = uri gfile = _gio.File(uri=uri) self.path = gfile.get_path() if self.path[-1] != "/": self.path += "/" if self.uri[-1] != "/": self.uri += "/" if gfile.get_uri_scheme() != "file": self.path_label.set_text(uri) else: self.path_label.set_text(self.path) self.file_monitor = gfile.monitor_directory( flags=_gio.FILE_MONITOR_NONE, cancellable=None) self.file_monitor.connect("changed", self._current_dir_changed) self.search_entry.set_text("") for i in _os.listdir(self.path): if i[0] != ".": file = _os.path.join(self.path, i) pixbuf, icon_name = _fileicon.get_file_icon_from_name(file) len_i = len(i) if len_i > 17: list_i = [i.decode("utf-8")] while len(list_i[-1]) > 17: new = [list_i[-1][:16], list_i[-1][16:]] list_i = list_i[:-1] + new display_name = "\n".join(list_i).encode("utf-8") else: display_name = i self.file_model.append([ pixbuf, icon_name, display_name, i, _os.path.join(self.uri, i) ])
def set_current_directory(self, uri): self.file_model.clear() self.uri = uri gfile = _gio.File(uri=uri) self.path = gfile.get_path() if self.path[-1] != "/": self.path += "/" if self.uri[-1] != "/": self.uri += "/" if gfile.get_uri_scheme() != "file": self.path_label.set_text(uri) else: self.path_label.set_text(self.path) self.file_monitor = gfile.monitor_directory(flags=_gio.FILE_MONITOR_NONE, cancellable=None) self.file_monitor.connect("changed", self._current_dir_changed) self.search_entry.set_text("") for i in _os.listdir(self.path): if i[0] != ".": file = _os.path.join(self.path, i) pixbuf, icon_name = _fileicon.get_file_icon_from_name(file) len_i = len(i) if len_i > 17: list_i = [i.decode("utf-8")] while len(list_i[-1]) > 17: new = [list_i[-1][:16], list_i[-1][16:]] list_i = list_i[:-1] + new display_name = "\n".join(list_i).encode("utf-8") else: display_name = i self.file_model.append([pixbuf, icon_name, display_name, i, _os.path.join(self.uri, i)])
def load_mount(self, mount): root = mount.get_root() icon = mount.get_icon().get_names() index = 0 pixbuf, icon_name = _fileicon.get_file_icon_from_name(root.get_path()) self.mounts_model.append([icon_name, mount.get_name(), root.get_uri()])