From ba5a48dae1c4c5f8b94c533006b79b6d380c3489 Mon Sep 17 00:00:00 2001 From: Benjamyn Love Date: Sun, 10 Mar 2024 23:08:17 +1100 Subject: [PATCH] Code cleanup --- README.md | 3 ++- src/config.rs | 22 ---------------------- src/enums.rs | 19 ------------------- src/files.rs | 9 ++------- src/handlers/gnome.rs | 2 +- src/handlers/mod.rs | 6 +----- 6 files changed, 6 insertions(+), 55 deletions(-) diff --git a/README.md b/README.md index 1b66d25..7b28f18 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,10 @@ Whats needed to get feature parity - Support for [ultrawide, horizontal, vertical] displays [✓] What still needs to be done -- Code cleanup [] +- Code cleanup [✓] - Handler for feh [✓] +I think this is now in feature parity of the python script What I want to add - Wallhaven API support diff --git a/src/config.rs b/src/config.rs index 9c33365..a2fc3da 100644 --- a/src/config.rs +++ b/src/config.rs @@ -10,10 +10,6 @@ pub struct Monitors { } impl Monitors { - pub fn new() -> Monitors { - Monitors { monitors: vec![] } - } - fn add(&mut self, mon_type: MonitorType) { self.monitors.push(mon_type); } @@ -37,15 +33,6 @@ pub struct WallpaperDir { } impl WallpaperDir { - pub fn new() -> WallpaperDir { - let expanded_tilde: String = untildify::untildify("~/"); - WallpaperDir { - ultrawide: expanded_tilde.clone(), - horizontal: expanded_tilde.clone(), - vertical: expanded_tilde.clone(), - } - } - pub fn get(&self, monitor_type: MonitorType) -> String { match monitor_type { MonitorType::Ultrawide => self.ultrawide.to_string(), @@ -77,15 +64,6 @@ pub struct Config { } impl Config { - pub fn new() -> Config { - Config { - x_server: String::new(), - wallpaper_engine: WallpaperHandler::Plasma, - wallpaper_dir: WallpaperDir::new(), - monitors: Monitors::new(), - } - } - pub fn from_config(file_path: String) -> Config { let mut config = Ini::new(); let map = config.load(file_path).unwrap(); diff --git a/src/enums.rs b/src/enums.rs index 8c7b458..4793555 100644 --- a/src/enums.rs +++ b/src/enums.rs @@ -49,22 +49,3 @@ impl fmt::Display for MonitorType { write!(f, "{:?}", self) } } - -#[derive(Debug)] -pub enum ImageTypes { - PNG, - JPG, - JPEG, -} - -impl ImageTypes { - pub fn get_types() -> Vec { - vec!["png".to_string(), "jpg".to_string(), "jpeg".to_string()] - } -} - -impl fmt::Display for ImageTypes { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{:?}", self) - } -} diff --git a/src/files.rs b/src/files.rs index 488435a..3c2103b 100644 --- a/src/files.rs +++ b/src/files.rs @@ -11,12 +11,6 @@ pub struct Wallpaper { path: String, } -impl Wallpaper { - pub fn new(path: String) -> Wallpaper { - Wallpaper { path } - } -} - impl fmt::Display for Wallpaper { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.path) @@ -56,7 +50,8 @@ impl Wallpapers { .wallpaper_dir .get(monitor_type.clone()) .to_owned(); - for filetype in ImageTypes::get_types().iter() { + let types = vec!["png".to_string(), "jpg".to_string(), "jpeg".to_string()]; + for filetype in types.iter() { let mut tmp_path = path.clone(); let mut tmp_glob = String::new(); write!(&mut tmp_glob, "/**/*.{}", filetype).unwrap(); diff --git a/src/handlers/gnome.rs b/src/handlers/gnome.rs index 6bd39cc..e3a9602 100644 --- a/src/handlers/gnome.rs +++ b/src/handlers/gnome.rs @@ -1,5 +1,5 @@ use crate::Wallpapers; -pub fn change_wallpapers(wallpapers: &Wallpapers) { +pub fn change_wallpapers(_wallpapers: &Wallpapers) { println!("Not implemented"); } diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs index 027a7d3..1593695 100644 --- a/src/handlers/mod.rs +++ b/src/handlers/mod.rs @@ -1,8 +1,4 @@ pub mod dbus_plasma_interface; -use dbus_plasma_interface::*; -pub mod plasma; -use plasma::*; pub mod feh; -use feh::*; pub mod gnome; -use gnome::*; +pub mod plasma;