1
0
Fork 0
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:
Jake Stanger 2025-05-18 15:17:09 +01:00
parent d5744f597c
commit f929aef2d9
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
50 changed files with 658 additions and 476 deletions

View file

@ -8,12 +8,12 @@ use serde::Deserialize;
use tokio::sync::mpsc;
use tracing::error;
use super::{CustomWidget, CustomWidgetContext, ExecEvent};
use crate::channels::{AsyncSenderExt, MpscReceiverExt};
use crate::config::ModuleOrientation;
use crate::modules::custom::set_length;
use crate::script::{OutputStream, Script, ScriptInput};
use crate::{build, glib_recv_mpsc, spawn, try_send};
use super::{CustomWidget, CustomWidgetContext, ExecEvent};
use crate::{build, spawn};
#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
@ -134,14 +134,11 @@ impl CustomWidget for SliderWidget {
let val = val.clamp(min, max);
if val != prev_value.get() {
try_send!(
tx,
ExecEvent {
cmd: on_change.clone(),
args: Some(vec![val.to_string()]),
id: usize::MAX // ignored
}
);
tx.send_spawn(ExecEvent {
cmd: on_change.clone(),
args: Some(vec![val.to_string()]),
id: usize::MAX, // ignored
});
prev_value.set(val);
}
@ -160,7 +157,7 @@ impl CustomWidget for SliderWidget {
script
.run(None, move |stream, _success| match stream {
OutputStream::Stdout(out) => match out.parse() {
Ok(value) => try_send!(tx, value),
Ok(value) => tx.send_spawn(value),
Err(err) => error!("{err:?}"),
},
OutputStream::Stderr(err) => error!("{err:?}"),
@ -168,7 +165,7 @@ impl CustomWidget for SliderWidget {
.await;
});
glib_recv_mpsc!(rx, value => scale.set_value(value));
rx.recv_glib(move |value| scale.set_value(value));
}
scale