tracklist: Add tooltips to tracklist buttons
Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
ddfd37130b
commit
87d8a2ae3a
|
@ -33,6 +33,7 @@ class Card(Gtk.Box):
|
|||
child=self._trackview)
|
||||
self._visible_cols = buttons.VisibleColumns(self._trackview.columns)
|
||||
self._unselect = Gtk.Button(icon_name="edit-select-none-symbolic",
|
||||
tooltip_text="unselect all tracks",
|
||||
has_frame=False, sensitive=False)
|
||||
self._loop = buttons.LoopButton()
|
||||
self._shuffle = buttons.ShuffleButton()
|
||||
|
|
|
@ -37,6 +37,7 @@ class VisibleColumns(buttons.PopoverButton):
|
|||
def __init__(self, columns: Gio.ListModel, **kwargs):
|
||||
"""Initialize the VisibleColumns button."""
|
||||
super().__init__(columns=columns, icon_name="columns-symbolic",
|
||||
tooltip_text="configure visible columns",
|
||||
has_frame=False, **kwargs)
|
||||
self.popover_child = Gtk.ListBox(selection_mode=Gtk.SelectionMode.NONE)
|
||||
self.popover_child.bind_model(columns, self.__create_func)
|
||||
|
@ -61,7 +62,9 @@ class LoopButton(buttons.ImageToggle):
|
|||
def __init__(self, **kwargs):
|
||||
"""Initialize a Loop Button."""
|
||||
super().__init__(active_icon_name="media-playlist-repeat-song",
|
||||
active_tooltip_text="loop: track",
|
||||
inactive_icon_name="media-playlist-repeat",
|
||||
inactive_tooltip_text="loop: disabled",
|
||||
large_icon=False, state="None",
|
||||
has_frame=False, **kwargs)
|
||||
|
||||
|
@ -87,9 +90,11 @@ class LoopButton(buttons.ImageToggle):
|
|||
case ("None", True):
|
||||
self.active = False
|
||||
self.icon_opacity = 0.5
|
||||
self.inactive_tooltip_text = "loop: disabled"
|
||||
case ("Playlist", _):
|
||||
self.active = False
|
||||
self.icon_opacity = 1.0
|
||||
self.inactive_tooltip_text = "loop: playlist"
|
||||
case ("Track", _):
|
||||
self.active = True
|
||||
self.icon_opacity = 1.0
|
||||
|
@ -101,7 +106,9 @@ class ShuffleButton(buttons.ImageToggle):
|
|||
def __init__(self, **kwargs):
|
||||
"""Initialize a Shuffle Button."""
|
||||
super().__init__(active_icon_name="media-playlist-shuffle",
|
||||
active_tooltip_text="shuffle: enabled",
|
||||
inactive_icon_name="media-playlist-consecutive",
|
||||
inactive_tooltip_text="shuffle: disabled",
|
||||
large_icon=False, icon_opacity=0.5,
|
||||
has_frame=False, **kwargs)
|
||||
|
||||
|
@ -172,6 +179,7 @@ class SortButton(buttons.PopoverButton):
|
|||
def __init__(self, **kwargs):
|
||||
"""Initialize the Sort button."""
|
||||
super().__init__(has_frame=False, model=sorter.SortOrderModel(),
|
||||
tooltip_text="configure playlist sort order",
|
||||
icon_name="view-list-ordered-symbolic", **kwargs)
|
||||
self.popover_child = Gtk.ListBox(selection_mode=Gtk.SelectionMode.NONE)
|
||||
self.popover_child.bind_model(self.model, self.__create_func)
|
||||
|
|
|
@ -99,8 +99,10 @@ class MoveButtons(Gtk.Box):
|
|||
"""Initialize the Move Buttons."""
|
||||
super().__init__(**kwargs)
|
||||
self._down = Gtk.Button(icon_name="go-down-symbolic",
|
||||
tooltip_text="move selected track down",
|
||||
hexpand=True, sensitive=False)
|
||||
self._up = Gtk.Button(icon_name="go-up-symbolic",
|
||||
tooltip_text="move selected track up",
|
||||
hexpand=True, sensitive=False)
|
||||
|
||||
self.bind_property("can-move-down", self._down, "sensitive")
|
||||
|
@ -149,12 +151,15 @@ class OSD(Gtk.Overlay):
|
|||
super().__init__(sql=sql, selection=selection, **kwargs)
|
||||
self._add = PopoverButton(child=Adw.ButtonContent(label="Add",
|
||||
icon_name="list-add-symbolic"),
|
||||
tooltip_text="add selected tracks "
|
||||
"to a playlist",
|
||||
halign=Gtk.Align.START, valign=Gtk.Align.END,
|
||||
margin_start=16, margin_bottom=16,
|
||||
direction=Gtk.ArrowType.UP, visible=False,
|
||||
popover_child=PlaylistView(sql))
|
||||
self._remove = Gtk.Button(child=Adw.ButtonContent(label="Remove",
|
||||
icon_name="list-remove-symbolic"),
|
||||
tooltip_text="remove selected tracks",
|
||||
halign=Gtk.Align.END, valign=Gtk.Align.END,
|
||||
margin_end=16, margin_bottom=16,
|
||||
visible=False)
|
||||
|
|
|
@ -70,6 +70,8 @@ class TestVisibleColumns(unittest.TestCase):
|
|||
self.assertIsInstance(self.button, emmental.buttons.PopoverButton)
|
||||
self.assertFalse(self.button.get_has_frame())
|
||||
self.assertEqual(self.button.get_icon_name(), "columns-symbolic")
|
||||
self.assertEqual(self.button.get_tooltip_text(),
|
||||
"configure visible columns")
|
||||
self.assertEqual(self.button.columns, self.columns)
|
||||
|
||||
def test_popover_child(self):
|
||||
|
@ -119,7 +121,9 @@ class TestLoopButton(unittest.TestCase):
|
|||
self.assertIsInstance(self.loop, emmental.buttons.ImageToggle)
|
||||
self.assertEqual(self.loop.active_icon_name,
|
||||
"media-playlist-repeat-song")
|
||||
self.assertEqual(self.loop.active_tooltip_text, "loop: track")
|
||||
self.assertEqual(self.loop.inactive_icon_name, "media-playlist-repeat")
|
||||
self.assertEqual(self.loop.inactive_tooltip_text, "loop: disabled")
|
||||
self.assertFalse(self.loop.large_icon)
|
||||
self.assertFalse(self.loop.get_has_frame())
|
||||
|
||||
|
@ -129,26 +133,31 @@ class TestLoopButton(unittest.TestCase):
|
|||
|
||||
self.assertEqual(self.loop.state, "None")
|
||||
self.assertAlmostEqual(self.loop.icon_opacity, 0.5, delta=0.005)
|
||||
self.assertEqual(self.loop.props.tooltip_text, "loop: disabled")
|
||||
self.assertFalse(self.loop.active)
|
||||
|
||||
self.loop.state = "Playlist"
|
||||
self.assertEqual(self.loop.state, "Playlist")
|
||||
self.assertEqual(self.loop.icon_opacity, 1.0)
|
||||
self.assertEqual(self.loop.props.tooltip_text, "loop: playlist")
|
||||
self.assertFalse(self.loop.active)
|
||||
|
||||
self.loop.state = "Track"
|
||||
self.assertEqual(self.loop.state, "Track")
|
||||
self.assertEqual(self.loop.icon_opacity, 1.0)
|
||||
self.assertEqual(self.loop.props.tooltip_text, "loop: track")
|
||||
self.assertTrue(self.loop.active)
|
||||
|
||||
self.loop.can_disable = False
|
||||
self.loop.state = "None"
|
||||
self.assertEqual(self.loop.state, "Track")
|
||||
self.assertEqual(self.loop.props.tooltip_text, "loop: track")
|
||||
self.assertTrue(self.loop.active)
|
||||
|
||||
self.loop.can_disable = True
|
||||
self.loop.state = "None"
|
||||
self.assertAlmostEqual(self.loop.icon_opacity, 0.5, delta=0.005)
|
||||
self.assertEqual(self.loop.inactive_tooltip_text, "loop: disabled")
|
||||
self.assertFalse(self.loop.active)
|
||||
|
||||
def test_click(self):
|
||||
|
@ -179,14 +188,20 @@ class TestShuffleButtons(unittest.TestCase):
|
|||
def test_init(self):
|
||||
"""Test that the shuffle button is configured correctly."""
|
||||
self.assertIsInstance(self.shuffle, emmental.buttons.ImageToggle)
|
||||
self.assertEqual(self.shuffle.active_icon_name,
|
||||
"media-playlist-shuffle")
|
||||
self.assertEqual(self.shuffle.inactive_icon_name,
|
||||
"media-playlist-consecutive")
|
||||
self.assertAlmostEqual(self.shuffle.icon_opacity, 0.5, delta=0.005)
|
||||
self.assertFalse(self.shuffle.large_icon)
|
||||
self.assertFalse(self.shuffle.get_has_frame())
|
||||
|
||||
self.assertEqual(self.shuffle.active_icon_name,
|
||||
"media-playlist-shuffle")
|
||||
self.assertEqual(self.shuffle.active_tooltip_text, "shuffle: enabled")
|
||||
|
||||
self.assertEqual(self.shuffle.inactive_icon_name,
|
||||
"media-playlist-consecutive")
|
||||
self.assertEqual(self.shuffle.inactive_tooltip_text,
|
||||
"shuffle: disabled")
|
||||
|
||||
self.assertAlmostEqual(self.shuffle.icon_opacity, 0.5, delta=0.005)
|
||||
|
||||
def test_opacity(self):
|
||||
"""Test adjusting the opacity based on active state."""
|
||||
self.shuffle.active = True
|
||||
|
@ -324,9 +339,10 @@ class TestSortButton(unittest.TestCase):
|
|||
def test_init(self):
|
||||
"""Test that the Sort button is configured correctly."""
|
||||
self.assertIsInstance(self.sort, emmental.buttons.PopoverButton)
|
||||
|
||||
self.assertEqual(self.sort.get_icon_name(),
|
||||
"view-list-ordered-symbolic")
|
||||
self.assertEqual(self.sort.get_tooltip_text(),
|
||||
"configure playlist sort order")
|
||||
self.assertFalse(self.sort.get_has_frame())
|
||||
|
||||
def test_popover_child(self):
|
||||
|
|
|
@ -169,6 +169,8 @@ class TestMoveButtons(unittest.TestCase):
|
|||
"""Test the move down button."""
|
||||
self.assertIsInstance(self.move._down, Gtk.Button)
|
||||
self.assertEqual(self.move._down.get_icon_name(), "go-down-symbolic")
|
||||
self.assertEqual(self.move._down.get_tooltip_text(),
|
||||
"move selected track down")
|
||||
self.assertTrue(self.move._down.has_css_class("opaque"))
|
||||
self.assertTrue(self.move._down.has_css_class("pill"))
|
||||
self.assertTrue(self.move._down.get_hexpand())
|
||||
|
@ -194,6 +196,8 @@ class TestMoveButtons(unittest.TestCase):
|
|||
"""Test the move up button."""
|
||||
self.assertIsInstance(self.move._up, Gtk.Button)
|
||||
self.assertEqual(self.move._up.get_icon_name(), "go-up-symbolic")
|
||||
self.assertEqual(self.move._up.get_tooltip_text(),
|
||||
"move selected track up")
|
||||
self.assertTrue(self.move._up.has_css_class("opaque"))
|
||||
self.assertTrue(self.move._up.has_css_class("pill"))
|
||||
self.assertTrue(self.move._up.get_hexpand())
|
||||
|
@ -249,6 +253,8 @@ class TestOsd(tests.util.TestCase):
|
|||
self.assertEqual(self.osd._add.get_child().get_icon_name(),
|
||||
"list-add-symbolic")
|
||||
self.assertEqual(self.osd._add.get_child().get_label(), "Add")
|
||||
self.assertEqual(self.osd._add.get_tooltip_text(),
|
||||
"add selected tracks to a playlist")
|
||||
self.assertEqual(self.osd._add.get_halign(), Gtk.Align.START)
|
||||
self.assertEqual(self.osd._add.get_valign(), Gtk.Align.END)
|
||||
self.assertEqual(self.osd._add.get_margin_start(), 16)
|
||||
|
@ -298,6 +304,8 @@ class TestOsd(tests.util.TestCase):
|
|||
self.assertEqual(self.osd._remove.get_child().get_icon_name(),
|
||||
"list-remove-symbolic")
|
||||
self.assertEqual(self.osd._remove.get_child().get_label(), "Remove")
|
||||
self.assertEqual(self.osd._remove.get_tooltip_text(),
|
||||
"remove selected tracks")
|
||||
self.assertEqual(self.osd._remove.get_halign(), Gtk.Align.END)
|
||||
self.assertEqual(self.osd._remove.get_valign(), Gtk.Align.END)
|
||||
self.assertEqual(self.osd._remove.get_margin_end(), 16)
|
||||
|
|
|
@ -60,6 +60,8 @@ class TestTracklist(tests.util.TestCase):
|
|||
self.assertIsInstance(self.tracklist._unselect, Gtk.Button)
|
||||
self.assertEqual(self.tracklist._unselect.get_icon_name(),
|
||||
"edit-select-none-symbolic")
|
||||
self.assertEqual(self.tracklist._unselect.get_tooltip_text(),
|
||||
"unselect all tracks")
|
||||
self.assertFalse(self.tracklist._unselect.get_has_frame())
|
||||
|
||||
self.assertFalse(self.tracklist._unselect.get_sensitive())
|
||||
|
|
Loading…
Reference in New Issue