playlist: Split out the ControlBox as a base class
And create a PlaylistBox inheriting from it containing the buttons. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
328dce0be2
commit
c4adea15bb
|
@ -74,20 +74,9 @@ class JumpButton(Gtk.Button):
|
|||
|
||||
class ControlBox(Gtk.Box):
|
||||
def __init__(self):
|
||||
Gtk.Box.__init__(self)
|
||||
Gtk.Box.__init__(self, margin_top=5, margin_bottom=5,
|
||||
margin_end=5, margin_start=5)
|
||||
self.add_css_class("linked")
|
||||
self.append(RandomToggle())
|
||||
self.append(LoopToggle())
|
||||
self.append(SortButton())
|
||||
self.append(JumpButton())
|
||||
|
||||
self.set_margin_top(5)
|
||||
self.set_margin_bottom(5)
|
||||
self.set_margin_start(5)
|
||||
self.set_margin_end(5)
|
||||
|
||||
def get_jump_button(self):
|
||||
return self.get_last_child()
|
||||
|
||||
def set_playlist(self, plist):
|
||||
child = self.get_first_child()
|
||||
|
@ -96,11 +85,23 @@ class ControlBox(Gtk.Box):
|
|||
child = child.get_next_sibling()
|
||||
|
||||
|
||||
class PlaylistBox(ControlBox):
|
||||
def __init__(self):
|
||||
ControlBox.__init__(self)
|
||||
self.append(RandomToggle())
|
||||
self.append(LoopToggle())
|
||||
self.append(SortButton())
|
||||
self.append(JumpButton())
|
||||
|
||||
def get_jump_button(self):
|
||||
return self.get_last_child()
|
||||
|
||||
|
||||
class Header(Gtk.Box):
|
||||
def __init__(self):
|
||||
Gtk.Box.__init__(self)
|
||||
self.append(FilterEntry())
|
||||
self.append(ControlBox())
|
||||
self.append(PlaylistBox())
|
||||
|
||||
def get_jump_button(self):
|
||||
return self.get_last_child().get_jump_button()
|
||||
|
|
|
@ -138,9 +138,15 @@ class TestControlBox(unittest.TestCase):
|
|||
self.assertEqual(box.get_margin_end(), 5)
|
||||
self.assertTrue(box.has_css_class("linked"))
|
||||
|
||||
|
||||
class TestPlaylistBox(unittest.TestCase):
|
||||
def test_init(self):
|
||||
box = header.PlaylistBox()
|
||||
self.assertIsInstance(box, header.ControlBox)
|
||||
|
||||
def test_children(self):
|
||||
collection = db.user.Table.find("Collection")
|
||||
box = header.ControlBox()
|
||||
box = header.PlaylistBox()
|
||||
box.set_playlist(collection)
|
||||
|
||||
child = box.get_first_child()
|
||||
|
|
Loading…
Reference in New Issue