diff --git a/src/lib.rs b/src/lib.rs index 1340d40..b0519f5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,9 +20,8 @@ use egui::{Context, Stroke}; #[cfg(target_os = "android")] use winit::platform::android::activity::AndroidApp; -pub use config::AppConfig; +pub use settings::AppConfig; pub use settings::Settings; -use crate::config::DEFAULT_LOCALE; use crate::gui::{Colors, PlatformApp}; use crate::gui::platform::PlatformCallbacks; @@ -35,7 +34,6 @@ mod node; mod wallet; mod settings; -mod config; pub mod gui; // Include build information. @@ -212,9 +210,9 @@ fn setup_i18n() { rust_i18n::set_locale(lang.as_str()); } } else { - let locale = sys_locale::get_locale().unwrap_or(String::from(DEFAULT_LOCALE)); + let locale = sys_locale::get_locale().unwrap_or(String::from(AppConfig::DEFAULT_LOCALE)); let locale_str = if locale.contains("-") { - locale.split("-").next().unwrap_or(DEFAULT_LOCALE) + locale.split("-").next().unwrap_or(AppConfig::DEFAULT_LOCALE) } else { locale.as_str() }; @@ -223,7 +221,7 @@ fn setup_i18n() { if rust_i18n::available_locales!().contains(&locale_str) { rust_i18n::set_locale(locale_str); } else { - rust_i18n::set_locale(DEFAULT_LOCALE); + rust_i18n::set_locale(AppConfig::DEFAULT_LOCALE); } } } \ No newline at end of file diff --git a/src/config.rs b/src/settings/config.rs similarity index 97% rename from src/config.rs rename to src/settings/config.rs index d44a2f5..f847919 100644 --- a/src/config.rs +++ b/src/settings/config.rs @@ -43,10 +43,8 @@ pub struct AppConfig { lang: Option } -pub const DEFAULT_LOCALE: &str = "en"; - -pub const DEFAULT_WIDTH: f32 = 1200.0; -pub const DEFAULT_HEIGHT: f32 = 720.0; +const DEFAULT_WIDTH: f32 = 1200.0; +const DEFAULT_HEIGHT: f32 = 720.0; impl Default for AppConfig { fn default() -> Self { @@ -68,6 +66,9 @@ impl AppConfig { /// Application configuration file name. pub const FILE_NAME: &'static str = "app.toml"; + /// Default i18n locale. + pub const DEFAULT_LOCALE: &'static str = "en"; + /// Save application configuration to the file. pub fn save(&self) { Settings::write_to_file(self, Settings::get_config_path(Self::FILE_NAME, None)); diff --git a/src/settings/mod.rs b/src/settings/mod.rs new file mode 100644 index 0000000..1e93697 --- /dev/null +++ b/src/settings/mod.rs @@ -0,0 +1,19 @@ +// Copyright 2024 The Grim Developers +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +mod settings; +pub use settings::Settings; + +mod config; +pub use config::AppConfig; \ No newline at end of file diff --git a/src/settings.rs b/src/settings/settings.rs similarity index 99% rename from src/settings.rs rename to src/settings/settings.rs index 1b32602..0f8de64 100644 --- a/src/settings.rs +++ b/src/settings/settings.rs @@ -22,8 +22,8 @@ use lazy_static::lazy_static; use serde::de::DeserializeOwned; use serde::Serialize; -use crate::config::AppConfig; use crate::node::NodeConfig; +use crate::settings::AppConfig; use crate::wallet::ConnectionsConfig; lazy_static! { diff --git a/src/wallet/connections/config.rs b/src/wallet/connections/config.rs index 37dd1a4..5ba9961 100644 --- a/src/wallet/connections/config.rs +++ b/src/wallet/connections/config.rs @@ -15,8 +15,7 @@ use grin_core::global::ChainTypes; use serde_derive::{Deserialize, Serialize}; -use crate::config::AppConfig; -use crate::Settings; +use crate::{AppConfig, Settings}; use crate::wallet::ExternalConnection; /// Wallet connections configuration.