remove track from playlist
This commit is contained in:
parent
a556ca4840
commit
cc2f9f1466
5 changed files with 36 additions and 0 deletions
|
@ -63,6 +63,15 @@ public class Playbin : GLib.Object {
|
||||||
(position+i).to_string (),
|
(position+i).to_string (),
|
||||||
}) >= 0);
|
}) >= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.play_queue_position == position && removed > 0) {
|
||||||
|
if (this.play_queue_position < this.play_queue.get_n_items ()) {
|
||||||
|
// edge case: new track plays, playlist-pos doesn't change, so now_playing never n gets triggered
|
||||||
|
this.now_playing (
|
||||||
|
(Subsonic.Song) this.play_queue.get_item (this.play_queue_position),
|
||||||
|
(Subsonic.Song?) this.play_queue.get_item (this.play_queue_position+1));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Playbin () {
|
public Playbin () {
|
||||||
|
|
|
@ -27,6 +27,7 @@ template $UiPlayQueue: Adw.NavigationPage {
|
||||||
factory: SignalListItemFactory {
|
factory: SignalListItemFactory {
|
||||||
setup => $on_song_list_setup ();
|
setup => $on_song_list_setup ();
|
||||||
bind => $on_song_list_bind ();
|
bind => $on_song_list_bind ();
|
||||||
|
unbind => $on_song_list_unbind ();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,16 @@ class Ui.PlayQueueSong : Gtk.ListBoxRow {
|
||||||
private Playbin playbin;
|
private Playbin playbin;
|
||||||
public PlayQueueSong (Playbin playbin) {
|
public PlayQueueSong (Playbin playbin) {
|
||||||
this.playbin = playbin;
|
this.playbin = playbin;
|
||||||
|
|
||||||
|
var action_group = new SimpleActionGroup ();
|
||||||
|
|
||||||
|
var remove = new SimpleAction ("remove", null);
|
||||||
|
remove.activate.connect (() => {
|
||||||
|
this.playbin.play_queue.remove (this.displayed_position-1);
|
||||||
|
});
|
||||||
|
action_group.add_action (remove);
|
||||||
|
|
||||||
|
this.insert_action_group ("song", action_group);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ulong connection;
|
private ulong connection;
|
||||||
|
@ -95,6 +105,13 @@ public class Ui.PlayQueue : Adw.NavigationPage {
|
||||||
child.bind (item.position, item.item as Subsonic.Song);
|
child.bind (item.position, item.item as Subsonic.Song);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[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) {
|
[GtkCallback] private void on_row_activated (uint position) {
|
||||||
playbin.select_track (position);
|
playbin.select_track (position);
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,6 +112,10 @@ template $UiPlayQueueSong: ListBoxRow {
|
||||||
focusable: true;
|
focusable: true;
|
||||||
icon-name: "view-more";
|
icon-name: "view-more";
|
||||||
styles [ "flat" ]
|
styles [ "flat" ]
|
||||||
|
|
||||||
|
popover: PopoverMenu {
|
||||||
|
menu-model: song-menu;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,3 +139,7 @@ SizeGroup {
|
||||||
mode: horizontal;
|
mode: horizontal;
|
||||||
widgets [title_box, artist_box, album_duration_box]
|
widgets [title_box, artist_box, album_duration_box]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menu song-menu {
|
||||||
|
item ("Remove", "song.remove")
|
||||||
|
}
|
||||||
|
|
|
@ -83,6 +83,7 @@ class Ui.Window : Adw.ApplicationWindow {
|
||||||
|
|
||||||
this.playbin.stopped.connect (() => {
|
this.playbin.stopped.connect (() => {
|
||||||
this.playing_cover_art = Gdk.Paintable.empty (1, 1);
|
this.playing_cover_art = Gdk.Paintable.empty (1, 1);
|
||||||
|
this.song = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.shuffle_all_tracks.sensitive = true;
|
this.shuffle_all_tracks.sensitive = true;
|
||||||
|
|
Loading…
Reference in a new issue