now tested and working
This commit is contained in:
parent
b0db4805a8
commit
c566c508ae
36
src/main.rs
36
src/main.rs
|
@ -22,6 +22,12 @@ fn main() {
|
|||
handler_borrowed.setup_greeter(handler.clone());
|
||||
handler_borrowed.setup_de_select(handler.clone());
|
||||
}
|
||||
{
|
||||
let handler_borrowed = handler.borrow();
|
||||
let greeter = handler_borrowed.greeter.as_ref().expect("no greeter");
|
||||
let user = handler_borrowed.user.as_ref().expect("no user");
|
||||
greeter.authenticate(Some(&user)).ok();
|
||||
}
|
||||
let handler_builder_clone = handler.clone();
|
||||
builder.connect_signals(move |_, name| {
|
||||
let h_login_cb_clone = handler_builder_clone.clone();
|
||||
|
@ -158,22 +164,19 @@ impl Handler {
|
|||
.set_text(msg);
|
||||
});
|
||||
greeter.connect_to_daemon_sync().ok();
|
||||
greeter.authenticate(Some(&self.user.clone().unwrap())).ok();
|
||||
self.greeter = Some(greeter);
|
||||
}
|
||||
|
||||
fn setup_de_select(&self, handler: Rc<RefCell<Self>>) {
|
||||
fn setup_de_select(&mut self, handler: Rc<RefCell<Self>>) {
|
||||
{
|
||||
let mut handler_borrowed = handler.borrow_mut();
|
||||
let session = handler_borrowed
|
||||
let session = self
|
||||
.greeter
|
||||
.as_ref()
|
||||
.expect("wheres the greeter at")
|
||||
.get_default_session_hint()
|
||||
.expect("no default session");
|
||||
handler_borrowed.session = Some(String::from(session));
|
||||
self.session = Some(String::from(session));
|
||||
}
|
||||
let first_handler = handler.clone();
|
||||
let vbox = gtk::BoxBuilder::new()
|
||||
.orientation(gtk::Orientation::Vertical)
|
||||
.visible(true)
|
||||
|
@ -187,22 +190,29 @@ impl Handler {
|
|||
});
|
||||
let (name, key) = sessions.next().expect("no session");
|
||||
let first = gtk::RadioButtonBuilder::new().label(&name).build();
|
||||
first.connect_toggled(move |_| {
|
||||
first_handler.borrow_mut().session = Some(key.clone());
|
||||
});
|
||||
let mut keys = Vec::new();
|
||||
let mut rbs = Vec::new();
|
||||
keys.push(key);
|
||||
rbs.push(first.clone());
|
||||
vbox.add(&first);
|
||||
for (name, key) in sessions {
|
||||
let handler_clone = handler.clone();
|
||||
let key_clone = key.clone();
|
||||
let rb = gtk::RadioButton::new_with_label_from_widget(&first, &name);
|
||||
rb.connect_toggled(move |_| {
|
||||
handler_clone.borrow_mut().session = Some(key.clone());
|
||||
});
|
||||
keys.push(key);
|
||||
rbs.push(rb.clone());
|
||||
vbox.add(&rb);
|
||||
if self.session.clone().expect("session not found") == key_clone {
|
||||
rb.set_active(true);
|
||||
}
|
||||
}
|
||||
let keys_iter = keys.iter();
|
||||
for (rb, key) in rbs.iter().zip(keys_iter) {
|
||||
let handler_clone = handler.clone();
|
||||
let key_clone = key.clone();
|
||||
rb.connect_toggled(move |_| {
|
||||
handler_clone.borrow_mut().session = Some(key_clone.clone());
|
||||
});
|
||||
};
|
||||
self.de_select.as_ref().expect("no de select").add(&vbox);
|
||||
vbox.show_all()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue