playlist: Create a new Panel class

Containing the ControlBox, PlaylistWindow, and FooterBox

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2021-10-30 16:28:32 -04:00
parent 50bf64faf3
commit dbad19ad46
2 changed files with 62 additions and 1 deletions

View File

@ -1,12 +1,35 @@
# Copyright 2021 (c) Anna Schumaker.
from . import column
from . import controls
from . import footer
from . import header
from . import model
from . import runtime
from . import view
from gi.repository import Gtk
import audio
import tagdb
class Panel(Gtk.Box):
def __init__(self):
Gtk.Box.__init__(self)
self.set_orientation(Gtk.Orientation.VERTICAL)
self.header = header.Header()
self.window = view.PlaylistWindow()
self.footer = footer.Footer(self.window.get_filter_model())
self.append(self.header)
self.append(Gtk.Separator.new(Gtk.Orientation.HORIZONTAL))
self.append(self.window)
self.append(Gtk.Separator.new(Gtk.Orientation.HORIZONTAL))
self.append(self.footer)
def get_playlist(self): return self.window.get_playlist()
def set_playlist(self, plist):
self.header.set_playlist(plist)
self.window.set_playlist(plist)
Model = model.TagModel()
def on_filter_pending(filter, pending):

View File

@ -1,8 +1,46 @@
# Copyright 2021 (c) Anna Schumaker.
from gi.repository import Gtk
import db
import lib
import playlist
import unittest
from gi.repository import Gtk
class TestPanel(unittest.TestCase):
def test_init(self):
panel = playlist.Panel()
self.assertIsInstance(panel, Gtk.Box)
self.assertIsInstance(panel.header, playlist.header.Header)
self.assertIsInstance(panel.window, playlist.view.PlaylistWindow)
self.assertIsInstance(panel.footer, playlist.footer.Footer)
self.assertEqual(panel.get_orientation(), Gtk.Orientation.VERTICAL)
def test_items(self):
panel = playlist.Panel()
child = panel.get_first_child()
self.assertEqual(child, panel.header)
child = child.get_next_sibling()
self.assertIsInstance(child, Gtk.Separator)
child = child.get_next_sibling()
self.assertEqual(child, panel.window)
child = child.get_next_sibling()
self.assertIsInstance(child, Gtk.Separator)
child = child.get_next_sibling()
self.assertEqual(child, panel.footer)
def test_set_playlist(self):
collection = db.user.Table.find("Collection")
panel = playlist.Panel()
self.assertIsNone(panel.get_playlist())
panel.set_playlist(collection)
self.assertEqual(panel.header.get_last_child().get_first_child().playlist, collection)
self.assertEqual(panel.get_playlist(), collection)
class ColumnEV:
def __init__(self, title, width, expand):