Commit 46798ffd authored by segfault's avatar segfault

Re-add the boolean return value to load() (refs: #17136)

Turns out there was actually a good reason to have those, because we
only want to add additional settings if the loaded value is not the
default value and if they haven't been added before.
parent f64d4e53
......@@ -44,7 +44,7 @@ class AdditionalSetting(GreeterSetting):
def on_opened_in_dialog(self):
pass
def load(self):
def load(self) -> bool:
pass
......@@ -130,12 +130,13 @@ class AdminSettingUI(AdditionalSetting):
self._admin_setting.delete()
super().apply()
def load(self):
def load(self) -> bool:
try:
self._admin_setting.load()
except SettingNotFoundError:
raise
self.password = True
return True
def cb_entry_admin_changed(self, editable, user_data=None):
self.update_check_icon()
......@@ -201,12 +202,18 @@ class MACSpoofSettingUI(AdditionalSetting):
self._macspoof_setting.save(self.spoofing_enabled)
super().apply()
def load(self):
def load(self) -> bool:
try:
self.spoofing_enabled = self._macspoof_setting.load()
value = self._macspoof_setting.load()
except SettingNotFoundError:
raise
if self.spoofing_enabled == value:
return False
self.spoofing_enabled = value
return True
def cb_listbox_macspoof_row_activated(self, listbox, row, user_data=None):
self.spoofing_enabled = row == self.listboxrow_macspoof_on
self.image_macspoof_on.set_visible(self.spoofing_enabled)
......@@ -268,10 +275,16 @@ class NetworkSettingUI(AdditionalSetting):
def load(self):
try:
self.value = self._network_setting.load()
value = self._network_setting.load()
except SettingNotFoundError:
raise
if self.value == value:
return False
self.value = value
return True
def cb_listbox_network_button_press(self, widget, event, user_data=None):
# On double-click: Close the window and apply chosen setting
if event.type == Gdk.EventType._2BUTTON_PRESS:
......
......@@ -192,8 +192,12 @@ class GreeterMainWindow(Gtk.Window, TranslatableWindow):
logging.debug(e)
for setting in self.settings.additional_settings:
try:
setting.load()
self.add_setting(setting.id)
changed = setting.load()
# We only add the setting to the list of additional settings
# if it was actually changed. Else it is either already added or
# it has the default value.
if changed:
self.add_setting(setting.id)
settings_loaded = True
except SettingNotFoundError as e:
logging.debug(e)
......
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