nowplaying: Create a PreferArtistMenu
For selecting between showing the artist or album-artist tag. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
81fdfe66cb
commit
997b1de012
|
@ -36,6 +36,30 @@ class Label(Gtk.Label):
|
|||
self.set_attributes(attrlist)
|
||||
|
||||
|
||||
class PreferArtistMenu(Gtk.Box):
|
||||
"""Menu for selecting the prefer-artist property."""
|
||||
|
||||
prefer_artist = GObject.Property(type=bool, default=True)
|
||||
|
||||
def __init__(self):
|
||||
"""Configure the Prefer Artist Menu."""
|
||||
super().__init__(orientation=Gtk.Orientation.VERTICAL)
|
||||
self._artist = Gtk.CheckButton(active=True)
|
||||
self._albumartist = Gtk.CheckButton()
|
||||
|
||||
self._artist.set_label("Prefer the artist tag.")
|
||||
self._albumartist.set_label("Prefer the album artist tag.")
|
||||
self._albumartist.set_group(self._artist)
|
||||
|
||||
self.bind_property("prefer-artist", self._artist, "active",
|
||||
GObject.BindingFlags.BIDIRECTIONAL)
|
||||
self.bind_property("prefer-artist", self._albumartist, "active",
|
||||
GObject.BindingFlags.INVERT_BOOLEAN)
|
||||
|
||||
self.append(self._artist)
|
||||
self.append(self._albumartist)
|
||||
|
||||
|
||||
class ArtistLabel(Label):
|
||||
"""A label that shows either Artist or Album Artist information."""
|
||||
|
||||
|
|
|
@ -62,6 +62,49 @@ class TestLabel(unittest.TestCase):
|
|||
f"{expected} {size * Pango.SCALE}")
|
||||
|
||||
|
||||
class TestPreferArtistMenu(unittest.TestCase):
|
||||
"""Test case for our prefer-artist menu."""
|
||||
|
||||
def setUp(self):
|
||||
"""Set up common variables."""
|
||||
self.menu = emmental.nowplaying.label.PreferArtistMenu()
|
||||
|
||||
def test_init(self):
|
||||
"""Test that the menu is configured correctly."""
|
||||
self.assertIsInstance(self.menu, Gtk.Box)
|
||||
self.assertIsInstance(self.menu._artist, Gtk.CheckButton)
|
||||
self.assertIsInstance(self.menu._albumartist, Gtk.CheckButton)
|
||||
|
||||
self.assertEqual(self.menu.get_orientation(), Gtk.Orientation.VERTICAL)
|
||||
self.assertEqual(self.menu._artist.get_label(),
|
||||
"Prefer the artist tag.")
|
||||
self.assertEqual(self.menu._albumartist.get_label(),
|
||||
"Prefer the album artist tag.")
|
||||
|
||||
self.assertEqual(self.menu.get_first_child(), self.menu._artist)
|
||||
self.assertEqual(self.menu._artist.get_next_sibling(),
|
||||
self.menu._albumartist)
|
||||
self.assertIsNone(self.menu._albumartist.get_next_sibling())
|
||||
|
||||
def test_prefer_artist(self):
|
||||
"""Test the prefer-artist property."""
|
||||
self.assertTrue(self.menu.prefer_artist)
|
||||
self.assertTrue(self.menu._artist.get_active())
|
||||
self.assertFalse(self.menu._albumartist.get_active())
|
||||
|
||||
self.menu.prefer_artist = False
|
||||
self.assertFalse(self.menu._artist.get_active())
|
||||
self.assertTrue(self.menu._albumartist.get_active())
|
||||
|
||||
self.menu._artist.set_active(True)
|
||||
self.assertTrue(self.menu.prefer_artist)
|
||||
self.assertFalse(self.menu._albumartist.get_active())
|
||||
|
||||
self.menu._albumartist.set_active(True)
|
||||
self.assertFalse(self.menu.prefer_artist)
|
||||
self.assertTrue(self.menu._albumartist.get_active())
|
||||
|
||||
|
||||
class TestArtistLabel(unittest.TestCase):
|
||||
"""Test case for our Artist label."""
|
||||
|
||||
|
|
Loading…
Reference in New Issue