connect css provider

This commit is contained in:
yggverse 2024-09-26 16:20:07 +03:00
parent 40a212199b
commit 2485595b58

View File

@ -1,14 +1,25 @@
use gtk::{Align, Label}; use gtk::{
prelude::{StyleContextExt, WidgetExt},
Align, CssProvider, Label, STYLE_PROVIDER_PRIORITY_APPLICATION,
};
pub struct Reader { pub struct Reader {
css: CssProvider,
widget: Label, widget: Label,
} }
impl Reader { impl Reader {
// Construct // Construct
pub fn new(gemtext: &str) -> Self { pub fn new(gemtext: &str) -> Self {
Self { // Init CSS
widget: Label::builder() let css = CssProvider::new();
css.load_from_path(
"src/browser/main/tab/page/content/text/gemini/reader/default.css", // @TODO
);
// Init widget
let widget = Label::builder()
.halign(Align::Start) .halign(Align::Start)
.valign(Align::Start) .valign(Align::Start)
.vexpand(true) .vexpand(true)
@ -18,8 +29,14 @@ impl Reader {
.selectable(true) .selectable(true)
.use_markup(true) .use_markup(true)
.label(gemtext) // @TODO .label(gemtext) // @TODO
.build(), .build();
}
widget
.style_context()
.add_provider(&css, STYLE_PROVIDER_PRIORITY_APPLICATION);
// Result
Self { css, widget }
} }
// Getters // Getters