sidebar: Create a Stack Switcher

This allocates a Stack during __init__(), which can then be displayed to
the user.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2021-10-12 14:57:58 -04:00
parent 16038a16f1
commit 7beebbc7d1
2 changed files with 19 additions and 0 deletions

View File

@ -35,3 +35,12 @@ class Stack(Gtk.Stack):
@GObject.Signal(arg_types=(db.playlist.Playlist,))
def playlist_changed(self, plist): pass
class Switcher(Gtk.StackSwitcher):
def __init__(self):
Gtk.StackSwitcher.__init__(self)
self.add_css_class("large-icons")
self.add_css_class("osd")
self.set_orientation(Gtk.Orientation.VERTICAL)
self.set_stack(Stack())

View File

@ -73,3 +73,13 @@ class TestStack(unittest.TestCase):
self.assertEqual(self.changed, g2)
child.get_selection().set_selected(0)
self.assertEqual(self.changed, g1)
class TestSwitcher(unittest.TestCase):
def test_init(self):
switcher = stack.Switcher()
self.assertIsInstance(switcher, Gtk.StackSwitcher)
self.assertIsInstance(switcher.get_stack(), stack.Stack)
self.assertEqual(switcher.get_orientation(), Gtk.Orientation.VERTICAL)
self.assertTrue(switcher.has_css_class("large-icons"))
self.assertTrue(switcher.has_css_class("osd"))