1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-04-19 19:34:24 +02:00

feat: option to disable module popup

This commit is contained in:
Jake Stanger 2024-04-01 01:30:19 +01:00
parent 994f4a4a12
commit 46cbaca5e0
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
3 changed files with 21 additions and 13 deletions

View file

@ -332,6 +332,7 @@ For information on the `Script` type, and embedding scripts in strings, see [her
| `show_if` | [Dynamic Boolean](dynamic-values#dynamic-boolean) | `null` | Polls the script to check its exit code. If exit code is zero, the module is shown. For other codes, it is hidden. | | `show_if` | [Dynamic Boolean](dynamic-values#dynamic-boolean) | `null` | Polls the script to check its exit code. If exit code is zero, the module is shown. For other codes, it is hidden. |
| `transition_type` | `slide_start` or `slide_end` or `crossfade` or `none` | `slide_start` | The transition animation to use when showing/hiding the widget. | | `transition_type` | `slide_start` or `slide_end` or `crossfade` or `none` | `slide_start` | The transition animation to use when showing/hiding the widget. |
| `transition_duration` | `integer` | `250` | The length of the transition animation to use when showing/hiding the widget. | | `transition_duration` | `integer` | `250` | The length of the transition animation to use when showing/hiding the widget. |
| `disable_popup` | `boolean` | `false` | Prevents the popup from opening on-click for this widget. |
#### Appearance #### Appearance

View file

@ -27,6 +27,7 @@ pub struct CommonConfig {
pub on_mouse_exit: Option<ScriptInput>, pub on_mouse_exit: Option<ScriptInput>,
pub tooltip: Option<String>, pub tooltip: Option<String>,
pub disable_popup: bool,
} }
#[derive(Debug, Deserialize, Clone)] #[derive(Debug, Deserialize, Clone)]

View file

@ -314,7 +314,7 @@ pub trait ModuleFactory {
.register_content(id, instance_name, popup_content); .register_content(id, instance_name, popup_content);
} }
self.setup_receiver(tx, ui_rx, module_name, id); self.setup_receiver(tx, ui_rx, module_name, id, common.disable_popup);
module_parts.setup_identifiers(&common); module_parts.setup_identifiers(&common);
@ -334,6 +334,7 @@ pub trait ModuleFactory {
rx: mpsc::Receiver<ModuleUpdateEvent<TSend>>, rx: mpsc::Receiver<ModuleUpdateEvent<TSend>>,
name: &'static str, name: &'static str,
id: usize, id: usize,
disable_popup: bool,
) where ) where
TSend: Debug + Clone + Send + 'static; TSend: Debug + Clone + Send + 'static;
@ -360,6 +361,7 @@ impl ModuleFactory for BarModuleFactory {
rx: mpsc::Receiver<ModuleUpdateEvent<TSend>>, rx: mpsc::Receiver<ModuleUpdateEvent<TSend>>,
name: &'static str, name: &'static str,
id: usize, id: usize,
disable_popup: bool,
) where ) where
TSend: Debug + Clone + Send + 'static, TSend: Debug + Clone + Send + 'static,
{ {
@ -369,7 +371,7 @@ impl ModuleFactory for BarModuleFactory {
ModuleUpdateEvent::Update(update) => { ModuleUpdateEvent::Update(update) => {
send!(tx, update); send!(tx, update);
} }
ModuleUpdateEvent::TogglePopup(button_id) => { ModuleUpdateEvent::TogglePopup(button_id) if !disable_popup => {
debug!("Toggling popup for {} [#{}] (button id: {button_id})", name, id); debug!("Toggling popup for {} [#{}] (button id: {button_id})", name, id);
if popup.is_visible() && popup.current_widget().unwrap_or_default() == id { if popup.is_visible() && popup.current_widget().unwrap_or_default() == id {
popup.hide(); popup.hide();
@ -377,22 +379,23 @@ impl ModuleFactory for BarModuleFactory {
popup.show(id, button_id); popup.show(id, button_id);
} }
} }
ModuleUpdateEvent::OpenPopup(button_id) => { ModuleUpdateEvent::OpenPopup(button_id) if !disable_popup => {
debug!("Opening popup for {} [#{}] (button id: {button_id})", name, id); debug!("Opening popup for {} [#{}] (button id: {button_id})", name, id);
popup.hide(); popup.hide();
popup.show(id, button_id); popup.show(id, button_id);
} }
#[cfg(feature = "launcher")] #[cfg(feature = "launcher")]
ModuleUpdateEvent::OpenPopupAt(geometry) => { ModuleUpdateEvent::OpenPopupAt(geometry) if !disable_popup => {
debug!("Opening popup for {} [#{}]", name, id); debug!("Opening popup for {} [#{}]", name, id);
popup.hide(); popup.hide();
popup.show_at(id, geometry); popup.show_at(id, geometry);
} }
ModuleUpdateEvent::ClosePopup => { ModuleUpdateEvent::ClosePopup if !disable_popup => {
debug!("Closing popup for {} [#{}]", name, id); debug!("Closing popup for {} [#{}]", name, id);
popup.hide(); popup.hide();
} },
_ => {}
} }
}); });
} }
@ -430,6 +433,7 @@ impl ModuleFactory for PopupModuleFactory {
rx: mpsc::Receiver<ModuleUpdateEvent<TSend>>, rx: mpsc::Receiver<ModuleUpdateEvent<TSend>>,
name: &'static str, name: &'static str,
id: usize, id: usize,
disable_popup: bool,
) where ) where
TSend: Debug + Clone + Send + 'static, TSend: Debug + Clone + Send + 'static,
{ {
@ -440,7 +444,7 @@ impl ModuleFactory for PopupModuleFactory {
ModuleUpdateEvent::Update(update) => { ModuleUpdateEvent::Update(update) => {
send!(tx, update); send!(tx, update);
} }
ModuleUpdateEvent::TogglePopup(_) => { ModuleUpdateEvent::TogglePopup(_) if !disable_popup => {
debug!("Toggling popup for {} [#{}] (button id: {button_id})", name, id); debug!("Toggling popup for {} [#{}] (button id: {button_id})", name, id);
if popup.is_visible() && popup.current_widget().unwrap_or_default() == id { if popup.is_visible() && popup.current_widget().unwrap_or_default() == id {
popup.hide(); popup.hide();
@ -448,22 +452,23 @@ impl ModuleFactory for PopupModuleFactory {
popup.show(id, button_id); popup.show(id, button_id);
} }
} }
ModuleUpdateEvent::OpenPopup(_) => { ModuleUpdateEvent::OpenPopup(_) if !disable_popup => {
debug!("Opening popup for {} [#{}] (button id: {button_id})", name, id); debug!("Opening popup for {} [#{}] (button id: {button_id})", name, id);
popup.hide(); popup.hide();
popup.show(id, button_id); popup.show(id, button_id);
} }
#[cfg(feature = "launcher")] #[cfg(feature = "launcher")]
ModuleUpdateEvent::OpenPopupAt(geometry) => { ModuleUpdateEvent::OpenPopupAt(geometry) if !disable_popup => {
debug!("Opening popup for {} [#{}]", name, id); debug!("Opening popup for {} [#{}]", name, id);
popup.hide(); popup.hide();
popup.show_at(id, geometry); popup.show_at(id, geometry);
} }
ModuleUpdateEvent::ClosePopup => { ModuleUpdateEvent::ClosePopup if !disable_popup => {
debug!("Closing popup for {} [#{}]", name, id); debug!("Closing popup for {} [#{}]", name, id);
popup.hide(); popup.hide();
} },
_ => {}
} }
}); });
} }
@ -490,12 +495,13 @@ impl ModuleFactory for AnyModuleFactory {
rx: mpsc::Receiver<ModuleUpdateEvent<TSend>>, rx: mpsc::Receiver<ModuleUpdateEvent<TSend>>,
name: &'static str, name: &'static str,
id: usize, id: usize,
disable_popup: bool,
) where ) where
TSend: Debug + Clone + Send + 'static, TSend: Debug + Clone + Send + 'static,
{ {
match self { match self {
AnyModuleFactory::Bar(bar) => bar.setup_receiver(tx, rx, name, id), AnyModuleFactory::Bar(bar) => bar.setup_receiver(tx, rx, name, id, disable_popup),
AnyModuleFactory::Popup(popup) => popup.setup_receiver(tx, rx, name, id), AnyModuleFactory::Popup(popup) => popup.setup_receiver(tx, rx, name, id, disable_popup),
} }
} }