header: Add a menu button
This will be expanded to contain the open file button, the settings dialog, and eventually a listenbrainz configuration option. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
e85bdcc7f4
commit
c5867badae
|
@ -44,11 +44,20 @@ class Header(Gtk.HeaderBar):
|
||||||
def __init__(self, sql: db.Connection, title: str):
|
def __init__(self, sql: db.Connection, title: str):
|
||||||
"""Initialize the HeaderBar."""
|
"""Initialize the HeaderBar."""
|
||||||
super().__init__(title=title, subtitle=SUBTITLE, sql=sql)
|
super().__init__(title=title, subtitle=SUBTITLE, sql=sql)
|
||||||
|
self._title = Adw.WindowTitle(title=self.title, subtitle=self.subtitle,
|
||||||
|
tooltip_text=gsetup.env_string())
|
||||||
|
|
||||||
icon = "sidebar-show-symbolic"
|
icon = "sidebar-show-symbolic"
|
||||||
self._show_sidebar = Gtk.ToggleButton(icon_name=icon, has_frame=False)
|
self._show_sidebar = Gtk.ToggleButton(icon_name=icon, has_frame=False)
|
||||||
self._open = open.Button()
|
self._open = open.Button()
|
||||||
self._title = Adw.WindowTitle(title=self.title, subtitle=self.subtitle,
|
|
||||||
tooltip_text=gsetup.env_string())
|
self._menu_box = Gtk.ListBox(selection_mode=Gtk.SelectionMode.NONE)
|
||||||
|
self._menu_box.add_css_class("boxed-list")
|
||||||
|
|
||||||
|
icon = "open-menu-symbolic"
|
||||||
|
self._menu_button = buttons.PopoverButton(popover_child=self._menu_box,
|
||||||
|
icon_name=icon)
|
||||||
|
|
||||||
self._volume = volume.VolumeRow()
|
self._volume = volume.VolumeRow()
|
||||||
self._volume_icon = Gtk.Image(icon_name=_volume_icon(self.volume))
|
self._volume_icon = Gtk.Image(icon_name=_volume_icon(self.volume))
|
||||||
self._background = volume.BackgroundRow()
|
self._background = volume.BackgroundRow()
|
||||||
|
@ -92,6 +101,7 @@ class Header(Gtk.HeaderBar):
|
||||||
tooltip_text="open settings editor")
|
tooltip_text="open settings editor")
|
||||||
self._settings.connect("clicked", self.__run_settings)
|
self._settings.connect("clicked", self.__run_settings)
|
||||||
self.pack_start(self._settings)
|
self.pack_start(self._settings)
|
||||||
|
self.pack_start(self._menu_button)
|
||||||
|
|
||||||
self.pack_end(self._vol_button)
|
self.pack_end(self._vol_button)
|
||||||
self.set_title_widget(self._title)
|
self.set_title_widget(self._title)
|
||||||
|
|
|
@ -77,6 +77,24 @@ class TestHeader(tests.util.TestCase):
|
||||||
self.header._settings.emit("clicked")
|
self.header._settings.emit("clicked")
|
||||||
mock_present.assert_called()
|
mock_present.assert_called()
|
||||||
|
|
||||||
|
def test_menu_button(self):
|
||||||
|
"""Check that the menu popover button is set up properly."""
|
||||||
|
self.assertIsInstance(self.header._menu_button,
|
||||||
|
emmental.buttons.PopoverButton)
|
||||||
|
self.assertIsNotNone(self.header._menu_button.props.parent)
|
||||||
|
|
||||||
|
self.assertEqual(self.header._menu_button.props.icon_name,
|
||||||
|
"open-menu-symbolic")
|
||||||
|
self.assertEqual(self.header._menu_button.popover_child,
|
||||||
|
self.header._menu_box)
|
||||||
|
|
||||||
|
def test_menu_popover_child(self):
|
||||||
|
"""Check that the menu popover button child was set up correctly."""
|
||||||
|
self.assertIsInstance(self.header._menu_box, Gtk.ListBox)
|
||||||
|
self.assertEqual(self.header._menu_box.get_selection_mode(),
|
||||||
|
Gtk.SelectionMode.NONE)
|
||||||
|
self.assertTrue(self.header._menu_box.has_css_class("boxed-list"))
|
||||||
|
|
||||||
def test_volume_icons(self):
|
def test_volume_icons(self):
|
||||||
"""Check that the volume icons box is set up properly."""
|
"""Check that the volume icons box is set up properly."""
|
||||||
self.assertIsInstance(self.header._icons, Gtk.Box)
|
self.assertIsInstance(self.header._icons, Gtk.Box)
|
||||||
|
|
Loading…
Reference in New Issue