blob: 368082002d0bc7d85179bdf21eefc20b10306744 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
use super::app_raw::AppConfigRaw;
use super::DEFAULT_CONFIG_FILE_PATH;
use crate::config::option::{DisplayOption, PreviewOption, SortOption, TabOption};
use crate::error::JoshutoResult;
#[derive(Debug, Clone)]
pub struct AppConfig {
pub use_trash: bool,
pub xdg_open: bool,
pub xdg_open_fork: bool,
pub watch_files: bool,
pub _display_options: DisplayOption,
pub _preview_options: PreviewOption,
pub _tab_options: TabOption,
}
impl AppConfig {
pub fn default_res() -> JoshutoResult<Self> {
let raw: AppConfigRaw = toml::from_str(DEFAULT_CONFIG_FILE_PATH)?;
Ok(Self::from(raw))
}
pub fn display_options_ref(&self) -> &DisplayOption {
&self._display_options
}
pub fn display_options_mut(&mut self) -> &mut DisplayOption {
&mut self._display_options
}
pub fn preview_options_ref(&self) -> &PreviewOption {
&self._preview_options
}
pub fn _preview_options_mut(&mut self) -> &mut PreviewOption {
&mut self._preview_options
}
pub fn sort_options_ref(&self) -> &SortOption {
self.display_options_ref().sort_options_ref()
}
pub fn sort_options_mut(&mut self) -> &mut SortOption {
self.display_options_mut().sort_options_mut()
}
pub fn tab_options_ref(&self) -> &TabOption {
&self._tab_options
}
}
impl std::default::Default for AppConfig {
fn default() -> Self {
// This should not fail.
// If it fails then there is a (syntax) error in the default config file
Self::default_res().unwrap()
}
}
|