Compare commits

..

No commits in common. "2f84c3932b084950bd2b9e119f2c421612584453" and "f15019f49d7f04a1e440242e7e0abff41520769c" have entirely different histories.

5 changed files with 34 additions and 4 deletions

1
Cargo.lock generated
View file

@ -217,6 +217,7 @@ checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
name = "audrey" name = "audrey"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"async-broadcast",
"async-channel", "async-channel",
"base16ct", "base16ct",
"bindgen", "bindgen",

View file

@ -5,6 +5,7 @@ edition = "2021"
[dependencies] [dependencies]
adw = { version = "0.7.0", package = "libadwaita", features = ["v1_6"] } adw = { version = "0.7.0", package = "libadwaita", features = ["v1_6"] }
async-broadcast = "0.7.1"
async-channel = "2.3.1" async-channel = "2.3.1"
base16ct = { version = "0.2.0", features = ["std"] } base16ct = { version = "0.2.0", features = ["std"] }
chrono = { version = "0.4.38", features = ["serde"] } chrono = { version = "0.4.38", features = ["serde"] }

29
src/event.rs Normal file
View 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());
}
});
}

View file

@ -16,6 +16,9 @@ pub use playbin_song::Song as PlaybinSong;
pub mod subsonic; pub mod subsonic;
pub mod event;
pub use event::Event;
use gettextrs::{bind_textdomain_codeset, bindtextdomain, setlocale, textdomain, LocaleCategory}; use gettextrs::{bind_textdomain_codeset, bindtextdomain, setlocale, textdomain, LocaleCategory};
use gtk::prelude::*; use gtk::prelude::*;
use gtk::{gio, glib}; use gtk::{gio, glib};

View file

@ -196,10 +196,6 @@ mod imp {
}; };
} }
Event::Unknown(_) => {
// either deprecated or future, ignore
}
_ => event!(Level::DEBUG, "unhandled {event:?}"), _ => event!(Level::DEBUG, "unhandled {event:?}"),
} }
} }