Cleanup of build.rs

parent c260f8f8
......@@ -6,3 +6,4 @@ Makefile
_build
Cargo.lock
vendor
*.gresource
use std::env;
use std::fs::File;
use std::io::Write;
use std::path::Path;
use std::process::Command;
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
// I think this is expected by Meson.
let fractal_res = env::var("FRACTAL_RES").unwrap_or(String::from("res"));
let dest_path = Path::new(&out_dir).join("config.rs");
let mut f = File::create(&dest_path).unwrap();
let code = format!("
mod config {{
pub fn datadir(res: &str) -> String {{
let out = String::from(\"{}/\");
out + res
}}
}}
", fractal_res);
f.write_all(code.as_bytes()).unwrap();
// Compile Gresource
Command::new("glib-compile-resources")
......
......@@ -40,9 +40,6 @@ use widgets;
use cache;
include!(concat!(env!("OUT_DIR"), "/config.rs"));
#[derive(Debug)]
pub enum Error {
SecretServiceError,
......@@ -1377,8 +1374,7 @@ impl App {
window.set_title("Fractal");
let pxbf = Pixbuf::new_from_resource("/org/gnome/fractal/fractal.svg").unwrap();
let _ = window.set_icon(&pxbf);
// let _ = window.set_icon_from_file(&config::datadir("fractal.svg"));
window.set_icon(&pxbf);
window.show_all();
let op = self.op.clone();
......@@ -1688,10 +1684,6 @@ impl App {
let provider = gtk::CssProvider::new();
provider.load_from_resource("/org/gnome/fractal/app.css");
// let uri = config::datadir("app.css");
// if let Err(_) = provider.load_from_path(&uri) {
// println!("Error: Failed to add application style");
// }
gtk::StyleContext::add_provider_for_screen(&gdk::Screen::get_default().unwrap(), &provider, 600);
gtk::main();
......
......@@ -5,7 +5,7 @@ pub fn init() -> Result<(), Error> {
// load the gresource binary at build time and include/link it into the final binary.
let res_bytes = include_bytes!("../res/resources.gresource");
// Create Resource it will live as long the value lives.
// Create Resource, it will live as long the value lives.
// TODO: change it into Bytes::From_static once the fix lands
// https://bugzilla.gnome.org/show_bug.cgi?id=790030
let gbytes = Bytes::from(&res_bytes.as_ref());
......
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