55 lines
1.9 KiB
Rust
55 lines
1.9 KiB
Rust
use adw::prelude::*;
|
|
use gtk::glib;
|
|
|
|
mod bus;
|
|
mod enroll_dialog;
|
|
mod error;
|
|
mod keys_page;
|
|
|
|
const APP_ID: &str = "io.dangerousthings.AuthForge";
|
|
|
|
fn main() -> glib::ExitCode {
|
|
// Multi-thread tokio runtime hosts zbus's tokio-flavored futures. The
|
|
// `_guard` keeps the runtime context active on this thread so calls like
|
|
// `zbus::Connection::system().await` from within `glib::MainContext::
|
|
// spawn_local` closures don't panic with "no current reactor".
|
|
let runtime = tokio::runtime::Builder::new_multi_thread()
|
|
.enable_all()
|
|
.build()
|
|
.expect("build tokio runtime");
|
|
let _guard = runtime.enter();
|
|
|
|
let app = adw::Application::builder().application_id(APP_ID).build();
|
|
app.connect_activate(|app| {
|
|
let win = adw::ApplicationWindow::builder()
|
|
.application(app)
|
|
.default_width(720)
|
|
.default_height(540)
|
|
.title("Authentication")
|
|
.build();
|
|
let header = adw::HeaderBar::new();
|
|
let stack = adw::ViewStack::new();
|
|
let switcher = adw::ViewSwitcher::builder()
|
|
.stack(&stack)
|
|
.policy(adw::ViewSwitcherPolicy::Wide)
|
|
.build();
|
|
header.set_title_widget(Some(&switcher));
|
|
|
|
let toast_overlay = adw::ToastOverlay::new();
|
|
let keys = keys_page::KeysPage::new(win.clone().upcast(), toast_overlay.clone());
|
|
stack.add_titled(&keys.root, Some("keys"), "Keys");
|
|
|
|
// ToolbarView is libadwaita v1_4-gated; the project sticks with the
|
|
// simpler Box layout for portability (see commit c6a5e94).
|
|
let layout = gtk::Box::new(gtk::Orientation::Vertical, 0);
|
|
layout.append(&header);
|
|
layout.append(&stack);
|
|
stack.set_vexpand(true);
|
|
toast_overlay.set_child(Some(&layout));
|
|
|
|
win.set_content(Some(&toast_overlay));
|
|
win.present();
|
|
});
|
|
app.run()
|
|
}
|