diff --git a/src/config.rs b/src/config.rs index 5ae1d27..452f4d7 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,24 +1,3 @@ -use std::path::PathBuf; -use std::env; - pub static VERSION: &str = "0.1.0"; pub static GETTEXT_PACKAGE: &str = "aardvark"; pub static LOCALEDIR: &str = "/app/share/locale"; - -pub fn get_pkgdatadir() -> PathBuf { - #[cfg(target_os = "macos")] - { - let exe_path = env::current_exe().expect("Failed to get current executable path"); - // Navigate to the 'Resources/share/aardvark' directory relative to the executable - exe_path - .parent() // Goes up to 'Contents/MacOS' - .and_then(|p| p.parent()) // Goes up to 'Contents' - .map(|p| p.join("Resources/share/aardvark")) - .expect("Failed to compute PKGDATADIR") - } - - #[cfg(not(target_os = "macos"))] - { - PathBuf::from("/app/share/aardvark") - } -} diff --git a/src/main.rs b/src/main.rs index 67c2874..d8e6c38 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,11 +25,14 @@ mod operation; mod window; mod textbuffer; +use std::path::PathBuf; +use std::env; use self::application::AardvarkApplication; use self::window::AardvarkWindow; use self::textbuffer::AardvarkTextBuffer; -use config::{GETTEXT_PACKAGE, LOCALEDIR, get_pkgdatadir}; + +use config::{GETTEXT_PACKAGE, LOCALEDIR}; use gettextrs::{bind_textdomain_codeset, bindtextdomain, textdomain}; use gtk::{gio, glib}; use gtk::prelude::*; @@ -57,3 +60,21 @@ fn main() -> glib::ExitCode { // terminal. app.run() } + +fn get_pkgdatadir() -> PathBuf { + #[cfg(target_os = "macos")] + { + let exe_path = env::current_exe().expect("Failed to get current executable path"); + // Navigate to the 'Resources/share/aardvark' directory relative to the executable + exe_path + .parent() // Goes up to 'Contents/MacOS' + .and_then(|p| p.parent()) // Goes up to 'Contents' + .map(|p| p.join("Resources/share/aardvark")) + .expect("Failed to compute PKGDATADIR") + } + + #[cfg(not(target_os = "macos"))] + { + PathBuf::from("/app/share/aardvark") + } +}