diff --git a/cachyos-welcome.gresource.xml b/cachyos-welcome.gresource.xml new file mode 100644 index 0000000..18c1508 --- /dev/null +++ b/cachyos-welcome.gresource.xml @@ -0,0 +1,7 @@ + + + + ui/cachyos-hello.glade + ui/style.css + + diff --git a/meson.build b/meson.build index a4e6a7c..58779a0 100644 --- a/meson.build +++ b/meson.build @@ -39,6 +39,15 @@ iconsdir = datadir / 'icons' podir = meson.project_source_root() / 'po' gettext_package = meson.project_name() +resources = gnome.compile_resources( + 'cachyos-welcome', + 'cachyos-welcome.gresource.xml', + gresource_bundle: true, + source_dir: meson.current_build_dir(), + install: true, + install_dir: pkgdatadir, +) + if get_option('profile') == 'development' profile = 'Devel' vcs_tag = run_command('git', 'rev-parse', '--short', 'HEAD').stdout().strip() diff --git a/postinstall.sh b/postinstall.sh index 34aaf0c..ee2eb12 100755 --- a/postinstall.sh +++ b/postinstall.sh @@ -3,7 +3,6 @@ mkdir -p "${DESTDIR}/${MESON_INSTALL_PREFIX}/share/cachyos-hello/" cp -r "${MESON_SOURCE_ROOT}/src/scripts" "${DESTDIR}/${MESON_INSTALL_PREFIX}/share/cachyos-hello/" cp -r "${MESON_SOURCE_ROOT}/data" "${DESTDIR}/${MESON_INSTALL_PREFIX}/share/cachyos-hello/" -cp -r "${MESON_SOURCE_ROOT}/ui" "${DESTDIR}/${MESON_INSTALL_PREFIX}/share/cachyos-hello/" cd "${MESON_SOURCE_ROOT}/po" for lang in $(ls *.po); do diff --git a/src/config.rs.in b/src/config.rs.in index a004bf7..07fd906 100644 --- a/src/config.rs.in +++ b/src/config.rs.in @@ -3,4 +3,5 @@ pub const GETTEXT_PACKAGE: &str = @GETTEXT_PACKAGE@; pub const LOCALEDIR: &str = @LOCALEDIR@; pub const PKGDATADIR: &str = @PKGDATADIR@; pub const PROFILE: &str = @PROFILE@; +pub const RESOURCES_FILE: &str = concat!(@PKGDATADIR@, "/cachyos-welcome.gresource"); pub const VERSION: &str = @VERSION@; diff --git a/src/main.rs b/src/main.rs index 44be17c..c84fe5b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,7 +9,7 @@ mod data_types; mod pages; mod utils; -use config::{APP_ID, GETTEXT_PACKAGE, LOCALEDIR, PKGDATADIR, PROFILE, VERSION}; +use config::{APP_ID, GETTEXT_PACKAGE, LOCALEDIR, PKGDATADIR, PROFILE, RESOURCES_FILE, VERSION}; use data_types::*; use gettextrs::LocaleCategory; use gtk::{gio, glib, Builder, HeaderBar, Window}; @@ -124,6 +124,9 @@ fn main() { gtk::init().expect("Unable to start GTK3."); + let res = gio::Resource::load(RESOURCES_FILE).expect("Could not load gresource file."); + gio::resources_register(&res); + let application = gtk::Application::new( Some(APP_ID), // Application id Default::default(), // Using default flags @@ -155,9 +158,7 @@ fn build_ui(application: >k::Application) { // Import Css let provider = gtk::CssProvider::new(); - provider - .load_from_path(preferences["style_path"].as_str().unwrap()) - .expect("Failed to load CSS"); + provider.load_from_resource("/org/cachyos/hello/ui/style.css"); gtk::StyleContext::add_provider_for_screen( &gdk::Screen::default().expect("Error initializing gtk css provider."), &provider, @@ -165,7 +166,7 @@ fn build_ui(application: >k::Application) { ); // Init window - let builder: Builder = Builder::from_file(preferences["ui_path"].as_str().unwrap()); + let builder: Builder = Builder::from_resource("/org/cachyos/hello/ui/cachyos-hello.glade"); builder.connect_signals(|_builder, handler_name| { match handler_name { // handler_name as defined in the glade file => handler function as defined above diff --git a/src/meson.build b/src/meson.build index 6b6aac5..66dd401 100644 --- a/src/meson.build +++ b/src/meson.build @@ -18,8 +18,12 @@ run_command( check: true ) -cargo_options = [ '--manifest-path', meson.project_source_root() / 'Cargo.toml' ] -cargo_options += [ '--target-dir', meson.project_build_root() / 'src' ] +manifest_path = meson.project_source_root() / 'Cargo.toml' +cargo_home = meson.project_build_root() / 'cargo-home' +cargo_target_dir = meson.project_build_root() / 'src' + +cargo_options = [ '--manifest-path', manifest_path ] +cargo_options += [ '--target-dir', cargo_target_dir ] if get_option('profile') == 'default' cargo_options += [ '--release' ] @@ -30,13 +34,14 @@ else message('Building in debug mode') endif -cargo_env = [ 'CARGO_HOME=' + meson.project_build_root() / 'cargo-home' ] +cargo_env = [ 'CARGO_HOME=' + cargo_home ] cargo_build = custom_target( 'cargo-build', build_by_default: true, build_always_stale: true, output: meson.project_name(), + depends: resources, console: true, install: true, install_dir: bindir, @@ -50,11 +55,7 @@ cargo_build = custom_target( ] ) -cargo_target_dir = meson.project_build_root() / 'target' -cargo_home = meson.project_build_root() / 'cargo-home' -manifest_path = meson.project_source_root() / 'Cargo.toml' - -test ( +test( 'cargo-test', cargo, args: [ @@ -65,13 +66,14 @@ test ( '--nocapture', ], env: [ + 'RUST_BACKTRACE=1', 'CARGO_HOME=@0@'.format(cargo_home), 'PATH=/app/bin:/usr/bin:/usr/lib/sdk/rust-stable/bin', ], timeout: 300, # give cargo more time ) -test ( +test( 'cargo-clippy', cargo, args: [