highlight current track
This commit is contained in:
parent
8966c5fff4
commit
a556ca4840
3 changed files with 43 additions and 7 deletions
|
@ -10,3 +10,7 @@
|
||||||
min-width: 15px;
|
min-width: 15px;
|
||||||
min-height: 15px;
|
min-height: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.playing .title-label {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
|
@ -1,8 +1,40 @@
|
||||||
[GtkTemplate (ui = "/eu/callcc/audrey/ui/play_queue_song.ui")]
|
[GtkTemplate (ui = "/eu/callcc/audrey/ui/play_queue_song.ui")]
|
||||||
class Ui.PlayQueueSong : Gtk.ListBoxRow {
|
class Ui.PlayQueueSong : Gtk.ListBoxRow {
|
||||||
public uint position { get; set; }
|
public bool current {
|
||||||
|
set {
|
||||||
|
if (value) {
|
||||||
|
this.play_icon_name = "media-playback-start";
|
||||||
|
this.add_css_class ("playing");
|
||||||
|
} else {
|
||||||
|
this.play_icon_name = "";
|
||||||
|
this.remove_css_class ("playing");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public uint displayed_position { get; set; }
|
||||||
public Subsonic.Song song { get; set; }
|
public Subsonic.Song song { get; set; }
|
||||||
|
|
||||||
|
public string play_icon_name { get; set; default = ""; }
|
||||||
|
|
||||||
|
private Playbin playbin;
|
||||||
|
public PlayQueueSong (Playbin playbin) {
|
||||||
|
this.playbin = playbin;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ulong connection;
|
||||||
|
public void bind (uint position, Subsonic.Song song) {
|
||||||
|
this.displayed_position = position+1;
|
||||||
|
this.song = song;
|
||||||
|
this.current = this.playbin.play_queue_position == position;
|
||||||
|
this.connection = this.playbin.notify["play-queue-position"].connect (() => {
|
||||||
|
this.current = this.playbin.play_queue_position == position;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unbind () {
|
||||||
|
this.playbin.disconnect (this.connection);
|
||||||
|
}
|
||||||
|
|
||||||
[GtkCallback] private string format_duration (int duration) {
|
[GtkCallback] private string format_duration (int duration) {
|
||||||
return "%02d:%02d".printf(duration/60, duration%60);
|
return "%02d:%02d".printf(duration/60, duration%60);
|
||||||
}
|
}
|
||||||
|
@ -17,7 +49,7 @@ class Ui.PlayQueueSong : Gtk.ListBoxRow {
|
||||||
|
|
||||||
[GtkCallback] private bool on_drop (Value value, double x, double y) {
|
[GtkCallback] private bool on_drop (Value value, double x, double y) {
|
||||||
var source = value as PlayQueueSong;
|
var source = value as PlayQueueSong;
|
||||||
print ("dropped %u on %u", source.position, this.position);
|
print ("dropped %u on %u", source.displayed_position, this.displayed_position);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +83,7 @@ public class Ui.PlayQueue : Adw.NavigationPage {
|
||||||
|
|
||||||
[GtkCallback] private void on_song_list_setup (Gtk.SignalListItemFactory factory, Object object) {
|
[GtkCallback] private void on_song_list_setup (Gtk.SignalListItemFactory factory, Object object) {
|
||||||
var item = object as Gtk.ListItem;
|
var item = object as Gtk.ListItem;
|
||||||
var child = new PlayQueueSong ();
|
var child = new PlayQueueSong (this.playbin);
|
||||||
|
|
||||||
item.child = child;
|
item.child = child;
|
||||||
}
|
}
|
||||||
|
@ -60,8 +92,7 @@ public class Ui.PlayQueue : Adw.NavigationPage {
|
||||||
var item = object as Gtk.ListItem;
|
var item = object as Gtk.ListItem;
|
||||||
var child = item.child as PlayQueueSong;
|
var child = item.child as PlayQueueSong;
|
||||||
|
|
||||||
child.position = item.position+1;
|
child.bind (item.position, item.item as Subsonic.Song);
|
||||||
child.song = item.item as Subsonic.Song;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[GtkCallback] private void on_row_activated (uint position) {
|
[GtkCallback] private void on_row_activated (uint position) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ template $UiPlayQueueSong: ListBoxRow {
|
||||||
Image {
|
Image {
|
||||||
focusable: false;
|
focusable: false;
|
||||||
icon-size: normal;
|
icon-size: normal;
|
||||||
//icon-name: "media-playback-start";
|
icon-name: bind template.play-icon-name;
|
||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
|
@ -30,7 +30,7 @@ template $UiPlayQueueSong: ListBoxRow {
|
||||||
justify: right;
|
justify: right;
|
||||||
styles [ "dim-label", "numeric" ]
|
styles [ "dim-label", "numeric" ]
|
||||||
|
|
||||||
label: bind template.position;
|
label: bind template.displayed_position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@ template $UiPlayQueueSong: ListBoxRow {
|
||||||
margin-start: 9;
|
margin-start: 9;
|
||||||
|
|
||||||
label: bind template.song as <$SubsonicSong>.title;
|
label: bind template.song as <$SubsonicSong>.title;
|
||||||
|
styles [ "title-label" ]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue