Philipp Hörist pushed to branch master at gajim / gajim
Commits: deb72c03 by lovetox at 2020-09-18T10:22:50+02:00 Settings: Init in Application startup
- - - - -
4 changed files:
- gajim/application.py - gajim/common/settings.py - gajim/common/types.py - gajim/gui_interface.py
Changes:
===================================== gajim/application.py ===================================== @@ -57,6 +57,8 @@ from gajim.common.contacts import LegacyContactsAPI from gajim.common.task_manager import TaskManager from gajim.common.storage.cache import CacheStorage from gajim.common.storage.archive import MessageArchiveStorage +from gajim.common.settings import Settings +from gajim.common.settings import LegacyConfig
class GajimApplication(Gtk.Application): @@ -184,6 +186,11 @@ class GajimApplication(Gtk.Application): app.detect_dependencies() configpaths.create_paths()
+ app.settings = Settings() + app.settings.init() + + app.config = LegacyConfig() # type: ignore + app.storage.cache = CacheStorage() app.storage.cache.init()
===================================== gajim/common/settings.py ===================================== @@ -70,7 +70,7 @@ CREATE_SQL = ''' json.dumps(PROXY_EXAMPLES))
-class _Settings: +class Settings: def __init__(self): self._con = None self._commit_scheduled = None @@ -158,8 +158,6 @@ class _Settings: self._migrate_old_config() self._commit() self._migrate_database() - app.settings = self # type: ignore - app.config = LegacyConfig() # type: ignore
@staticmethod def _setup_installation_defaults() -> None: @@ -890,30 +888,27 @@ class _Settings: self.set_account_setting(account, 'proxy', None)
-Settings = _Settings() - - class LegacyConfig:
@staticmethod def get(setting: str) -> SETTING_TYPE: - return Settings.get_app_setting(setting) + return app.settings.get_app_setting(setting)
@staticmethod def set(setting: str, value: SETTING_TYPE) -> None: - Settings.set_app_setting(setting, value) + app.settings.set_app_setting(setting, value)
@staticmethod def get_per(kind: str, key: str, setting: str) -> SETTING_TYPE: if kind == 'accounts': - return Settings.get_account_setting(key, setting) + return app.settings.get_account_setting(key, setting)
if kind == 'plugins': - return Settings.get_plugin_setting(key, setting) + return app.settings.get_plugin_setting(key, setting) raise ValueError
@staticmethod def set_per(kind: str, key: str, setting: str, value: SETTING_TYPE) -> None: if kind == 'accounts': - Settings.set_account_setting(key, setting, value) + app.settings.set_account_setting(key, setting, value) raise ValueError
===================================== gajim/common/types.py ===================================== @@ -37,7 +37,7 @@ if TYPE_CHECKING: from gajim.common.nec import NetworkEventsController
from gajim.gui_interface import Interface - from gajim.common.settings import _Settings + from gajim.common.settings import Settings
NetworkEventsControllerT = Union['NetworkEventsController'] @@ -61,4 +61,4 @@ PluginExtensionPoints = Dict[str, Tuple[Optional[Callable[..., None]], EventHandlersDict = Dict[str, Tuple[int, Callable[['NetworkEvent'], Optional[bool]]]] PluginEvents = List['NetworkEvent']
-SettingsT = Union['_Settings'] +SettingsT = Union['Settings']
===================================== gajim/gui_interface.py ===================================== @@ -81,7 +81,6 @@ from gajim.common.structs import MUCData from gajim.common.nec import NetworkEvent from gajim.common.i18n import _ from gajim.common.client import Client -from gajim.common.settings import Settings from gajim.common.const import Display
from gajim.common.file_props import FilesProp @@ -2023,8 +2022,6 @@ class Interface:
self.avatar_storage = AvatarStorage()
- Settings.init() - # Load CSS files app.load_css_config()
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/commit/deb72c03565d921e0508623f5f0a5c2ca...