playbinsong -> model::song
This commit is contained in:
parent
b5fadce142
commit
dae2882e0d
7 changed files with 28 additions and 27 deletions
|
@ -39,7 +39,7 @@ template $AudreyUiPlayQueueSong: Box {
|
|||
margin-top: 1;
|
||||
margin-bottom: 1;
|
||||
pixel-size: 50;
|
||||
// paintable: bind template.song as <$AudreyPlaybinSong>.thumbnail;
|
||||
// paintable: bind template.song as <$AudreyModelSong>.thumbnail;
|
||||
}
|
||||
|
||||
Box title_box {
|
||||
|
@ -70,7 +70,7 @@ template $AudreyUiPlayQueueSong: Box {
|
|||
ellipsize: end;
|
||||
max-width-chars: 90;
|
||||
justify: fill;
|
||||
label: bind template.song as <$AudreyPlaybinSong>.title;
|
||||
label: bind template.song as <$AudreyModelSong>.title;
|
||||
}
|
||||
|
||||
Label {
|
||||
|
@ -85,7 +85,7 @@ template $AudreyUiPlayQueueSong: Box {
|
|||
ellipsize: end;
|
||||
max-width-chars: 90;
|
||||
justify: fill;
|
||||
label: bind template.song as <$AudreyPlaybinSong>.artist;
|
||||
label: bind template.song as <$AudreyModelSong>.artist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -101,12 +101,12 @@ template $AudreyUiPlayQueueSong: Box {
|
|||
"dim-label"
|
||||
]
|
||||
|
||||
label: bind $format_duration(template.song as <$AudreyPlaybinSong>.duration) as <string>;
|
||||
label: bind $format_duration(template.song as <$AudreyModelSong>.duration) as <string>;
|
||||
}
|
||||
|
||||
Button {
|
||||
focusable: true;
|
||||
// TODO icon-name: bind $star_button_icon_name (template.song as <$AudreyPlaybinSong>.starred) as <string>;
|
||||
// TODO icon-name: bind $star_button_icon_name (template.song as <$AudreyModelSong>.starred) as <string>;
|
||||
icon-name: bind $star_button_icon_name() as <string>;
|
||||
|
||||
styles [
|
||||
|
|
|
@ -11,8 +11,7 @@ pub mod ui;
|
|||
pub mod mpris;
|
||||
pub use mpris::Mpris;
|
||||
|
||||
pub mod playbin_song;
|
||||
pub use playbin_song::Song as PlaybinSong;
|
||||
pub mod model;
|
||||
|
||||
pub mod subsonic;
|
||||
|
||||
|
|
2
src/model.rs
Normal file
2
src/model.rs
Normal file
|
@ -0,0 +1,2 @@
|
|||
mod song;
|
||||
pub use song::Song;
|
|
@ -35,7 +35,7 @@ mod imp {
|
|||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for Song {
|
||||
const NAME: &'static str = "AudreyPlaybinSong";
|
||||
const NAME: &'static str = "AudreyModelSong";
|
||||
type Type = super::Song;
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
mod imp {
|
||||
use crate::PlaybinSong;
|
||||
use crate::model::Song as ModelSong;
|
||||
use glib::subclass::InitializingObject;
|
||||
use gtk::{gdk, gio, glib, prelude::*, subclass::prelude::*};
|
||||
use std::cell::{Cell, RefCell};
|
||||
|
@ -28,7 +28,7 @@ mod imp {
|
|||
#[property(set, get)]
|
||||
displayed_position: Cell<u32>,
|
||||
#[property(get, set)]
|
||||
song: RefCell<Option<PlaybinSong>>,
|
||||
song: RefCell<Option<ModelSong>>,
|
||||
|
||||
drag_pos: Cell<(i32, i32)>,
|
||||
drag_widget: Cell<Option<gtk::ListBox>>,
|
||||
|
@ -174,7 +174,7 @@ mod imp {
|
|||
}
|
||||
}
|
||||
|
||||
use crate::PlaybinSong;
|
||||
use crate::model::Song as ModelSong;
|
||||
use adw::prelude::*;
|
||||
use gtk::glib;
|
||||
|
||||
|
@ -190,7 +190,7 @@ impl Song {
|
|||
}
|
||||
|
||||
pub fn bind(&self, position: u32, window: &crate::ui::Window) {
|
||||
let song: PlaybinSong = window
|
||||
let song: ModelSong = window
|
||||
.playlist_model()
|
||||
.item(position)
|
||||
.unwrap()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
mod imp {
|
||||
use crate::PlaybinSong;
|
||||
use crate::model::Song;
|
||||
use adw::prelude::*;
|
||||
use adw::subclass::prelude::*;
|
||||
use glib::subclass::InitializingObject;
|
||||
|
@ -16,7 +16,7 @@ mod imp {
|
|||
pulse_bar: TemplateChild<gtk::ProgressBar>,
|
||||
|
||||
#[property(get, set, nullable)]
|
||||
song: RefCell<Option<PlaybinSong>>,
|
||||
song: RefCell<Option<Song>>,
|
||||
#[property(get, set)]
|
||||
playing_cover_art: RefCell<Option<gdk::Paintable>>,
|
||||
#[property(get, set, default = true)]
|
||||
|
@ -168,18 +168,18 @@ mod imp {
|
|||
// these are nedeed because with regular bindings, if song becomes None, the labes are not
|
||||
// updated
|
||||
#[template_callback]
|
||||
fn song_title(&self, song: Option<&PlaybinSong>) -> String {
|
||||
song.map(PlaybinSong::title).unwrap_or("".to_string())
|
||||
fn song_title(&self, song: Option<&Song>) -> String {
|
||||
song.map(Song::title).unwrap_or("".to_string())
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
fn song_artist(&self, song: Option<&PlaybinSong>) -> String {
|
||||
song.map(PlaybinSong::artist).unwrap_or("".to_string())
|
||||
fn song_artist(&self, song: Option<&Song>) -> String {
|
||||
song.map(Song::artist).unwrap_or("".to_string())
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
fn song_album(&self, song: Option<&PlaybinSong>) -> String {
|
||||
song.map(PlaybinSong::album).unwrap_or("".to_string())
|
||||
fn song_album(&self, song: Option<&Song>) -> String {
|
||||
song.map(Song::album).unwrap_or("".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
mod imp {
|
||||
use crate::model::Song;
|
||||
use crate::mpv;
|
||||
use crate::PlaybinSong;
|
||||
use adw::prelude::*;
|
||||
use adw::subclass::prelude::*;
|
||||
use glib::subclass::InitializingObject;
|
||||
|
@ -26,7 +26,7 @@ mod imp {
|
|||
#[property(get, set, nullable)]
|
||||
playing_cover_art: RefCell<Option<gdk::Paintable>>,
|
||||
|
||||
#[property(type = Option<PlaybinSong>, get = Self::song, nullable)]
|
||||
#[property(type = Option<Song>, get = Self::song, nullable)]
|
||||
_song: (),
|
||||
|
||||
pub(super) setup: crate::ui::Setup,
|
||||
|
@ -95,7 +95,7 @@ mod imp {
|
|||
setup: Default::default(),
|
||||
api: Default::default(),
|
||||
mpv,
|
||||
playlist_model: gio::ListStore::new::<PlaybinSong>(),
|
||||
playlist_model: gio::ListStore::new::<Song>(),
|
||||
|
||||
_volume: (),
|
||||
_mute: (),
|
||||
|
@ -398,7 +398,7 @@ mod imp {
|
|||
Rc::clone(api.as_ref().unwrap())
|
||||
};
|
||||
for song in api.get_random_songs(10).await.unwrap().into_iter() {
|
||||
let song = PlaybinSong::from_child(&api, &song);
|
||||
let song = Song::from_child(&api, &song);
|
||||
self.mpv
|
||||
.command(["loadfile", &song.stream_url(), "append-play"])
|
||||
.unwrap();
|
||||
|
@ -474,7 +474,7 @@ mod imp {
|
|||
|
||||
{
|
||||
let left = duration.map(|f| f as i64);
|
||||
let right = self.song().as_ref().map(crate::PlaybinSong::duration);
|
||||
let right = self.song().as_ref().map(crate::model::Song::duration);
|
||||
if left != right {
|
||||
event!(
|
||||
Level::WARN,
|
||||
|
@ -498,11 +498,11 @@ mod imp {
|
|||
.unwrap()
|
||||
}
|
||||
|
||||
fn song(&self) -> Option<PlaybinSong> {
|
||||
fn song(&self) -> Option<Song> {
|
||||
if self.obj().playlist_pos() < 0 {
|
||||
None
|
||||
} else {
|
||||
let song: PlaybinSong = self
|
||||
let song: Song = self
|
||||
.obj()
|
||||
.playlist_model()
|
||||
.item(self.obj().playlist_pos() as u32)
|
||||
|
|
Loading…
Reference in a new issue