summaryrefslogtreecommitdiffstats
path: root/ui/src/conf.rs
diff options
context:
space:
mode:
authorManos Pitsidianakis <el13635@mail.ntua.gr>2019-02-18 23:14:06 +0200
committerManos Pitsidianakis <el13635@mail.ntua.gr>2019-06-10 19:40:37 +0300
commit62168e9183eefdc07f0755f36eb501bd512e91f3 (patch)
tree784450fcab4b5232d4a353cbbf01011f664169d2 /ui/src/conf.rs
parent1883bb46dd6bb7bac12527e1f73f8c08c352fcbd (diff)
Add contact view page, edit headers in compose, index style in conf
Diffstat (limited to 'ui/src/conf.rs')
-rw-r--r--ui/src/conf.rs39
1 files changed, 32 insertions, 7 deletions
diff --git a/ui/src/conf.rs b/ui/src/conf.rs
index b10dd2ae..7e6a1c26 100644
--- a/ui/src/conf.rs
+++ b/ui/src/conf.rs
@@ -28,11 +28,13 @@ pub mod pager;
pub mod accounts;
pub use self::accounts::Account;
+use self::config::{Config, File, FileFormat};
use melib::conf::AccountSettings;
use melib::error::*;
use pager::PagerSettings;
+use self::serde::{de, Deserialize, Deserializer};
use std::collections::HashMap;
use std::env;
use std::path::PathBuf;
@@ -63,7 +65,8 @@ pub struct FileAccount {
draft_folder: String,
identity: String,
display_name: Option<String>,
- threaded: bool,
+ #[serde(deserialize_with = "index_from_str")]
+ index: IndexStyle,
folders: Option<HashMap<String, FolderConf>>,
}
@@ -98,11 +101,8 @@ impl FileAccount {
pub fn folder(&self) -> &str {
&self.root_folder
}
- pub fn threaded(&self) -> bool {
- self.threaded
- }
- pub fn toggle_threaded(&mut self) {
- self.threaded = !self.threaded;
+ pub fn index(&self) -> IndexStyle {
+ self.index
}
}
@@ -136,7 +136,6 @@ pub struct Settings {
pub pager: PagerSettings,
}
-use self::config::{Config, File, FileFormat};
impl FileSettings {
pub fn new() -> Result<FileSettings> {
let config_path = match env::var("MELI_CONFIG") {
@@ -183,3 +182,29 @@ impl Settings {
}
}
}
+
+
+#[derive(Copy, Debug, Clone, Deserialize)]
+pub enum IndexStyle {
+ Plain,
+ Threaded,
+ Compact,
+}
+
+impl Default for IndexStyle {
+ fn default() -> Self {
+ IndexStyle::Compact
+ }
+}
+
+fn index_from_str<'de, D>(deserializer: D) -> std::result::Result<IndexStyle, D::Error>
+ where D: Deserializer<'de>
+{
+ let s = <String>::deserialize(deserializer)?;
+ match s.as_str() {
+ "Plain" | "plain" => Ok(IndexStyle::Plain),
+ "Threaded" | "threaded" => Ok(IndexStyle::Threaded),
+ "Compact" | "compact" => Ok(IndexStyle::Compact),
+ _ => Err(de::Error::custom("invalid `index` value")),
+ }
+}