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
|
@ -139,7 +139,7 @@ impl Module<Button> for ClockModule {
|
|||
let locale = Locale::try_from(self.locale.as_str()).unwrap_or(Locale::POSIX);
|
||||
|
||||
let rx = context.subscribe();
|
||||
rx.recv_glib(move |date| {
|
||||
rx.recv_glib((), move |(), date| {
|
||||
let date_string = format!("{}", date.format_localized(&format, locale));
|
||||
label.set_label(&date_string);
|
||||
});
|
||||
|
@ -173,7 +173,7 @@ impl Module<Button> for ClockModule {
|
|||
let format = self.format_popup;
|
||||
let locale = Locale::try_from(self.locale.as_str()).unwrap_or(Locale::POSIX);
|
||||
|
||||
context.subscribe().recv_glib(move |date| {
|
||||
context.subscribe().recv_glib((), move |(), date| {
|
||||
let date_string = format!("{}", date.format_localized(&format, locale));
|
||||
clock.set_label(&date_string);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue