playlist: Add a ControlBox box
Containing the RandomToggle, LoopToggle, and SortButton Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
c5aff410b4
commit
b09baf3d99
|
@ -60,3 +60,23 @@ class SortButton(Gtk.MenuButton):
|
|||
def set_playlist(self, plist):
|
||||
self.get_popover().set_playlist(plist)
|
||||
self.set_sensitive(plist != db.user.Table.find("Previous"))
|
||||
|
||||
|
||||
class ControlBox(Gtk.Box):
|
||||
def __init__(self):
|
||||
Gtk.Box.__init__(self)
|
||||
self.add_css_class("linked")
|
||||
self.append(RandomToggle())
|
||||
self.append(LoopToggle())
|
||||
self.append(SortButton())
|
||||
|
||||
self.set_margin_top(5)
|
||||
self.set_margin_bottom(5)
|
||||
self.set_margin_start(5)
|
||||
self.set_margin_end(5)
|
||||
|
||||
def set_playlist(self, plist):
|
||||
child = self.get_first_child()
|
||||
while child:
|
||||
child.set_playlist(plist)
|
||||
child = child.get_next_sibling()
|
||||
|
|
|
@ -111,3 +111,31 @@ class TestSortButton(unittest.TestCase):
|
|||
self.assertFalse(sort.get_sensitive())
|
||||
sort.set_playlist(db.user.Table.find("Queued Tracks"))
|
||||
self.assertTrue(sort.get_sensitive())
|
||||
|
||||
|
||||
class TestControlBox(unittest.TestCase):
|
||||
def test_init(self):
|
||||
box = header.ControlBox()
|
||||
self.assertIsInstance(box, Gtk.Box)
|
||||
self.assertEqual(box.get_orientation(), Gtk.Orientation.HORIZONTAL)
|
||||
self.assertEqual(box.get_margin_top(), 5)
|
||||
self.assertEqual(box.get_margin_bottom(), 5)
|
||||
self.assertEqual(box.get_margin_start(), 5)
|
||||
self.assertEqual(box.get_margin_end(), 5)
|
||||
self.assertTrue(box.has_css_class("linked"))
|
||||
|
||||
def test_children(self):
|
||||
collection = db.user.Table.find("Collection")
|
||||
box = header.ControlBox()
|
||||
box.set_playlist(collection)
|
||||
|
||||
child = box.get_first_child()
|
||||
self.assertIsInstance(child, header.RandomToggle)
|
||||
self.assertEqual(child.playlist, collection)
|
||||
|
||||
child = child.get_next_sibling()
|
||||
self.assertIsInstance(child, header.LoopToggle)
|
||||
self.assertEqual(child.playlist, collection)
|
||||
|
||||
child = child.get_next_sibling()
|
||||
self.assertIsInstance(child, header.SortButton)
|
||||
|
|
Loading…
Reference in New Issue