Make some notification noise when the application terminates without request
This commit is contained in:
1 parent
36867dca97
commit
caecef4ecd
2 files changed
+10
-2
No files matched your search
@@ -519,7 +519,7 @@ class LoginForm:
|
|||||||
async def ask_login(self) -> LoginData:
|
async def ask_login(self) -> LoginData:
|
||||||
self.update(_("gui", "login", "required"), None)
|
self.update(_("gui", "login", "required"), None)
|
||||||
# ensure the window isn't hidden into tray when this runs
|
# ensure the window isn't hidden into tray when this runs
|
||||||
self._manager.tray.restore()
|
self._manager.grab_attention(sound=False)
|
||||||
while True:
|
while True:
|
||||||
self._manager.print(_("gui", "login", "request"))
|
self._manager.print(_("gui", "login", "request"))
|
||||||
await self.wait_for_login_press()
|
await self.wait_for_login_press()
|
||||||
@@ -546,7 +546,7 @@ class LoginForm:
|
|||||||
async def ask_enter_code(self, user_code: str) -> None:
|
async def ask_enter_code(self, user_code: str) -> None:
|
||||||
self.update(_("gui", "login", "required"), None)
|
self.update(_("gui", "login", "required"), None)
|
||||||
# ensure the window isn't hidden into tray when this runs
|
# ensure the window isn't hidden into tray when this runs
|
||||||
self._manager.tray.restore()
|
self._manager.grab_attention(sound=False)
|
||||||
self._manager.print(_("gui", "login", "request"))
|
self._manager.print(_("gui", "login", "request"))
|
||||||
await self.wait_for_login_press()
|
await self.wait_for_login_press()
|
||||||
self._manager.print(f"Enter this code on the Twitch's device activation page: {user_code}")
|
self._manager.print(f"Enter this code on the Twitch's device activation page: {user_code}")
|
||||||
@@ -2108,6 +2108,11 @@ class GUIManager:
|
|||||||
def save(self, *, force: bool = False) -> None:
|
def save(self, *, force: bool = False) -> None:
|
||||||
self._cache.save(force=force)
|
self._cache.save(force=force)
|
||||||
|
|
||||||
|
def grab_attention(self, *, sound: bool = True):
|
||||||
|
self.tray.restore()
|
||||||
|
self._root.focus_force()
|
||||||
|
self._root.bell()
|
||||||
|
|
||||||
def set_games(self, games: abc.Iterable[Game]) -> None:
|
def set_games(self, games: abc.Iterable[Game]) -> None:
|
||||||
self.settings.set_games(games)
|
self.settings.set_games(games)
|
||||||
|
|
||||||
|
|||||||
@@ -172,8 +172,11 @@ if __name__ == "__main__":
|
|||||||
client.print(_("gui", "status", "exiting"))
|
client.print(_("gui", "status", "exiting"))
|
||||||
await client.shutdown()
|
await client.shutdown()
|
||||||
if not client.gui.close_requested:
|
if not client.gui.close_requested:
|
||||||
|
# user didn't request the closure
|
||||||
client.print(_("status", "terminated"))
|
client.print(_("status", "terminated"))
|
||||||
client.gui.status.update(_("gui", "status", "terminated"))
|
client.gui.status.update(_("gui", "status", "terminated"))
|
||||||
|
# notify the user about the closure
|
||||||
|
client.gui.grab_attention(sound=True)
|
||||||
await client.gui.wait_until_closed()
|
await client.gui.wait_until_closed()
|
||||||
# save the application state
|
# save the application state
|
||||||
# NOTE: we have to do it after wait_until_closed,
|
# NOTE: we have to do it after wait_until_closed,
|
||||||
|
|||||||
Reference in new issue
Block a user