Philipp Hörist pushed to branch master at gajim / gajim

Commits:

4 changed files:

Changes:

  • gajim/application.py
    ... ... @@ -57,6 +57,8 @@ from gajim.common.contacts import LegacyContactsAPI
    57 57
     from gajim.common.task_manager import TaskManager
    
    58 58
     from gajim.common.storage.cache import CacheStorage
    
    59 59
     from gajim.common.storage.archive import MessageArchiveStorage
    
    60
    +from gajim.common.settings import Settings
    
    61
    +from gajim.common.settings import LegacyConfig
    
    60 62
     
    
    61 63
     
    
    62 64
     class GajimApplication(Gtk.Application):
    
    ... ... @@ -184,6 +186,11 @@ class GajimApplication(Gtk.Application):
    184 186
             app.detect_dependencies()
    
    185 187
             configpaths.create_paths()
    
    186 188
     
    
    189
    +        app.settings = Settings()
    
    190
    +        app.settings.init()
    
    191
    +
    
    192
    +        app.config = LegacyConfig() # type: ignore
    
    193
    +
    
    187 194
             app.storage.cache = CacheStorage()
    
    188 195
             app.storage.cache.init()
    
    189 196
     
    

  • gajim/common/settings.py
    ... ... @@ -70,7 +70,7 @@ CREATE_SQL = '''
    70 70
                json.dumps(PROXY_EXAMPLES))
    
    71 71
     
    
    72 72
     
    
    73
    -class _Settings:
    
    73
    +class Settings:
    
    74 74
         def __init__(self):
    
    75 75
             self._con = None
    
    76 76
             self._commit_scheduled = None
    
    ... ... @@ -158,8 +158,6 @@ class _Settings:
    158 158
                 self._migrate_old_config()
    
    159 159
                 self._commit()
    
    160 160
             self._migrate_database()
    
    161
    -        app.settings = self # type: ignore
    
    162
    -        app.config = LegacyConfig() # type: ignore
    
    163 161
     
    
    164 162
         @staticmethod
    
    165 163
         def _setup_installation_defaults() -> None:
    
    ... ... @@ -890,30 +888,27 @@ class _Settings:
    890 888
                     self.set_account_setting(account, 'proxy', None)
    
    891 889
     
    
    892 890
     
    
    893
    -Settings = _Settings()
    
    894
    -
    
    895
    -
    
    896 891
     class LegacyConfig:
    
    897 892
     
    
    898 893
         @staticmethod
    
    899 894
         def get(setting: str) -> SETTING_TYPE:
    
    900
    -        return Settings.get_app_setting(setting)
    
    895
    +        return app.settings.get_app_setting(setting)
    
    901 896
     
    
    902 897
         @staticmethod
    
    903 898
         def set(setting: str, value: SETTING_TYPE) -> None:
    
    904
    -        Settings.set_app_setting(setting, value)
    
    899
    +        app.settings.set_app_setting(setting, value)
    
    905 900
     
    
    906 901
         @staticmethod
    
    907 902
         def get_per(kind: str, key: str, setting: str) -> SETTING_TYPE:
    
    908 903
             if kind == 'accounts':
    
    909
    -            return Settings.get_account_setting(key, setting)
    
    904
    +            return app.settings.get_account_setting(key, setting)
    
    910 905
     
    
    911 906
             if kind == 'plugins':
    
    912
    -            return Settings.get_plugin_setting(key, setting)
    
    907
    +            return app.settings.get_plugin_setting(key, setting)
    
    913 908
             raise ValueError
    
    914 909
     
    
    915 910
         @staticmethod
    
    916 911
         def set_per(kind: str, key: str, setting: str, value: SETTING_TYPE) -> None:
    
    917 912
             if kind == 'accounts':
    
    918
    -            Settings.set_account_setting(key, setting, value)
    
    913
    +            app.settings.set_account_setting(key, setting, value)
    
    919 914
             raise ValueError

  • gajim/common/types.py
    ... ... @@ -37,7 +37,7 @@ if TYPE_CHECKING:
    37 37
         from gajim.common.nec import NetworkEventsController
    
    38 38
     
    
    39 39
         from gajim.gui_interface import Interface
    
    40
    -    from gajim.common.settings import _Settings
    
    40
    +    from gajim.common.settings import Settings
    
    41 41
     
    
    42 42
     
    
    43 43
     NetworkEventsControllerT = Union['NetworkEventsController']
    
    ... ... @@ -61,4 +61,4 @@ PluginExtensionPoints = Dict[str, Tuple[Optional[Callable[..., None]],
    61 61
     EventHandlersDict = Dict[str, Tuple[int, Callable[['NetworkEvent'], Optional[bool]]]]
    
    62 62
     PluginEvents = List['NetworkEvent']
    
    63 63
     
    
    64
    -SettingsT = Union['_Settings']
    64
    +SettingsT = Union['Settings']

  • gajim/gui_interface.py
    ... ... @@ -81,7 +81,6 @@ from gajim.common.structs import MUCData
    81 81
     from gajim.common.nec import NetworkEvent
    
    82 82
     from gajim.common.i18n import _
    
    83 83
     from gajim.common.client import Client
    
    84
    -from gajim.common.settings import Settings
    
    85 84
     from gajim.common.const import Display
    
    86 85
     
    
    87 86
     from gajim.common.file_props import FilesProp
    
    ... ... @@ -2023,8 +2022,6 @@ class Interface:
    2023 2022
     
    
    2024 2023
             self.avatar_storage = AvatarStorage()
    
    2025 2024
     
    
    2026
    -        Settings.init()
    
    2027
    -
    
    2028 2025
             # Load CSS files
    
    2029 2026
             app.load_css_config()
    
    2030 2027