playlist: Create a TrackBox containing the JumpButton

And put it before the filter entry in the ui

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2021-12-28 15:20:58 -05:00
parent c4adea15bb
commit 15059db59a
2 changed files with 28 additions and 9 deletions

View File

@ -85,26 +85,33 @@ class ControlBox(Gtk.Box):
child = child.get_next_sibling()
class PlaylistBox(ControlBox):
class TrackBox(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 PlaylistBox(ControlBox):
def __init__(self):
ControlBox.__init__(self)
self.append(RandomToggle())
self.append(LoopToggle())
self.append(SortButton())
class Header(Gtk.Box):
def __init__(self):
Gtk.Box.__init__(self)
self.append(TrackBox())
self.append(FilterEntry())
self.append(PlaylistBox())
def get_jump_button(self):
return self.get_last_child().get_jump_button()
return self.get_first_child().get_jump_button()
def set_playlist(self, plist):
self.get_first_child().set_playlist(plist)
self.get_last_child().set_playlist(plist)

View File

@ -139,6 +139,19 @@ class TestControlBox(unittest.TestCase):
self.assertTrue(box.has_css_class("linked"))
class TestTrackBox(unittest.TestCase):
def test_init(self):
box = header.TrackBox()
self.assertIsInstance(box, header.ControlBox)
def test_children(self):
box = header.TrackBox()
child = box.get_first_child()
self.assertIsInstance(child, header.JumpButton)
self.assertEqual(box.get_jump_button(), child)
class TestPlaylistBox(unittest.TestCase):
def test_init(self):
box = header.PlaylistBox()
@ -160,10 +173,6 @@ class TestPlaylistBox(unittest.TestCase):
child = child.get_next_sibling()
self.assertIsInstance(child, header.SortButton)
child = child.get_next_sibling()
self.assertIsInstance(child, header.JumpButton)
self.assertEqual(box.get_jump_button(), child)
class TestHeader(unittest.TestCase):
def test_init(self):
@ -178,6 +187,9 @@ class TestHeader(unittest.TestCase):
box.set_playlist(collection)
child = box.get_first_child()
self.assertIsInstance(child, header.TrackBox)
child = child.get_next_sibling()
self.assertIsInstance(child, header.FilterEntry)
child = child.get_next_sibling()