[gnome-tour/bilelmoussaoui/fixes] move from embedded resources



commit 97f35aff2ed065583aa338685dd6a0824228edb2
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date:   Sat Jan 1 10:27:02 2022 +0100

    move from embedded resources
    
    makes iteration on the UI slower

 .gitignore                 |  1 -
 .gitlab-ci.yml             |  1 -
 data/meson.build           |  5 +++--
 src/config.rs.in           |  1 +
 src/main.rs                |  6 +++---
 src/meson.build            | 17 -----------------
 src/static_resources.rs.in | 20 --------------------
 7 files changed, 7 insertions(+), 44 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 4521a7a..d43f6d5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,6 @@ _build/
 build-aux/app
 build-aux/.flatpak-builder/
 src/config.rs
-src/static_resources.rs
 *.ui.in~
 *.ui~
 .flatpak
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7edeeed..ab90986 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -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
diff --git a/data/meson.build b/data/meson.build
index 52c3d1d..4d6f342 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -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,
 )
-
diff --git a/src/config.rs.in b/src/config.rs.in
index aebf16d..85f7309 100644
--- a/src/config.rs.in
+++ b/src/config.rs.in
@@ -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@;
diff --git a/src/main.rs b/src/main.rs
index adf21f5..16fa280 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,9 +1,8 @@
 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()
 }
diff --git a/src/meson.build b/src/meson.build
index 801b3a1..2899e81 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -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',
 )
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]