Compare commits
No commits in common. "2f84c3932b084950bd2b9e119f2c421612584453" and "f15019f49d7f04a1e440242e7e0abff41520769c" have entirely different histories.
2f84c3932b
...
f15019f49d
5 changed files with 34 additions and 4 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -217,6 +217,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
|||
name = "audrey"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"async-broadcast",
|
||||
"async-channel",
|
||||
"base16ct",
|
||||
"bindgen",
|
||||
|
|
|
@ -5,6 +5,7 @@ edition = "2021"
|
|||
|
||||
[dependencies]
|
||||
adw = { version = "0.7.0", package = "libadwaita", features = ["v1_6"] }
|
||||
async-broadcast = "0.7.1"
|
||||
async-channel = "2.3.1"
|
||||
base16ct = { version = "0.2.0", features = ["std"] }
|
||||
chrono = { version = "0.4.38", features = ["serde"] }
|
||||
|
|
29
src/event.rs
Normal file
29
src/event.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
#[derive(Clone, Debug)]
|
||||
pub enum Event {
|
||||
PlaybinVolumeChanged,
|
||||
PlaybinMutedChanged,
|
||||
PlaybinPausedChanged,
|
||||
PlaybinCurrentEntryChanged,
|
||||
|
||||
PlaybinEntryInserted(usize),
|
||||
PlaybinStopped,
|
||||
PlaybinEntryRemoved(usize),
|
||||
|
||||
PlaybinFileStarted,
|
||||
}
|
||||
|
||||
use adw::prelude::*;
|
||||
use gtk::glib;
|
||||
|
||||
pub fn spawn_object_listener<O: IsA<glib::Object>>(
|
||||
mut receiver: async_broadcast::Receiver<Event>,
|
||||
obj: &O,
|
||||
mut f: impl FnMut(O, Event) + 'static,
|
||||
) {
|
||||
let weak = obj.downgrade();
|
||||
glib::spawn_future_local(async move {
|
||||
while let Some(obj) = weak.upgrade() {
|
||||
f(obj, receiver.recv_direct().await.unwrap());
|
||||
}
|
||||
});
|
||||
}
|
|
@ -16,6 +16,9 @@ pub use playbin_song::Song as PlaybinSong;
|
|||
|
||||
pub mod subsonic;
|
||||
|
||||
pub mod event;
|
||||
pub use event::Event;
|
||||
|
||||
use gettextrs::{bind_textdomain_codeset, bindtextdomain, setlocale, textdomain, LocaleCategory};
|
||||
use gtk::prelude::*;
|
||||
use gtk::{gio, glib};
|
||||
|
|
|
@ -196,10 +196,6 @@ mod imp {
|
|||
};
|
||||
}
|
||||
|
||||
Event::Unknown(_) => {
|
||||
// either deprecated or future, ignore
|
||||
}
|
||||
|
||||
_ => event!(Level::DEBUG, "unhandled {event:?}"),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue