audio: Implement a Header bar
This moves the code out of ui/ and turns it into a class for easier testing. Implements: Issue #22 (Move Gtk.HeaderBar code into audio/) Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
03b3c4a806
commit
049eeec38a
|
@ -1,6 +1,7 @@
|
|||
# Copyright 2021 (c) Anna Schumaker.
|
||||
import sys
|
||||
import tagdb
|
||||
from gi.repository import Gtk
|
||||
|
||||
from . import player
|
||||
Player = player.Player()
|
||||
|
@ -23,6 +24,14 @@ def SeekControl():
|
|||
return scale.ScaleButtonBox(scale.SeekScale(Player))
|
||||
|
||||
|
||||
class Header(Gtk.HeaderBar):
|
||||
def __init__(self):
|
||||
Gtk.HeaderBar.__init__(self)
|
||||
self.pack_start(controls.AudioControls(Player, Player.Autopause))
|
||||
self.pack_end(scale.ScaleButtonBox(scale.SeekScale(Player)))
|
||||
self.set_title_widget(nowplaying.NowPlaying(Player))
|
||||
|
||||
|
||||
def play_track(track):
|
||||
if track == Player.track:
|
||||
return False
|
||||
|
|
|
@ -3,14 +3,15 @@ import audio
|
|||
import pathlib
|
||||
import tagdb
|
||||
import unittest
|
||||
from gi.repository import Gtk
|
||||
|
||||
test_album = pathlib.Path("./data/Test Album/")
|
||||
|
||||
class TestAudio(unittest.TestCase):
|
||||
def test_audio_init(self):
|
||||
def test_init(self):
|
||||
self.assertIsInstance(audio.Player, audio.player.Player)
|
||||
|
||||
def test_audio_play_track(self):
|
||||
def test_play_track(self):
|
||||
lib = tagdb.Library.add(test_album)
|
||||
lib.scan().join()
|
||||
track = [ t for t in lib.tracks if t.tracknumber == 1 ][0]
|
||||
|
@ -20,7 +21,13 @@ class TestAudio(unittest.TestCase):
|
|||
self.assertFalse(audio.play_track(track))
|
||||
audio.Player.playing = False
|
||||
|
||||
def test_audio_widgets(self):
|
||||
def test_header(self):
|
||||
header = audio.Header()
|
||||
self.assertIsInstance(header, Gtk.HeaderBar)
|
||||
self.assertIsInstance(header.get_title_widget(),
|
||||
audio.nowplaying.NowPlaying)
|
||||
|
||||
def test_widgets(self):
|
||||
seeker = audio.SeekControl()
|
||||
|
||||
self.assertIsInstance(audio.AudioControls(),
|
||||
|
|
Loading…
Reference in New Issue