Overhaul icons: bundled Lucide symbolics, soft tiles, mixer app icon, container host icons
This commit is contained in:
1 parent
b1f0965e02
commit
011dab35a2
47 files changed
+970
-158
No files matched your search
@@ -229,6 +229,7 @@ pub fn accent_css(accent : Rgb, dark : Bool) -> String {
|
||||
"notebook > header.left > tabs > tab:checked { box-shadow: inset -4px 0 \{bg}; }",
|
||||
"notebook > header.right > tabs > tab:checked { box-shadow: inset 4px 0 \{bg}; }",
|
||||
"button.mm-default:checked { background-image: none; background-color: \{bg}; border-color: \{border}; color: \{fg}; }",
|
||||
".mm-icon-tile.mm-default-tile { background-color: alpha(\{bg}, 0.16); box-shadow: inset 0 0 0 1px alpha(\{bg}, 0.36); color: \{text}; }",
|
||||
"check:checked, radio:checked, switch:checked { background-image: none; background-color: \{bg}; border-color: \{border}; color: \{fg}; }",
|
||||
"row:selected, .view:selected { background-color: \{bg}; color: \{fg}; }",
|
||||
"link, button.link { color: \{text}; }",
|
||||
|
||||
@@ -105,6 +105,7 @@ test "accent css overrides named colours and widget fills" {
|
||||
assert_true(css.contains("levelbar > trough > block.high"))
|
||||
assert_true(css.contains("tab:checked { box-shadow: inset 0 -4px #ff7800; }"))
|
||||
assert_true(css.contains("button.mm-default:checked"))
|
||||
assert_true(css.contains(".mm-icon-tile.mm-default-tile"))
|
||||
// The text colour is the darkened accent, not the raw one.
|
||||
let text = @model.accent_text_color(hex("#ff7800"), false).to_hex()
|
||||
assert_true(text != "#ff7800")
|
||||
|
||||
+210
-32
@@ -5,16 +5,21 @@
|
||||
//
|
||||
// Chain entries starting with `APP_LOOKUP_PREFIX` ("app:<key>") ask the GUI
|
||||
// to look the application up in the installed .desktop files and use that
|
||||
// launcher's icon.
|
||||
// launcher's icon. Entries starting with `FILE_ICON_PREFIX` ("file:<path>")
|
||||
// point to an icon file directly.
|
||||
|
||||
///|
|
||||
pub fn icon_fallback_device() -> Array[String] {
|
||||
["audio-card-symbolic", "audio-x-generic-symbolic"]
|
||||
[
|
||||
"moonmix-device-audio-symbolic", "audio-card-symbolic", "audio-x-generic-symbolic",
|
||||
]
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn icon_fallback_stream() -> Array[String] {
|
||||
["application-x-executable-symbolic", "audio-x-generic-symbolic"]
|
||||
[
|
||||
"moonmix-app-fallback-symbolic", "application-x-executable-symbolic", "audio-x-generic-symbolic",
|
||||
]
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -24,10 +29,22 @@ pub const ICON_MISSING : String = "image-missing"
|
||||
///|
|
||||
pub const APP_LOOKUP_PREFIX : String = "app:"
|
||||
|
||||
///|
|
||||
pub const FILE_ICON_PREFIX : String = "file:"
|
||||
|
||||
///|
|
||||
/// True if a resolved icon name or path is a symbolic monochrome asset.
|
||||
pub fn is_symbolic_icon(name : String) -> Bool {
|
||||
name == ICON_MISSING ||
|
||||
name.has_suffix("-symbolic") ||
|
||||
name.has_suffix("-symbolic.svg") ||
|
||||
name.has_suffix("-symbolic.png")
|
||||
}
|
||||
|
||||
///|
|
||||
/// "Default" toggle: first icon the theme has.
|
||||
pub fn default_button_icons() -> Array[String] {
|
||||
["emblem-ok-symbolic", "object-select-symbolic", "emblem-default-symbolic"]
|
||||
["moonmix-default-symbolic", "emblem-ok-symbolic", "object-select-symbolic"]
|
||||
}
|
||||
|
||||
///|
|
||||
@@ -64,7 +81,61 @@ fn has_any(haystack : String, needles : Array[String]) -> Bool {
|
||||
}
|
||||
|
||||
///|
|
||||
/// Icon (without suffix) for a `device.form-factor` value, "" if unknown.
|
||||
/// Bundled Lucide symbolic icon name for a `device.form-factor` value, "" if unknown.
|
||||
pub fn bundled_form_factor_icon(
|
||||
form_factor : String,
|
||||
kind : NodeKind,
|
||||
) -> String {
|
||||
match form_factor {
|
||||
"headphone" => "moonmix-device-headphones-symbolic"
|
||||
"headset" => "moonmix-device-headset-symbolic"
|
||||
"speaker" | "hifi" => "moonmix-device-speaker-symbolic"
|
||||
"microphone" => "moonmix-device-mic-symbolic"
|
||||
"webcam" => "moonmix-device-webcam-symbolic"
|
||||
"handset" | "hands-free" | "portable" => "moonmix-device-phone-symbolic"
|
||||
"tv" | "hdmi" | "computer" => "moonmix-device-display-symbolic"
|
||||
"car" =>
|
||||
if kind is Source {
|
||||
"moonmix-device-mic-symbolic"
|
||||
} else {
|
||||
"moonmix-device-speaker-symbolic"
|
||||
}
|
||||
_ => ""
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
/// Map a freedesktop/PipeWire device icon hint to one of our bundled Lucide icons.
|
||||
fn bundled_hint_icon(hint : String) -> String {
|
||||
let h = hint.to_lower()
|
||||
if h.contains("headset") {
|
||||
"moonmix-device-headset-symbolic"
|
||||
} else if h.contains("headphone") {
|
||||
"moonmix-device-headphones-symbolic"
|
||||
} else if h.contains("webcam") || h.contains("camera") {
|
||||
"moonmix-device-webcam-symbolic"
|
||||
} else if h.contains("display") ||
|
||||
h.contains("monitor") ||
|
||||
h.contains("hdmi") ||
|
||||
h.contains("tv") {
|
||||
"moonmix-device-display-symbolic"
|
||||
} else if h.contains("phone") {
|
||||
"moonmix-device-phone-symbolic"
|
||||
} else if h.contains("microphone") {
|
||||
"moonmix-device-mic-symbolic"
|
||||
} else if h.contains("speaker") {
|
||||
"moonmix-device-speaker-symbolic"
|
||||
} else if h.contains("bluetooth") {
|
||||
"moonmix-device-bluetooth-symbolic"
|
||||
} else if h.contains("usb") {
|
||||
"moonmix-device-usb-symbolic"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
/// Standard freedesktop icon (without suffix) for a `device.form-factor` value, "" if unknown.
|
||||
pub fn form_factor_icon(form_factor : String, kind : NodeKind) -> String {
|
||||
match form_factor {
|
||||
"headphone" => "audio-headphones"
|
||||
@@ -106,26 +177,58 @@ pub fn device_bus(n : Node) -> String {
|
||||
}
|
||||
|
||||
///|
|
||||
/// Icon chain for a sink or source.
|
||||
/// Icon chain for a sink or source: bundled crisp Lucide symbolic icons first,
|
||||
/// keeping standard freedesktop names as secondary fallbacks.
|
||||
pub fn device_icon_chain(n : Node) -> Array[String] {
|
||||
let kind = n.kind()
|
||||
let out : Array[String] = []
|
||||
// 1. what the device itself says
|
||||
for h in n.icon_hints {
|
||||
push_symbolic_first(out, h)
|
||||
}
|
||||
// 2. form factor, then HDMI / webcam heuristics, then bus
|
||||
push_symbolic_first(out, form_factor_icon(n.form_factor, kind))
|
||||
let text = n.name + " " + n.description
|
||||
if has_any(text, ["hdmi", "displayport", "display port"]) {
|
||||
push_symbolic_first(out, "video-display")
|
||||
}
|
||||
let bus = device_bus(n)
|
||||
if kind is Source &&
|
||||
let is_hdmi = has_any(text, ["hdmi", "displayport", "display port"])
|
||||
let is_webcam = kind is Source &&
|
||||
(
|
||||
has_any(n.description, ["webcam", "camera"]) ||
|
||||
(bus == "usb" && n.description.to_lower().contains("cam"))
|
||||
) {
|
||||
)
|
||||
|
||||
// Phase 1: bundled Lucide symbolic icons
|
||||
push_unique(out, bundled_form_factor_icon(n.form_factor, kind))
|
||||
if is_hdmi {
|
||||
push_unique(out, "moonmix-device-display-symbolic")
|
||||
}
|
||||
if is_webcam {
|
||||
push_unique(out, "moonmix-device-webcam-symbolic")
|
||||
}
|
||||
for h in n.icon_hints {
|
||||
push_unique(out, bundled_hint_icon(h))
|
||||
}
|
||||
if has_any(text, ["headset"]) {
|
||||
push_unique(out, "moonmix-device-headset-symbolic")
|
||||
}
|
||||
if has_any(text, ["headphone", "earbud"]) {
|
||||
push_unique(out, "moonmix-device-headphones-symbolic")
|
||||
}
|
||||
if bus == "bluetooth" {
|
||||
push_unique(out, "moonmix-device-bluetooth-symbolic")
|
||||
} else if bus == "usb" {
|
||||
push_unique(out, "moonmix-device-usb-symbolic")
|
||||
}
|
||||
match kind {
|
||||
Source => push_unique(out, "moonmix-device-mic-symbolic")
|
||||
Sink => push_unique(out, "moonmix-device-speaker-symbolic")
|
||||
_ => push_unique(out, "moonmix-device-audio-symbolic")
|
||||
}
|
||||
push_unique(out, "moonmix-device-audio-symbolic")
|
||||
|
||||
// Phase 2: freedesktop secondary fallbacks
|
||||
for h in n.icon_hints {
|
||||
push_symbolic_first(out, h)
|
||||
}
|
||||
push_symbolic_first(out, form_factor_icon(n.form_factor, kind))
|
||||
if is_hdmi {
|
||||
push_symbolic_first(out, "video-display")
|
||||
}
|
||||
if is_webcam {
|
||||
push_symbolic_first(out, "camera-web")
|
||||
}
|
||||
match (bus, kind) {
|
||||
@@ -133,12 +236,10 @@ pub fn device_icon_chain(n : Node) -> Array[String] {
|
||||
("bluetooth", _) => push_symbolic_first(out, "audio-headphones")
|
||||
_ => ()
|
||||
}
|
||||
// 3. by direction
|
||||
match kind {
|
||||
Source => push_symbolic_first(out, "audio-input-microphone")
|
||||
_ => push_symbolic_first(out, "audio-speakers")
|
||||
}
|
||||
// 4. generic cards, then the placeholder
|
||||
for f in icon_fallback_device() {
|
||||
push_unique(out, f)
|
||||
}
|
||||
@@ -147,31 +248,56 @@ pub fn device_icon_chain(n : Node) -> Array[String] {
|
||||
}
|
||||
|
||||
///|
|
||||
/// Icon chain for an application stream: the icons the app announces, its
|
||||
/// launcher's icon from the installed .desktop files, names derived from the
|
||||
/// binary / app name, then generic ones.
|
||||
/// Icon chain for an application stream: prefer real full-colour host app
|
||||
/// icons first (non-symbolic hints, .desktop lookup, direct binary/app_id),
|
||||
/// then any symbolic hints, then crisp bundled fallbacks.
|
||||
pub fn stream_icon_chain(n : Node) -> Array[String] {
|
||||
let out : Array[String] = []
|
||||
// 1. Non-symbolic icon hints (including absolute file paths).
|
||||
for h in n.icon_hints {
|
||||
push_unique(out, h)
|
||||
if h.has_prefix("/") {
|
||||
if !is_symbolic_icon(h) {
|
||||
push_unique(out, FILE_ICON_PREFIX + h)
|
||||
}
|
||||
} else if !h.has_suffix("-symbolic") {
|
||||
push_unique(out, h)
|
||||
}
|
||||
}
|
||||
// 2. Installed .desktop lookup (prefers full-colour icons on the GTK side).
|
||||
for key in [n.app_id, n.app_binary, n.app_name] {
|
||||
if key != "" {
|
||||
push_unique(out, APP_LOOKUP_PREFIX + key)
|
||||
}
|
||||
}
|
||||
// 3. Direct non-symbolic icon-theme lookup by app id / binary / lower name.
|
||||
for key in [n.app_id, n.app_binary, n.app_name.to_lower()] {
|
||||
// Many apps ship an icon named after their binary or app id.
|
||||
if key != "" && !key.contains(" ") && !key.contains("/") {
|
||||
if key != "" &&
|
||||
!key.contains(" ") &&
|
||||
!key.contains("/") &&
|
||||
!key.has_suffix("-symbolic") {
|
||||
push_unique(out, key)
|
||||
}
|
||||
}
|
||||
// 4. Symbolic hints only if no full-colour app icon was found.
|
||||
for h in n.icon_hints {
|
||||
if h.has_prefix("/") {
|
||||
if is_symbolic_icon(h) {
|
||||
push_unique(out, FILE_ICON_PREFIX + h)
|
||||
}
|
||||
} else if h.has_suffix("-symbolic") {
|
||||
push_unique(out, h)
|
||||
}
|
||||
}
|
||||
// 5-8. Record-stream mic, bundled fallback, freedesktop fallback, placeholder.
|
||||
if n.kind() is RecordStream {
|
||||
push_unique(out, "audio-input-microphone-symbolic")
|
||||
push_unique(out, "moonmix-device-mic-symbolic")
|
||||
}
|
||||
for f in icon_fallback_stream() {
|
||||
push_unique(out, f)
|
||||
}
|
||||
if n.kind() is RecordStream {
|
||||
push_unique(out, "audio-input-microphone-symbolic")
|
||||
}
|
||||
push_unique(out, ICON_MISSING)
|
||||
out
|
||||
}
|
||||
@@ -180,13 +306,36 @@ pub fn stream_icon_chain(n : Node) -> Array[String] {
|
||||
/// Speaker icon for a volume (linked percent, 100 = 0 dB) and mute state.
|
||||
pub fn volume_icon(percent : Double, mute : Bool) -> String {
|
||||
if mute || percent <= 0.0 {
|
||||
"audio-volume-muted-symbolic"
|
||||
"moonmix-volume-muted-symbolic"
|
||||
} else if percent < 34.0 {
|
||||
"audio-volume-low-symbolic"
|
||||
"moonmix-volume-low-symbolic"
|
||||
} else if percent < 67.0 {
|
||||
"audio-volume-medium-symbolic"
|
||||
"moonmix-volume-medium-symbolic"
|
||||
} else {
|
||||
"audio-volume-high-symbolic"
|
||||
"moonmix-volume-high-symbolic"
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
/// Volume icon resolution chain: bundled Lucide symbolic first, then
|
||||
/// standard freedesktop fallbacks.
|
||||
pub fn volume_icon_chain(percent : Double, mute : Bool) -> Array[String] {
|
||||
if mute || percent <= 0.0 {
|
||||
[
|
||||
"moonmix-volume-muted-symbolic", "audio-volume-muted-symbolic", "audio-volume-muted",
|
||||
]
|
||||
} else if percent < 34.0 {
|
||||
[
|
||||
"moonmix-volume-low-symbolic", "audio-volume-low-symbolic", "audio-volume-low",
|
||||
]
|
||||
} else if percent < 67.0 {
|
||||
[
|
||||
"moonmix-volume-medium-symbolic", "audio-volume-medium-symbolic", "audio-volume-medium",
|
||||
]
|
||||
} else {
|
||||
[
|
||||
"moonmix-volume-high-symbolic", "audio-volume-high-symbolic", "audio-volume-high",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +343,36 @@ pub fn volume_icon(percent : Double, mute : Bool) -> String {
|
||||
/// Small symbolic icon next to a tab's label.
|
||||
pub fn Tab::icon(self : Tab) -> String {
|
||||
match self {
|
||||
Playback | OutputDevices => "audio-speakers-symbolic"
|
||||
Recording | InputDevices => "audio-input-microphone-symbolic"
|
||||
Playback => "moonmix-tab-playback-symbolic"
|
||||
Recording => "moonmix-tab-recording-symbolic"
|
||||
OutputDevices => "moonmix-tab-output-symbolic"
|
||||
InputDevices => "moonmix-tab-input-symbolic"
|
||||
}
|
||||
}
|
||||
|
||||
///|
|
||||
/// Tab icon resolution chain: bundled Lucide symbolic first, then
|
||||
/// standard freedesktop fallbacks.
|
||||
pub fn Tab::icon_chain(self : Tab) -> Array[String] {
|
||||
match self {
|
||||
Playback =>
|
||||
[
|
||||
"moonmix-tab-playback-symbolic", "multimedia-volume-control-symbolic", "audio-speakers-symbolic",
|
||||
"audio-x-generic",
|
||||
]
|
||||
Recording =>
|
||||
[
|
||||
"moonmix-tab-recording-symbolic", "audio-input-microphone-symbolic", "audio-x-generic",
|
||||
]
|
||||
OutputDevices =>
|
||||
[
|
||||
"moonmix-tab-output-symbolic", "audio-speakers-symbolic", "audio-card-symbolic",
|
||||
"audio-x-generic",
|
||||
]
|
||||
InputDevices =>
|
||||
[
|
||||
"moonmix-tab-input-symbolic", "audio-input-microphone-symbolic", "audio-card-symbolic",
|
||||
"audio-x-generic",
|
||||
]
|
||||
}
|
||||
}
|
||||
+94
-41
@@ -19,34 +19,41 @@ fn dev(
|
||||
}
|
||||
|
||||
///|
|
||||
test "device hint comes first, symbolic variant before plain" {
|
||||
test "device bundled icon beats form factor/hint freedesktop fallback" {
|
||||
let c = @model.device_icon_chain(
|
||||
dev("Audio/Sink", hints=["audio-card-pci"], form_factor="headphone"),
|
||||
)
|
||||
assert_eq(c[0], "audio-card-pci-symbolic")
|
||||
assert_eq(c[1], "audio-card-pci")
|
||||
assert_eq(c[2], "audio-headphones-symbolic")
|
||||
assert_eq(c[0], "moonmix-device-headphones-symbolic")
|
||||
assert_true(c.contains("audio-card-pci-symbolic"))
|
||||
assert_true(c.contains("audio-headphones-symbolic"))
|
||||
let card_idx = c.search("audio-card-pci-symbolic").unwrap()
|
||||
let hp_idx = c.search("audio-headphones-symbolic").unwrap()
|
||||
assert_true(card_idx < hp_idx)
|
||||
}
|
||||
|
||||
///|
|
||||
test "device form factors" {
|
||||
test "device form factors prefer bundled lucide icons" {
|
||||
let first = fn(ff, cls) {
|
||||
@model.device_icon_chain(dev(cls, form_factor=ff))[0]
|
||||
}
|
||||
assert_eq(first("headset", "Audio/Sink"), "audio-headset-symbolic")
|
||||
assert_eq(first("speaker", "Audio/Sink"), "audio-speakers-symbolic")
|
||||
assert_eq(first("headset", "Audio/Sink"), "moonmix-device-headset-symbolic")
|
||||
assert_eq(
|
||||
first("microphone", "Audio/Source"),
|
||||
"audio-input-microphone-symbolic",
|
||||
first("headphone", "Audio/Sink"),
|
||||
"moonmix-device-headphones-symbolic",
|
||||
)
|
||||
assert_eq(first("webcam", "Audio/Source"), "camera-web-symbolic")
|
||||
assert_eq(first("handset", "Audio/Sink"), "phone-symbolic")
|
||||
assert_eq(first("tv", "Audio/Sink"), "video-display-symbolic")
|
||||
assert_eq(first("car", "Audio/Source"), "audio-input-microphone-symbolic")
|
||||
assert_eq(first("speaker", "Audio/Sink"), "moonmix-device-speaker-symbolic")
|
||||
assert_eq(first("hifi", "Audio/Sink"), "moonmix-device-speaker-symbolic")
|
||||
assert_eq(first("microphone", "Audio/Source"), "moonmix-device-mic-symbolic")
|
||||
assert_eq(first("webcam", "Audio/Source"), "moonmix-device-webcam-symbolic")
|
||||
assert_eq(first("handset", "Audio/Sink"), "moonmix-device-phone-symbolic")
|
||||
assert_eq(first("tv", "Audio/Sink"), "moonmix-device-display-symbolic")
|
||||
assert_eq(first("hdmi", "Audio/Sink"), "moonmix-device-display-symbolic")
|
||||
assert_eq(first("car", "Audio/Source"), "moonmix-device-mic-symbolic")
|
||||
assert_eq(first("car", "Audio/Sink"), "moonmix-device-speaker-symbolic")
|
||||
}
|
||||
|
||||
///|
|
||||
test "hdmi, webcam and bluetooth heuristics" {
|
||||
test "hdmi, webcam, bluetooth and usb heuristics" {
|
||||
let hdmi = @model.device_icon_chain(
|
||||
dev(
|
||||
"Audio/Sink",
|
||||
@@ -54,7 +61,8 @@ test "hdmi, webcam and bluetooth heuristics" {
|
||||
description="HDMI / DisplayPort",
|
||||
),
|
||||
)
|
||||
assert_eq(hdmi[0], "video-display-symbolic")
|
||||
assert_eq(hdmi[0], "moonmix-device-display-symbolic")
|
||||
assert_true(hdmi.contains("video-display-symbolic"))
|
||||
let cam = @model.device_icon_chain(
|
||||
dev(
|
||||
"Audio/Source",
|
||||
@@ -62,61 +70,106 @@ test "hdmi, webcam and bluetooth heuristics" {
|
||||
description="EMEET SmartCam C960 Mono",
|
||||
),
|
||||
)
|
||||
assert_eq(cam[0], "camera-web-symbolic")
|
||||
assert_eq(cam[0], "moonmix-device-webcam-symbolic")
|
||||
assert_true(cam.contains("camera-web-symbolic"))
|
||||
let bt = @model.device_icon_chain(
|
||||
dev("Audio/Sink", name="bluez_output.AA_BB.1"),
|
||||
)
|
||||
assert_eq(bt[0], "audio-headphones-symbolic")
|
||||
assert_eq(
|
||||
@model.device_bus(dev("Audio/Sink", name="alsa_output.usb-X.analog-stereo")),
|
||||
"usb",
|
||||
assert_eq(bt[0], "moonmix-device-bluetooth-symbolic")
|
||||
assert_true(bt.contains("audio-headphones-symbolic"))
|
||||
let usb = @model.device_icon_chain(
|
||||
dev("Audio/Sink", name="alsa_output.usb-Focusrite_Scarlett.analog-stereo"),
|
||||
)
|
||||
assert_eq(usb[0], "moonmix-device-usb-symbolic")
|
||||
assert_eq(@model.device_bus(usb_dev()), "usb")
|
||||
}
|
||||
|
||||
///|
|
||||
test "device chain always ends in fallbacks" {
|
||||
fn usb_dev() -> @model.Node {
|
||||
dev("Audio/Sink", name="alsa_output.usb-X.analog-stereo")
|
||||
}
|
||||
|
||||
///|
|
||||
test "device chain always ends in bundled and freedesktop fallbacks" {
|
||||
let c = @model.device_icon_chain(dev("Audio/Sink"))
|
||||
assert_eq(c, [
|
||||
"audio-speakers-symbolic", "audio-speakers", "audio-card-symbolic", "audio-x-generic-symbolic",
|
||||
"image-missing",
|
||||
])
|
||||
assert_eq(c[0], "moonmix-device-speaker-symbolic")
|
||||
assert_true(c.contains("moonmix-device-audio-symbolic"))
|
||||
assert_true(c.contains("audio-speakers-symbolic"))
|
||||
assert_true(c.contains("audio-card-symbolic"))
|
||||
assert_eq(c[c.length() - 1], "image-missing")
|
||||
let s = @model.device_icon_chain(dev("Audio/Source"))
|
||||
assert_eq(s[0], "audio-input-microphone-symbolic")
|
||||
assert_eq(s[0], "moonmix-device-mic-symbolic")
|
||||
assert_eq(s[s.length() - 1], "image-missing")
|
||||
}
|
||||
|
||||
///|
|
||||
test "stream chain: hints, desktop lookup, binary, fallbacks" {
|
||||
test "stream chain prefers full-colour app icons before symbolic hints" {
|
||||
let n = @model.Node::new(
|
||||
9,
|
||||
"Stream/Output/Audio",
|
||||
app_name="Firefox",
|
||||
app_binary="firefox",
|
||||
app_id="org.mozilla.firefox",
|
||||
icon_hints=["firefox-esr"],
|
||||
icon_hints=["applications-multimedia-symbolic", "firefox-esr"],
|
||||
)
|
||||
assert_eq(@model.stream_icon_chain(n), [
|
||||
"firefox-esr", "app:org.mozilla.firefox", "app:firefox", "app:Firefox", "org.mozilla.firefox",
|
||||
"firefox", "application-x-executable-symbolic", "audio-x-generic-symbolic", "image-missing",
|
||||
"firefox", "applications-multimedia-symbolic", "moonmix-app-fallback-symbolic",
|
||||
"application-x-executable-symbolic", "audio-x-generic-symbolic", "image-missing",
|
||||
])
|
||||
let bare = @model.Node::new(10, "Stream/Input/Audio")
|
||||
assert_eq(@model.stream_icon_chain(bare), [
|
||||
"audio-input-microphone-symbolic", "application-x-executable-symbolic", "audio-x-generic-symbolic",
|
||||
let with_path = @model.Node::new(
|
||||
11,
|
||||
"Stream/Output/Audio",
|
||||
app_name="Player",
|
||||
icon_hints=["/usr/share/pixmaps/player.png"],
|
||||
)
|
||||
assert_eq(
|
||||
@model.stream_icon_chain(with_path)[0],
|
||||
"file:/usr/share/pixmaps/player.png",
|
||||
)
|
||||
let bare_play = @model.Node::new(12, "Stream/Output/Audio")
|
||||
assert_eq(@model.stream_icon_chain(bare_play), [
|
||||
"moonmix-app-fallback-symbolic", "application-x-executable-symbolic", "audio-x-generic-symbolic",
|
||||
"image-missing",
|
||||
])
|
||||
let bare_rec = @model.Node::new(10, "Stream/Input/Audio")
|
||||
assert_eq(@model.stream_icon_chain(bare_rec), [
|
||||
"moonmix-device-mic-symbolic", "moonmix-app-fallback-symbolic", "application-x-executable-symbolic",
|
||||
"audio-x-generic-symbolic", "audio-input-microphone-symbolic", "image-missing",
|
||||
])
|
||||
}
|
||||
|
||||
///|
|
||||
test "volume icon follows volume and mute" {
|
||||
assert_eq(@model.volume_icon(100.0, false), "audio-volume-high-symbolic")
|
||||
assert_eq(@model.volume_icon(50.0, false), "audio-volume-medium-symbolic")
|
||||
assert_eq(@model.volume_icon(10.0, false), "audio-volume-low-symbolic")
|
||||
assert_eq(@model.volume_icon(0.0, false), "audio-volume-muted-symbolic")
|
||||
assert_eq(@model.volume_icon(100.0, true), "audio-volume-muted-symbolic")
|
||||
test "volume icon and chain follow volume and mute" {
|
||||
assert_eq(@model.volume_icon(100.0, false), "moonmix-volume-high-symbolic")
|
||||
assert_eq(@model.volume_icon(50.0, false), "moonmix-volume-medium-symbolic")
|
||||
assert_eq(@model.volume_icon(10.0, false), "moonmix-volume-low-symbolic")
|
||||
assert_eq(@model.volume_icon(0.0, false), "moonmix-volume-muted-symbolic")
|
||||
assert_eq(@model.volume_icon(100.0, true), "moonmix-volume-muted-symbolic")
|
||||
assert_eq(@model.volume_icon_chain(100.0, false), [
|
||||
"moonmix-volume-high-symbolic", "audio-volume-high-symbolic", "audio-volume-high",
|
||||
])
|
||||
assert_eq(@model.volume_icon_chain(0.0, false), [
|
||||
"moonmix-volume-muted-symbolic", "audio-volume-muted-symbolic", "audio-volume-muted",
|
||||
])
|
||||
}
|
||||
|
||||
///|
|
||||
test "tab icons" {
|
||||
assert_eq(@model.Tab::Playback.icon(), "audio-speakers-symbolic")
|
||||
assert_eq(@model.Tab::InputDevices.icon(), "audio-input-microphone-symbolic")
|
||||
test "default button, tab icons, and symbolic check" {
|
||||
assert_eq(@model.default_button_icons(), [
|
||||
"moonmix-default-symbolic", "emblem-ok-symbolic", "object-select-symbolic",
|
||||
])
|
||||
assert_eq(@model.Tab::Playback.icon(), "moonmix-tab-playback-symbolic")
|
||||
assert_eq(@model.Tab::Recording.icon(), "moonmix-tab-recording-symbolic")
|
||||
assert_eq(@model.Tab::OutputDevices.icon(), "moonmix-tab-output-symbolic")
|
||||
assert_eq(@model.Tab::InputDevices.icon(), "moonmix-tab-input-symbolic")
|
||||
assert_eq(
|
||||
@model.Tab::Playback.icon_chain()[0],
|
||||
"moonmix-tab-playback-symbolic",
|
||||
)
|
||||
assert_true(@model.is_symbolic_icon("moonmix-device-speaker-symbolic"))
|
||||
assert_true(@model.is_symbolic_icon("file:/tmp/foo-symbolic.svg"))
|
||||
assert_true(@model.is_symbolic_icon("image-missing"))
|
||||
assert_false(@model.is_symbolic_icon("firefox"))
|
||||
assert_false(@model.is_symbolic_icon("file:/usr/share/pixmaps/vlc.png"))
|
||||
}
|
||||
@@ -8,6 +8,8 @@ import {
|
||||
// Values
|
||||
pub const APP_LOOKUP_PREFIX : String = "app:"
|
||||
|
||||
pub const FILE_ICON_PREFIX : String = "file:"
|
||||
|
||||
pub const ICON_MISSING : String = "image-missing"
|
||||
|
||||
pub const MAX_PERCENT : Double = 150.0
|
||||
@@ -26,6 +28,8 @@ pub fn accent_text_color(Rgb, Bool) -> Rgb
|
||||
|
||||
pub let black : Rgb
|
||||
|
||||
pub fn bundled_form_factor_icon(String, NodeKind) -> String
|
||||
|
||||
pub fn clamp_percent(Double) -> Double
|
||||
|
||||
pub fn compare_text(String, String) -> Int32
|
||||
@@ -54,6 +58,8 @@ pub fn icon_fallback_device() -> Array[String]
|
||||
|
||||
pub fn icon_fallback_stream() -> Array[String]
|
||||
|
||||
pub fn is_symbolic_icon(String) -> Bool
|
||||
|
||||
pub fn linear_to_db(Double) -> Double?
|
||||
|
||||
pub fn linear_to_percent(Double) -> Double
|
||||
@@ -80,6 +86,8 @@ pub fn symbolic(String) -> String
|
||||
|
||||
pub fn volume_icon(Double, Bool) -> String
|
||||
|
||||
pub fn volume_icon_chain(Double, Bool) -> Array[String]
|
||||
|
||||
pub let white : Rgb
|
||||
|
||||
pub fn window_bg(Bool) -> Rgb
|
||||
@@ -212,6 +220,7 @@ pub(all) enum Tab {
|
||||
pub fn Tab::all() -> Array[Self]
|
||||
pub fn Tab::empty_text(Self) -> String
|
||||
pub fn Tab::icon(Self) -> String
|
||||
pub fn Tab::icon_chain(Self) -> Array[String]
|
||||
pub fn Tab::label(Self) -> String
|
||||
pub fn Tab::node_kind(Self) -> NodeKind
|
||||
|
||||
|
||||
+2
-2
@@ -33,8 +33,8 @@ test "device rows" {
|
||||
assert_eq(ins.length(), 1)
|
||||
assert_true(ins[0].mute)
|
||||
assert_true(ins[0].is_default)
|
||||
assert_eq(ins[0].icons[0], "audio-input-microphone-symbolic")
|
||||
assert_eq(ins[0].volume_icon, "audio-volume-muted-symbolic")
|
||||
assert_eq(ins[0].icons[0], "moonmix-device-mic-symbolic")
|
||||
assert_eq(ins[0].volume_icon, "moonmix-volume-muted-symbolic")
|
||||
}
|
||||
|
||||
///|
|
||||
|
||||
Reference in new issue
Block a user