1
0
Fork 0

custom styling maybe?

This commit is contained in:
Raatty 2020-09-16 21:52:26 +12:00
parent 4c7a51cacc
commit e29ec82802
1 changed files with 30 additions and 12 deletions

View File

@ -5,9 +5,10 @@ use libhandy;
use lightdm; use lightdm;
use lightdm::{GreeterExt, SessionExt, UserExt, UserListExt}; use lightdm::{GreeterExt, SessionExt, UserExt, UserListExt};
use std::cell::RefCell; use std::cell::RefCell;
use std::rc::Rc;
use std::{fs,io};
use std::io::prelude::*; use std::io::prelude::*;
use std::path::*;
use std::rc::Rc;
use std::{fs, io};
fn main() { fn main() {
if gtk::init().is_err() { if gtk::init().is_err() {
@ -27,7 +28,11 @@ fn main() {
{ {
let handler_borrowed = handler.borrow(); let handler_borrowed = handler.borrow();
if let Ok(os_str) = pretty_name() { if let Ok(os_str) = pretty_name() {
handler_borrowed.msg_label.as_ref().expect("no msg label").set_text(&os_str); handler_borrowed
.msg_label
.as_ref()
.expect("no msg label")
.set_text(&os_str);
} }
} }
{ {
@ -94,14 +99,27 @@ fn main() {
(screen_size.height as f32 * 0.8) as i32, (screen_size.height as f32 * 0.8) as i32,
); );
let style = gtk::CssProvider::new(); let style = gtk::CssProvider::new();
let screen = gdk::Screen::get_default().expect("cant get screen");
style style
.load_from_data(include_bytes!("../style.css")) .load_from_data(include_bytes!("../style.css"))
.expect("failed to load style"); .expect("failed to load style");
gtk::StyleContext::add_provider_for_screen( gtk::StyleContext::add_provider_for_screen(
&gdk::Screen::get_default().expect("cant get screen"), &screen,
&style, &style,
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION, gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
); );
let custom_conf = Path::new("/etc/lightdm/lightdm_mobile_greeter.css");
if custom_conf.exists() {
let style2 = gtk::CssProvider::new();
if let Some(path) = custom_conf.to_str() {
style2.load_from_path(path).expect("failed to load style2");
}
gtk::StyleContext::add_provider_for_screen(
&screen,
&style,
gtk::STYLE_PROVIDER_PRIORITY_USER,
)
}
} }
window.show(); window.show();
gtk::main(); gtk::main();
@ -215,12 +233,12 @@ impl Handler {
} }
let keys_iter = keys.iter(); let keys_iter = keys.iter();
for (rb, key) in rbs.iter().zip(keys_iter) { for (rb, key) in rbs.iter().zip(keys_iter) {
let handler_clone = handler.clone(); let handler_clone = handler.clone();
let key_clone = key.clone(); let key_clone = key.clone();
rb.connect_toggled(move |_| { rb.connect_toggled(move |_| {
handler_clone.borrow_mut().session = Some(key_clone.clone()); handler_clone.borrow_mut().session = Some(key_clone.clone());
}); });
}; }
self.de_select.as_ref().expect("no de select").add(&vbox); self.de_select.as_ref().expect("no de select").add(&vbox);
vbox.show_all() vbox.show_all()
} }