Add "auth failed" message to unlock dialog
This commit is contained in:
parent
8394d45d1a
commit
99ffa88657
@ -25,6 +25,8 @@ fn main() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
gtk::init()?;
|
gtk::init()?;
|
||||||
|
|
||||||
|
let (tx, rx) = glib::MainContext::sync_channel(glib::PRIORITY_DEFAULT, 1);
|
||||||
|
|
||||||
let top_sg = gtk::SizeGroup::builder()
|
let top_sg = gtk::SizeGroup::builder()
|
||||||
.mode(gtk::SizeGroupMode::Horizontal)
|
.mode(gtk::SizeGroupMode::Horizontal)
|
||||||
.build();
|
.build();
|
||||||
@ -143,7 +145,31 @@ fn main() -> anyhow::Result<()> {
|
|||||||
vbox.pack_start(&label, false, false, 0);
|
vbox.pack_start(&label, false, false, 0);
|
||||||
glib::timeout_add_seconds_local(1, move || {
|
glib::timeout_add_seconds_local(1, move || {
|
||||||
set_time_label(&label);
|
set_time_label(&label);
|
||||||
glib::source::Continue(true)
|
glib::Continue(true)
|
||||||
|
});
|
||||||
|
|
||||||
|
let attrs = gtk::pango::AttrList::new();
|
||||||
|
attrs.insert(gtk::pango::AttrFloat::new_scale(gtk::pango::SCALE_XX_LARGE));
|
||||||
|
let mut bold_desc = gtk::pango::FontDescription::new();
|
||||||
|
bold_desc.set_weight(gtk::pango::Weight::Bold);
|
||||||
|
attrs.insert(gtk::pango::AttrFontDesc::new(&bold_desc));
|
||||||
|
let auth_failed_label = gtk::Label::builder()
|
||||||
|
.label("Authentication Failed!")
|
||||||
|
.xalign(0.5)
|
||||||
|
.yalign(0.5)
|
||||||
|
.attributes(&attrs)
|
||||||
|
.opacity(0.0)
|
||||||
|
.build();
|
||||||
|
vbox.pack_start(&auth_failed_label, false, false, 0);
|
||||||
|
|
||||||
|
rx.attach(None, move |exit_status| {
|
||||||
|
if exit_status != 0 {
|
||||||
|
auth_failed_label.set_opacity(1.0);
|
||||||
|
glib::timeout_add_seconds_local_once(2, move || exit(exit_status));
|
||||||
|
} else {
|
||||||
|
exit(exit_status);
|
||||||
|
}
|
||||||
|
glib::Continue(true)
|
||||||
});
|
});
|
||||||
|
|
||||||
let sep = gtk::Separator::builder()
|
let sep = gtk::Separator::builder()
|
||||||
@ -243,11 +269,12 @@ fn main() -> anyhow::Result<()> {
|
|||||||
let username = username.clone();
|
let username = username.clone();
|
||||||
let password = password_box.text().to_string();
|
let password = password_box.text().to_string();
|
||||||
|
|
||||||
|
let tx = tx.clone();
|
||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
if authenticate(&username, &password) {
|
let status = if authenticate(&username, &password) { 0 } else { -1 };
|
||||||
exit(0);
|
if let Err(err) = tx.send(status) {
|
||||||
} else {
|
error!("Failed to send exit status to main thread: {}", err);
|
||||||
exit(-1);
|
exit(2);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -268,7 +295,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
{
|
{
|
||||||
let timer = Rc::clone(&timer);
|
let timer = Rc::clone(&timer);
|
||||||
let delta = (DIALOG_UPDATE_INTERVAL.as_millis() as f64) / (DIALOG_TIMEOUT.as_millis() as f64);
|
let delta = (DIALOG_UPDATE_INTERVAL.as_millis() as f64) / (DIALOG_TIMEOUT.as_millis() as f64);
|
||||||
gtk::glib::source::timeout_add_local(DIALOG_UPDATE_INTERVAL, move || {
|
glib::timeout_add_local(DIALOG_UPDATE_INTERVAL, move || {
|
||||||
let new_fraction = timer.fraction() - delta;
|
let new_fraction = timer.fraction() - delta;
|
||||||
if new_fraction <= 0.0 {
|
if new_fraction <= 0.0 {
|
||||||
exit(1);
|
exit(1);
|
||||||
|
Loading…
Reference in New Issue
Block a user