Esempio n. 1
0
    def _set_directory_location(self, location: Location) -> None:
        self.file_collection.clear()

        if self._directory_watcher is not None:
            self._directory_watcher.close()
        self._directory_watcher = self.app.vfs.opendir(location)

        if hasattr(self._directory_watcher, 'sig_file_added'):
            self._directory_watcher.sig_file_added.connect(
                self.file_collection.add_fileinfo)

        if hasattr(self._directory_watcher, 'sig_file_removed'):
            self._directory_watcher.sig_file_removed.connect(
                self.file_collection.remove_file)

        if hasattr(self._directory_watcher, 'sig_file_modified'):
            self._directory_watcher.sig_file_modified.connect(
                self.file_collection.modify_file)

        if hasattr(self._directory_watcher, 'sig_file_closed'):
            self._directory_watcher.sig_file_closed.connect(
                self.file_collection.close_file)

        if hasattr(self._directory_watcher, 'sig_finished'):
            self._directory_watcher.sig_finished.connect(self._on_finished)

        if hasattr(self._directory_watcher, 'sig_scandir_finished'):
            self._directory_watcher.sig_scandir_finished.connect(
                self._on_scandir_finished)

        if hasattr(self._directory_watcher, 'sig_message'):
            self._directory_watcher.sig_message.connect(
                self._on_directory_watcher_message)

        self._directory_watcher.start()

        if location.protocol() == "search":
            abspath, query = location.search_query()
            search_location = Location.from_path(abspath)
            self.location = search_location
            self._gui._window.set_location(search_location)
            self._gui._window.search_lineedit.setText(query)
            self._gui._window.search_toolbar.show()
        else:
            self.location = location
            self._gui._window.set_location(self.location)
Esempio n. 2
0
    def opendir(self, location: Location) -> Any:
        if location.protocol() == "history":
            return HistoryProvider(self._app)

        elif location.protocol() == "bookmarks":
            return BookmarksProvider(self._app)

        elif location.protocol() == "file":
            return self._stdio_fs.opendir(location)

        elif location.protocol() == "stream":
            return FileListStream.from_location(self._app, "\n", location)

        elif location.protocol() == "stream0":
            return FileListStream.from_location(self._app, "\0", location)

        elif location.protocol() == "search":
            abspath, query = location.search_query()
            return SearchStream(abspath, query)

        else:
            raise Exception("unknown protocol: {}", location.protocol())
Esempio n. 3
0
    def opendir(self, location: Location) -> Any:
        if location.protocol() == "history":
            return HistoryProvider(self._app)

        elif location.protocol() == "bookmarks":
            return BookmarksProvider(self._app)

        elif location.protocol() == "file":
            return self._stdio_fs.opendir(location)

        elif location.protocol() == "stream":
            return FileListStream.from_location(self._app, "\n", location)

        elif location.protocol() == "stream0":
            return FileListStream.from_location(self._app, "\0", location)

        elif location.protocol() == "search":
            abspath, query = location.search_query()
            return SearchStream(abspath, query)

        else:
            raise Exception("unknown protocol: {}", location.protocol())