diff --git a/src/style.css b/src/style.css index a90a6e8..d2828fe 100644 --- a/src/style.css +++ b/src/style.css @@ -10,3 +10,7 @@ min-width: 15px; min-height: 15px; } + +.playing .title-label { + font-weight: bold; +} diff --git a/src/ui/play_queue.vala b/src/ui/play_queue.vala index 69d8a28..e834e54 100644 --- a/src/ui/play_queue.vala +++ b/src/ui/play_queue.vala @@ -1,8 +1,40 @@ [GtkTemplate (ui = "/eu/callcc/audrey/ui/play_queue_song.ui")] 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 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) { 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) { 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; } } @@ -51,7 +83,7 @@ public class Ui.PlayQueue : Adw.NavigationPage { [GtkCallback] private void on_song_list_setup (Gtk.SignalListItemFactory factory, Object object) { var item = object as Gtk.ListItem; - var child = new PlayQueueSong (); + var child = new PlayQueueSong (this.playbin); item.child = child; } @@ -60,8 +92,7 @@ public class Ui.PlayQueue : Adw.NavigationPage { var item = object as Gtk.ListItem; var child = item.child as PlayQueueSong; - child.position = item.position+1; - child.song = item.item as Subsonic.Song; + child.bind (item.position, item.item as Subsonic.Song); } [GtkCallback] private void on_row_activated (uint position) { diff --git a/src/ui/play_queue_song.blp b/src/ui/play_queue_song.blp index 0e3aaf1..2fac9c8 100644 --- a/src/ui/play_queue_song.blp +++ b/src/ui/play_queue_song.blp @@ -21,7 +21,7 @@ template $UiPlayQueueSong: ListBoxRow { Image { focusable: false; icon-size: normal; - //icon-name: "media-playback-start"; + icon-name: bind template.play-icon-name; } Label { @@ -30,7 +30,7 @@ template $UiPlayQueueSong: ListBoxRow { justify: right; styles [ "dim-label", "numeric" ] - label: bind template.position; + label: bind template.displayed_position; } } @@ -49,6 +49,7 @@ template $UiPlayQueueSong: ListBoxRow { margin-start: 9; label: bind template.song as <$SubsonicSong>.title; + styles [ "title-label" ] } }