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
|
@ -184,9 +184,9 @@ impl Module<Button> for ClipboardModule {
|
|||
|
||||
let mut items = HashMap::new();
|
||||
|
||||
{
|
||||
let hidden_option = hidden_option.clone();
|
||||
context.subscribe().recv_glib(move |event| {
|
||||
context
|
||||
.subscribe()
|
||||
.recv_glib(&hidden_option, move |hidden_option, event| {
|
||||
match event {
|
||||
ControllerEvent::Add(id, item) => {
|
||||
debug!("Adding new value with ID {}", id);
|
||||
|
@ -196,7 +196,7 @@ impl Module<Button> for ClipboardModule {
|
|||
|
||||
let button = match item.value.as_ref() {
|
||||
ClipboardValue::Text(value) => {
|
||||
let button = RadioButton::from_widget(&hidden_option);
|
||||
let button = RadioButton::from_widget(hidden_option);
|
||||
|
||||
let label = Label::new(Some(value));
|
||||
button.add(&label);
|
||||
|
@ -222,7 +222,7 @@ impl Module<Button> for ClipboardModule {
|
|||
Ok(pixbuf) => {
|
||||
let image = Image::from_pixbuf(Some(&pixbuf));
|
||||
|
||||
let button = RadioButton::from_widget(&hidden_option);
|
||||
let button = RadioButton::from_widget(hidden_option);
|
||||
button.set_image(Some(&image));
|
||||
button.set_always_show_image(true);
|
||||
button.style_context().add_class("image");
|
||||
|
@ -320,7 +320,6 @@ impl Module<Button> for ClipboardModule {
|
|||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
container.show_all();
|
||||
hidden_option.hide();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue