[GtkTemplate (ui = "/eu/callcc/audrey/play_queue.ui")] public class Audrey.Ui.PlayQueue : Adw.Bin { private weak Playbin _playbin; public Playbin playbin { get { return _playbin; } set { 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; } } public bool can_clear_all { get; private set; } /*[GtkCallback] private void on_clear () { this.playbin.clear (); }*/ private void on_store_items_changed (GLib.ListModel store, uint position, uint removed, uint added) { this.can_clear_all = store.get_n_items () > 0; } [GtkCallback] private void on_song_list_setup (Gtk.SignalListItemFactory factory, Object object) { var item = object as Gtk.ListItem; var child = new PlayQueueSong (this.playbin); child.draggable = true; child.show_position = true; child.show_artist = true; child.show_cover = true; item.child = child; } [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.bind (item.position, item.item as PlaybinSong); } [GtkCallback] private void on_song_list_unbind (Gtk.SignalListItemFactory factory, Object object) { var item = object as Gtk.ListItem; var child = item.child as PlayQueueSong; child.unbind (); } [GtkCallback] private void on_row_activated (uint position) { playbin.select_track (position); } [GtkCallback] private string visible_child_name (uint n_items) { return n_items > 0 ? "not-empty" : "empty"; } ~PlayQueue () { debug ("destroying play queue widget"); } }