From 8569fbc2da43b2591a036d52066301d3519dec39 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Fri, 3 May 2024 21:55:25 +0200 Subject: [PATCH] Add login shortcut --- gui/src/gui/login.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/gui/src/gui/login.py b/gui/src/gui/login.py index 9dfd00b..a062b1a 100644 --- a/gui/src/gui/login.py +++ b/gui/src/gui/login.py @@ -31,6 +31,19 @@ class GoldwardenLoginApp(Adw.Application): self.server_row = builder.get_object("server_row") self.login_button = builder.get_object("login_button") self.login_button.connect("clicked", lambda x: self.on_login()) + + evk = Gtk.EventControllerKey.new() + evk.set_propagation_phase(Gtk.PropagationPhase.CAPTURE) + evk.connect("key-pressed", self.key_press) + self.window.add_controller(evk) + + def key_press(self, event, keyval, keycode, state): + if keyval == Gdk.KEY_Escape: + os._exit(0) + + if keyval == Gdk.KEY_Return and state & Gdk.ModifierType.CONTROL_MASK: + self.on_login() + return True def on_login(self): email = self.email_row.get_text() @@ -43,6 +56,7 @@ class GoldwardenLoginApp(Adw.Application): if client_secret != "": goldwarden.set_client_secret(client_secret) goldwarden.login_with_password(email, "") + self.window.close() if __name__ == "__main__": settings = Gtk.Settings.get_default()