Include CSS as GResource

Also use explicit namespace for bare functions and constants used in
main.rs.
This commit is contained in:
Reinout Meliesie 2026-01-21 16:56:05 +01:00
commit 5e5df5c401
Signed by: zedfrigg
GPG key ID: 3AFCC06481308BC6
6 changed files with 39 additions and 6 deletions

View file

@ -1,8 +0,0 @@
.media-grid flowboxchild {
padding: 0;
}
.media-grid-item {
/* No bold text by default for this kind of button */
font-weight: normal;
}

View file

@ -5,10 +5,8 @@ mod ui;
mod views;
use gtk4::gdk::Display;
use gtk4::{
CssProvider, STYLE_PROVIDER_PRIORITY_APPLICATION, Settings,
style_context_add_provider_for_display,
};
use gtk4::gio::File;
use gtk4::{CssProvider, Settings, gio};
use relm4::RelmApp;
use crate::ui::App;
@ -30,11 +28,19 @@ fn include_app_css() {
// We can't use relm4::set_global_css because we need access to the CSS provider
// to relay color scheme changes to it.
gio::resources_register_include!("zoodex.gresource")
.expect("CSS resource bundle should have valid format");
let app_css = File::for_uri("resource:///com/kernelmaft/zoodex/application.css");
let provider = CssProvider::new();
let display = Display::default().expect("getting the default GDK4 display should never fail");
provider.load_from_string(include_str!("application.css"));
style_context_add_provider_for_display(&display, &provider, STYLE_PROVIDER_PRIORITY_APPLICATION);
provider.load_from_file(&app_css);
gtk4::style_context_add_provider_for_display(
&display,
&provider,
gtk4::STYLE_PROVIDER_PRIORITY_APPLICATION,
);
let settings = Settings::for_display(&display);
provider.set_prefers_color_scheme(settings.gtk_interface_color_scheme());