From a626a1f3c4edea8785d3aa4eb554f00d47d6f2ef Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 31 May 2023 13:49:44 -0400 Subject: [PATCH] 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 --- emmental/header/__init__.py | 4 ++-- tests/header/test_header.py | 27 +++++++++++++-------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/emmental/header/__init__.py b/emmental/header/__init__.py index 2047e50..5f1ac98 100644 --- a/emmental/header/__init__.py +++ b/emmental/header/__init__.py @@ -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) diff --git a/tests/header/test_header.py b/tests/header/test_header.py index 713916e..58267ae 100644 --- a/tests/header/test_header.py +++ b/tests/header/test_header.py @@ -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)