sidebar: Give the Library tab a few extra widgets

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2021-06-27 12:41:57 -04:00
parent ac282cb9e3
commit bb44fbd128
4 changed files with 43 additions and 3 deletions

View File

@ -1,4 +1,5 @@
# Copyright 2021 (c) Anna Schumaker.
from . import library
from . import tagbox
from lib import settings
from gi.repository import Gtk
@ -44,7 +45,7 @@ add_stack_page("Playlists", tagbox.TagBox("audio-x-generic"))
add_stack_page("Artists", tagbox.TagBox("avatar-default-symbolic"))
add_stack_page("Genres", tagbox.TagBox("emblem-generic"))
add_stack_page("Decades", tagbox.TagBox("x-office-calendar"))
add_stack_page("Libraries", tagbox.TagBox("folder-music"))
add_stack_page("Libraries", library.Box)
Box.append(Switcher)

17
sidebar/library.py Normal file
View File

@ -0,0 +1,17 @@
# Copyright 2021 (c) Anna Schumaker.
from . import tagbox
from gi.repository import Gtk
TagBox = tagbox.TagBox("folder-music")
Add = Gtk.MenuButton()
Add.add_css_class("large-icons")
Add.set_icon_name("folder-new")
Add.set_direction(Gtk.ArrowType.UP)
Box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
Box.add_css_class("linked")
Box.set_hexpand(True)
Box.append(TagBox)
Box.append(Add)
Box.icon = TagBox.icon

22
sidebar/test_library.py Normal file
View File

@ -0,0 +1,22 @@
# Copyright 2021 (c) Anna Schumaker.
from . import library
from . import tagbox
from gi.repository import Gtk
import unittest
class TestLibrarySidebar(unittest.TestCase):
def test_library_sidebar_init(self):
self.assertIsInstance(library.TagBox, tagbox.TagBox)
self.assertIsInstance(library.Add, Gtk.MenuButton)
self.assertIsInstance(library.Box, Gtk.Box)
self.assertTrue(library.Box.has_css_class("linked"))
self.assertTrue(library.Box.get_hexpand())
self.assertIn(library.TagBox, library.Box)
self.assertIn(library.Add, library.Box)
def test_library_sidebar_add(self):
self.assertEqual(library.Add.get_icon_name(), "folder-new")
self.assertEqual(library.Add.get_direction(), Gtk.ArrowType.UP)
self.assertTrue(library.Add.has_css_class("large-icons"))

View File

@ -61,8 +61,8 @@ class TestSidebar(unittest.TestCase):
self.assertEqual(sidebar.Stack.get_visible_child_name(), "Decades")
self.assertEqual(settings.get("sidebar.page"), "Decades")
self.assertIsInstance(sidebar.Stack.get_child_by_name("Libraries"),
sidebar.tagbox.TagBox)
self.assertEqual(sidebar.Stack.get_child_by_name("Libraries"),
sidebar.library.Box)
self.assertEqual(sidebar.Toggles[4].get_icon_name(), "folder-music")
self.assertEqual(sidebar.Toggles[4].get_name(), "Libraries")
sidebar.Toggles[4].set_active(True)