Commit 97f35aff authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

move from embedded resources

makes iteration on the UI slower
parent d39c8164
......@@ -4,7 +4,6 @@ _build/
build-aux/app
build-aux/.flatpak-builder/
src/config.rs
src/static_resources.rs
*.ui.in~
*.ui~
.flatpak
......
......@@ -26,7 +26,6 @@ rustfmt:
# Create blank versions of our configured files
# so rustfmt does not yell about non-existent files or completely empty files
- echo -e "" >> src/config.rs
- echo -e "" >> src/static_resources.rs
- rustc -Vv && cargo -Vv
- cargo fmt --version
- cargo fmt --all -- --color=always --check
......@@ -56,6 +56,7 @@ resources = gnome.compile_resources(
'resources',
'resources.gresource.xml',
gresource_bundle: true,
source_dir: meson.current_build_dir()
source_dir: meson.current_build_dir(),
install: true,
install_dir: pkgdatadir,
)
......@@ -4,5 +4,6 @@ pub static PROFILE: &str = @PROFILE@;
pub static VERSION: &str = @VERSION@;
pub static GETTEXT_PACKAGE: &str = @GETTEXT_PACKAGE@;
pub static LOCALEDIR: &str = @LOCALEDIR@;
pub const RESOURCES_FILE: &str = concat!(@PKGDATADIR@, "/resources.gresource");
#[cfg(feature = "video")]
pub static VIDEO_PATH: &str = @VIDEO_PATH@;
use gettextrs::*;
use gtk::glib;
use gtk::{gio, glib};
mod application;
mod config;
mod static_resources;
mod utils;
mod widgets;
......@@ -26,7 +25,8 @@ fn main() {
#[cfg(feature = "video")]
gst::init().expect("Unable to start gst");
static_resources::init().expect("Failed to initialize the resource file.");
let res = gio::Resource::load(config::RESOURCES_FILE).expect("Could not load resources");
gio::resources_register(&res);
Application::run()
}
......@@ -19,22 +19,6 @@ run_command(
check: true
)
# include_bytes! only takes a string literal
resource_conf = configuration_data()
resource_conf.set_quoted('RESOURCEFILE', resources.full_path())
resource_rs = configure_file(
input: 'static_resources.rs.in',
output: 'static_resources.rs',
configuration: resource_conf
)
run_command(
'cp',
resource_rs,
meson.current_source_dir(),
check: true
)
sources = files(
'widgets/pages/image.rs',
'widgets/pages/mod.rs',
......@@ -45,7 +29,6 @@ sources = files(
'application.rs',
'config.rs',
'main.rs',
'static_resources.rs',
'utils.rs',
)
......
// Source: https://gitlab.gnome.org/World/podcasts/blob/master/podcasts-gtk/src/static_resource.rs
use gtk::gio::{resources_register, Resource};
use gtk::glib::{Bytes, Error};
pub(crate) fn init() -> Result<(), Error> {
// load the gresource binary at build time and include/link it into the final
// binary.
let res_bytes = include_bytes!(@RESOURCEFILE@);
// Create Resource it will live as long the value lives.
let gbytes = Bytes::from_static(res_bytes.as_ref());
let resource = Resource::from_data(&gbytes)?;
// Register the resource so it won't be dropped and will continue to live in
// memory.
resources_register(&resource);
Ok(())
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment