👷 use compressed gresource instead

This commit is contained in:
Vladislav Nepogodin 2023-02-17 21:48:59 +04:00
parent 6226aa4879
commit af13cf75ad
No known key found for this signature in database
GPG Key ID: B62C3D10C54D5DA9
6 changed files with 34 additions and 15 deletions

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/cachyos/hello">
<file compressed="true" preprocess="xml-stripblanks">ui/cachyos-hello.glade</file>
<file compressed="true">ui/style.css</file>
</gresource>
</gresources>

View File

@ -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()

View File

@ -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

View File

@ -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@;

View File

@ -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: &gtk::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: &gtk::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

View File

@ -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: [