44 */
55
66public class Music.TrackRow : Granite .Bin {
7- public AudioObject audio_object { get ; set ; }
7+ private AudioObject _audio_object = null ;
8+ public AudioObject audio_object {
9+ get {
10+ return _audio_object;
11+ }
12+
13+ set {
14+ if (_audio_object != null ) {
15+ artist_binding. unbind ();
16+ texture_binding. unbind ();
17+ title_binding. unbind ();
18+ }
19+
20+ _audio_object = value ;
21+
22+ if (_audio_object == null ) {
23+ return ;
24+ }
25+
26+ artist_binding = _audio_object. bind_property (" artist" , artist_label, " label" , SYNC_CREATE );
27+ title_binding = _audio_object. bind_property (" title" , title_label, " label" , SYNC_CREATE );
28+ texture_binding = _audio_object. bind_property (" texture" , album_image. image, " paintable" , SYNC_CREATE );
29+ }
30+ }
831
932 private static PlaybackManager playback_manager;
1033
34+ private Binding artist_binding;
35+ private Binding texture_binding;
36+ private Binding title_binding;
37+
38+ private Gtk . Label artist_label;
39+ private Gtk . Label title_label;
1140 private Gtk . Spinner play_icon;
41+ private Music . AlbumImage album_image;
1242
1343 static construct {
1444 playback_manager = PlaybackManager . get_default ();
@@ -18,17 +48,17 @@ public class Music.TrackRow : Granite.Bin {
1848 play_icon = new Gtk .Spinner ();
1949 play_icon. add_css_class (" play-indicator" );
2050
21- var album_image = new Music .AlbumImage ();
51+ album_image = new Music .AlbumImage ();
2252 album_image. image. height_request = 32 ;
2353 album_image. image. width_request = 32 ;
2454
25- var title_label = new Gtk .Label (null ) {
55+ title_label = new Gtk .Label (null ) {
2656 ellipsize = Pango . EllipsizeMode . MIDDLE ,
2757 hexpand = true ,
2858 xalign = 0
2959 };
3060
31- var artist_label = new Gtk .Label (null ) {
61+ artist_label = new Gtk .Label (null ) {
3262 ellipsize = Pango . EllipsizeMode . MIDDLE ,
3363 hexpand = true ,
3464 xalign = 0
@@ -64,10 +94,6 @@ public class Music.TrackRow : Granite.Bin {
6494 });
6595
6696 notify[" audio-object" ]. connect (() = > {
67- audio_object. bind_property (" artist" , artist_label, " label" , SYNC_CREATE );
68- audio_object. bind_property (" title" , title_label, " label" , SYNC_CREATE );
69- audio_object. bind_property (" texture" , album_image. image, " paintable" , SYNC_CREATE );
70-
7197 play_icon. spinning = playback_manager. current_audio == audio_object;
7298 });
7399 }
0 commit comments