playlist: Create a Footer box
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
289a980390
commit
50bf64faf3
|
@ -29,3 +29,21 @@ class Runtime(Gtk.Label):
|
|||
text = [ f"{v} {k}{'s' if v != 1 else ''}" for (k, v) in vals if v != 0 ]
|
||||
|
||||
self.set_text(', '.join(text) if len(text) > 0 else "0 seconds")
|
||||
|
||||
|
||||
class Footer(Gtk.Box):
|
||||
def __init__(self, filter):
|
||||
Gtk.Box.__init__(self)
|
||||
self.visible = VisibleTracks()
|
||||
self.runtime = Runtime()
|
||||
|
||||
self.append(self.visible)
|
||||
self.append(self.runtime)
|
||||
|
||||
filter.connect("notify::pending", self.update_visible)
|
||||
self.set_margin_start(5)
|
||||
self.set_margin_end(5)
|
||||
|
||||
def update_visible(self, model, param):
|
||||
self.visible.set_count(model.get_n_items())
|
||||
self.runtime.set_runtime(model.get_runtime())
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
# Copyright 2021 (c) Anna Schumaker.
|
||||
import db
|
||||
import unittest
|
||||
from gi.repository import Gtk
|
||||
from . import footer
|
||||
from . import model
|
||||
|
||||
class TestVisibleTracks(unittest.TestCase):
|
||||
def test_init(self):
|
||||
|
@ -41,3 +43,27 @@ class TestRuntime(unittest.TestCase):
|
|||
self.assertEqual(runtime.get_text(), "1 week, 2 days")
|
||||
runtime.set_runtime(1209600)
|
||||
self.assertEqual(runtime.get_text(), "2 weeks")
|
||||
|
||||
|
||||
class TestFooter(unittest.TestCase):
|
||||
def test_init(self):
|
||||
foot = footer.Footer(model.FilterPlaylistModel())
|
||||
self.assertIsInstance(foot, Gtk.Box)
|
||||
self.assertIsInstance(foot.visible, footer.VisibleTracks)
|
||||
self.assertIsInstance(foot.runtime, footer.Runtime)
|
||||
|
||||
self.assertEqual(foot.get_orientation(), Gtk.Orientation.HORIZONTAL)
|
||||
self.assertEqual(foot.get_margin_start(), 5)
|
||||
self.assertEqual(foot.get_margin_end(), 5)
|
||||
self.assertEqual(foot.get_first_child(), foot.visible)
|
||||
self.assertEqual(foot.visible.get_next_sibling(), foot.runtime)
|
||||
|
||||
def test_updates(self):
|
||||
db.reset()
|
||||
filter = model.FilterPlaylistModel()
|
||||
foot = footer.Footer(filter)
|
||||
filter.set_playlist(db.user.Table.find("Collection"))
|
||||
|
||||
db.make_fake_track(1, 1, "Test Track 1", "/a/b/c/1.ogg")
|
||||
self.assertEqual(foot.visible.get_text(), "Showing 1 track")
|
||||
self.assertEqual(foot.runtime.get_text(), "1 second")
|
||||
|
|
Loading…
Reference in New Issue