Skip to content

Commit

Permalink
Did I delete the ("working", True) event emission?
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende committed Dec 20, 2023
1 parent dcc5aeb commit fcc0fe8
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions cozy/ui/preferences_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,36 +18,34 @@ class PreferencesView(Adw.PreferencesWindow):
_view_model: SettingsViewModel = inject.attr(SettingsViewModel)

storages_page: Adw.PreferencesPage = Gtk.Template.Child()
user_feedback_preference_group: Adw.PreferencesGroup = Gtk.Template.Child()

dark_mode_switch: Gtk.Switch = Gtk.Template.Child()
swap_author_reader_switch: Gtk.Switch = Gtk.Template.Child()
replay_switch: Gtk.Switch = Gtk.Template.Child()
dark_mode_switch: Adw.SwitchRow = Gtk.Template.Child()
swap_author_reader_switch: Adw.SwitchRow = Gtk.Template.Child()
replay_switch: Adw.SwitchRow = Gtk.Template.Child()
sleep_timer_fadeout_switch: Adw.SwitchRow = Gtk.Template.Child()
fadeout_duration_spin_button: Adw.SpinRow = Gtk.Template.Child()
artwork_prefer_external_switch: Gtk.Switch = Gtk.Template.Child()
artwork_prefer_external_switch: Adw.SwitchRow = Gtk.Template.Child()

rewind_duration_adjustment: Gtk.Adjustment = Gtk.Template.Child()
forward_duration_adjustment: Gtk.Adjustment = Gtk.Template.Child()
fadeout_duration_adjustment: Gtk.Adjustment = Gtk.Template.Child()

user_feedback_preference_group: Adw.PreferencesRow = Gtk.Template.Child()

def __init__(self, **kwargs):
super().__init__(transient_for=self.main_window.window, **kwargs)

error_reporting = ErrorReporting()
error_reporting.show_header(False)
self.user_feedback_preference_group.add(error_reporting)

storage_locations = StorageLocations()
self.storages_page.add(storage_locations)
self.storage_locations_view = StorageLocations()
self.storages_page.add(self.storage_locations_view)

self._bind_settings()

self.connect("close-request", self._hide_window)
self._view_model.bind_to("lock_ui", self._on_lock_ui_changed)

self.sleep_timer_fadeout_switch.connect("notify::active", self._on_sleep_fadeout_switch_changed)
self.fadeout_duration_spin_button.set_sensitive(self.sleep_timer_fadeout_switch.props.active)
self.connect("close-request", self._hide_window)

def _bind_settings(self):
self._glib_settings.bind("dark-mode", self.dark_mode_switch, "active",
Expand All @@ -71,19 +69,10 @@ def _bind_settings(self):
self._glib_settings.bind("prefer-external-cover", self.artwork_prefer_external_switch, "active",
Gio.SettingsBindFlags.DEFAULT)

def _on_sleep_fadeout_switch_changed(self, widget, param):
state = widget.get_property(param.name)
self.fadeout_duration_spin_button.set_sensitive(state)

def _on_lock_ui_changed(self):
sensitive = not self._view_model.lock_ui

self.storage_locations_list.set_sensitive(sensitive)
self.add_storage_button.set_sensitive(sensitive)
self.remove_storage_button.set_sensitive(sensitive)
self.external_storage_toggle_button.set_sensitive(sensitive)
self.default_storage_button.set_sensitive(sensitive)
self._on_storage_box_changed(None, self.storage_locations_list.get_selected_row())
self.storage_locations_view.set_sensitive(sensitive)

def _hide_window(self, *_):
self.hide()
Expand Down

0 comments on commit fcc0fe8

Please sign in to comment.