diff --git a/src/ui/play_queue.blp b/src/ui/play_queue.blp index 5934841..342df32 100644 --- a/src/ui/play_queue.blp +++ b/src/ui/play_queue.blp @@ -20,6 +20,7 @@ template $UiPlayQueue: Adw.NavigationPage { ColumnViewColumn { factory: SignalListItemFactory { + setup => $on_delete_cell_setup (); }; } diff --git a/src/ui/play_queue.vala b/src/ui/play_queue.vala index 0b06ecc..3230f17 100644 --- a/src/ui/play_queue.vala +++ b/src/ui/play_queue.vala @@ -13,6 +13,7 @@ class Ui.PlayQueueStore : Object, ListModel, Gtk.SelectionModel { if (this.playing_index < position+removed) { this.playing_index = position; if (this.playing_index < this.inner.get_n_items ()) { + emit_signal = true; this.begin_playback ((Song) this.inner.get_item (this.playing_index)); this.prepare_next ((Song?) this.inner.get_item (this.playing_index+1)); } else { @@ -27,7 +28,7 @@ class Ui.PlayQueueStore : Object, ListModel, Gtk.SelectionModel { } this.items_changed (position, removed, added); - if (this.playing_index < this.inner.get_n_items ()) { + if (emit_signal) { this.selection_changed (this.playing_index, 1); } }); @@ -128,11 +129,6 @@ public class Ui.PlayQueue : Adw.NavigationPage { construct { this.view.model = this.store; - } - - [GtkCallback] public void clear () { - this.store.inner.remove_all (); - this.can_clear_all = false; this.store.begin_playback.connect ((song) => this.begin_playback (song)); this.store.prepare_next.connect ((next_song) => this.prepare_next (next_song)); @@ -140,6 +136,11 @@ public class Ui.PlayQueue : Adw.NavigationPage { this.store.stop_playback.connect (() => this.stop_playback ()); } + [GtkCallback] public void clear () { + this.store.inner.remove_all (); + this.can_clear_all = false; + } + public void queue (Song song) { this.store.inner.append (song); } @@ -165,4 +166,14 @@ public class Ui.PlayQueue : Adw.NavigationPage { this.store.select_item (this.store.playing_index-1, true); } } + + [GtkCallback] private void on_delete_cell_setup (Object object) { + var cell = (Gtk.ColumnViewCell) object; + var button = new Gtk.Button.from_icon_name ("edit-delete"); + button.add_css_class ("flat"); + button.clicked.connect (() => { + this.store.inner.remove (cell.position); + }); + cell.child = button; + } }