Fix logins

This commit is contained in:
Alexander Rosenberg 2023-10-23 18:01:39 -07:00
parent 67440ccca1
commit c3cc233132
Signed by: Zander671
GPG Key ID: 5FD0394ADBD72730
7 changed files with 349 additions and 15 deletions

View File

@ -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",
]
}
}
}

View File

@ -21,16 +21,16 @@
<child> <child>
<object class="GtkDropDown" id="view_dropdown"> <object class="GtkDropDown" id="view_dropdown">
<property name="hexpand">True</property> <property name="hexpand">True</property>
<property name="model"> <!-- <property name="model"> -->
<object class="GtkStringList"> <!-- <object class="GtkStringList"> -->
<items> <!-- <items> -->
<item>All aliases</item> <!-- <item>All aliases</item> -->
<item>Pinned only</item> <!-- <item>Pinned only</item> -->
<item>Enabled only</item> <!-- <item>Enabled only</item> -->
<item>Disabled only</item> <!-- <item>Disabled only</item> -->
</items> <!-- </items> -->
</object> <!-- </object> -->
</property> <!-- </property> -->
<property name="selected">0</property> <property name="selected">0</property>
</object> </object>
</child> </child>

View File

@ -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",
]
}

View File

@ -20,7 +20,7 @@ mod imp {
impl Application { impl Application {
fn api_key(&self) -> Option<String> { fn api_key(&self) -> Option<String> {
self.settings.borrow().value("api-key").get() self.settings.borrow().value("api-key").get::<Option<String>>()?
} }
fn set_api_key(&self, value: Option<String>) { fn set_api_key(&self, value: Option<String>) {

View File

@ -156,10 +156,6 @@ mod imp {
vec![Signal::builder("logged-in").build()]); vec![Signal::builder("logged-in").build()]);
SIGNALS.as_ref() SIGNALS.as_ref()
} }
fn constructed(&self) {
self.parent_constructed();
}
} }
impl WidgetImpl for LoginWindow {} impl WidgetImpl for LoginWindow {}

View File

@ -1,6 +1,7 @@
mod login_window; mod login_window;
mod totp_window; mod totp_window;
mod application; mod application;
mod main_panel;
use gtk4 as gtk; use gtk4 as gtk;
use gtk::prelude::*; use gtk::prelude::*;

View File

@ -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::Overlay>,
}
#[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<Self>) {
obj.init_template();
}
}
impl ObjectImpl for MainPanel {
fn signals() -> &'static [Signal] {
static SIGNALS: Lazy<Vec<Signal>> = 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<imp::MainPanel>)
@extends gtk::Widget, @implements gtk::Accessible,
gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
}