(sickos) yes... yes!!

This commit is contained in:
Erica Z 2024-11-03 19:36:52 +01:00
parent 1b8a59bef5
commit e7e7341c89
10 changed files with 35 additions and 74 deletions

View file

@ -128,7 +128,6 @@ template $AudreyUiWindow: Adw.ApplicationWindow {
[bottom] [bottom]
$AudreyUiPlaybar playbar { $AudreyUiPlaybar playbar {
song: bind template.song; song: bind template.song;
playbin: bind template.playbin;
playing_cover_art: bind template.playing_cover_art; playing_cover_art: bind template.playing_cover_art;
show_cover_art: bind $show_playbar_cover_art (stack.visible-child-name) as <bool>; show_cover_art: bind $show_playbar_cover_art (stack.visible-child-name) as <bool>;
} }

View file

@ -11,13 +11,14 @@ pub mod ui;
pub mod mpris; pub mod mpris;
pub use mpris::Mpris; pub use mpris::Mpris;
pub mod playbin; pub mod playbin_vala;
pub use playbin::Playbin; pub use playbin_vala::Song as PlaybinSong;
pub mod subsonic; pub mod subsonic;
pub mod subsonic_vala; pub mod subsonic_vala;
pub mod playbin2; pub mod playbin2;
pub type Playbin = playbin2::Playbin<PlaybinSong>;
mod signal; mod signal;
pub use signal::{Signal, SignalEmitter, SignalHandler}; pub use signal::{Signal, SignalEmitter, SignalHandler};

View file

@ -1,11 +1,9 @@
use crate::{Playbin, PlaybinSong};
use gtk::glib::spawn_future_local; use gtk::glib::spawn_future_local;
use std::collections::HashMap; use std::collections::HashMap;
use std::rc::{Rc, Weak}; use std::rc::{Rc, Weak};
use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Value}; use zbus::zvariant::{ObjectPath, OwnedObjectPath, OwnedValue, Value};
use crate::playbin::Song as PlaybinSong;
type Playbin = crate::playbin2::Playbin<PlaybinSong>;
const MICROSECONDS: f64 = 1e6; // in a second const MICROSECONDS: f64 = 1e6; // in a second
#[derive(Default)] #[derive(Default)]
@ -37,7 +35,7 @@ struct MetadataMap {
} }
impl MetadataMap { impl MetadataMap {
fn from_playbin_song(song: Option<&crate::playbin::Song>) -> Self { fn from_playbin_song(song: Option<&PlaybinSong>) -> Self {
song.map(|song| MetadataMap { song.map(|song| MetadataMap {
// use a unique growing counter to identify tracks // use a unique growing counter to identify tracks
track_id: Some({ track_id: Some({

View file

@ -2,14 +2,12 @@ pub mod song;
pub use song::Song; pub use song::Song;
mod imp { mod imp {
use crate::playbin::Song as PlaybinSong; use crate::{Playbin, PlaybinSong};
use adw::{gio, glib, prelude::*, subclass::prelude::*}; use adw::{gio, glib, prelude::*, subclass::prelude::*};
use glib::{subclass::InitializingObject, WeakRef}; use glib::{subclass::InitializingObject, WeakRef};
use std::cell::{Cell, RefCell}; use std::cell::{Cell, RefCell};
use std::rc::Rc; use std::rc::Rc;
type Playbin = crate::playbin2::Playbin<PlaybinSong>;
#[derive(gtk::CompositeTemplate, glib::Properties, Default)] #[derive(gtk::CompositeTemplate, glib::Properties, Default)]
#[template(resource = "/eu/callcc/audrey/play_queue.ui")] #[template(resource = "/eu/callcc/audrey/play_queue.ui")]
#[properties(wrapper_type = super::PlayQueue)] #[properties(wrapper_type = super::PlayQueue)]
@ -78,10 +76,7 @@ mod imp {
child.bind( child.bind(
item.position(), item.position(),
item.item() item.item().unwrap().downcast_ref::<PlaybinSong>().unwrap(),
.unwrap()
.downcast_ref::<crate::playbin::Song>()
.unwrap(),
); );
} }
@ -109,13 +104,11 @@ mod imp {
} }
} }
use crate::playbin::Song as PlaybinSong; use crate::Playbin;
use adw::subclass::prelude::*; use adw::subclass::prelude::*;
use gtk::glib; use gtk::glib;
use std::rc::Rc; use std::rc::Rc;
type Playbin = crate::playbin2::Playbin<PlaybinSong>;
glib::wrapper! { glib::wrapper! {
pub struct PlayQueue(ObjectSubclass<imp::PlayQueue>) pub struct PlayQueue(ObjectSubclass<imp::PlayQueue>)
@extends adw::Bin, gtk::Widget, @extends adw::Bin, gtk::Widget,

View file

@ -1,13 +1,11 @@
mod imp { mod imp {
use crate::playbin::Song as PlaybinSong;
use crate::signal::SignalHandler; use crate::signal::SignalHandler;
use crate::{Playbin, PlaybinSong};
use glib::{subclass::InitializingObject, WeakRef}; use glib::{subclass::InitializingObject, WeakRef};
use gtk::{gdk, gio, glib, prelude::*, subclass::prelude::*}; use gtk::{gdk, gio, glib, prelude::*, subclass::prelude::*};
use std::cell::{Cell, RefCell}; use std::cell::{Cell, RefCell};
use std::rc::Rc; use std::rc::Rc;
type Playbin = crate::playbin2::Playbin<PlaybinSong>;
#[derive(gtk::CompositeTemplate, glib::Properties, Default)] #[derive(gtk::CompositeTemplate, glib::Properties, Default)]
#[template(resource = "/eu/callcc/audrey/play_queue_song.ui")] #[template(resource = "/eu/callcc/audrey/play_queue_song.ui")]
#[properties(wrapper_type = super::Song)] #[properties(wrapper_type = super::Song)]
@ -167,15 +165,13 @@ mod imp {
} }
} }
use crate::playbin::Song as PlaybinSong; use crate::{Playbin, PlaybinSong};
use adw::prelude::*; use adw::prelude::*;
use adw::subclass::prelude::*; use adw::subclass::prelude::*;
use glib::Object; use glib::Object;
use gtk::glib; use gtk::glib;
use std::rc::Rc; use std::rc::Rc;
type Playbin = crate::playbin2::Playbin<PlaybinSong>;
glib::wrapper! { glib::wrapper! {
pub struct Song(ObjectSubclass<imp::Song>) pub struct Song(ObjectSubclass<imp::Song>)
@extends gtk::Box, gtk::Widget, @extends gtk::Box, gtk::Widget,
@ -199,7 +195,7 @@ impl Song {
Rc::clone(self.imp().playbin.borrow().as_ref().unwrap()) Rc::clone(self.imp().playbin.borrow().as_ref().unwrap())
} }
pub fn bind(&self, position: u32, song: &crate::playbin::Song) { pub fn bind(&self, position: u32, song: &PlaybinSong) {
self.set_displayed_position(position + 1); self.set_displayed_position(position + 1);
self.set_song(song); self.set_song(song);
self.set_current(self.playbin().current_entry() == Some(position as usize)); self.set_current(self.playbin().current_entry() == Some(position as usize));

View file

@ -1,4 +1,5 @@
mod imp { mod imp {
use crate::PlaybinSong;
use adw::prelude::*; use adw::prelude::*;
use adw::subclass::prelude::*; use adw::subclass::prelude::*;
use glib::subclass::InitializingObject; use glib::subclass::InitializingObject;
@ -11,7 +12,7 @@ mod imp {
#[template(resource = "/eu/callcc/audrey/playbar.ui")] #[template(resource = "/eu/callcc/audrey/playbar.ui")]
pub struct Playbar { pub struct Playbar {
#[property(get, set)] #[property(get, set)]
song: RefCell<Option<crate::playbin::Song>>, song: RefCell<Option<PlaybinSong>>,
#[property(get, set)] #[property(get, set)]
playing_cover_art: RefCell<Option<gdk::Paintable>>, playing_cover_art: RefCell<Option<gdk::Paintable>>,
#[property(get, set, default = true)] #[property(get, set, default = true)]
@ -53,17 +54,17 @@ mod imp {
#[gtk::template_callbacks] #[gtk::template_callbacks]
impl Playbar { impl Playbar {
#[template_callback] #[template_callback]
fn song_title(&self, song: Option<&crate::playbin::Song>) -> Option<GString> { fn song_title(&self, song: Option<&PlaybinSong>) -> Option<GString> {
song.map(|song| song.title()) song.map(|song| song.title())
} }
#[template_callback] #[template_callback]
fn song_artist(&self, song: Option<&crate::playbin::Song>) -> Option<GString> { fn song_artist(&self, song: Option<&PlaybinSong>) -> Option<GString> {
song.map(|song| song.artist()) song.map(|song| song.artist())
} }
#[template_callback] #[template_callback]
fn song_album(&self, song: Option<&crate::playbin::Song>) -> Option<GString> { fn song_album(&self, song: Option<&PlaybinSong>) -> Option<GString> {
song.map(|song| song.album()) song.map(|song| song.album())
} }
@ -72,25 +73,6 @@ mod imp {
gformat!("{:02}:{:02}", (s as i64) / 64, (s as i64) % 60) gformat!("{:02}:{:02}", (s as i64) / 64, (s as i64) % 60)
} }
#[template_callback]
fn playbin_active(&self, state: crate::playbin::State) -> bool {
true // TODO
}
#[template_callback]
fn can_press_play(&self, state: crate::playbin::State, n_items: u32) -> bool {
true // TODO
}
#[template_callback]
fn play_pause_icon_name(&self, state: crate::playbin::State) -> &'static str {
/*
match state {
crate::playbin::State::Playing => "media-playback-pause",
_ => "media-playback-start",
}*/todo!()
}
#[template_callback] #[template_callback]
fn mute_button_icon_name(&self, mute: bool) -> &'static str { fn mute_button_icon_name(&self, mute: bool) -> &'static str {
if mute { if mute {
@ -112,21 +94,24 @@ mod imp {
if range.adjustment().lower() < range.adjustment().upper() { if range.adjustment().lower() < range.adjustment().upper() {
playbin.seek(value); playbin.seek(value);
} }
false*/todo!() false*/
todo!()
} }
#[template_callback] #[template_callback]
fn on_skip_forward_clicked(&self) { fn on_skip_forward_clicked(&self) {
/* /*
let playbin = self.playbin.upgrade().unwrap(); let playbin = self.playbin.upgrade().unwrap();
playbin.go_to_next_track();*/todo!() playbin.go_to_next_track();*/
todo!()
} }
#[template_callback] #[template_callback]
fn on_skip_backward_clicked(&self) { fn on_skip_backward_clicked(&self) {
/* /*
let playbin = self.playbin.upgrade().unwrap(); let playbin = self.playbin.upgrade().unwrap();
playbin.go_to_prev_track();*/todo!() playbin.go_to_prev_track();*/
todo!()
} }
#[template_callback] #[template_callback]
@ -138,7 +123,8 @@ mod imp {
if new_position < 0.0 { if new_position < 0.0 {
new_position = 0.0; new_position = 0.0;
} }
playbin.seek(new_position);*/todo!() playbin.seek(new_position);*/
todo!()
} }
#[template_callback] #[template_callback]
@ -150,7 +136,8 @@ mod imp {
if new_position > playbin.duration() { if new_position > playbin.duration() {
new_position = playbin.duration(); new_position = playbin.duration();
} }
playbin.seek(new_position);*/todo!() playbin.seek(new_position);*/
todo!()
} }
#[template_callback] #[template_callback]
@ -162,7 +149,8 @@ mod imp {
playbin.pause(); playbin.pause();
} else { } else {
playbin.play(); playbin.play();
}*/todo!() }*/
todo!()
} }
#[template_callback] #[template_callback]

View file

@ -1,4 +1,5 @@
mod imp { mod imp {
use crate::{Playbin, PlaybinSong};
use adw::prelude::*; use adw::prelude::*;
use adw::subclass::prelude::*; use adw::subclass::prelude::*;
use glib::subclass::InitializingObject; use glib::subclass::InitializingObject;
@ -6,7 +7,7 @@ mod imp {
use std::cell::{Cell, RefCell}; use std::cell::{Cell, RefCell};
use std::rc::Rc; use std::rc::Rc;
impl crate::playbin2::PlaybinEntry for crate::playbin::Song { impl crate::playbin2::PlaybinEntry for PlaybinSong {
fn url(&self) -> url::Url { fn url(&self) -> url::Url {
self.stream_url() self.stream_url()
} }
@ -22,9 +23,6 @@ mod imp {
#[template_child] #[template_child]
pub(super) play_queue: TemplateChild<crate::ui::PlayQueue>, pub(super) play_queue: TemplateChild<crate::ui::PlayQueue>,
#[property(get, set)]
playbin: RefCell<crate::Playbin>,
#[property(get, set, default = false)] #[property(get, set, default = false)]
can_click_shuffle_all: Cell<bool>, can_click_shuffle_all: Cell<bool>,
@ -32,11 +30,11 @@ mod imp {
playing_cover_art: RefCell<Option<gdk::Paintable>>, playing_cover_art: RefCell<Option<gdk::Paintable>>,
#[property(get, set, nullable)] #[property(get, set, nullable)]
song: RefCell<Option<crate::playbin::Song>>, song: RefCell<Option<PlaybinSong>>,
pub(super) setup: crate::ui::Setup, pub(super) setup: crate::ui::Setup,
pub(super) playbin2: Rc<crate::playbin2::Playbin<crate::playbin::Song>>, pub(super) playbin2: Rc<Playbin>,
pub(super) api2: RefCell<Option<Rc<crate::subsonic::Client>>>, pub(super) api2: RefCell<Option<Rc<crate::subsonic::Client>>>,
} }
@ -138,7 +136,7 @@ mod imp {
let api = api.as_ref().unwrap(); let api = api.as_ref().unwrap();
for song in api.get_random_songs(10).await.unwrap().into_iter() { for song in api.get_random_songs(10).await.unwrap().into_iter() {
self.playbin2 self.playbin2
.push_entry(crate::playbin::Song::from_child(api, &song)); .push_entry(PlaybinSong::from_child(api, &song));
} }
self.obj().set_can_click_shuffle_all(true); self.obj().set_can_click_shuffle_all(true);
} }
@ -148,7 +146,7 @@ mod imp {
self.setup.present(Some(self.obj().as_ref())); self.setup.present(Some(self.obj().as_ref()));
} }
pub(super) fn now_playing(&self, _song: &crate::playbin::Song) { pub(super) fn now_playing(&self, _song: PlaybinSong) {
/* /*
this.song = song; this.song = song;
// api.scrobble.begin (this.song.id); TODO // api.scrobble.begin (this.song.id); TODO
@ -185,6 +183,7 @@ mod imp {
} }
} }
use crate::PlaybinSong;
use adw::prelude::*; use adw::prelude::*;
use adw::subclass::prelude::*; use adw::subclass::prelude::*;
use gtk::{gdk, gio, glib}; use gtk::{gdk, gio, glib};
@ -286,19 +285,6 @@ impl Window {
true true
}); });
window.playbin().connect_closure(
"stopped",
false,
glib::closure_local!(
#[weak]
window,
move |_playbin: crate::Playbin| {
window.set_playing_cover_art(None::<gdk::Paintable>);
window.set_song(None::<crate::playbin::Song>);
}
),
);
window window
} }
} }