Commit 0686e6fc authored by segfault's avatar segfault
Browse files

Greeter: Fix "settings were loaded" notification always being displayed

... even on the first boot after creating the Persistent Storage, which
should not actually load any settings (see the comment in the code
explaining why this happened).
parent c1613748
......@@ -186,8 +186,21 @@ class GreeterMainWindow(Gtk.Window, TranslatableWindow):
settings_loaded = False
for setting in reversed(list(self.settings.region_settings)):
try:
setting.load()
settings_loaded = True
changed = setting.load()
if changed:
# We only want to show the "settings loaded" notification
# if settings were actually changed, i.e. the settings
# in the persistent settings dir were not the same as
# the already configured ones.
# Else, the notification would also be shown the first time
# the system is booted after creating the Persistent Storage
# (which currently means that the Persistent Storage is empty,
# but that's WIP on #11529), because then the persistent
# settings dir doesn't exist yet, which means that live-boot
# copies the current settings dir to the Persistent Storage -
# which contains the currently configured settings, which are
# then loaded.
settings_loaded = True
except SettingNotFoundError as e:
logging.debug(e)
# The settings file does not exist, so we create it by
......@@ -202,7 +215,7 @@ class GreeterMainWindow(Gtk.Window, TranslatableWindow):
# it has the default value.
if changed:
self.add_setting(setting.id)
settings_loaded = True
settings_loaded = True
except SettingNotFoundError as e:
logging.debug(e)
# The settings file does not exist, so we create it by
......
......@@ -61,14 +61,19 @@ class LocalizationSettingUI(GreeterSetting):
self._setting.save(self.value, is_default=False)
super().apply()
def load(self):
def load(self) -> bool:
try:
value, is_default = self._setting.load()
except SettingNotFoundError:
raise
if value == self.value:
return False
self.value = value
self.value_changed_by_user = not is_default
self.apply()
return True
@property
def default(self) -> {str, None}:
......@@ -179,13 +184,15 @@ class LanguageSettingUI(LocalizationSettingUI):
self._setting.apply_language(self.value)
self.changed_cb(self.value)
def load(self):
def load(self) -> bool:
try:
super().load()
changed = super().load()
except SettingNotFoundError:
raise
self._setting.apply_language(self.value)
self.changed_cb(self.value)
if changed:
self._setting.apply_language(self.value)
self.changed_cb(self.value)
return changed
class FormatsSettingUI(LocalizationSettingUI):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment