sidebar: Create an AddPlaylistPopover
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
5d18c336d5
commit
5b5d166db3
|
@ -3,6 +3,7 @@ import db
|
|||
import scanner
|
||||
import unittest
|
||||
from gi.repository import Gtk
|
||||
from . import view
|
||||
from . import widgets
|
||||
|
||||
class TestLibraryButtons(unittest.TestCase):
|
||||
|
@ -77,3 +78,24 @@ class TestAddPlaylistEntry(unittest.TestCase):
|
|||
self.assertIsNotNone(db.user.Table.lookup("Test Playlist"))
|
||||
entry.icon_released(entry, Gtk.EntryIconPosition.PRIMARY)
|
||||
self.assertIsNone(db.user.Table.lookup(""))
|
||||
|
||||
|
||||
class TestAddPlaylistPopover(unittest.TestCase):
|
||||
def test_init(self):
|
||||
popover = widgets.AddPlaylistPopover()
|
||||
self.assertIsInstance(popover, Gtk.Popover)
|
||||
self.assertIsInstance(popover.box, Gtk.Box)
|
||||
self.assertEqual(popover.get_child(), popover.box)
|
||||
self.assertEqual(popover.box.get_spacing(), 5)
|
||||
self.assertEqual(popover.box.get_orientation(),
|
||||
Gtk.Orientation.VERTICAL)
|
||||
self.assertEqual(popover.box.get_focus_child(),
|
||||
popover.box.get_last_child())
|
||||
self.assertTrue(popover.has_css_class("normal-icons"))
|
||||
|
||||
def test_children(self):
|
||||
popover = widgets.AddPlaylistPopover()
|
||||
child = popover.box.get_first_child()
|
||||
self.assertIsInstance(child, view.UserView)
|
||||
child = child.get_next_sibling()
|
||||
self.assertIsInstance(child, widgets.AddPlaylistEntry)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
import db
|
||||
import scanner
|
||||
from gi.repository import Gtk
|
||||
from . import view
|
||||
|
||||
class LibraryButtons(Gtk.Box):
|
||||
def __init__(self, library):
|
||||
|
@ -50,3 +51,14 @@ class AddPlaylistEntry(Gtk.Entry):
|
|||
def do_changed(self):
|
||||
icon = None if self.get_text() == "" else "edit-clear-symbolic"
|
||||
self.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, icon)
|
||||
|
||||
|
||||
class AddPlaylistPopover(Gtk.Popover):
|
||||
def __init__(self):
|
||||
Gtk.Popover.__init__(self)
|
||||
self.add_css_class("normal-icons")
|
||||
self.box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 5)
|
||||
self.box.append(view.UserView())
|
||||
self.box.append(AddPlaylistEntry())
|
||||
self.box.set_focus_child(self.box.get_last_child())
|
||||
self.set_child(self.box)
|
||||
|
|
Loading…
Reference in New Issue