2024-10-19 11:07:22 +00:00
|
|
|
[GtkTemplate (ui = "/eu/callcc/audrey/ui/play_queue_song.ui")]
|
|
|
|
class Ui.PlayQueueSong : Gtk.ListBoxRow {
|
|
|
|
public uint position { get; set; }
|
|
|
|
public Subsonic.Song song { get; set; }
|
|
|
|
|
|
|
|
[GtkCallback] private string format_duration (int duration) {
|
|
|
|
return "%02d:%02d".printf(duration/60, duration%60);
|
|
|
|
}
|
|
|
|
|
|
|
|
[GtkCallback] private string star_button_icon_name (DateTime? starred) {
|
|
|
|
return starred == null ? "non-starred" : "starred";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-10-13 14:24:25 +00:00
|
|
|
[GtkTemplate (ui = "/eu/callcc/audrey/ui/play_queue.ui")]
|
|
|
|
public class Ui.PlayQueue : Adw.NavigationPage {
|
2024-10-19 11:29:39 +00:00
|
|
|
private Playbin _playbin;
|
|
|
|
public Playbin playbin {
|
|
|
|
get { return _playbin; }
|
2024-10-16 09:43:11 +00:00
|
|
|
set {
|
2024-10-19 11:29:39 +00:00
|
|
|
assert (_playbin == null); // only set once
|
|
|
|
_playbin = value;
|
|
|
|
|
|
|
|
_playbin.play_queue.items_changed.connect (this.on_store_items_changed);
|
|
|
|
this.can_clear_all = _playbin.play_queue.get_n_items () > 0;
|
|
|
|
|
|
|
|
_playbin.notify["play-queue-position"].connect (() => {
|
|
|
|
});
|
2024-10-16 09:43:11 +00:00
|
|
|
}
|
|
|
|
}
|
2024-10-13 14:24:25 +00:00
|
|
|
|
2024-10-16 09:43:11 +00:00
|
|
|
public bool can_clear_all { get; private set; }
|
2024-10-13 15:21:29 +00:00
|
|
|
|
2024-10-15 11:27:47 +00:00
|
|
|
[GtkCallback] private void on_clear () {
|
2024-10-19 11:29:39 +00:00
|
|
|
this.playbin.play_queue.remove_all ();
|
2024-10-16 09:43:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void on_store_items_changed (GLib.ListModel store, uint position, uint removed, uint added) {
|
|
|
|
this.can_clear_all = store.get_n_items () > 0;
|
|
|
|
}
|
2024-10-19 11:07:22 +00:00
|
|
|
|
|
|
|
[GtkCallback] private void on_song_list_setup (Gtk.SignalListItemFactory factory, Object object) {
|
|
|
|
var item = object as Gtk.ListItem;
|
2024-10-19 11:29:39 +00:00
|
|
|
var child = new PlayQueueSong ();
|
|
|
|
|
|
|
|
item.child = child;
|
2024-10-19 11:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[GtkCallback] private void on_song_list_bind (Gtk.SignalListItemFactory factory, Object object) {
|
|
|
|
var item = object as Gtk.ListItem;
|
|
|
|
var child = item.child as PlayQueueSong;
|
|
|
|
|
|
|
|
child.position = item.position+1;
|
|
|
|
child.song = item.item as Subsonic.Song;
|
|
|
|
}
|
2024-10-16 09:43:11 +00:00
|
|
|
|
2024-10-19 11:29:39 +00:00
|
|
|
[GtkCallback] private void on_row_activated (uint position) {
|
|
|
|
playbin.select_track (position);
|
2024-10-12 12:28:05 +00:00
|
|
|
}
|
2024-10-10 09:53:52 +00:00
|
|
|
}
|