sidebar: Create a LibraryPopover

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2021-11-05 16:30:17 -04:00
parent 0014e5fa55
commit fdc4bb7275
2 changed files with 25 additions and 0 deletions

View File

@ -16,3 +16,19 @@ class TestLibraryButtons(unittest.TestCase):
self.assertIsInstance(child, scanner.widgets.RemoveButton)
child = child.get_next_sibling()
self.assertIsInstance(child, scanner.widgets.UpdateButton)
class TestLibraryPopover(unittest.TestCase):
def test_init(self):
library = db.library.Table.find("/a/b/c")
popover = widgets.LibraryPopover(library)
self.assertIsInstance(popover, Gtk.Popover)
box = popover.get_child()
self.assertIsInstance(box, Gtk.Box)
self.assertEqual(box.get_spacing(), 10)
child = box.get_first_child()
self.assertIsInstance(child, widgets.LibraryButtons)
child = child.get_next_sibling()
self.assertIsInstance(child, scanner.widgets.EnableSwitch)

View File

@ -9,3 +9,12 @@ class LibraryButtons(Gtk.Box):
self.append(scanner.RemoveButton(library))
self.append(scanner.UpdateButton(library))
self.add_css_class("linked")
class LibraryPopover(Gtk.Popover):
def __init__(self, library):
Gtk.Popover.__init__(self)
box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 10)
box.append(LibraryButtons(library))
box.append(scanner.EnableSwitch(library))
self.set_child(box)