1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-04 04:01:03 +02:00

refactor: macros to reduce repeated code

This commit is contained in:
Jake Stanger 2022-12-11 22:45:52 +00:00
parent 9d5049dde0
commit 5e21cbcca6
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
18 changed files with 225 additions and 248 deletions

View file

@ -1,7 +1,7 @@
use crate::clients::sway::{get_client, get_sub_client};
use crate::config::CommonConfig;
use crate::modules::{Module, ModuleInfo, ModuleUpdateEvent, ModuleWidget, WidgetContext};
use crate::{await_sync, error};
use crate::{await_sync, send_async, try_send};
use color_eyre::{Report, Result};
use gtk::prelude::*;
use gtk::Button;
@ -53,7 +53,7 @@ fn create_button(
let tx = tx.clone();
let name = name.to_string();
button.connect_clicked(move |_item| {
tx.try_send(name.clone()).expect(error::ERR_CHANNEL_SEND);
try_send!(tx, name.clone());
});
}
@ -93,8 +93,10 @@ impl Module<gtk::Box> for WorkspacesModule {
}
};
tx.try_send(ModuleUpdateEvent::Update(WorkspaceUpdate::Init(workspaces)))
.expect(error::ERR_CHANNEL_SEND);
try_send!(
tx,
ModuleUpdateEvent::Update(WorkspaceUpdate::Init(workspaces))
);
// Subscribe & send events
spawn(async move {
@ -106,9 +108,10 @@ impl Module<gtk::Box> for WorkspacesModule {
trace!("Set up Sway workspace subscription");
while let Ok(payload) = srx.recv().await {
tx.send(ModuleUpdateEvent::Update(WorkspaceUpdate::Update(payload)))
.await
.expect(error::ERR_CHANNEL_SEND);
send_async!(
tx,
ModuleUpdateEvent::Update(WorkspaceUpdate::Update(payload))
);
}
});