1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-08-18 07:11:04 +02:00

refactor: fix some pedantic clippy warnings

This commit is contained in:
Jake Stanger 2024-08-14 21:23:28 +01:00
parent 4d30819ff6
commit 04f45ccae1
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
12 changed files with 43 additions and 46 deletions

View file

@ -6,12 +6,13 @@ use crate::Ironbar;
use std::rc::Rc;
pub fn handle_command(command: BarCommand, ironbar: &Rc<Ironbar>) -> Response {
use BarCommandType::*;
let bar = ironbar.bar_by_name(&command.name);
let Some(bar) = bar else {
return Response::error("Invalid bar name");
};
use BarCommandType::*;
match command.subcommand {
Show => set_visible(&bar, true),
Hide => set_visible(&bar, false),
@ -21,14 +22,14 @@ pub fn handle_command(command: BarCommand, ironbar: &Rc<Ironbar>) -> Response {
value: bar.visible().to_string(),
},
ShowPopup { widget_name } => show_popup(&bar, widget_name),
ShowPopup { widget_name } => show_popup(&bar, &widget_name),
HidePopup => hide_popup(&bar),
SetPopupVisible {
widget_name,
visible,
} => {
if visible {
show_popup(&bar, widget_name)
show_popup(&bar, &widget_name)
} else {
hide_popup(&bar)
}
@ -37,7 +38,7 @@ pub fn handle_command(command: BarCommand, ironbar: &Rc<Ironbar>) -> Response {
if bar.popup().visible() {
hide_popup(&bar)
} else {
show_popup(&bar, widget_name)
show_popup(&bar, &widget_name)
}
}
GetPopupVisible => Response::OkValue {
@ -56,7 +57,7 @@ fn set_visible(bar: &Bar, visible: bool) -> Response {
Response::Ok
}
fn show_popup(bar: &Bar, widget_name: String) -> Response {
fn show_popup(bar: &Bar, widget_name: &str) -> Response {
let popup = bar.popup();
// only one popup per bar, so hide if open for another widget