37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
"""Cards tab: horizontally-scrolling row of every sound card (pactl cards) —
|
|
onboard audio, USB headsets, HDMI, Bluetooth devices — each with just its
|
|
profile dropdown (pro-audio vs stereo duplex etc.). See ui/profile_card.py
|
|
for why this is its own tab rather than living on individual device cards."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import gi
|
|
|
|
gi.require_version("Gtk", "4.0")
|
|
from gi.repository import Gtk # noqa: E402
|
|
|
|
from ui.profile_card import ProfileCard
|
|
from ui.scroll_row import ScrollRow
|
|
|
|
|
|
class CardsTab(Gtk.Box):
|
|
def __init__(self, backend) -> None:
|
|
super().__init__(orientation=Gtk.Orientation.VERTICAL)
|
|
self.add_css_class("sb-tab-page")
|
|
self._backend = backend
|
|
self._row = ScrollRow(self._make_card, empty_text="No sound cards found")
|
|
self.append(self._row)
|
|
|
|
def _make_card(self, item: dict) -> ProfileCard:
|
|
return ProfileCard(self._backend, item)
|
|
|
|
def refresh(self) -> None:
|
|
self._backend.list_cards(self._row.sync)
|
|
|
|
def activate(self) -> None:
|
|
self._row.activate()
|
|
self.refresh()
|
|
|
|
def deactivate(self) -> None:
|
|
self._row.deactivate()
|