Verified Commit b72ba8c6 authored by Jordan Petridis's avatar Jordan Petridis 🌱

podcasts-gtk: make it possible to compile with just cargo

This is not supported at all, and it still won't run with cargo
run, thankfully, you should use meson instead...

The only purpose of this commit is to make it possible for
cargo check, and by extension rls, to function and work
properly.

Part of #110
parent fc9de568
......@@ -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<T, F>(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<String> = env::args().collect();
ApplicationExtManual::run(&application, &args);
}
......
......@@ -47,12 +47,12 @@ pub(crate) fn about_dialog(window: &gtk::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());
......
......@@ -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)
}
}
......
......@@ -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} \
......
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