diff --git a/podcasts-gtk/src/app.rs b/podcasts-gtk/src/app.rs index a3757e8..63f4261 100644 --- a/podcasts-gtk/src/app.rs +++ b/podcasts-gtk/src/app.rs @@ -48,8 +48,20 @@ use std::sync::Arc; use crate::i18n::i18n; -pub(crate) const APP_ID: &str = env!("APP_ID"); -pub(crate) const VERSION: &str = env!("VERSION"); +#[rustfmt::skip] +lazy_static! { + pub static ref APP_ID: &'static str = { + option_env!("APP_ID").unwrap_or("org.gnome.Podcasts") + }; + + pub static ref VERSION: &'static str = { + option_env!("VERSION").unwrap_or("0.0.1") + }; + + pub static ref LOCALEDIR: &'static str = { + option_env!("LOCALEDIR").unwrap_or("./podcasts-gtk/po") + }; +} /// Creates an action named `name` in the action map `T with the handler `F` fn action(thing: &T, name: &str, action: F) @@ -404,10 +416,10 @@ impl App { pub(crate) fn run() { // Set up the textdomain for gettext setlocale(LocaleCategory::LcAll, ""); - bindtextdomain("gnome-podcasts", env!("LOCALEDIR")); + bindtextdomain("gnome-podcasts", *LOCALEDIR); textdomain("gnome-podcasts"); - let application = gtk::Application::new(APP_ID, gio::ApplicationFlags::empty()) + let application = gtk::Application::new(*APP_ID, gio::ApplicationFlags::empty()) .expect("Application initialization failed..."); application.set_resource_base_path("/org/gnome/Podcasts"); @@ -438,7 +450,7 @@ impl App { // Weird magic I copy-pasted that sets the Application Name in the Shell. glib::set_application_name(&i18n("Podcasts")); glib::set_prgname(Some("gnome-podcasts")); - gtk::Window::set_default_icon_name(APP_ID); + gtk::Window::set_default_icon_name(*APP_ID); let args: Vec = env::args().collect(); ApplicationExtManual::run(&application, &args); } diff --git a/podcasts-gtk/src/widgets/aboutdialog.rs b/podcasts-gtk/src/widgets/aboutdialog.rs index 0fc6dcf..f29ce06 100644 --- a/podcasts-gtk/src/widgets/aboutdialog.rs +++ b/podcasts-gtk/src/widgets/aboutdialog.rs @@ -47,12 +47,12 @@ pub(crate) fn about_dialog(window: >k::ApplicationWindow) { ]; let dialog = gtk::AboutDialog::new(); - dialog.set_logo_icon_name(APP_ID); + dialog.set_logo_icon_name(*APP_ID); dialog.set_comments(i18n("Podcast Client for the GNOME Desktop.").as_str()); dialog.set_copyright("© 2017, 2018 Jordan Petridis"); dialog.set_license_type(gtk::License::Gpl30); dialog.set_modal(true); - dialog.set_version(VERSION); + dialog.set_version(*VERSION); dialog.set_program_name(&i18n("Podcasts")); dialog.set_website("https://wiki.gnome.org/Apps/Podcasts"); dialog.set_website_label(i18n("Learn more about GNOME Podcasts").as_str()); diff --git a/podcasts-gtk/src/widgets/empty.rs b/podcasts-gtk/src/widgets/empty.rs index 8abd6ce..fcf4d55 100644 --- a/podcasts-gtk/src/widgets/empty.rs +++ b/podcasts-gtk/src/widgets/empty.rs @@ -36,7 +36,7 @@ impl Default for EmptyView { let builder = gtk::Builder::new_from_resource("/org/gnome/Podcasts/gtk/empty_view.ui"); let view: gtk::Box = builder.get_object("empty_view").unwrap(); let image: gtk::Image = builder.get_object("image").unwrap(); - image.set_from_icon_name(format!("{}-symbolic", APP_ID).as_str(), 256); + image.set_from_icon_name(format!("{}-symbolic", *APP_ID).as_str(), 256); EmptyView(view) } } diff --git a/scripts/test.sh b/scripts/test.sh index 5665a36..12c7724 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -23,9 +23,6 @@ flatpak-builder --run \ # Run the tests xvfb-run -a -s "-screen 0 1024x768x24" \ flatpak-builder --run \ - --env=APP_ID="org.gnome.PodcastsDevel" \ - --env=LOCALEDIR="./podcasts-gtk/po" \ - --env=VERSION="0.0.0" \ --env=CARGO_HOME="target/cargo-home" \ --env=CARGO_TARGET_DIR="target_test/" \ app ${MANIFEST_PATH} \