playlist: Don't leave the Subtitle column blank
Instead, fill in something generated from the disc number but make it dimmed. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
73ba296d74
commit
1296857189
|
@ -33,13 +33,17 @@ class LabelFactory(Gtk.SignalListItemFactory):
|
|||
def get_track_text(self, track):
|
||||
raise NotImplementedError
|
||||
|
||||
def get_track_dim(self, track):
|
||||
return False
|
||||
|
||||
def on_setup(self, factory, listitem):
|
||||
listitem.set_child(TrackLabel(xalign=self.xalign))
|
||||
|
||||
def on_bind(self, factory, listitem):
|
||||
item = listitem.get_item()
|
||||
text = self.get_track_text(item)
|
||||
listitem.get_child().set_item(item, text)
|
||||
if child := listitem.get_child():
|
||||
child.set_item(item, self.get_track_text(item))
|
||||
child.set_sensitive(not self.get_track_dim(item))
|
||||
|
||||
def on_unbind(self, factory, listitem):
|
||||
listitem.get_child().unset_item(listitem.get_item())
|
||||
|
@ -77,7 +81,10 @@ class AlbumFactory(LabelFactory):
|
|||
|
||||
class SubtitleFactory(LabelFactory):
|
||||
def __init__(self): LabelFactory.__init__(self, xalign=0)
|
||||
def get_track_text(self, track): return track.disc.subtitle
|
||||
def get_track_dim(self, track): return len(track.disc.subtitle) == 0
|
||||
def get_track_text(self, track):
|
||||
subtitle = track.disc.subtitle
|
||||
return subtitle if len(subtitle) > 0 else track.disc.name
|
||||
|
||||
|
||||
class YearFactory(LabelFactory):
|
||||
|
|
|
@ -100,9 +100,11 @@ class TestColumnFactories(unittest.TestCase):
|
|||
def test_subtitle(self):
|
||||
factory = column.SubtitleFactory()
|
||||
self.assertIsInstance(factory, column.LabelFactory)
|
||||
self.assertEqual(factory.get_track_text(self.track), "")
|
||||
self.assertEqual(factory.get_track_text(self.track), "Disc 1")
|
||||
self.assertTrue(factory.get_track_dim(self.track))
|
||||
self.track.disc._subtitle = "Test Subtitle"
|
||||
self.assertEqual(factory.get_track_text(self.track), "Test Subtitle")
|
||||
self.assertFalse(factory.get_track_dim(self.track))
|
||||
|
||||
def test_year(self):
|
||||
factory = column.YearFactory()
|
||||
|
|
Loading…
Reference in New Issue