mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-08-17 14:51:04 +02:00
refactor: replace channel macros with ext trait methods
This commit is contained in:
parent
d5744f597c
commit
f929aef2d9
50 changed files with 658 additions and 476 deletions
|
@ -1,3 +1,4 @@
|
|||
use crate::channels::{AsyncSenderExt, BroadcastReceiverExt};
|
||||
use crate::clients::clipboard::{self, ClipboardEvent};
|
||||
use crate::clients::wayland::{ClipboardItem, ClipboardValue};
|
||||
use crate::config::{CommonConfig, LayoutConfig, TruncateMode};
|
||||
|
@ -7,7 +8,7 @@ use crate::image::IconButton;
|
|||
use crate::modules::{
|
||||
Module, ModuleInfo, ModuleParts, ModulePopup, ModuleUpdateEvent, PopupButton, WidgetContext,
|
||||
};
|
||||
use crate::{glib_recv, module_impl, spawn, try_send};
|
||||
use crate::{module_impl, spawn};
|
||||
use glib::Propagation;
|
||||
use gtk::gdk_pixbuf::Pixbuf;
|
||||
use gtk::gio::{Cancellable, MemoryInputStream};
|
||||
|
@ -109,18 +110,16 @@ impl Module<Button> for ClipboardModule {
|
|||
match event {
|
||||
ClipboardEvent::Add(item) => {
|
||||
let msg = match item.value.as_ref() {
|
||||
ClipboardValue::Other => {
|
||||
ModuleUpdateEvent::Update(ControllerEvent::Deactivate)
|
||||
}
|
||||
_ => ModuleUpdateEvent::Update(ControllerEvent::Add(item.id, item)),
|
||||
ClipboardValue::Other => ControllerEvent::Deactivate,
|
||||
_ => ControllerEvent::Add(item.id, item),
|
||||
};
|
||||
try_send!(tx, msg);
|
||||
tx.send_update_spawn(msg);
|
||||
}
|
||||
ClipboardEvent::Remove(id) => {
|
||||
try_send!(tx, ModuleUpdateEvent::Update(ControllerEvent::Remove(id)));
|
||||
tx.send_update_spawn(ControllerEvent::Remove(id));
|
||||
}
|
||||
ClipboardEvent::Activate(id) => {
|
||||
try_send!(tx, ModuleUpdateEvent::Update(ControllerEvent::Activate(id)));
|
||||
tx.send_update_spawn(ControllerEvent::Activate(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,7 +155,7 @@ impl Module<Button> for ClipboardModule {
|
|||
|
||||
let tx = context.tx.clone();
|
||||
button.connect_clicked(move |button| {
|
||||
try_send!(tx, ModuleUpdateEvent::TogglePopup(button.popup_id()));
|
||||
tx.send_spawn(ModuleUpdateEvent::TogglePopup(button.popup_id()));
|
||||
});
|
||||
|
||||
let rx = context.subscribe();
|
||||
|
@ -189,7 +188,7 @@ impl Module<Button> for ClipboardModule {
|
|||
|
||||
{
|
||||
let hidden_option = hidden_option.clone();
|
||||
glib_recv!(rx, event => {
|
||||
rx.recv_glib(move |event| {
|
||||
match event {
|
||||
ControllerEvent::Add(id, item) => {
|
||||
debug!("Adding new value with ID {}", id);
|
||||
|
@ -231,7 +230,7 @@ impl Module<Button> for ClipboardModule {
|
|||
button.style_context().add_class("image");
|
||||
|
||||
button
|
||||
},
|
||||
}
|
||||
Err(err) => {
|
||||
error!("{err:?}");
|
||||
return;
|
||||
|
@ -260,7 +259,7 @@ impl Module<Button> for ClipboardModule {
|
|||
.expect("Failed to get id from button name");
|
||||
|
||||
debug!("Copying item with id: {id}");
|
||||
try_send!(tx, UIEvent::Copy(id));
|
||||
tx.send_spawn(UIEvent::Copy(id));
|
||||
}
|
||||
|
||||
Propagation::Stop
|
||||
|
@ -282,7 +281,7 @@ impl Module<Button> for ClipboardModule {
|
|||
.expect("Failed to get id from button name");
|
||||
|
||||
debug!("Removing item with id: {id}");
|
||||
try_send!(tx, UIEvent::Remove(id));
|
||||
tx.send_spawn(UIEvent::Remove(id));
|
||||
|
||||
entries.remove(&row);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue