How to use the qutebrowser.utils.message function in qutebrowser

To help you get started, we’ve selected a few qutebrowser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github qutebrowser / qutebrowser / tests / helpers / messagemock.py View on Github external
def patch(self):
        """Start recording messages."""
        message.global_bridge.show_message.connect(self._record_message)
        message.global_bridge._connected = True
github qutebrowser / qutebrowser / qutebrowser / commands / managers.py View on Github external
def run_safely_init(self, text, count=None):
        """Run a command and display exceptions in the statusbar.

        Contrary to run_safely, error messages are queued so this is more
        suitable to use while initializing."""
        try:
            self.run(text, count)
        except (CommandMetaError, CommandError) as e:
            message.error(e)
github qutebrowser / qutebrowser / qutebrowser / browser / bookmarks.py View on Github external
"""Add a new bookmark.

        Args:
            win_id: The window ID to display the errors in.
            url: The url to add as bookmark.
            title: The title for the new bookmark.
        """
        urlstr = url.toString(QUrl.RemovePassword | QUrl.FullyEncoded)

        if urlstr in self.bookmarks:
            message.error(win_id, "Bookmark already exists!")
        else:
            self.bookmarks[urlstr] = title
            self.changed.emit()
            self.added.emit(title, urlstr)
            message.info(win_id, "Bookmark added")
github qutebrowser / qutebrowser / qutebrowser / misc / utilcmds.py View on Github external
def clear_messages():
    """Clear all message notifications."""
    message.global_bridge.clear_messages.emit()
github qutebrowser / qutebrowser / qutebrowser / browser / urlmarks.py View on Github external
You can view all saved quickmarks on the
        link:qute://bookmarks[bookmarks page].

        Args:
            win_id: The window ID to display the errors in.
            url: The url to add as quickmark.
            name: The name for the new quickmark.
        """
        # We don't raise cmdexc.CommandError here as this can be called async
        # via prompt_save.
        if not name:
            message.error(win_id, "Can't set mark with empty name!")
            return
        if not url:
            message.error(win_id, "Can't set mark with empty URL!")
            return

        def set_mark():
            """Really set the quickmark."""
            self.marks[name] = url
            self.changed.emit()
            self.added.emit(name, url)

        if name in self.marks:
            message.confirm_async(
                win_id, "Override existing quickmark?", set_mark, default=True)
        else:
            set_mark()
github qutebrowser / qutebrowser / qutebrowser / config / parsers / keyconf.py View on Github external
def save(self):
        """Save the key config file."""
        log.destroy.debug("Saving key config to {}".format(self._configfile))

        try:
            with qtutils.savefile_open(self._configfile,
                                       encoding='utf-8') as f:
                data = str(self)
                f.write(data)
        except OSError as e:
            message.error("Could not save key config: {}".format(e))
github qutebrowser / qutebrowser / qutebrowser / utils / version.py View on Github external
def _on_paste_version_err(text: str) -> None:
        assert pbclient is not None
        message.error("Failed to pastebin version"
                      " info: {}".format(text))
        pbclient.deleteLater()
github qutebrowser / qutebrowser / qutebrowser / mainwindow / tabbedbrowser.py View on Github external
def set_mark(self, key):
        """Set a mark at the current scroll position in the current tab.

        Args:
            key: mark identifier; capital indicates a global mark
        """
        # strip the fragment as it may interfere with scrolling
        try:
            url = self.current_url().adjusted(QUrl.RemoveFragment)
        except qtutils.QtValueError:
            # show an error only if the mark is not automatically set
            if key != "'":
                message.error("Failed to set mark: url invalid")
            return
        point = self.widget.currentWidget().scroller.pos_px()

        if key.isupper():
            self._global_marks[key] = point, url
        else:
            if url not in self._local_marks:
                self._local_marks[url] = {}
            self._local_marks[url][key] = point
github qutebrowser / qutebrowser / qutebrowser / keyinput / keyparser.py View on Github external
def execute(self, cmdstr, _keytype, count=None):
        try:
            self._commandrunner.run(cmdstr, count)
        except cmdexc.Error as e:
            message.error(str(e), stack=traceback.format_exc())
github qutebrowser / qutebrowser / qutebrowser / mainwindow / mainwindow.py View on Github external
# - browsertab -> hints -> webelem -> mainwindow -> bar -> browsertab
        from qutebrowser.mainwindow import tabbedbrowser
        from qutebrowser.mainwindow.statusbar import bar

        self.setAttribute(Qt.WA_DeleteOnClose)
        self._overlays = []  # type: typing.MutableSequence[_OverlayInfoType]
        self.win_id = next(win_id_gen)
        self.registry = objreg.ObjectRegistry()
        objreg.window_registry[self.win_id] = self
        objreg.register('main-window', self, scope='window',
                        window=self.win_id)
        tab_registry = objreg.ObjectRegistry()
        objreg.register('tab-registry', tab_registry, scope='window',
                        window=self.win_id)

        message_bridge = message.MessageBridge(self)
        objreg.register('message-bridge', message_bridge, scope='window',
                        window=self.win_id)

        self.setWindowTitle('qutebrowser')
        self._vbox = QVBoxLayout(self)
        self._vbox.setContentsMargins(0, 0, 0, 0)
        self._vbox.setSpacing(0)

        self._init_downloadmanager()
        self._downloadview = downloadview.DownloadView(
            model=self._download_model)

        if config.val.content.private_browsing:
            # This setting always trumps what's passed in.
            private = True
        else: