From c3cc23313271b0602a6f8afd05053185f2317ebc Mon Sep 17 00:00:00 2001 From: Alexander Rosenberg Date: Mon, 23 Oct 2023 18:01:39 -0700 Subject: [PATCH] Fix logins --- simplelogin-gui/data/main_panel.blp | 162 ++++++++++++++++++++++++ simplelogin-gui/res.old/main-panel.ui | 20 +-- simplelogin-gui/res.old/totp-dialog.blp | 121 ++++++++++++++++++ simplelogin-gui/src/application.rs | 2 +- simplelogin-gui/src/login_window.rs | 4 - simplelogin-gui/src/main.rs | 1 + simplelogin-gui/src/main_panel.rs | 54 ++++++++ 7 files changed, 349 insertions(+), 15 deletions(-) create mode 100644 simplelogin-gui/data/main_panel.blp create mode 100644 simplelogin-gui/res.old/totp-dialog.blp create mode 100644 simplelogin-gui/src/main_panel.rs diff --git a/simplelogin-gui/data/main_panel.blp b/simplelogin-gui/data/main_panel.blp new file mode 100644 index 0000000..c4899ee --- /dev/null +++ b/simplelogin-gui/data/main_panel.blp @@ -0,0 +1,162 @@ +using Gtk 4.0; + +template $MainPanel : Box { + Overlay overlay { + child: Box content_wrapper { + orientation: vertical; + vexpand: true; + + Box { + SearchEntry search_box { + hexpand: true; + placeholder-text: "Filter by email, description, etc."; + } + + DropDown view_dropdown { + hexpand: true; + selected: 0; + model: StringList { + strings ["All aliases", "Pinned only", "Enabled only", "Disabled only",] + }; + } + + Button search_button { + label: "Search"; + } + } + + Box { + Button new_button { + label: "New"; + } + + Button edit_button { + label: "Edit"; + } + + Button delete_button { + label: "Delete"; + } + + Button prev_page_button { + halign: end; + hexpand: true; + icon-name: "go-previous-symbolic"; + } + + Entry page_label { + has-frame: false; + input-hints: no_emoji | no_spellcheck; + input-purpose: digits; + max-width-chars: 0; + text: "1"; + truncate-multiline: true; + width-chars: 5; + xalign: 0.5; + } + + Button next_page_button { + icon-name: "go-next-symbolic"; + } + } + + Overlay scroll_overlay { + child: ScrolledWindow { + vexpand: true; + + ListView alias_list_view { + factory: SignalListItemFactory alias_item_factory { + }; + + model: MultiSelection alias_selection_model { + }; + } + }; + + [overlay] + Label no_content_label { + hexpand: true; + label: "No more results"; + vexpand: true; + + styles [ + "loading-label", + ] + } + } + }; + + [overlay] + Box error_overlay { + hexpand: true; + orientation: vertical; + visible: false; + + Box { + halign: center; + valign: end; + + Button error_refresh_button { + halign: center; + icon-name: "view-refresh-symbolic"; + valign: end; + vexpand: true; + + styles [ + "loading-label", + ] + } + + Button error_close_button { + halign: center; + icon-name: "window-close-symbolic"; + valign: end; + + styles [ + "loading-label", + ] + } + } + + Label error_label { + label: "ERROR"; + valign: start; + vexpand: true; + + styles [ + "error-message-label", + "loading-label", + ] + } + } + + [overlay] + Box loading_overlay { + orientation: vertical; + + Spinner { + spinning: true; + valign: end; + vexpand: true; + + styles [ + "loading-label", + ] + } + + Label { + label: "Loading..."; + valign: start; + vexpand: true; + + styles [ + "loading-label", + ] + } + + styles [ + "loading-label", + ] + } + } +} diff --git a/simplelogin-gui/res.old/main-panel.ui b/simplelogin-gui/res.old/main-panel.ui index 873787e..eb5a30f 100644 --- a/simplelogin-gui/res.old/main-panel.ui +++ b/simplelogin-gui/res.old/main-panel.ui @@ -21,16 +21,16 @@ True - - - - All aliases - Pinned only - Enabled only - Disabled only - - - + + + + + + + + + + 0 diff --git a/simplelogin-gui/res.old/totp-dialog.blp b/simplelogin-gui/res.old/totp-dialog.blp new file mode 100644 index 0000000..43b4d0c --- /dev/null +++ b/simplelogin-gui/res.old/totp-dialog.blp @@ -0,0 +1,121 @@ +using Gtk 4.0; + +template $SLTotpDialog : Window { + modal: true; + title: "TOTP Entry"; + + Overlay overlay { + child: form_wrapper; + halign: center; + hexpand: true; + valign: center; + vexpand: true; + + Grid form_wrapper { + column-spacing: 5; + halign: center; + hexpand: true; + margin-bottom: 10; + margin-end: 10; + margin-start: 10; + margin-top: 10; + row-spacing: 5; + valign: center; + vexpand: true; + + Box { + halign: center; + hexpand: true; + + Image { + halign: center; + icon-name: "dialog-password-symbolic"; + } + + Label { + label: "TOTP"; + + styles [ + "login-title-label", + ] + } + + layout { + column: "0"; + column-span: "2"; + row: "0"; + } + } + + Button accept_button { + label: "Accept"; + + layout { + column: "1"; + row: "3"; + } + } + + Button cancel_button { + label: "Cancel"; + + layout { + column: "0"; + row: "3"; + } + } + + Entry code_entry { + placeholder-text: "TOTP Code"; + + layout { + column: "0"; + column-span: "2"; + row: "1"; + } + } + + Label error_label { + label: "ERROR"; + + styles [ + "error-message-label", + ] + + layout { + column: "0"; + column-span: "2"; + row: "2"; + } + } + } + } +} + +Box loading_overlay { + orientation: vertical; + + Spinner { + spinning: true; + valign: end; + vexpand: true; + + styles [ + "loading-label", + ] + } + + Label { + label: "Loading..."; + valign: start; + vexpand: true; + + styles [ + "loading-label", + ] + } + + styles [ + "loading-label", + ] +} diff --git a/simplelogin-gui/src/application.rs b/simplelogin-gui/src/application.rs index 68c1513..d98033d 100644 --- a/simplelogin-gui/src/application.rs +++ b/simplelogin-gui/src/application.rs @@ -20,7 +20,7 @@ mod imp { impl Application { fn api_key(&self) -> Option { - self.settings.borrow().value("api-key").get() + self.settings.borrow().value("api-key").get::>()? } fn set_api_key(&self, value: Option) { diff --git a/simplelogin-gui/src/login_window.rs b/simplelogin-gui/src/login_window.rs index a52303f..2b323b4 100644 --- a/simplelogin-gui/src/login_window.rs +++ b/simplelogin-gui/src/login_window.rs @@ -156,10 +156,6 @@ mod imp { vec![Signal::builder("logged-in").build()]); SIGNALS.as_ref() } - - fn constructed(&self) { - self.parent_constructed(); - } } impl WidgetImpl for LoginWindow {} diff --git a/simplelogin-gui/src/main.rs b/simplelogin-gui/src/main.rs index 6682100..061ca39 100644 --- a/simplelogin-gui/src/main.rs +++ b/simplelogin-gui/src/main.rs @@ -1,6 +1,7 @@ mod login_window; mod totp_window; mod application; +mod main_panel; use gtk4 as gtk; use gtk::prelude::*; diff --git a/simplelogin-gui/src/main_panel.rs b/simplelogin-gui/src/main_panel.rs new file mode 100644 index 0000000..af3d439 --- /dev/null +++ b/simplelogin-gui/src/main_panel.rs @@ -0,0 +1,54 @@ +use gtk4 as gtk; +use gtk::{glib, prelude::*, subclass::prelude::*}; + +mod imp { + use super::*; + use glib::subclass::Signal; + use once_cell::sync::Lazy; + + #[derive(Debug, Default, gtk::CompositeTemplate)] + #[template(file = "data/main_panel.blp")] + pub struct MainPanel { + #[template_child] + pub overlay: TemplateChild, + } + + #[gtk::template_callbacks] + impl MainPanel { + + } + + #[glib::object_subclass] + impl ObjectSubclass for MainPanel { + const NAME: &'static str = "MainPanel"; + type Type = super::MainPanel; + type ParentType = gtk::Box; + + fn class_init(class: &mut Self::Class) { + class.bind_template(); + class.bind_template_callbacks(); + } + + fn instance_init(obj: &glib::subclass::InitializingObject) { + obj.init_template(); + } + } + + impl ObjectImpl for MainPanel { + fn signals() -> &'static [Signal] { + static SIGNALS: Lazy> = Lazy::new(|| + vec![Signal::builder("logged-out").build(), + Signal::builder("api-key-cleared").build()]); + SIGNALS.as_ref() + } + } + + impl BoxImpl for MainPanel {} + impl WidgetImpl for MainPanel {} +} + +glib::wrapper! { + pub struct MainPanel(ObjectSubclass) + @extends gtk::Widget, @implements gtk::Accessible, + gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable; +}