summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsegfault <segfault@riseup.net>2020-02-15 01:32:21 +0100
committersegfault <segfault@riseup.net>2020-02-15 01:32:21 +0100
commit3bb8f74dc58fc871bea7dc61b831add067c813f5 (patch)
tree16afedba2d9f7d1e6ef7893701897078292e5adb
parent49e904982c0e78bb0a5d618b3909b585a79d9d85 (diff)
Re-add the boolean return value to load() (refs: #17136)feature/17136-persist-greeter-settings
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.
-rw-r--r--config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/ui/additional_settings.py23
-rw-r--r--config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/ui/main_window.py8
2 files changed, 24 insertions, 7 deletions
diff --git a/config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/ui/additional_settings.py b/config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/ui/additional_settings.py
index b725ad2..543d60b 100644
--- a/config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/ui/additional_settings.py
+++ b/config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/ui/additional_settings.py
@@ -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:
diff --git a/config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/ui/main_window.py b/config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/ui/main_window.py
index 9addcd4..ea042fc 100644
--- a/config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/ui/main_window.py
+++ b/config/chroot_local-includes/usr/lib/python3/dist-packages/tailsgreeter/ui/main_window.py
@@ -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)