header: Convert the volume button box to a Gtk.ListBox

And give it the boxed-list style class so it looks nice.

Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
Anna Schumaker 2023-05-31 13:49:44 -04:00
parent dae588bfaf
commit a626a1f3c4
2 changed files with 15 additions and 16 deletions

View File

@ -46,9 +46,9 @@ class Header(Gtk.HeaderBar):
self._volume = volume.VolumeRow()
self._replaygain = replaygain.ReplayGainRow()
self._box = Gtk.Box.new(Gtk.Orientation.VERTICAL, 0)
self._box = Gtk.ListBox(selection_mode=Gtk.SelectionMode.NONE)
self._box.add_css_class("boxed-list")
self._box.append(self._volume)
self._box.append(Gtk.Separator())
self._box.append(self._replaygain)
icon = _volume_icon(self.volume)

View File

@ -106,23 +106,22 @@ class TestHeader(tests.util.TestCase):
self.assertEqual(self.header._button.get_tooltip_text(),
"volume: 100%\nnormalizing: off")
def test_popover(self):
"""Check that the menu popover was set up correctly."""
def test_popover_button(self):
"""Check that the menu popover button was set up correctly."""
self.assertIsInstance(self.header._button,
emmental.buttons.PopoverButton)
self.assertIsInstance(self.header._box, Gtk.Box)
self.assertEqual(self.header._box.get_orientation(),
Gtk.Orientation.VERTICAL)
self.assertEqual(self.header._box.get_spacing(), 0)
self.assertEqual(self.header._button.get_icon_name(),
"audio-volume-high-symbolic")
self.assertEqual(self.header._button.popover_child, self.header._box)
self.assertEqual(self.header._box.get_first_child(),
self.header._volume)
sep = self.header._volume.get_next_sibling()
self.assertIsInstance(sep, Gtk.Separator)
self.assertEqual(sep.get_orientation(), Gtk.Orientation.HORIZONTAL)
self.assertEqual(sep.get_next_sibling(), self.header._replaygain)
def test_popover_child(self):
"""Check that the menu popover button child was set up correctly."""
self.assertIsInstance(self.header._box, Gtk.ListBox)
self.assertEqual(self.header._box.get_selection_mode(),
Gtk.SelectionMode.NONE)
self.assertTrue(self.header._box.has_css_class("boxed-list"))
self.assertEqual(self.header._box.get_row_at_index(0),
self.header._volume)
self.assertEqual(self.header._box.get_row_at_index(1),
self.header._replaygain)