Compare commits
2 commits
859e1ca527
...
7f70ad44de
Author | SHA1 | Date | |
---|---|---|---|
7f70ad44de | |||
b04b4f800d |
9 changed files with 72 additions and 1 deletions
|
@ -6,6 +6,7 @@ mod imp {
|
|||
|
||||
#[derive(Default)]
|
||||
pub struct Application {
|
||||
// FIXME: move somewhere else
|
||||
mpv: Rc<mpv::Handle>,
|
||||
}
|
||||
|
||||
|
@ -91,6 +92,13 @@ mod imp {
|
|||
impl AdwApplicationImpl for Application {}
|
||||
|
||||
impl Application {}
|
||||
|
||||
impl Drop for Application {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping AudreyApplication");
|
||||
self.mpv.command(["quit"]).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use gtk::{gio, glib};
|
||||
|
|
|
@ -93,3 +93,9 @@ impl Mpris {
|
|||
vec![]
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Mpris {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping Mpris");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -504,3 +504,9 @@ impl Player {
|
|||
true
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Player {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping MprisPlayer");
|
||||
}
|
||||
}
|
||||
|
|
23
src/mpv.rs
23
src/mpv.rs
|
@ -1,6 +1,6 @@
|
|||
mod ffi;
|
||||
|
||||
use std::ffi::{c_int, c_void, CStr, CString};
|
||||
use std::ffi::{c_char, c_int, c_void, CStr, CString};
|
||||
|
||||
#[link(name = "mpv")]
|
||||
extern "C" {}
|
||||
|
@ -114,6 +114,25 @@ impl Handle {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn command<'a>(&self, args: impl IntoIterator<Item = &'a str>) -> Result<(), Error> {
|
||||
// add zero terminators to Everything
|
||||
let args: Vec<CString> = args
|
||||
.into_iter()
|
||||
.map(CString::new)
|
||||
.map(Result::unwrap)
|
||||
.collect();
|
||||
let mut args: Vec<*const c_char> = args
|
||||
.iter()
|
||||
.map(CString::as_c_str)
|
||||
.map(CStr::as_ptr)
|
||||
.collect();
|
||||
// must be null terminated
|
||||
args.push(std::ptr::null_mut());
|
||||
let args: *mut *const c_char = args.as_mut_ptr();
|
||||
|
||||
Error::from_return_code(unsafe { ffi::mpv_command(self.inner.as_ptr(), args) })
|
||||
}
|
||||
|
||||
// TODO: return None on SHUTDOWN possibly?
|
||||
pub fn tick(&self) -> Option<EventListener> {
|
||||
// take listener before we drain the event queue, so we don't miss any notifications
|
||||
|
@ -151,6 +170,8 @@ impl Handle {
|
|||
|
||||
impl Drop for Handle {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping MpvHandle");
|
||||
|
||||
// let any executor ticking tasks know we're ded
|
||||
self.wakeup.notify(u32::MAX.relaxed());
|
||||
|
||||
|
|
|
@ -171,3 +171,9 @@ impl Client {
|
|||
.map(|response| response.random_songs.song)
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Client {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping SubsonicClient");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,6 +84,12 @@ mod imp {
|
|||
self.obj().playbin().unwrap().select_track(position);
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for PlayQueue {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping AudreyUiPlayQueue");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use gtk::glib;
|
||||
|
|
|
@ -161,6 +161,12 @@ mod imp {
|
|||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Song {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping AudreyUiPlayQueueSong");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use adw::prelude::*;
|
||||
|
|
|
@ -160,6 +160,12 @@ mod imp {
|
|||
playbin.set_mute(!playbin.mute());
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Playbar {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping AudreyUiPlaybar");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use gtk::glib;
|
||||
|
|
|
@ -147,6 +147,12 @@ mod imp {
|
|||
self.obj().emit_by_name::<()>("connected", &[&vala_api]);
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for Setup {
|
||||
fn drop(&mut self) {
|
||||
println!("dropping AudreyUiSetup");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
use adw::subclass::prelude::*;
|
||||
|
|
Loading…
Reference in a new issue