thingks
This commit is contained in:
parent
cad786213c
commit
930430d5ec
4 changed files with 55 additions and 13 deletions
|
@ -46,7 +46,7 @@ template $AudreyUiPlaybar: Adw.Bin {
|
||||||
|
|
||||||
xalign: 0;
|
xalign: 0;
|
||||||
halign: start;
|
halign: start;
|
||||||
label: bind template.song as <$AudreyPlaybinSong>.title;
|
label: bind $song_title(template.song) as <string>;
|
||||||
ellipsize: end;
|
ellipsize: end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ template $AudreyUiPlaybar: Adw.Bin {
|
||||||
]
|
]
|
||||||
|
|
||||||
xalign: 0;
|
xalign: 0;
|
||||||
label: bind template.song as <$AudreyPlaybinSong>.artist;
|
label: bind $song_artist(template.song) as <string>;
|
||||||
ellipsize: end;
|
ellipsize: end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ template $AudreyUiPlaybar: Adw.Bin {
|
||||||
]
|
]
|
||||||
|
|
||||||
xalign: 0;
|
xalign: 0;
|
||||||
label: bind template.song as <$AudreyPlaybinSong>.album;
|
label: bind $song_album(template.song) as <string>;
|
||||||
ellipsize: end;
|
ellipsize: end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,7 +87,9 @@ mod imp {
|
||||||
|
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
fn on_row_activated(&self, position: u32) {
|
fn on_row_activated(&self, position: u32) {
|
||||||
self.obj().window().playlist_play_index(position as i64);
|
self.obj()
|
||||||
|
.window()
|
||||||
|
.playlist_play_index(Some(position as i64));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ mod imp {
|
||||||
#[property(get)]
|
#[property(get)]
|
||||||
pulse_bar: TemplateChild<gtk::ProgressBar>,
|
pulse_bar: TemplateChild<gtk::ProgressBar>,
|
||||||
|
|
||||||
#[property(get, set)]
|
#[property(get, set, nullable)]
|
||||||
song: RefCell<Option<PlaybinSong>>,
|
song: RefCell<Option<PlaybinSong>>,
|
||||||
#[property(get, set)]
|
#[property(get, set)]
|
||||||
playing_cover_art: RefCell<Option<gdk::Paintable>>,
|
playing_cover_art: RefCell<Option<gdk::Paintable>>,
|
||||||
|
@ -95,12 +95,20 @@ mod imp {
|
||||||
|
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
fn on_skip_forward_clicked(&self) {
|
fn on_skip_forward_clicked(&self) {
|
||||||
|
if self.window().playlist_pos() + 1 < self.window().playlist_count() as i32 {
|
||||||
self.window().playlist_next();
|
self.window().playlist_next();
|
||||||
|
} else {
|
||||||
|
self.window().playlist_play_index(None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
fn on_skip_backward_clicked(&self) {
|
fn on_skip_backward_clicked(&self) {
|
||||||
|
if self.window().playlist_pos() > 0 {
|
||||||
self.window().playlist_prev();
|
self.window().playlist_prev();
|
||||||
|
} else {
|
||||||
|
self.window().playlist_play_index(None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
|
@ -126,8 +134,13 @@ mod imp {
|
||||||
|
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
fn on_play_pause_clicked(&self, _button: >k::Button) {
|
fn on_play_pause_clicked(&self, _button: >k::Button) {
|
||||||
|
if self.window().idle_active() {
|
||||||
|
self.window().playlist_play_index(Some(0));
|
||||||
|
self.window().set_pause(false);
|
||||||
|
} else {
|
||||||
self.window().set_pause(!self.window().pause());
|
self.window().set_pause(!self.window().pause());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[template_callback]
|
#[template_callback]
|
||||||
fn on_mute_toggle(&self) {
|
fn on_mute_toggle(&self) {
|
||||||
|
@ -151,6 +164,23 @@ mod imp {
|
||||||
fn window(&self) -> crate::ui::Window {
|
fn window(&self) -> crate::ui::Window {
|
||||||
self.obj().root().unwrap().dynamic_cast().unwrap()
|
self.obj().root().unwrap().dynamic_cast().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[template_callback]
|
||||||
|
fn song_artist(&self, song: Option<&PlaybinSong>) -> String {
|
||||||
|
song.map(PlaybinSong::artist).unwrap_or("".to_string())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[template_callback]
|
||||||
|
fn song_album(&self, song: Option<&PlaybinSong>) -> String {
|
||||||
|
song.map(PlaybinSong::album).unwrap_or("".to_string())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for Playbar {
|
impl Drop for Playbar {
|
||||||
|
|
|
@ -305,6 +305,8 @@ mod imp {
|
||||||
|
|
||||||
Event::EndFile(event) => {
|
Event::EndFile(event) => {
|
||||||
event!(Level::INFO, "end file event: {event:?}");
|
event!(Level::INFO, "end file event: {event:?}");
|
||||||
|
window.notify("song");
|
||||||
|
window.imp().buffering_end();
|
||||||
|
|
||||||
if let Err(err) = event.reason {
|
if let Err(err) = event.reason {
|
||||||
event!(Level::ERROR, "end file error: {err}");
|
event!(Level::ERROR, "end file error: {err}");
|
||||||
|
@ -575,11 +577,19 @@ impl Window {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn playlist_play_index(&self, index: i64) {
|
pub fn playlist_play_index(&self, index: Option<i64>) {
|
||||||
self.imp()
|
match index.as_ref() {
|
||||||
|
Some(index) => self
|
||||||
|
.imp()
|
||||||
.mpv
|
.mpv
|
||||||
.command(["playlist-play-index", &index.to_string()])
|
.command(["playlist-play-index", &index.to_string()])
|
||||||
.unwrap();
|
.unwrap(),
|
||||||
|
None => self
|
||||||
|
.imp()
|
||||||
|
.mpv
|
||||||
|
.command(["playlist-play-index", "none"])
|
||||||
|
.unwrap(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn playlist_remove(&self, index: i64) {
|
pub fn playlist_remove(&self, index: i64) {
|
||||||
|
|
Loading…
Reference in a new issue