Commit 1e3b6473 authored by Daniel Garcia Moreno's avatar Daniel Garcia Moreno

Merge branch 'alatiera/build-stuff' into 'master'

Globals: Avoid duplication

See merge request World/fractal!231
parents f1fcb00d 9d713ac7
use std::process::Command;
use std::env;
use std::fs::File;
use std::path::Path;
use std::io::Write;
fn main() {
// Compile Gresource
......@@ -12,29 +8,4 @@ fn main() {
.status()
.expect("failed to generate resources");
assert!(out.success());
// Generating build globals
let default_locales = "./fractal-gtk/po".to_string();
let default_app_id = "org.gnome.Fractal".to_string();
let default_name_suffix = "".to_string();
let default_version = "".to_string();
let localedir = env::var("FRACTAL_LOCALEDIR").unwrap_or(default_locales);
let app_id = env::var("FRACTAL_APP_ID").unwrap_or(default_app_id);
let name_suffix = env::var("FRACTAL_NAME_SUFFIX").unwrap_or(default_name_suffix);
let version = env::var("FRACTAL_VERSION").unwrap_or(default_version);
let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("build_globals.rs");
let mut f = File::create(&dest_path).unwrap();
let globals = format!("
pub static LOCALEDIR: &'static str = \"{}\";
pub static APP_ID: &'static str = \"{}\";
pub static NAME_SUFFIX: &'static str = \"{}\";
pub static VERSION: &'static str = \"{}\";
",
localedir, app_id, name_suffix, version);
f.write_all(&globals.into_bytes()[..]).unwrap();
}
......@@ -60,7 +60,7 @@ pub struct App {
impl App {
/// Create an App instance
pub fn new() {
let appid = globals::APP_ID.to_string();
let appid = globals::APP_ID.unwrap_or("org.gnome.FractalDevel").to_string();
let gtk_app = gtk::Application::new(Some(&appid[..]), gio::ApplicationFlags::empty())
.expect("Failed to initialize GtkApplication");
......@@ -79,7 +79,7 @@ impl App {
// Set up the textdomain for gettext
setlocale(LocaleCategory::LcAll, "");
bindtextdomain("fractal", globals::LOCALEDIR);
bindtextdomain("fractal", globals::LOCALEDIR.unwrap_or("./fractal-gtk/po"));
textdomain("fractal");
......
......@@ -14,15 +14,15 @@ impl AppOp {
.get_object("main_window")
.expect("Can't find main_window in ui file.");
let program_name = format!("Fractal{}", globals::NAME_SUFFIX);
let program_name = format!("Fractal{}", globals::NAME_SUFFIX.unwrap_or(" (Development)"));
let dialog = gtk::AboutDialog::new();
dialog.set_logo_icon_name(globals::APP_ID);
dialog.set_logo_icon_name(globals::APP_ID.unwrap_or("org.gnome.FractalDevel"));
dialog.set_comments(i18n("A Matrix.org client for GNOME").as_str());
dialog.set_copyright(i18n("© 2017–2018 Daniel García Moreno, et al.").as_str());
dialog.set_license_type(gtk::License::Gpl30);
dialog.set_modal(true);
dialog.set_version(globals::VERSION);
dialog.set_version(globals::VERSION.unwrap_or("0.0.0"));
dialog.set_program_name(&program_name);
dialog.set_website("https://wiki.gnome.org/Fractal");
dialog.set_website_label(i18n("Learn more about Fractal").as_str());
......
......@@ -9,4 +9,7 @@ pub static DEFAULT_IDENTITYSERVER: &'static str = "https://vector.im";
pub static MAX_IMAGE_SIZE: (i32, i32) = (600, 400);
pub static MAX_STICKER_SIZE: (i32, i32) = (200, 130);
include!(concat!(env!("OUT_DIR"), "/build_globals.rs"));
pub static LOCALEDIR: Option<&'static str> = option_env!("FRACTAL_LOCALEDIR");
pub static APP_ID: Option<&'static str> = option_env!("FRACTAL_APP_ID");
pub static NAME_SUFFIX: Option<&'static str> = option_env!("FRACTAL_NAME_SUFFIX");
pub static VERSION: Option<&'static str> = option_env!("FRACTAL_VERSION");
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