From 13bd29dbf938bcdff0c49ca3377a5a59221bb2e5 Mon Sep 17 00:00:00 2001 From: Bernd Schoolmann Date: Sat, 17 Feb 2024 12:48:26 +0100 Subject: [PATCH] Add browser biometrics setup window --- gui/src/gui/browserbiometrics.py | 53 ++++++++++++++++++++++++++++++++ gui/src/gui/settings.py | 10 ++++++ 2 files changed, 63 insertions(+) create mode 100644 gui/src/gui/browserbiometrics.py diff --git a/gui/src/gui/browserbiometrics.py b/gui/src/gui/browserbiometrics.py new file mode 100644 index 0000000..3199786 --- /dev/null +++ b/gui/src/gui/browserbiometrics.py @@ -0,0 +1,53 @@ +import gi +gi.require_version('Gtk', '4.0') +gi.require_version('Adw', '1') +import gc +import time +from gi.repository import Gtk, Adw, GLib, Notify, Gdk +from threading import Thread +import sys +import os +from . import components + +class MyApp(Adw.Application): + def __init__(self, **kwargs): + super().__init__(**kwargs) + self.connect('activate', self.on_activate) + + def on_activate(self, app): + self.pinentry_window = MainWindow(application=app) + self.pinentry_window.present() + self.app = app + +class MainWindow(Gtk.ApplicationWindow): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + + # vertical box + self.box = Gtk.Box() + self.box.set_orientation(Gtk.Orientation.VERTICAL) + self.set_child(self.box) + + self.stack = Gtk.Stack() + self.stack.set_transition_type(Gtk.StackTransitionType.SLIDE_LEFT_RIGHT) + self.box.append(self.stack) + + self.preferences_page = Adw.PreferencesPage() + self.preferences_page.set_title("General") + self.stack.add_named(self.preferences_page, "preferences_page") + + self.register_browser_biometrics_group = Adw.PreferencesGroup() + self.register_browser_biometrics_group.set_title("Register Browser Biometrics") + self.register_browser_biometrics_group.set_description("Run the following command in your terminal to set up the browser biometrics integration") + self.preferences_page.add(self.register_browser_biometrics_group) + + self.setup_command_row = Adw.ActionRow() + self.setup_command_row.set_subtitle("flatpak run --filesystem=home --command=goldwarden com.quexten.Goldwarden setup browserbiometrics") + self.setup_command_row.set_subtitle_selectable(True) + self.register_browser_biometrics_group.add(self.setup_command_row) + + self.set_default_size(700, 400) + self.set_title("Goldwarden Browser Biometrics Setup") + +app = MyApp(application_id="com.quexten.Goldwarden.browserbiometrics") +app.run(sys.argv) \ No newline at end of file diff --git a/gui/src/gui/settings.py b/gui/src/gui/settings.py index a73e56a..0c01750 100644 --- a/gui/src/gui/settings.py +++ b/gui/src/gui/settings.py @@ -31,6 +31,11 @@ def ssh_button_clicked(): p.stdin.write(f"{token}\n".encode()) p.stdin.flush() +def browserbiometrics_button_clicked(): + p = subprocess.Popen(["python3", "-m", "src.gui.browserbiometrics"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, cwd=root_path, start_new_session=True) + p.stdin.write(f"{token}\n".encode()) + p.stdin.flush() + def add_action_row(parent, title, subtitle, icon=None): row = Adw.ActionRow() row.set_title(title) @@ -154,6 +159,11 @@ class SettingsWinvdow(Gtk.ApplicationWindow): action.connect("activate", lambda action, parameter: ssh_button_clicked()) self.add_action(action) menu.append("SSH Agent", "win.ssh") + + action = Gio.SimpleAction.new("browserbiometrics", None) + action.connect("activate", lambda action, parameter: browserbiometrics_button_clicked()) + self.add_action(action) + menu.append("Browser Biometrics", "win.browserbiometrics") self.hamburger = Gtk.MenuButton() self.hamburger.set_popover(self.popover)