an attempt at bringing back the delete buttons

This commit is contained in:
me 2024-10-13 15:43:24 +00:00
parent 353596d65d
commit ebcf0dca68
2 changed files with 18 additions and 6 deletions

View file

@ -20,6 +20,7 @@ template $UiPlayQueue: Adw.NavigationPage {
ColumnViewColumn {
factory: SignalListItemFactory {
setup => $on_delete_cell_setup ();
};
}

View file

@ -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;
}
}