Add state config sections when initializing.

This commit is contained in:
Florian Bruhin 2015-04-01 18:21:02 +02:00
parent eeb875d098
commit 6e435ad215
4 changed files with 5 additions and 22 deletions

View File

@ -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):

View File

@ -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)

View File

@ -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):

View File

@ -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')