Delete unneeded name() method from BarModuleFn trait

main
Tassilo Horn 3 years ago
parent 726d9a0a9e
commit 7035268413
  1. 3
      swayrbar/src/bar/module.rs
  2. 8
      swayrbar/src/bar/module/battery.rs
  3. 6
      swayrbar/src/bar/module/date.rs
  4. 6
      swayrbar/src/bar/module/sysinfo.rs
  5. 10
      swayrbar/src/bar/module/window.rs

@ -28,9 +28,6 @@ pub trait BarModuleFn: Sync + Send {
where where
Self: Sized; Self: Sized;
fn default_config(instance: String) -> config::ModuleConfig fn default_config(instance: String) -> config::ModuleConfig
where
Self: Sized;
fn name() -> &'static str
where where
Self: Sized; Self: Sized;
fn get_config(&self) -> &config::ModuleConfig; fn get_config(&self) -> &config::ModuleConfig;

@ -96,7 +96,7 @@ impl BarModuleFn for BarModuleBattery {
fn default_config(instance: String) -> config::ModuleConfig { fn default_config(instance: String) -> config::ModuleConfig {
config::ModuleConfig { config::ModuleConfig {
name: Self::name().to_owned(), name: NAME.to_owned(),
instance, instance,
format: "🔋 Bat: {state_of_charge:{:5.1}}%, {state}, Health: {state_of_health:{:5.1}}%".to_owned(), format: "🔋 Bat: {state_of_charge:{:5.1}}%, {state}, Health: {state_of_health:{:5.1}}%".to_owned(),
html_escape: true, html_escape: true,
@ -104,10 +104,6 @@ impl BarModuleFn for BarModuleBattery {
} }
} }
fn name() -> &'static str {
NAME
}
fn get_config(&self) -> &config::ModuleConfig { fn get_config(&self) -> &config::ModuleConfig {
&self.config &self.config
} }
@ -115,7 +111,7 @@ impl BarModuleFn for BarModuleBattery {
fn build(&self) -> s::Block { fn build(&self) -> s::Block {
let text = get_text(&self.config); let text = get_text(&self.config);
s::Block { s::Block {
name: Some(Self::name().to_owned()), name: Some(NAME.to_owned()),
instance: Some(self.config.instance.clone()), instance: Some(self.config.instance.clone()),
full_text: text, full_text: text,
align: Some(s::Align::Right), align: Some(s::Align::Right),

@ -46,10 +46,6 @@ impl BarModuleFn for BarModuleDate {
} }
} }
fn name() -> &'static str {
NAME
}
fn get_config(&self) -> &config::ModuleConfig { fn get_config(&self) -> &config::ModuleConfig {
&self.config &self.config
} }
@ -57,7 +53,7 @@ impl BarModuleFn for BarModuleDate {
fn build(&self) -> s::Block { fn build(&self) -> s::Block {
let text = chrono::Local::now().format(&self.config.format).to_string(); let text = chrono::Local::now().format(&self.config.format).to_string();
s::Block { s::Block {
name: Some(Self::name().to_owned()), name: Some(NAME.to_owned()),
instance: Some(self.config.instance.clone()), instance: Some(self.config.instance.clone()),
full_text: text, full_text: text,
align: Some(s::Align::Right), align: Some(s::Align::Right),

@ -104,10 +104,6 @@ impl BarModuleFn for BarModuleSysInfo {
} }
} }
fn name() -> &'static str {
NAME
}
fn get_config(&self) -> &config::ModuleConfig { fn get_config(&self) -> &config::ModuleConfig {
&self.config &self.config
} }
@ -115,7 +111,7 @@ impl BarModuleFn for BarModuleSysInfo {
fn build(&self) -> s::Block { fn build(&self) -> s::Block {
let updater = OnceRefresher::new(); let updater = OnceRefresher::new();
s::Block { s::Block {
name: Some(Self::name().to_owned()), name: Some(NAME.to_owned()),
instance: Some(self.config.instance.clone()), instance: Some(self.config.instance.clone()),
full_text: { full_text: {
let mut sys = self.system.lock().unwrap(); let mut sys = self.system.lock().unwrap();

@ -37,7 +37,7 @@ impl BarModuleFn for BarModuleWindow {
fn default_config(instance: String) -> config::ModuleConfig { fn default_config(instance: String) -> config::ModuleConfig {
config::ModuleConfig { config::ModuleConfig {
name: Self::name().to_owned(), name: NAME.to_owned(),
instance, instance,
format: "🪟 {title} — {app_name}".to_owned(), format: "🪟 {title} — {app_name}".to_owned(),
html_escape: true, html_escape: true,
@ -45,10 +45,6 @@ impl BarModuleFn for BarModuleWindow {
} }
} }
fn name() -> &'static str {
NAME
}
fn get_config(&self) -> &config::ModuleConfig { fn get_config(&self) -> &config::ModuleConfig {
&self.config &self.config
} }
@ -61,14 +57,14 @@ impl BarModuleFn for BarModuleWindow {
let text = match focused_win { let text = match focused_win {
Some(win) => { Some(win) => {
fmt_replace!(&self.config.format, self.config.html_escape, { fmt_replace!(&self.config.format, self.config.html_escape, {
"title" |"name" => win.get_name(), "title" | "name" => win.get_name(),
"app_name" => win.get_app_name(), "app_name" => win.get_app_name(),
}) })
} }
None => String::new(), None => String::new(),
}; };
s::Block { s::Block {
name: Some(Self::name().to_owned()), name: Some(NAME.to_owned()),
instance: Some(self.config.instance.clone()), instance: Some(self.config.instance.clone()),
full_text: text, full_text: text,
align: Some(s::Align::Left), align: Some(s::Align::Left),

Loading…
Cancel
Save