Commit 0b381fb9 authored by segfault's avatar segfault

Greeter: Refactor

Instead of always calling update_value_label() after apply(), call it
inside apply().
parent 805428e9
......@@ -120,7 +120,9 @@ class GreeterApplication(object):
def on_language_changed(self, locale_code: str):
"""Translate to the given locale"""
self.localisationsettings.formats.on_language_changed(locale_code) # XXX: notify
self.mainwindow.settings["formats"].update_value_label()
self.localisationsettings.keyboard.on_language_changed(locale_code) # XXX: notify
self.mainwindow.settings["keyboard"].update_value_label()
self.translate_to(locale_code)
self.mainwindow.current_language = localization.language_from_locale(locale_code)
......
......@@ -39,9 +39,6 @@ class AdditionalSetting(GreeterSetting):
else:
self.dialog.response(response)
def apply(self):
pass
def on_opened_in_dialog(self):
pass
......@@ -118,6 +115,7 @@ class AdminSettingUI(AdditionalSetting):
# This writes the password to a file from which it will be set
# as the amnesia password when the greeter is closed.
self._admin_setting.password = self.password
super().apply()
def cb_entry_admin_changed(self, editable, user_data=None):
self.update_check_icon()
......@@ -179,6 +177,7 @@ class MACSpoofSettingUI(AdditionalSetting):
def apply(self):
self._macspoof_setting.value = self.spoofing_enabled
super().apply()
def cb_listbox_macspoof_row_activated(self, listbox, row, user_data=None):
self.spoofing_enabled = row == self.listboxrow_macspoof_on
......@@ -237,6 +236,7 @@ class NetworkSettingUI(AdditionalSetting):
self._network_setting.value = self.value
is_bridge = self.value == self._network_setting.NETCONF_OBSTACLE
self.main_window.set_bridge_infobar_visibility(is_bridge)
super().apply()
def cb_listbox_network_button_press(self, widget, event, user_data=None):
# On double-click: Close the window and apply chosen setting
......
......@@ -337,15 +337,6 @@ class GreeterMainWindow(Gtk.Window, TranslatableWindow):
setting.apply()
# If the language is changed, the values of the other region settings
# are changed as well, so we have to update the value labels for all
# region settings in that case.
if isinstance(setting, LanguageSettingUI):
for s in self.settings.region_settings:
s.update_value_label()
else:
setting.update_value_label()
def cb_listbox_settings_row_activated(self, listbox, row, user_data=None):
setting = self.settings[self.settings.id_from_row(row)]
if not setting.popover.is_open():
......@@ -358,7 +349,6 @@ class GreeterMainWindow(Gtk.Window, TranslatableWindow):
self.listbox_settings.unselect_all()
if popover.response == Gtk.ResponseType.YES:
setting.apply()
setting.update_value_label()
def cb_toolbutton_settings_add_clicked(self, user_data=None):
self.add_setting()
......
......@@ -54,6 +54,7 @@ class LocalizationSettingUI(GreeterSetting):
def apply(self):
self._localization_setting.set_value(self.selected_code, chosen_by_user=True)
super().apply()
def cb_searchentry_activate(self, searchentry, user_data=None):
"""Selects the topmost item in the treeview when pressing Enter"""
......
......@@ -49,6 +49,9 @@ class GreeterSetting(object):
self.title_label.set_label(self.title)
self.update_value_label()
def apply(self):
self.update_value_label()
def update_value_label(self):
self.value_label.set_label(self.value_for_display)
......
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