Better icons: device/app icon chains, volume icons, app icon (#2)
CI / check (push) Successful in 10s
CI / native (push) Successful in 1m10s

This commit was merged in pull request #2.
This commit is contained in:
nandi committed 2026-11-23 01:07:41 +00:00
1 parent f08f241edb
commit 02b08cb471
21 files changed
+658 -70

No files matched your search

+38 -27
View File
@@ -54,6 +54,10 @@ struct App {
meters_paused : Ref[Bool]
}
///|
/// Device / application icon in each row; buttons use 16 px icons.
const ROW_ICON_SIZE : Int32 = 32
///|
const METER_INTERVAL_MS : Int32 = 40
@@ -66,15 +70,6 @@ const CSS : String =
#|levelbar.mm-meter trough, levelbar.mm-meter block { min-height: 4px; }
#|levelbar.mm-meter { margin: 0 10px; }
///|
fn mute_icon(muted : Bool) -> String {
if muted {
"audio-volume-muted-symbolic"
} else {
"audio-volume-high-symbolic"
}
}
///|
fn new_row_view(app : App, tab : @model.Tab, row : @model.Row) -> RowView {
let id = row.id
@@ -82,7 +77,7 @@ fn new_row_view(app : App, tab : @model.Tab, row : @model.Row) -> RowView {
let root = @gtk.vbox(4)
root.add_css_class("mm-row")
let header = @gtk.hbox(8)
let icon = @gtk.image(row.icon_name, 32)
let icon = @gtk.image(@gtk.resolve_icon(row.icons), ROW_ICON_SIZE)
let texts = @gtk.vbox(0)
texts.set_hexpand(true)
texts.set_valign_center()
@@ -122,17 +117,21 @@ fn new_row_view(app : App, tab : @model.Tab, row : @model.Row) -> RowView {
}
let default_btn = match tab {
OutputDevices | InputDevices => {
let (b, tag) = @gtk.toggle("object-select-symbolic", "Default", fn(on) {
if on {
let _ = if tab is OutputDevices {
@wp.set_default_sink(id)
} else {
@wp.set_default_source(id)
let (b, tag) = @gtk.toggle(
@gtk.resolve_icon(@model.default_button_icons()),
"Default",
fn(on) {
if on {
let _ = if tab is OutputDevices {
@wp.set_default_sink(id)
} else {
@wp.set_default_source(id)
}
}
}
// The button reflects the actual default; re-sync it.
app.sync_default_button(tab, id)
})
// The button reflects the actual default; re-sync it.
app.sync_default_button(tab, id)
},
)
tags.push(tag)
b.set_tooltip("Set as default (fallback) device")
header.append(b)
@@ -140,9 +139,11 @@ fn new_row_view(app : App, tab : @model.Tab, row : @model.Row) -> RowView {
}
_ => None
}
let (mute, mute_tag) = @gtk.toggle(mute_icon(row.mute), "", fn(on) {
let _ = @wp.set_mute(id, on)
})
let (mute, mute_tag) = @gtk.toggle(
@gtk.resolve_icon([row.volume_icon, "audio-volume-high"]),
"",
fn(on) { let _ = @wp.set_mute(id, on) },
)
tags.push(mute_tag)
mute.set_tooltip("Mute")
header.append(mute)
@@ -208,8 +209,8 @@ fn apply_row(view : RowView, row : @model.Row, force~ : Bool = false) -> Unit {
view.subtitle.set_text(row.subtitle)
view.subtitle.set_visible(row.subtitle != "")
}
if force || old.icon_name != row.icon_name {
view.icon.set_icon(row.icon_name)
if force || old.icons != row.icons {
view.icon.set_icon(@gtk.resolve_icon(row.icons))
}
view.scale.set_sensitive(row.has_volume)
if force || @model.should_apply_remote(view.last_local_us, @gtk.now_us()) {
@@ -217,7 +218,9 @@ fn apply_row(view : RowView, row : @model.Row, force~ : Bool = false) -> Unit {
view.volume_label.set_text(row.volume_text)
}
view.mute.set_active(row.mute)
view.mute.set_button_icon(mute_icon(row.mute))
view.mute.set_button_icon(
@gtk.resolve_icon([row.volume_icon, "audio-volume-high"]),
)
match view.default_btn {
Some(b) => b.set_active(row.is_default)
None => ()
@@ -436,7 +439,15 @@ fn build_ui() -> App {
empty.set_margins(24)
empty.add_css_class("dim-label")
list.append(empty)
nb.append_page(@gtk.scrolled(list), tab.label())
nb.append_page(
@gtk.scrolled(list),
tab.label(),
icon=@gtk.resolve_icon([
tab.icon(),
"audio-card-symbolic",
"audio-x-generic",
]),
)
tabs.push({ tab, list, empty, views: Map([]), rows: [], })
}
outer.append(nb)