(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]
$AudreyUiPlaybar playbar {
song: bind template.song;
playbin: bind template.playbin;
playing_cover_art: bind template.playing_cover_art;
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 use mpris::Mpris;
pub mod playbin;
pub use playbin::Playbin;
pub mod playbin_vala;
pub use playbin_vala::Song as PlaybinSong;
pub mod subsonic;
pub mod subsonic_vala;
pub mod playbin2;
pub type Playbin = playbin2::Playbin<PlaybinSong>;
mod signal;
pub use signal::{Signal, SignalEmitter, SignalHandler};

View file

@ -1,11 +1,9 @@
use crate::{Playbin, PlaybinSong};
use gtk::glib::spawn_future_local;
use std::collections::HashMap;
use std::rc::{Rc, Weak};
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
#[derive(Default)]
@ -37,7 +35,7 @@ struct 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 {
// use a unique growing counter to identify tracks
track_id: Some({

View file

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

View file

@ -1,13 +1,11 @@
mod imp {
use crate::playbin::Song as PlaybinSong;
use crate::signal::SignalHandler;
use crate::{Playbin, PlaybinSong};
use glib::{subclass::InitializingObject, WeakRef};
use gtk::{gdk, gio, glib, prelude::*, subclass::prelude::*};
use std::cell::{Cell, RefCell};
use std::rc::Rc;
type Playbin = crate::playbin2::Playbin<PlaybinSong>;
#[derive(gtk::CompositeTemplate, glib::Properties, Default)]
#[template(resource = "/eu/callcc/audrey/play_queue_song.ui")]
#[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::subclass::prelude::*;
use glib::Object;
use gtk::glib;
use std::rc::Rc;
type Playbin = crate::playbin2::Playbin<PlaybinSong>;
glib::wrapper! {
pub struct Song(ObjectSubclass<imp::Song>)
@extends gtk::Box, gtk::Widget,
@ -199,7 +195,7 @@ impl Song {
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_song(song);
self.set_current(self.playbin().current_entry() == Some(position as usize));

View file

@ -1,4 +1,5 @@
mod imp {
use crate::PlaybinSong;
use adw::prelude::*;
use adw::subclass::prelude::*;
use glib::subclass::InitializingObject;
@ -11,7 +12,7 @@ mod imp {
#[template(resource = "/eu/callcc/audrey/playbar.ui")]
pub struct Playbar {
#[property(get, set)]
song: RefCell<Option<crate::playbin::Song>>,
song: RefCell<Option<PlaybinSong>>,
#[property(get, set)]
playing_cover_art: RefCell<Option<gdk::Paintable>>,
#[property(get, set, default = true)]
@ -53,17 +54,17 @@ mod imp {
#[gtk::template_callbacks]
impl Playbar {
#[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())
}
#[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())
}
#[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())
}
@ -72,25 +73,6 @@ mod imp {
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]
fn mute_button_icon_name(&self, mute: bool) -> &'static str {
if mute {
@ -112,21 +94,24 @@ mod imp {
if range.adjustment().lower() < range.adjustment().upper() {
playbin.seek(value);
}
false*/todo!()
false*/
todo!()
}
#[template_callback]
fn on_skip_forward_clicked(&self) {
/*
let playbin = self.playbin.upgrade().unwrap();
playbin.go_to_next_track();*/todo!()
playbin.go_to_next_track();*/
todo!()
}
#[template_callback]
fn on_skip_backward_clicked(&self) {
/*
let playbin = self.playbin.upgrade().unwrap();
playbin.go_to_prev_track();*/todo!()
playbin.go_to_prev_track();*/
todo!()
}
#[template_callback]
@ -138,7 +123,8 @@ mod imp {
if new_position < 0.0 {
new_position = 0.0;
}
playbin.seek(new_position);*/todo!()
playbin.seek(new_position);*/
todo!()
}
#[template_callback]
@ -150,7 +136,8 @@ mod imp {
if new_position > playbin.duration() {
new_position = playbin.duration();
}
playbin.seek(new_position);*/todo!()
playbin.seek(new_position);*/
todo!()
}
#[template_callback]
@ -162,7 +149,8 @@ mod imp {
playbin.pause();
} else {
playbin.play();
}*/todo!()
}*/
todo!()
}
#[template_callback]

View file

@ -1,4 +1,5 @@
mod imp {
use crate::{Playbin, PlaybinSong};
use adw::prelude::*;
use adw::subclass::prelude::*;
use glib::subclass::InitializingObject;
@ -6,7 +7,7 @@ mod imp {
use std::cell::{Cell, RefCell};
use std::rc::Rc;
impl crate::playbin2::PlaybinEntry for crate::playbin::Song {
impl crate::playbin2::PlaybinEntry for PlaybinSong {
fn url(&self) -> url::Url {
self.stream_url()
}
@ -22,9 +23,6 @@ mod imp {
#[template_child]
pub(super) play_queue: TemplateChild<crate::ui::PlayQueue>,
#[property(get, set)]
playbin: RefCell<crate::Playbin>,
#[property(get, set, default = false)]
can_click_shuffle_all: Cell<bool>,
@ -32,11 +30,11 @@ mod imp {
playing_cover_art: RefCell<Option<gdk::Paintable>>,
#[property(get, set, nullable)]
song: RefCell<Option<crate::playbin::Song>>,
song: RefCell<Option<PlaybinSong>>,
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>>>,
}
@ -138,7 +136,7 @@ mod imp {
let api = api.as_ref().unwrap();
for song in api.get_random_songs(10).await.unwrap().into_iter() {
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);
}
@ -148,7 +146,7 @@ mod imp {
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;
// api.scrobble.begin (this.song.id); TODO
@ -185,6 +183,7 @@ mod imp {
}
}
use crate::PlaybinSong;
use adw::prelude::*;
use adw::subclass::prelude::*;
use gtk::{gdk, gio, glib};
@ -286,19 +285,6 @@ impl Window {
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
}
}