connect css provider

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

View File

@ -1,25 +1,42 @@
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();
.halign(Align::Start)
.valign(Align::Start) css.load_from_path(
.vexpand(true) "src/browser/main/tab/page/content/text/gemini/reader/default.css", // @TODO
.margin_start(8) );
.margin_end(8)
.wrap(true) // Init widget
.selectable(true) let widget = Label::builder()
.use_markup(true) .halign(Align::Start)
.label(gemtext) // @TODO .valign(Align::Start)
.build(), .vexpand(true)
} .margin_start(8)
.margin_end(8)
.wrap(true)
.selectable(true)
.use_markup(true)
.label(gemtext) // @TODO
.build();
widget
.style_context()
.add_provider(&css, STYLE_PROVIDER_PRIORITY_APPLICATION);
// Result
Self { css, widget }
} }
// Getters // Getters