mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-02 11:11:04 +02:00
refactor: update gtk/glib, remove glib channels
This is a major refactor which updates GTK, GLib and GTK Layer Shell to their latest versions. GLib channels, previously used for receiving events on the GLib Main Context thread have been deprecated and a new method for running Futures on the main thread has been added instead. This commit also replaces all the deprecated code with this. As part of the above, a bug was uncovered related to creating the GLib main context inside the Tokio runtime. Spawning of Tokio tasks has been refactored to fix this.
This commit is contained in:
parent
2c2f1c1243
commit
bea442ed96
39 changed files with 426 additions and 465 deletions
|
@ -43,6 +43,55 @@ macro_rules! try_send {
|
|||
};
|
||||
}
|
||||
|
||||
/// Spawns a `GLib` future on the local thread, and calls `rx.recv()`
|
||||
/// in a loop.
|
||||
///
|
||||
/// This allows use of `GObjects` and futures in the same context.
|
||||
///
|
||||
/// For use with receivers which return a `Result`.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rs
|
||||
/// let (tx, mut rx) = broadcast::channel(32);
|
||||
/// glib_recv(rx, msg => println!("{msg}"));
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! glib_recv {
|
||||
($rx:expr, $val:ident => $expr:expr) => {
|
||||
glib::spawn_future_local(async move {
|
||||
while let Ok($val) = $rx.recv().await {
|
||||
$expr
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/// Spawns a `GLib` future on the local thread, and calls `rx.recv()`
|
||||
/// in a loop.
|
||||
///
|
||||
/// This allows use of `GObjects` and futures in the same context.
|
||||
///
|
||||
/// For use with receivers which return an `Option`,
|
||||
/// such as Tokio's `mpsc` channel.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// ```rs
|
||||
/// let (tx, mut rx) = broadcast::channel(32);
|
||||
/// glib_recv_mpsc(rx, msg => println!("{msg}"));
|
||||
/// ```
|
||||
#[macro_export]
|
||||
macro_rules! glib_recv_mpsc {
|
||||
($rx:expr, $val:ident => $expr:expr) => {
|
||||
glib::spawn_future_local(async move {
|
||||
while let Some($val) = $rx.recv().await {
|
||||
$expr
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
/// Locks a `Mutex`.
|
||||
/// Panics if the `Mutex` cannot be locked.
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue