From 4fd4376c6a2822729798994705cec90ca5d949bb Mon Sep 17 00:00:00 2001 From: Brian Jackson Date: Tue, 25 Nov 2014 11:19:00 -0600 Subject: [PATCH] Pass around win_id so we can use it in the error message handler The message class needs a win_id to know where to send error messages. Just pass it through the jinja->js->qtwebbridge as it's just a simple int. --- qutebrowser/config/config.py | 6 +++--- qutebrowser/html/settings.html | 3 ++- qutebrowser/network/qutescheme.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index ad9c81fdd..bb8b2b2ea 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -520,12 +520,12 @@ class ConfigManager(QObject): if self._initialized: self._after_set(sectname, optname) - @pyqtSlot(str, str, str) - def set_javascript(self, sectname, optname, value): + @pyqtSlot(int, str, str, str) + def set_javascript(self, win_id, sectname, optname, value): try: self.set('conf', sectname, optname, value) except configtypes.ValidationError as e: - message.error(e) + message.error(win_id, e) @cmdutils.register(instance='config') def save(self): diff --git a/qutebrowser/html/settings.html b/qutebrowser/html/settings.html index d8994e111..38449ad95 100644 --- a/qutebrowser/html/settings.html +++ b/qutebrowser/html/settings.html @@ -1,9 +1,10 @@ {% extends "base.html" %} {% block script %} +var win_id = {{ win_id }}; var cset = function(section, option, el) { value = el.value; - window.qutesettings.set_javascript(section, option, value); + window.qutesettings.set_javascript(win_id, section, option, value); } {% endblock %} diff --git a/qutebrowser/network/qutescheme.py b/qutebrowser/network/qutescheme.py index 542281ff2..e29f4631d 100644 --- a/qutebrowser/network/qutescheme.py +++ b/qutebrowser/network/qutescheme.py @@ -156,7 +156,7 @@ def qute_settings(win_id, request): frame.addToJavaScriptWindowObject("qutesettings", cfg) html = jinja.env.get_template('settings.html').render( - title='settings', config=configdata, cfg=cfg) + win_id=win_id, title='settings', config=configdata, cfg=cfg) return html.encode('UTF-8', errors='xmlcharrefreplace')