From 6e435ad2157afc379fdeb883110e0950136d9cf8 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Wed, 1 Apr 2015 18:21:02 +0200 Subject: [PATCH] Add state config sections when initializing. --- qutebrowser/app.py | 12 ------------ qutebrowser/config/config.py | 5 +++++ qutebrowser/misc/sessions.py | 5 ----- qutebrowser/misc/utilcmds.py | 5 ----- 4 files changed, 5 insertions(+), 22 deletions(-) diff --git a/qutebrowser/app.py b/qutebrowser/app.py index ffe515f4c..cf6ba5a72 100644 --- a/qutebrowser/app.py +++ b/qutebrowser/app.py @@ -437,10 +437,6 @@ class Application(QApplication): window='last-focused') tabbed_browser.tabopen( QUrl('http://www.qutebrowser.org/quickstart.html')) - try: - state_config.add_section('general') - except configparser.DuplicateSectionError: - pass state_config['general']['quickstart-done'] = '1' def _setup_signals(self): @@ -561,19 +557,11 @@ class Application(QApplication): if self.geometry is not None: state_config = objreg.get('state-config') geom = base64.b64encode(self.geometry).decode('ASCII') - try: - state_config.add_section('geometry') - except configparser.DuplicateSectionError: - pass state_config['geometry']['mainwindow'] = geom def _save_version(self): """Save the current version to the state config.""" state_config = objreg.get('state-config') - try: - state_config.add_section('general') - except configparser.DuplicateSectionError: - pass state_config['general']['version'] = qutebrowser.__version__ def _destroy_crashlogfile(self): diff --git a/qutebrowser/config/config.py b/qutebrowser/config/config.py index 621eba4a8..6b7f1f8fb 100644 --- a/qutebrowser/config/config.py +++ b/qutebrowser/config/config.py @@ -179,6 +179,11 @@ def _init_misc(): """Initialize misc. config-related files.""" save_manager = objreg.get('save-manager') state_config = ini.ReadWriteConfigParser(standarddir.data(), 'state') + for sect in ('general', 'geometry'): + try: + state_config.add_section(sect) + except configparser.DuplicateSectionError: + pass objreg.register('state-config', state_config) save_manager.add_saveable('state-config', state_config.save) diff --git a/qutebrowser/misc/sessions.py b/qutebrowser/misc/sessions.py index 45ddeabd2..0e0c22b9e 100644 --- a/qutebrowser/misc/sessions.py +++ b/qutebrowser/misc/sessions.py @@ -21,7 +21,6 @@ import os import os.path -import configparser from PyQt5.QtCore import pyqtSignal, QUrl, QObject, QPoint, QTimer from PyQt5.QtWidgets import QApplication @@ -185,10 +184,6 @@ class SessionManager(QObject): self.update_completion.emit() if load_next_time: state_config = objreg.get('state-config') - try: - state_config.add_section('general') - except configparser.DuplicateSectionError: - pass state_config['general']['session'] = name def save_last_window_session(self): diff --git a/qutebrowser/misc/utilcmds.py b/qutebrowser/misc/utilcmds.py index b5a8e7e03..826ea8fc0 100644 --- a/qutebrowser/misc/utilcmds.py +++ b/qutebrowser/misc/utilcmds.py @@ -19,7 +19,6 @@ """Misc. utility commands exposed to the user.""" -import configparser import functools import types @@ -144,9 +143,5 @@ def fooled(): """Turn off april's fools.""" from qutebrowser.config import websettings state_config = objreg.get('state-config') - try: - state_config.add_section('general') - except configparser.DuplicateSectionError: - pass state_config['general']['fooled'] = '1' websettings.update_settings('ui', 'user-stylesheet')