mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 14:51:04 +02:00
refactor: recv_glib
dependency arrays
Adds a dependency array system to `recv_glib` which internally clones the passed deps and then passes by reference to the callback. This cleans up a lot of the big `{}` blocks full of `widget.clone()` and removes a lot of boilerplate. Yay!
This commit is contained in:
parent
beab26a37e
commit
9d18ce52f5
31 changed files with 539 additions and 517 deletions
24
src/popup.rs
24
src/popup.rs
|
@ -113,21 +113,15 @@ impl Popup {
|
|||
let output_size = rc_mut!(output_size);
|
||||
|
||||
// respond to resolution changes
|
||||
{
|
||||
let output_size = output_size.clone();
|
||||
let output_name = module_info.output_name.to_string();
|
||||
|
||||
let on_output_event = move |event: OutputEvent| {
|
||||
if event.event_type == OutputEventType::Update
|
||||
&& event.output.name.unwrap_or_default() == output_name
|
||||
{
|
||||
*output_size.borrow_mut() = event.output.logical_size.unwrap_or_default();
|
||||
}
|
||||
};
|
||||
|
||||
let rx = ironbar.clients.borrow_mut().wayland().subscribe_outputs();
|
||||
rx.recv_glib(on_output_event);
|
||||
}
|
||||
let rx = ironbar.clients.borrow_mut().wayland().subscribe_outputs();
|
||||
let output_name = module_info.output_name.to_string();
|
||||
rx.recv_glib(&output_size, move |output_size, event: OutputEvent| {
|
||||
if event.event_type == OutputEventType::Update
|
||||
&& event.output.name.unwrap_or_default() == output_name
|
||||
{
|
||||
*output_size.borrow_mut() = event.output.logical_size.unwrap_or_default();
|
||||
}
|
||||
});
|
||||
|
||||
Self {
|
||||
window: win,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue