Skip to content

Commit

Permalink
Disable storage list while work is being done
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende committed Dec 21, 2023
1 parent 96f5090 commit 3f1fb74
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions cozy/app_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def __init__(self, gtk_app, main_window_builder, main_window):
self.library_view_model.add_listener(self._on_open_view)
self.library_view_model.add_listener(self._on_library_view_event)
self.playback_control_view_model.add_listener(self._on_open_view)
self.headerbar_view_model.add_listener(self._on_open_view)
self.headerbar_view_model.add_listener(self._on_working_event)
self.app_view_model.add_listener(self._on_app_view_event)

self.main_window.add_listener(self._on_main_window_event)
Expand Down Expand Up @@ -148,10 +148,12 @@ def _on_app_view_event(self, event: str, data):
if event == "view":
self.headerbar_view_model.set_view(data)

def _on_main_window_event(self, event: str, data):
def _on_working_event(self, event: str, data) -> None:
if event == "working":
self.book_detail_view_model.lock_ui = data
self.settings_view_model.lock_ui = data

def _on_main_window_event(self, event: str, data):
if event == "open_view":
self._on_open_view(data, None)

Expand Down
2 changes: 1 addition & 1 deletion cozy/ui/main_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ def switch_to_playing(self):
self.block_ui_buttons(False, True)
else:
# we want to only block the player controls
# TODO: rework. this is messy
self.block_ui_buttons(False, True)
self.block_ui_buttons(True, False)
self.emit_event_main_thread("working", False)

def check_for_tracks(self):
"""
Expand Down
2 changes: 2 additions & 0 deletions cozy/view_model/headerbar_view_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,12 @@ def _start_working(self, message: str):
self._notify("work_message")
self._notify("work_progress")
self._notify("state")
self.emit_event_main_thread("working", True)

def _stop_working(self):
self._state = HeaderBarState.PLAYING
self._notify("state")
self.emit_event_main_thread("working", False)

def _on_importer_event(self, event: str, message):
if event == "scan-progress" and isinstance(message, float):
Expand Down

0 comments on commit 3f1fb74

Please sign in to comment.