control panel: lay the audio page out like the home page
Wrapping the whole page in a ScrolledWindow meant the sliders themselves could scroll out of view, which was the wrong shape entirely. The page is plain stacked cards now, spaced like the home view, and nothing scrolls unless more than four applications are playing - only that list gets a scroller. The 'unplugged' marker was appended to the device name and ellipsis ate it on long names; it is a right-aligned tag now. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Cn3dHfbgNYdbZvzb1b3GQt
This commit is contained in:
parent
3f9383e3d1
commit
8cf900b58b
1 changed files with 20 additions and 15 deletions
|
|
@ -494,23 +494,16 @@ class Panel(Gtk.Window):
|
|||
return outer
|
||||
|
||||
def build_audio_view(self):
|
||||
outer = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
|
||||
outer = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=16)
|
||||
head = Gtk.Box(spacing=8)
|
||||
head.set_margin_bottom(2)
|
||||
back = Gtk.Button(label=f"{ICON['back']} Audio")
|
||||
back.get_style_context().add_class("rowbtn")
|
||||
back.connect("clicked", lambda *_: self.go("main"))
|
||||
head.pack_start(back, True, True, 0)
|
||||
outer.add(head)
|
||||
|
||||
scroller = Gtk.ScrolledWindow()
|
||||
scroller.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
||||
scroller.set_min_content_height(120)
|
||||
scroller.set_max_content_height(520)
|
||||
scroller.set_propagate_natural_height(True)
|
||||
self.audio_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
|
||||
scroller.add(self.audio_box)
|
||||
outer.add(scroller)
|
||||
# laid out like the home page: plain stacked cards, nothing scrolls
|
||||
self.audio_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=16)
|
||||
outer.add(self.audio_box)
|
||||
return outer
|
||||
|
||||
def section(self, text):
|
||||
|
|
@ -533,10 +526,14 @@ class Panel(Gtk.Window):
|
|||
t = Gtk.Label(label=desc, xalign=0)
|
||||
t.set_ellipsize(3)
|
||||
h.pack_start(t, True, True, 0)
|
||||
if not available:
|
||||
# a right-aligned tag, so ellipsis on a long name cannot eat it
|
||||
tag = Gtk.Label(label="unplugged")
|
||||
tag.get_style_context().add_class("subtle")
|
||||
h.pack_end(tag, False, False, 0)
|
||||
b.add(h)
|
||||
if not available:
|
||||
b.get_style_context().add_class("unavail")
|
||||
t.set_text(f"{desc} (unplugged)")
|
||||
b.connect("clicked",
|
||||
lambda *_: self.set_device(kind, name, node_id, available))
|
||||
return b
|
||||
|
|
@ -603,7 +600,7 @@ class Panel(Gtk.Window):
|
|||
for c in self.audio_box.get_children():
|
||||
self.audio_box.remove(c)
|
||||
|
||||
card = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
|
||||
card = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
|
||||
card.get_style_context().add_class("card")
|
||||
v, vm = vol_get()
|
||||
m, mm = mic_get()
|
||||
|
|
@ -632,11 +629,19 @@ class Panel(Gtk.Window):
|
|||
apps = sink_inputs()
|
||||
if apps:
|
||||
self.audio_box.add(self.section("Applications"))
|
||||
card = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=6)
|
||||
card = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=10)
|
||||
card.get_style_context().add_class("card")
|
||||
for idx, app, vol, muted in apps:
|
||||
card.add(self.app_row(idx, app, vol, muted))
|
||||
self.audio_box.add(card)
|
||||
if len(apps) > 4: # only a long list needs to scroll
|
||||
sc = Gtk.ScrolledWindow()
|
||||
sc.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
||||
sc.set_max_content_height(260)
|
||||
sc.set_propagate_natural_height(True)
|
||||
sc.add(card)
|
||||
self.audio_box.add(sc)
|
||||
else:
|
||||
self.audio_box.add(card)
|
||||
self.audio_box.show_all()
|
||||
|
||||
def on_map(self, *_):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue