Overhaul icons: bundled Lucide symbolics, soft tiles, mixer app icon, and container host icons #4

Merged
nandi merged 1 commits from geordi/ffc6c241 into main 2026-11-23 05:40:43 +00:00
47 changed files with 965 additions and 153 deletions

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
type: feature
---
Overhaul icons with bundled Lucide symbolic vectors, soft rounded icon tiles, redesigned mixer-fader app icon, and read-only host app icons in the OCI container.
+2 -1
View File
@@ -38,7 +38,8 @@ RUN apt-get update \
&& test -r /usr/share/pipewire/client.conf && test -r /usr/share/pipewire/client.conf
COPY --from=build /out/ / COPY --from=build /out/ /
COPY data/org.latha.moonmix.desktop /usr/share/applications/org.latha.moonmix.desktop COPY data/org.latha.moonmix.desktop /usr/share/applications/org.latha.moonmix.desktop
COPY data/icons/ /usr/share/icons/ COPY data/icons/hicolor/ /usr/share/icons/hicolor/
COPY data/icons/LICENSE.lucide /usr/share/doc/moonmix/LICENSE.lucide
COPY --chmod=755 tools/container-entrypoint /usr/local/bin/moonmix-entrypoint COPY --chmod=755 tools/container-entrypoint /usr/local/bin/moonmix-entrypoint
RUN gtk-update-icon-cache -f -t /usr/share/icons/hicolor RUN gtk-update-icon-cache -f -t /usr/share/icons/hicolor
+44 -27
View File
@@ -153,14 +153,16 @@ install -Dm755 _build/native/release/build/cmd/moonmix/moonmix.exe ~/.local/bin/
install -Dm644 data/org.latha.moonmix.desktop ~/.local/share/applications/org.latha.moonmix.desktop install -Dm644 data/org.latha.moonmix.desktop ~/.local/share/applications/org.latha.moonmix.desktop
install -Dm644 data/icons/hicolor/scalable/apps/org.latha.moonmix.svg ~/.local/share/icons/hicolor/scalable/apps/org.latha.moonmix.svg install -Dm644 data/icons/hicolor/scalable/apps/org.latha.moonmix.svg ~/.local/share/icons/hicolor/scalable/apps/org.latha.moonmix.svg
install -Dm644 data/icons/hicolor/symbolic/apps/org.latha.moonmix-symbolic.svg ~/.local/share/icons/hicolor/symbolic/apps/org.latha.moonmix-symbolic.svg install -Dm644 data/icons/hicolor/symbolic/apps/org.latha.moonmix-symbolic.svg ~/.local/share/icons/hicolor/symbolic/apps/org.latha.moonmix-symbolic.svg
install -Dm644 -t ~/.local/share/icons/hicolor/scalable/actions data/icons/hicolor/scalable/actions/moonmix-*.svg
gtk-update-icon-cache -f -t ~/.local/share/icons/hicolor # optional gtk-update-icon-cache -f -t ~/.local/share/icons/hicolor # optional
``` ```
The app icon is `org.latha.moonmix` (a speaker with a volume slider), shipped The app icon is `org.latha.moonmix` (three gold-lit mixer faders on a dark
as scalable and symbolic SVGs under `data/icons/hicolor/`. The window uses it violet-slate card), shipped as scalable and symbolic SVGs under
as its icon and the program name is `org.latha.moonmix`, which matches the `data/icons/hicolor/`. The window uses it as its icon and the program name is
`.desktop` file so Wayland shells show it too. Run from a checkout, moonmix `org.latha.moonmix`, which matches the `.desktop` file so Wayland shells show
also searches `./data/icons` and `$MOONMIX_ICON_DIR`. it too. Run from a checkout, moonmix also searches `./data/icons` and
`$MOONMIX_ICON_DIR`.
### OCI container and desktop launcher (Wayland) ### OCI container and desktop launcher (Wayland)
@@ -190,12 +192,19 @@ set `MOONMIX_IMAGE` to run a different local tag.
The runner maps your user ID and mounts only the Wayland and PipeWire The runner maps your user ID and mounts only the Wayland and PipeWire
sockets (including `PIPEWIRE_RUNTIME_DIR` / `PIPEWIRE_REMOTE` overrides), sockets (including `PIPEWIRE_RUNTIME_DIR` / `PIPEWIRE_REMOTE` overrides),
plus `$XDG_RUNTIME_DIR/bus` when present for desktop appearance settings. `$XDG_RUNTIME_DIR/bus` when present for desktop appearance settings, and
It has no network, GPU devices, home-directory mount or elevated privileges; whichever standard host icon, pixmap and `.desktop` directories exist
the root filesystem is read-only and temporary files disappear on exit. (`/usr/share/{icons,pixmaps,applications}`, Flatpak exports and
Software rendering avoids depending on the host's GPU drivers. The image `$XDG_DATA_HOME/{icons,applications}`) read-only under `/run/moonmix/host/`.
sets `MOONMIX_ICON_THEME=Adwaita` so a host-only icon theme (such as Papirus) Setting `XDG_DATA_DIRS` inside the container lets GIO and `GtkIconTheme`
does not cause missing icons; native runs keep the desktop's icon theme. resolve full-colour host application icons (such as Firefox, Spotify or
Flatpaks) while bundled Lucide symbolic icons in `/usr/share/icons/hicolor`
remain used for devices and controls. It has no network, GPU devices,
home-directory mount or elevated privileges; the root filesystem is
read-only and temporary files disappear on exit. Software rendering avoids
depending on the host's GPU drivers. The image sets
`MOONMIX_ICON_THEME=Adwaita` so a host-only icon theme does not leave
symbolic fallback icons missing; native runs keep the desktop's icon theme.
This is packaging, **not a sandbox for untrusted apps**: the sockets still This is packaging, **not a sandbox for untrusted apps**: the sockets still
grant access to your audio session, display and, when mounted, session grant access to your audio session, display and, when mounted, session
D-Bus. X11 sessions are not supported by this runner. D-Bus. X11 sessions are not supported by this runner.
@@ -206,23 +215,31 @@ graph without changing it.
### Icons ### Icons
Everything else uses the desktop's icon theme (Adwaita, Breeze, Papirus... UI controls, tabs, devices and fallback streams use bundled crisp 24×24
any theme with the standard freedesktop names; install `adwaita-icon-theme` [Lucide](https://lucide.dev) symbolic SVGs (`data/icons/hicolor/scalable/actions/moonmix-*.svg`,
if icons are missing). The names are chosen in `model/icons.mbt` and tested under the ISC License — see [LICENSE.lucide](data/icons/LICENSE.lucide)),
with `moon test`; the GTK layer only asks the theme `has_icon`: which GTK4 recolours automatically to match light, dark and accent-tinted
surfaces, with standard freedesktop icon names as secondary fallbacks.
Row icons sit inside a 36×36 px soft rounded tile (20 px for symbolic icons,
26 px for full-colour app icons, and accent-tinted for the default device);
button and tab icons are 16 px.
- **Devices**: the device's own `device.icon-name` / `node.icon-name`, then The chains are chosen in `model/icons.mbt` and tested with `moon test`;
`device.form-factor` (headphone, headset, speaker, microphone, webcam, the GTK layer checks `has_icon` (or `"file:<path>"` for absolute icon paths):
handset, tv, hdmi...), HDMI/webcam/Bluetooth/USB hints, then the direction
(speakers or microphone), then `audio-card-symbolic` and - **Devices**: bundled `moonmix-device-*-symbolic` icons matched from
`audio-x-generic-symbolic`. Symbolic variants are tried first so they follow `device.form-factor` (speaker, headphones, headset, microphone, webcam,
the theme's foreground colour. `image-missing` is the very last resort. phone, tv/hdmi display), HDMI/DisplayPort/webcam/Bluetooth/USB hints and
- **Streams**: `application.icon-name` / `media.icon-name`, then the app's sink/source direction, falling back to freedesktop names (`audio-card-symbolic`,
launcher icon found in the installed `.desktop` files (by `audio-x-generic-symbolic`).
`pipewire.access.portal.app_id`, `application.process.binary` or - **Streams**: full-colour application icons first (`application.icon-name` /
`application.name`), then `application-x-executable-symbolic`. `media.icon-name`, `.desktop` lookup via `GDesktopAppInfo` including `GFileIcon`
- **Mute button**: `audio-volume-high/medium/low/muted-symbolic` following the file paths, and direct theme names from `app_id` / binary), then any
volume and mute state. Row icons are 32 px, button and tab icons 16 px. symbolic hints, then `moonmix-device-mic-symbolic` for recording streams and
`moonmix-app-fallback-symbolic`.
- **Mute button & tabs**: `moonmix-volume-high/medium/low/muted-symbolic` and
`moonmix-tab-{playback,recording,output,input}-symbolic` (with freedesktop
fallbacks).
Pkg-config flags: moon does not expand `$(pkg-config ...)` in `moon.pkg` Pkg-config flags: moon does not expand `$(pkg-config ...)` in `moon.pkg`
link options. Instead, the packages point `link.native.stub-cc` and `cc` at link options. Instead, the packages point `link.native.stub-cc` and `cc` at
+75 -14
View File
@@ -15,6 +15,7 @@ extern "C" fn c_exit(code : Int32) = "exit"
/// Widgets of one row (a stream or a device). /// Widgets of one row (a stream or a device).
struct RowView { struct RowView {
root : @gtk.Widget root : @gtk.Widget
icon_tile : @gtk.Widget
icon : @gtk.Widget icon : @gtk.Widget
title : @gtk.Widget title : @gtk.Widget
subtitle : @gtk.Widget subtitle : @gtk.Widget
@@ -55,8 +56,12 @@ struct App {
} }
///| ///|
/// Device / application icon in each row; buttons use 16 px icons. /// Symbolic device / fallback icons render at 20 px inside a 36×36 soft tile;
const ROW_ICON_SIZE : Int32 = 32 /// full-colour application icons render larger at 26 px. Buttons use 16 px.
const ROW_SYMBOLIC_ICON_SIZE : Int32 = 20
///|
const ROW_APP_ICON_SIZE : Int32 = 26
///| ///|
const METER_INTERVAL_MS : Int32 = 40 const METER_INTERVAL_MS : Int32 = 40
@@ -65,19 +70,69 @@ const METER_INTERVAL_MS : Int32 = 40
const CSS : String = const CSS : String =
#|.mm-title { font-weight: bold; } #|.mm-title { font-weight: bold; }
#|.mm-subtitle { opacity: 0.7; font-size: smaller; } #|.mm-subtitle { opacity: 0.7; font-size: smaller; }
#|.mm-row { padding: 6px 12px; } #|.mm-row { padding: 8px 12px; }
#|.mm-status { padding: 4px 8px; opacity: 0.8; font-size: smaller; } #|.mm-status { padding: 4px 8px; opacity: 0.8; font-size: smaller; }
#|.mm-icon-tile {
#| min-width: 36px;
#| min-height: 36px;
#| border-radius: 10px;
#| background-color: alpha(currentColor, 0.08);
#| box-shadow: inset 0 0 0 1px alpha(currentColor, 0.08);
#|}
#|.mm-icon-tile.mm-app-tile {
#| background-color: alpha(currentColor, 0.05);
#|}
#|.mm-icon-tile.mm-default-tile {
#| background-color: alpha(@theme_selected_bg_color, 0.14);
#| box-shadow: inset 0 0 0 1px alpha(@theme_selected_bg_color, 0.34);
#| color: @theme_selected_bg_color;
#|}
#|levelbar.mm-meter trough, levelbar.mm-meter block { min-height: 4px; } #|levelbar.mm-meter trough, levelbar.mm-meter block { min-height: 4px; }
#|levelbar.mm-meter { margin: 0 10px; } #|levelbar.mm-meter { margin: 0 10px; }
///|
fn set_row_icon(
tile : @gtk.Widget,
icon : @gtk.Widget,
icons : Array[String],
) -> Unit {
let resolved = @gtk.resolve_icon(icons)
let sym = @model.is_symbolic_icon(resolved)
icon.set_icon(resolved)
icon.set_pixel_size(
if sym {
ROW_SYMBOLIC_ICON_SIZE
} else {
ROW_APP_ICON_SIZE
},
)
if sym {
icon.remove_css_class("mm-icon-app")
tile.remove_css_class("mm-app-tile")
} else {
icon.add_css_class("mm-icon-app")
tile.add_css_class("mm-app-tile")
}
}
///| ///|
fn new_row_view(app : App, tab : @model.Tab, row : @model.Row) -> RowView { fn new_row_view(app : App, tab : @model.Tab, row : @model.Row) -> RowView {
let id = row.id let id = row.id
let tags = [] let tags = []
let root = @gtk.vbox(4) let root = @gtk.vbox(4)
root.add_css_class("mm-row") root.add_css_class("mm-row")
let header = @gtk.hbox(8) let header = @gtk.hbox(10)
let icon = @gtk.image(@gtk.resolve_icon(row.icons), ROW_ICON_SIZE) let icon_tile = @gtk.hbox(0)
icon_tile.add_css_class("mm-icon-tile")
icon_tile.set_hexpand(false)
icon_tile.set_vexpand(false)
icon_tile.set_valign_center()
let icon = @gtk.image("", ROW_SYMBOLIC_ICON_SIZE)
icon.set_hexpand(true)
icon.set_vexpand(true)
icon.set_halign_center()
icon.set_valign_center()
icon_tile.append(icon)
let texts = @gtk.vbox(0) let texts = @gtk.vbox(0)
texts.set_hexpand(true) texts.set_hexpand(true)
texts.set_valign_center() texts.set_valign_center()
@@ -87,7 +142,7 @@ fn new_row_view(app : App, tab : @model.Tab, row : @model.Row) -> RowView {
subtitle.add_css_class("mm-subtitle") subtitle.add_css_class("mm-subtitle")
texts.append(title) texts.append(title)
texts.append(subtitle) texts.append(subtitle)
header.append(icon) header.append(icon_tile)
header.append(texts) header.append(texts)
// Streams: device selector. Devices: "default" toggle. // Streams: device selector. Devices: "default" toggle.
@@ -142,7 +197,7 @@ fn new_row_view(app : App, tab : @model.Tab, row : @model.Row) -> RowView {
_ => None _ => None
} }
let (mute, mute_tag) = @gtk.toggle( let (mute, mute_tag) = @gtk.toggle(
@gtk.resolve_icon([row.volume_icon, "audio-volume-high"]), @gtk.resolve_icon(@model.volume_icon_chain(row.percent, row.mute)),
"", "",
fn(on) { let _ = @wp.set_mute(id, on) }, fn(on) { let _ = @wp.set_mute(id, on) },
) )
@@ -180,6 +235,7 @@ fn new_row_view(app : App, tab : @model.Tab, row : @model.Row) -> RowView {
root.append(slider_row) root.append(slider_row)
let view = { let view = {
root, root,
icon_tile,
icon, icon,
title, title,
subtitle, subtitle,
@@ -212,7 +268,14 @@ fn apply_row(view : RowView, row : @model.Row, force~ : Bool = false) -> Unit {
view.subtitle.set_visible(row.subtitle != "") view.subtitle.set_visible(row.subtitle != "")
} }
if force || old.icons != row.icons { if force || old.icons != row.icons {
view.icon.set_icon(@gtk.resolve_icon(row.icons)) set_row_icon(view.icon_tile, view.icon, row.icons)
}
if force || old.is_default != row.is_default {
if row.is_default {
view.icon_tile.add_css_class("mm-default-tile")
} else {
view.icon_tile.remove_css_class("mm-default-tile")
}
} }
view.scale.set_sensitive(row.has_volume) view.scale.set_sensitive(row.has_volume)
if force || @model.should_apply_remote(view.last_local_us, @gtk.now_us()) { if force || @model.should_apply_remote(view.last_local_us, @gtk.now_us()) {
@@ -220,9 +283,11 @@ fn apply_row(view : RowView, row : @model.Row, force~ : Bool = false) -> Unit {
view.volume_label.set_text(row.volume_text) view.volume_label.set_text(row.volume_text)
} }
view.mute.set_active(row.mute) view.mute.set_active(row.mute)
if force || old.volume_icon != row.volume_icon {
view.mute.set_button_icon( view.mute.set_button_icon(
@gtk.resolve_icon([row.volume_icon, "audio-volume-high"]), @gtk.resolve_icon(@model.volume_icon_chain(row.percent, row.mute)),
) )
}
match view.default_btn { match view.default_btn {
Some(b) => b.set_active(row.is_default) Some(b) => b.set_active(row.is_default)
None => () None => ()
@@ -444,11 +509,7 @@ fn build_ui() -> App {
nb.append_page( nb.append_page(
@gtk.scrolled(list), @gtk.scrolled(list),
tab.label(), tab.label(),
icon=@gtk.resolve_icon([ icon=@gtk.resolve_icon(tab.icon_chain()),
tab.icon(),
"audio-card-symbolic",
"audio-x-generic",
]),
) )
tabs.push({ tab, list, empty, views: Map([]), rows: [], }) tabs.push({ tab, list, empty, views: Map([]), rows: [], })
} }
+43
View File
@@ -0,0 +1,43 @@
ISC License
Copyright (c) 2026 Lucide Icons and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
---
The following Lucide icons are derived from the Feather project:
airplay, alert-circle, alert-octagon, alert-triangle, aperture, arrow-down-circle, arrow-down-left, arrow-down-right, arrow-down, arrow-left-circle, arrow-left, arrow-right-circle, arrow-right, arrow-up-circle, arrow-up-left, arrow-up-right, arrow-up, at-sign, calendar, cast, check, chevron-down, chevron-left, chevron-right, chevron-up, chevrons-down, chevrons-left, chevrons-right, chevrons-up, circle, clipboard, clock, code, columns, command, compass, corner-down-left, corner-down-right, corner-left-down, corner-left-up, corner-right-down, corner-right-up, corner-up-left, corner-up-right, crosshair, database, divide-circle, divide-square, dollar-sign, download, external-link, feather, frown, hash, headphones, help-circle, info, italic, key, layout, life-buoy, link-2, link, loader, lock, log-in, log-out, maximize, meh, minimize, minimize-2, minus-circle, minus-square, minus, monitor, moon, more-horizontal, more-vertical, move, music, navigation-2, navigation, octagon, pause-circle, percent, plus-circle, plus-square, plus, power, radio, rss, search, server, share, shopping-bag, sidebar, smartphone, smile, square, table-2, tablet, target, terminal, trash-2, trash, triangle, tv, type, upload, x-circle, x-octagon, x-square, x, zoom-in, zoom-out
The MIT License (MIT) (for the icons listed above)
Copyright (c) 2013-present Cole Bemis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<path class="transparent-fill foreground-stroke" d="M2 13a2 2 0 0 0 2-2V7a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0V4a2 2 0 0 1 4 0v13a2 2 0 0 0 4 0v-4a2 2 0 0 1 2-2"/>
</svg>

After

Width:  |  Height:  |  Size: 386 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<path class="transparent-fill foreground-stroke" d="M20 6 9 17l-5-5"/>
</svg>

After

Width:  |  Height:  |  Size: 299 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<path class="transparent-fill foreground-stroke" d="M10 5H3"/><path class="transparent-fill foreground-stroke" d="M12 19H3"/><path class="transparent-fill foreground-stroke" d="M14 3v4"/><path class="transparent-fill foreground-stroke" d="M16 17v4"/><path class="transparent-fill foreground-stroke" d="M21 12h-9"/><path class="transparent-fill foreground-stroke" d="M21 19h-5"/><path class="transparent-fill foreground-stroke" d="M21 5h-7"/><path class="transparent-fill foreground-stroke" d="M8 10v4"/><path class="transparent-fill foreground-stroke" d="M8 12H3"/>
</svg>

After

Width:  |  Height:  |  Size: 794 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<path class="transparent-fill foreground-stroke" d="m7 7 10 10-5 5V2l5 5L7 17"/>
</svg>

After

Width:  |  Height:  |  Size: 309 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<rect class="transparent-fill foreground-stroke" width="20" height="14" x="2" y="3" rx="2"/><line class="transparent-fill foreground-stroke" x1="8" x2="16" y1="21" y2="21"/><line class="transparent-fill foreground-stroke" x1="12" x2="12" y1="17" y2="21"/>
</svg>

After

Width:  |  Height:  |  Size: 484 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<path class="transparent-fill foreground-stroke" d="M3 14h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-7a9 9 0 0 1 18 0v7a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3"/>
</svg>

After

Width:  |  Height:  |  Size: 407 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<path class="transparent-fill foreground-stroke" d="M3 11h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-5Zm0 0a9 9 0 1 1 18 0m0 0v5a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3Z"/><path class="transparent-fill foreground-stroke" d="M21 16v2a4 4 0 0 1-4 4h-5"/>
</svg>

After

Width:  |  Height:  |  Size: 497 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<path class="transparent-fill foreground-stroke" d="M12 19v3"/><path class="transparent-fill foreground-stroke" d="M19 10v2a7 7 0 0 1-14 0v-2"/><rect class="transparent-fill foreground-stroke" x="9" y="2" width="6" height="13" rx="3"/>
</svg>

After

Width:  |  Height:  |  Size: 464 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<rect class="transparent-fill foreground-stroke" width="14" height="20" x="5" y="2" rx="2" ry="2"/><path class="transparent-fill foreground-stroke" d="M12 18h.01"/>
</svg>

After

Width:  |  Height:  |  Size: 393 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<rect class="transparent-fill foreground-stroke" width="16" height="20" x="4" y="2" rx="2"/><path class="transparent-fill foreground-stroke" d="M12 6h.01"/><circle class="transparent-fill foreground-stroke" cx="12" cy="14" r="4"/><path class="transparent-fill foreground-stroke" d="M12 14h.01"/>
</svg>

After

Width:  |  Height:  |  Size: 524 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<circle class="transparent-fill foreground-stroke" cx="10" cy="7" r="1"/><circle class="transparent-fill foreground-stroke" cx="4" cy="20" r="1"/><path class="transparent-fill foreground-stroke" d="M4.7 19.3 19 5"/><path class="transparent-fill foreground-stroke" d="m21 3-3 1 2 2Z"/><path class="transparent-fill foreground-stroke" d="M9.26 7.68 5 12l2 5"/><path class="transparent-fill foreground-stroke" d="m10 14 5 2 3.5-3.5"/><path class="transparent-fill foreground-stroke" d="m18 12 1-1 1 1-1 1Z"/>
</svg>

After

Width:  |  Height:  |  Size: 734 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<circle class="transparent-fill foreground-stroke" cx="12" cy="10" r="8"/><circle class="transparent-fill foreground-stroke" cx="12" cy="10" r="3"/><path class="transparent-fill foreground-stroke" d="M7 22h10"/><path class="transparent-fill foreground-stroke" d="M12 22v-4"/>
</svg>

After

Width:  |  Height:  |  Size: 504 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<path class="transparent-fill foreground-stroke" d="M12 19v3"/><path class="transparent-fill foreground-stroke" d="M19 10v2a7 7 0 0 1-14 0v-2"/><rect class="transparent-fill foreground-stroke" x="9" y="2" width="6" height="13" rx="3"/>
</svg>

After

Width:  |  Height:  |  Size: 464 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<rect class="transparent-fill foreground-stroke" width="16" height="20" x="4" y="2" rx="2"/><path class="transparent-fill foreground-stroke" d="M12 6h.01"/><circle class="transparent-fill foreground-stroke" cx="12" cy="14" r="4"/><path class="transparent-fill foreground-stroke" d="M12 14h.01"/>
</svg>

After

Width:  |  Height:  |  Size: 524 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<path class="transparent-fill foreground-stroke" d="M21 16V3a1 1 0 0 0-1.28-.96l-10 2.917a1 1 0 0 0-.72.96V19"/><circle class="transparent-fill foreground-stroke" cx="18" cy="16" r="3"/><circle class="transparent-fill foreground-stroke" cx="6" cy="19" r="3"/>
</svg>

After

Width:  |  Height:  |  Size: 488 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<path class="transparent-fill foreground-stroke" d="M16.247 7.761a6 6 0 0 1 0 8.478"/><path class="transparent-fill foreground-stroke" d="M19.075 4.933a10 10 0 0 1 0 14.134"/><path class="transparent-fill foreground-stroke" d="M4.925 19.067a10 10 0 0 1 0-14.134"/><path class="transparent-fill foreground-stroke" d="M7.753 16.239a6 6 0 0 1 0-8.478"/><circle class="transparent-fill foreground-stroke" cx="12" cy="12" r="2"/>
</svg>

After

Width:  |  Height:  |  Size: 653 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<path class="transparent-fill foreground-stroke" d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><path class="transparent-fill foreground-stroke" d="M16 9a5 5 0 0 1 0 6"/><path class="transparent-fill foreground-stroke" d="M19.364 18.364a9 9 0 0 0 0-12.728"/>
</svg>

After

Width:  |  Height:  |  Size: 614 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<path class="transparent-fill foreground-stroke" d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/>
</svg>

After

Width:  |  Height:  |  Size: 452 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<path class="transparent-fill foreground-stroke" d="M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z"/><path class="transparent-fill foreground-stroke" d="M16 9a5 5 0 0 1 0 6"/>
</svg>

After

Width:  |  Height:  |  Size: 526 B

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#2e3436" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round">
<path class="transparent-fill foreground-stroke" d="M11 4.702a.7.7 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.7.7 0 0 0 11 19.298z"/><path class="transparent-fill foreground-stroke" d="m16.5 14.5 5-5"/><path class="transparent-fill foreground-stroke" d="m16.5 9.5 5 5"/>
</svg>

After

Width:  |  Height:  |  Size: 581 B

@@ -2,17 +2,57 @@
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128"> <svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
<defs> <defs>
<linearGradient id="bg" x1="0" y1="0" x2="0" y2="1"> <linearGradient id="bg" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="#4b5fc8"/> <stop offset="0" stop-color="#2a2d3a"/>
<stop offset="1" stop-color="#2a2f6b"/> <stop offset="0.55" stop-color="#1d202a"/>
<stop offset="1" stop-color="#17191f"/>
</linearGradient>
<linearGradient id="rim" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="#ffffff" stop-opacity="0.18"/>
<stop offset="0.38" stop-color="#ffffff" stop-opacity="0"/>
</linearGradient>
<radialGradient id="glow" cx="50%" cy="54%" r="44%">
<stop offset="0" stop-color="#f5b021" stop-opacity="0.09"/>
<stop offset="1" stop-color="#f5b021" stop-opacity="0"/>
</radialGradient>
<linearGradient id="gold" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="#f9c94e"/>
<stop offset="0.55" stop-color="#f5b021"/>
<stop offset="1" stop-color="#db9512"/>
</linearGradient>
<linearGradient id="cap" x1="0" y1="0" x2="0" y2="1">
<stop offset="0" stop-color="#ffffff"/>
<stop offset="1" stop-color="#d7dbe5"/>
</linearGradient> </linearGradient>
</defs> </defs>
<!-- Squircle card -->
<rect x="8" y="8" width="112" height="112" rx="26" fill="url(#bg)"/> <rect x="8" y="8" width="112" height="112" rx="26" fill="url(#bg)"/>
<!-- speaker --> <rect x="8" y="8" width="112" height="112" rx="26" fill="url(#glow)"/>
<path d="M26 54h16l20-16v52L42 74H26z" fill="#ffffff"/> <rect x="8.5" y="8.5" width="111" height="111" rx="25.5" fill="none" stroke="#3c4154" stroke-opacity="0.65" stroke-width="1"/>
<path d="M74 52c5 6 5 18 0 24" fill="none" stroke="#ffffff" stroke-width="6" stroke-linecap="round"/> <rect x="9" y="9" width="110" height="110" rx="25" fill="none" stroke="url(#rim)" stroke-width="1.2"/>
<path d="M84 42c10 13 10 31 0 44" fill="none" stroke="#ffffff" stroke-width="6" stroke-linecap="round" opacity=".7"/>
<!-- slider --> <!-- Recessed fader troughs -->
<rect x="26" y="98" width="76" height="8" rx="4" fill="#ffffff" opacity=".3"/> <rect x="33" y="30" width="10" height="68" rx="5" fill="#0e1015" stroke="#ffffff" stroke-opacity="0.06" stroke-width="1"/>
<rect x="26" y="98" width="50" height="8" rx="4" fill="#f5c542"/> <rect x="59" y="30" width="10" height="68" rx="5" fill="#0e1015" stroke="#ffffff" stroke-opacity="0.06" stroke-width="1"/>
<circle cx="76" cy="102" r="9" fill="#f5c542" stroke="#ffffff" stroke-width="3"/> <rect x="85" y="30" width="10" height="68" rx="5" fill="#0e1015" stroke="#ffffff" stroke-opacity="0.06" stroke-width="1"/>
<!-- Warm gold active level fills -->
<rect x="33" y="56" width="10" height="42" rx="5" fill="url(#gold)"/>
<rect x="59" y="44" width="10" height="54" rx="5" fill="url(#gold)"/>
<rect x="85" y="70" width="10" height="28" rx="5" fill="url(#gold)"/>
<!-- Left fader cap (cx=38, cy=56) -->
<rect x="27" y="51" width="22" height="14" rx="7" fill="#07080b" opacity="0.55"/>
<rect x="27" y="49" width="22" height="14" rx="7" fill="url(#cap)"/>
<rect x="33" y="55" width="10" height="2" rx="1" fill="#232632" opacity="0.26"/>
<!-- Center fader cap (cx=64, cy=44) -->
<rect x="53" y="39" width="22" height="14" rx="7" fill="#07080b" opacity="0.55"/>
<rect x="53" y="37" width="22" height="14" rx="7" fill="url(#cap)"/>
<rect x="59" y="43" width="10" height="2" rx="1" fill="#232632" opacity="0.26"/>
<!-- Right fader cap (cx=90, cy=70) -->
<rect x="79" y="65" width="22" height="14" rx="7" fill="#07080b" opacity="0.55"/>
<rect x="79" y="63" width="22" height="14" rx="7" fill="url(#cap)"/>
<rect x="85" y="69" width="10" height="2" rx="1" fill="#232632" opacity="0.26"/>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 947 B

After

Width:  |  Height:  |  Size: 3.0 KiB

@@ -1,9 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path d="M1 5h2.5L7 2v8L3.5 7H1z" fill="#bebebe"/> <!-- Upper inactive fader segments -->
<path d="M9 4.5c1.2 1.6 1.2 2.4 0 4" fill="none" stroke="#bebebe" stroke-width="1.2" stroke-linecap="round"/> <rect x="2.1" y="2" width="1.8" height="4.5" rx="0.9" fill="#2e3436" opacity="0.45"/>
<path d="M11 3c2 2.6 2 5.4 0 8" fill="none" stroke="#bebebe" stroke-width="1.2" stroke-linecap="round"/> <rect x="7.1" y="2" width="1.8" height="2.6" rx="0.9" fill="#2e3436" opacity="0.45"/>
<rect x="1" y="12.2" width="14" height="1.6" rx=".8" fill="#bebebe" opacity=".5"/> <rect x="12.1" y="2" width="1.8" height="7.5" rx="0.9" fill="#2e3436" opacity="0.45"/>
<rect x="1" y="12.2" width="9" height="1.6" rx=".8" fill="#bebebe"/> <!-- Lower active fader segments -->
<circle cx="10" cy="13" r="1.8" fill="#bebebe"/> <rect x="2.1" y="7.5" width="1.8" height="6.5" rx="0.9" fill="#2e3436"/>
<rect x="7.1" y="5.5" width="1.8" height="8.5" rx="0.9" fill="#2e3436"/>
<rect x="12.1" y="10.5" width="1.8" height="3.5" rx="0.9" fill="#2e3436"/>
<!-- Pill knob caps at staggered heights (cy=7, 5, 10) -->
<rect x="0.9" y="5.7" width="4.2" height="2.6" rx="1.3" fill="#2e3436"/>
<rect x="5.9" y="3.7" width="4.2" height="2.6" rx="1.3" fill="#2e3436"/>
<rect x="10.9" y="8.7" width="4.2" height="2.6" rx="1.3" fill="#2e3436"/>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 609 B

After

Width:  |  Height:  |  Size: 989 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 42 KiB

+36 -2
View File
@@ -110,6 +110,9 @@ extern "C" fn ffi_image_new(icon : Bytes, size : Int32) -> Widget = "mm_gtk_imag
#borrow(icon) #borrow(icon)
extern "C" fn ffi_image_set_icon(img : Widget, icon : Bytes) = "mm_gtk_image_set_icon" extern "C" fn ffi_image_set_icon(img : Widget, icon : Bytes) = "mm_gtk_image_set_icon"
///|
extern "C" fn ffi_image_set_pixel_size(img : Widget, size : Int32) = "mm_gtk_image_set_pixel_size"
///| ///|
#borrow(name) #borrow(name)
extern "C" fn ffi_has_icon(name : Bytes) -> Int32 = "mm_gtk_has_icon" extern "C" fn ffi_has_icon(name : Bytes) -> Int32 = "mm_gtk_has_icon"
@@ -169,6 +172,10 @@ extern "C" fn ffi_set_margins(w : Widget, m : Int32) = "mm_gtk_widget_set_margin
#borrow(cls) #borrow(cls)
extern "C" fn ffi_add_css_class(w : Widget, cls : Bytes) = "mm_gtk_widget_add_css_class" extern "C" fn ffi_add_css_class(w : Widget, cls : Bytes) = "mm_gtk_widget_add_css_class"
///|
#borrow(cls)
extern "C" fn ffi_remove_css_class(w : Widget, cls : Bytes) = "mm_gtk_widget_remove_css_class"
///| ///|
extern "C" fn ffi_set_visible(w : Widget, v : Int32) = "mm_gtk_widget_set_visible" extern "C" fn ffi_set_visible(w : Widget, v : Int32) = "mm_gtk_widget_set_visible"
@@ -178,6 +185,12 @@ extern "C" fn ffi_set_sensitive(w : Widget, v : Int32) = "mm_gtk_widget_set_sens
///| ///|
extern "C" fn ffi_set_valign_center(w : Widget) = "mm_gtk_widget_set_valign_center" extern "C" fn ffi_set_valign_center(w : Widget) = "mm_gtk_widget_set_valign_center"
///|
extern "C" fn ffi_set_halign_center(w : Widget) = "mm_gtk_widget_set_halign_center"
///|
extern "C" fn ffi_set_vexpand(w : Widget, v : Int32) = "mm_gtk_widget_set_vexpand"
///| ///|
#borrow(path) #borrow(path)
extern "C" fn ffi_save_png(w : Widget, path : Bytes) -> Int32 = "mm_gtk_save_png" extern "C" fn ffi_save_png(w : Widget, path : Bytes) -> Int32 = "mm_gtk_save_png"
@@ -460,6 +473,11 @@ pub fn Widget::set_icon(self : Widget, icon : String) -> Unit {
ffi_image_set_icon(self, cstr(icon)) ffi_image_set_icon(self, cstr(icon))
} }
///|
pub fn Widget::set_pixel_size(self : Widget, size : Int32) -> Unit {
ffi_image_set_pixel_size(self, size)
}
///| ///|
/// A slider from 0 to `max` with a mark at `norm`. Returns (widget, tag). /// A slider from 0 to `max` with a mark at `norm`. Returns (widget, tag).
pub fn scale( pub fn scale(
@@ -549,6 +567,11 @@ pub fn Widget::add_css_class(self : Widget, cls : String) -> Unit {
ffi_add_css_class(self, cstr(cls)) ffi_add_css_class(self, cstr(cls))
} }
///|
pub fn Widget::remove_css_class(self : Widget, cls : String) -> Unit {
ffi_remove_css_class(self, cstr(cls))
}
///| ///|
pub fn Widget::set_visible(self : Widget, v : Bool) -> Unit { pub fn Widget::set_visible(self : Widget, v : Bool) -> Unit {
ffi_set_visible(self, int(v)) ffi_set_visible(self, int(v))
@@ -564,6 +587,16 @@ pub fn Widget::set_valign_center(self : Widget) -> Unit {
ffi_set_valign_center(self) ffi_set_valign_center(self)
} }
///|
pub fn Widget::set_halign_center(self : Widget) -> Unit {
ffi_set_halign_center(self)
}
///|
pub fn Widget::set_vexpand(self : Widget, v : Bool) -> Unit {
ffi_set_vexpand(self, int(v))
}
///| ///|
/// Render the widget offscreen to a PNG file (for headless screenshots). /// Render the widget offscreen to a PNG file (for headless screenshots).
pub fn Widget::save_png(self : Widget, path : String) -> Bool { pub fn Widget::save_png(self : Widget, path : String) -> Bool {
@@ -585,8 +618,9 @@ pub fn app_icon(key : String) -> String {
///| ///|
/// First entry of an icon chain (see @model.device_icon_chain) that the theme /// First entry of an icon chain (see @model.device_icon_chain) that the theme
/// has. "app:<key>" entries are looked up in the .desktop files. The last /// has or that resolves on disk. "app:<key>" entries are looked up in the
/// entry is returned if nothing matches, so the result is never empty. /// .desktop files (and may resolve to a theme icon name or "file:<path>").
/// The last entry is returned if nothing matches, so the result is never empty.
pub fn resolve_icon(chain : Array[String]) -> String { pub fn resolve_icon(chain : Array[String]) -> String {
for name in chain { for name in chain {
if name.has_prefix("app:") { if name.has_prefix("app:") {
+125 -15
View File
@@ -43,6 +43,48 @@ MOONBIT_FFI_EXPORT void mm_gtk_set_handler(mm_gcall_t call, void *closure) {
g_closure = closure; g_closure = closure;
} }
static void add_icon_search_path_if_new(GtkIconTheme *theme, const char *dir) {
if (!dir || !*dir)
return;
char **paths = gtk_icon_theme_get_search_path(theme);
int found = 0;
for (char **p = paths; p && *p; p++) {
if (strcmp(*p, dir) == 0) {
found = 1;
break;
}
}
g_strfreev(paths);
if (!found)
gtk_icon_theme_add_search_path(theme, dir);
}
static char *resolve_icon_file_path(const char *path) {
if (!path || !*path)
return NULL;
if (g_file_test(path, G_FILE_TEST_IS_REGULAR))
return g_strdup(path);
static const struct {
const char *host_prefix;
const char *container_prefix;
} remaps[] = {
{"/usr/share/pixmaps/", "/run/moonmix/host/usr/pixmaps/"},
{"/usr/share/icons/", "/run/moonmix/host/usr/icons/"},
{"/var/lib/flatpak/exports/share/icons/",
"/run/moonmix/host/flatpak-sys/icons/"},
};
for (size_t i = 0; i < sizeof(remaps) / sizeof(remaps[0]); i++) {
if (g_str_has_prefix(path, remaps[i].host_prefix)) {
const char *rest = path + strlen(remaps[i].host_prefix);
char *mapped = g_strconcat(remaps[i].container_prefix, rest, NULL);
if (g_file_test(mapped, G_FILE_TEST_IS_REGULAR))
return mapped;
g_free(mapped);
}
}
return NULL;
}
MOONBIT_FFI_EXPORT int32_t mm_gtk_init(void) { MOONBIT_FFI_EXPORT int32_t mm_gtk_init(void) {
/* The Wayland app id comes from the program name; match the .desktop file /* The Wayland app id comes from the program name; match the .desktop file
* so the compositor shows the app icon. */ * so the compositor shows the app icon. */
@@ -54,41 +96,72 @@ MOONBIT_FFI_EXPORT int32_t mm_gtk_init(void) {
const char *icon_theme = g_getenv("MOONMIX_ICON_THEME"); const char *icon_theme = g_getenv("MOONMIX_ICON_THEME");
if (icon_theme && *icon_theme) if (icon_theme && *icon_theme)
g_object_set(gtk_settings_get_default(), "gtk-icon-theme-name", icon_theme, NULL); g_object_set(gtk_settings_get_default(), "gtk-icon-theme-name", icon_theme, NULL);
/* Let an uninstalled checkout find data/icons/hicolor/... too: /* Let an uninstalled checkout and standard local/container prefixes find
* $MOONMIX_ICON_DIR, then ./data/icons. */ * bundled moonmix-* icons and host pixmaps. */
GtkIconTheme *theme = gtk_icon_theme_get_for_display(gdk_display_get_default()); GtkIconTheme *theme = gtk_icon_theme_get_for_display(gdk_display_get_default());
const char *dir = g_getenv("MOONMIX_ICON_DIR"); add_icon_search_path_if_new(theme, g_getenv("MOONMIX_ICON_DIR"));
if (dir && *dir) add_icon_search_path_if_new(theme, "data/icons");
gtk_icon_theme_add_search_path(theme, dir); char *user_icons = g_build_filename(g_get_user_data_dir(), "icons", NULL);
gtk_icon_theme_add_search_path(theme, "data/icons"); add_icon_search_path_if_new(theme, user_icons);
g_free(user_icons);
add_icon_search_path_if_new(theme, "/usr/local/share/icons");
if (g_file_test("/run/moonmix/host/usr/pixmaps", G_FILE_TEST_IS_DIR))
add_icon_search_path_if_new(theme, "/run/moonmix/host/usr/pixmaps");
gtk_window_set_default_icon_name("org.latha.moonmix"); gtk_window_set_default_icon_name("org.latha.moonmix");
return 1; return 1;
} }
/* 1 if the icon theme has `name`. */ /* 1 if the icon theme has `name` or a "file:<path>" icon exists. */
MOONBIT_FFI_EXPORT int32_t mm_gtk_has_icon(moonbit_bytes_t name) { MOONBIT_FFI_EXPORT int32_t mm_gtk_has_icon(moonbit_bytes_t name) {
const char *n = s(name);
if (!n || !*n)
return 0;
if (g_str_has_prefix(n, "file:")) {
char *resolved = resolve_icon_file_path(n + 5);
int ok = resolved != NULL;
g_free(resolved);
return ok;
}
GdkDisplay *d = gdk_display_get_default(); GdkDisplay *d = gdk_display_get_default();
if (!d) if (!d)
return 0; return 0;
return gtk_icon_theme_has_icon(gtk_icon_theme_get_for_display(d), s(name)); return gtk_icon_theme_has_icon(gtk_icon_theme_get_for_display(d), n);
} }
static int theme_icon_of(GAppInfo *info, GtkIconTheme *theme, char **out) { static int theme_icon_of(GAppInfo *info, GtkIconTheme *theme, char **out) {
GIcon *icon = g_app_info_get_icon(info); GIcon *icon = g_app_info_get_icon(info);
if (icon && G_IS_THEMED_ICON(icon)) { if (!icon)
return 0;
if (G_IS_THEMED_ICON(icon)) {
const char *const *names = g_themed_icon_get_names(G_THEMED_ICON(icon)); const char *const *names = g_themed_icon_get_names(G_THEMED_ICON(icon));
for (int i = 0; names && names[i]; i++) /* Prefer full-colour non-symbolic icons before falling back to -symbolic. */
if (gtk_icon_theme_has_icon(theme, names[i])) { for (int pass = 0; pass < 2; pass++) {
for (int i = 0; names && names[i]; i++) {
int is_sym = g_str_has_suffix(names[i], "-symbolic");
if ((pass == 0) == !is_sym &&
gtk_icon_theme_has_icon(theme, names[i])) {
*out = g_strdup(names[i]); *out = g_strdup(names[i]);
return 1; return 1;
} }
} }
}
} else if (G_IS_FILE_ICON(icon)) {
GFile *f = g_file_icon_get_file(G_FILE_ICON(icon));
char *path = f ? g_file_get_path(f) : NULL;
char *resolved = resolve_icon_file_path(path);
g_free(path);
if (resolved) {
*out = g_strconcat("file:", resolved, NULL);
g_free(resolved);
return 1;
}
}
return 0; return 0;
} }
/* Look an application up in the installed .desktop files by desktop id /* Look an application up in the installed .desktop files by desktop id
* ("org.mozilla.firefox"), executable basename ("firefox") or display name * ("org.mozilla.firefox"), executable basename ("firefox") or display name
* ("Firefox"), and return its icon name if the theme has it. "" if none. */ * ("Firefox"), and return its icon name (or "file:<path>") if available. "" if none. */
MOONBIT_FFI_EXPORT moonbit_bytes_t mm_gtk_app_icon(moonbit_bytes_t key) { MOONBIT_FFI_EXPORT moonbit_bytes_t mm_gtk_app_icon(moonbit_bytes_t key) {
const char *k = s(key); const char *k = s(key);
char *found = NULL; char *found = NULL;
@@ -120,7 +193,7 @@ MOONBIT_FFI_EXPORT moonbit_bytes_t mm_gtk_app_icon(moonbit_bytes_t key) {
} }
} }
size_t n = found ? strlen(found) : 0; size_t n = found ? strlen(found) : 0;
moonbit_bytes_t out = moonbit_make_bytes(n + 1, 0); moonbit_bytes_t out = moonbit_make_bytes((int32_t)n, 0);
if (found) if (found)
memcpy(out, found, n); memcpy(out, found, n);
g_free(found); g_free(found);
@@ -481,16 +554,40 @@ MOONBIT_FFI_EXPORT void mm_gtk_label_set_width_chars(GtkWidget *l,
gtk_label_set_xalign(GTK_LABEL(l), 1.0f); gtk_label_set_xalign(GTK_LABEL(l), 1.0f);
} }
static void image_apply_icon(GtkImage *img, const char *icon) {
if (!icon || !*icon) {
gtk_image_clear(img);
return;
}
if (g_str_has_prefix(icon, "file:")) {
char *resolved = resolve_icon_file_path(icon + 5);
if (resolved) {
gtk_image_set_from_file(img, resolved);
g_free(resolved);
} else {
gtk_image_set_from_file(img, icon + 5);
}
} else {
gtk_image_set_from_icon_name(img, icon);
}
}
MOONBIT_FFI_EXPORT GtkWidget *mm_gtk_image_new(moonbit_bytes_t icon, MOONBIT_FFI_EXPORT GtkWidget *mm_gtk_image_new(moonbit_bytes_t icon,
int32_t size) { int32_t size) {
GtkWidget *img = gtk_image_new_from_icon_name(s(icon)); GtkWidget *img = gtk_image_new();
image_apply_icon(GTK_IMAGE(img), s(icon));
gtk_image_set_pixel_size(GTK_IMAGE(img), size); gtk_image_set_pixel_size(GTK_IMAGE(img), size);
return img; return img;
} }
MOONBIT_FFI_EXPORT void mm_gtk_image_set_icon(GtkWidget *img, MOONBIT_FFI_EXPORT void mm_gtk_image_set_icon(GtkWidget *img,
moonbit_bytes_t icon) { moonbit_bytes_t icon) {
gtk_image_set_from_icon_name(GTK_IMAGE(img), s(icon)); image_apply_icon(GTK_IMAGE(img), s(icon));
}
MOONBIT_FFI_EXPORT void mm_gtk_image_set_pixel_size(GtkWidget *img,
int32_t size) {
gtk_image_set_pixel_size(GTK_IMAGE(img), size);
} }
static void on_value_changed(GtkRange *r, gpointer d) { static void on_value_changed(GtkRange *r, gpointer d) {
@@ -642,6 +739,11 @@ MOONBIT_FFI_EXPORT void mm_gtk_widget_add_css_class(GtkWidget *w,
gtk_widget_add_css_class(w, s(cls)); gtk_widget_add_css_class(w, s(cls));
} }
MOONBIT_FFI_EXPORT void mm_gtk_widget_remove_css_class(GtkWidget *w,
moonbit_bytes_t cls) {
gtk_widget_remove_css_class(w, s(cls));
}
MOONBIT_FFI_EXPORT void mm_gtk_widget_set_visible(GtkWidget *w, int32_t v) { MOONBIT_FFI_EXPORT void mm_gtk_widget_set_visible(GtkWidget *w, int32_t v) {
gtk_widget_set_visible(w, v != 0); gtk_widget_set_visible(w, v != 0);
} }
@@ -654,6 +756,14 @@ MOONBIT_FFI_EXPORT void mm_gtk_widget_set_valign_center(GtkWidget *w) {
gtk_widget_set_valign(w, GTK_ALIGN_CENTER); gtk_widget_set_valign(w, GTK_ALIGN_CENTER);
} }
MOONBIT_FFI_EXPORT void mm_gtk_widget_set_halign_center(GtkWidget *w) {
gtk_widget_set_halign(w, GTK_ALIGN_CENTER);
}
MOONBIT_FFI_EXPORT void mm_gtk_widget_set_vexpand(GtkWidget *w, int32_t v) {
gtk_widget_set_vexpand(w, v != 0);
}
/* ---- headless screenshots ------------------------------------------------ */ /* ---- headless screenshots ------------------------------------------------ */
/* Render a realized widget (usually the window) to a PNG via GSK, without /* Render a realized widget (usually the window) to a PNG via GSK, without
+4
View File
@@ -71,22 +71,26 @@ pub fn Widget::append(Self, Self) -> Unit
pub fn Widget::append_page(Self, Self, String, icon? : String) -> Unit pub fn Widget::append_page(Self, Self, String, icon? : String) -> Unit
pub fn Widget::present(Self) -> Unit pub fn Widget::present(Self) -> Unit
pub fn Widget::remove(Self, Self) -> Unit pub fn Widget::remove(Self, Self) -> Unit
pub fn Widget::remove_css_class(Self, String) -> Unit
pub fn Widget::reorder_after(Self, Self, Self?) -> Unit pub fn Widget::reorder_after(Self, Self, Self?) -> Unit
pub fn Widget::save_png(Self, String) -> Bool pub fn Widget::save_png(Self, String) -> Bool
pub fn Widget::set_active(Self, Bool) -> Unit pub fn Widget::set_active(Self, Bool) -> Unit
pub fn Widget::set_button_icon(Self, String) -> Unit pub fn Widget::set_button_icon(Self, String) -> Unit
pub fn Widget::set_child(Self, Self) -> Unit pub fn Widget::set_child(Self, Self) -> Unit
pub fn Widget::set_halign_center(Self) -> Unit
pub fn Widget::set_hexpand(Self, Bool) -> Unit pub fn Widget::set_hexpand(Self, Bool) -> Unit
pub fn Widget::set_icon(Self, String) -> Unit pub fn Widget::set_icon(Self, String) -> Unit
pub fn Widget::set_items(Self, Array[String], Int32) -> Unit pub fn Widget::set_items(Self, Array[String], Int32) -> Unit
pub fn Widget::set_level(Self, Double) -> Unit pub fn Widget::set_level(Self, Double) -> Unit
pub fn Widget::set_margins(Self, Int32) -> Unit pub fn Widget::set_margins(Self, Int32) -> Unit
pub fn Widget::set_page(Self, Int32) -> Unit pub fn Widget::set_page(Self, Int32) -> Unit
pub fn Widget::set_pixel_size(Self, Int32) -> Unit
pub fn Widget::set_sensitive(Self, Bool) -> Unit pub fn Widget::set_sensitive(Self, Bool) -> Unit
pub fn Widget::set_text(Self, String) -> Unit pub fn Widget::set_text(Self, String) -> Unit
pub fn Widget::set_tooltip(Self, String) -> Unit pub fn Widget::set_tooltip(Self, String) -> Unit
pub fn Widget::set_valign_center(Self) -> Unit pub fn Widget::set_valign_center(Self) -> Unit
pub fn Widget::set_value(Self, Double) -> Unit pub fn Widget::set_value(Self, Double) -> Unit
pub fn Widget::set_vexpand(Self, Bool) -> Unit
pub fn Widget::set_visible(Self, Bool) -> Unit pub fn Widget::set_visible(Self, Bool) -> Unit
pub fn Widget::set_width_chars(Self, Int32) -> Unit pub fn Widget::set_width_chars(Self, Int32) -> Unit
pub fn Widget::value(Self) -> Double pub fn Widget::value(Self) -> Double
+1
View File
@@ -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.left > tabs > tab:checked { box-shadow: inset -4px 0 \{bg}; }",
"notebook > header.right > 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}; }", "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}; }", "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}; }", "row:selected, .view:selected { background-color: \{bg}; color: \{fg}; }",
"link, button.link { color: \{text}; }", "link, button.link { color: \{text}; }",
+1
View File
@@ -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("levelbar > trough > block.high"))
assert_true(css.contains("tab:checked { box-shadow: inset 0 -4px #ff7800; }")) assert_true(css.contains("tab:checked { box-shadow: inset 0 -4px #ff7800; }"))
assert_true(css.contains("button.mm-default:checked")) 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. // The text colour is the darkened accent, not the raw one.
let text = @model.accent_text_color(hex("#ff7800"), false).to_hex() let text = @model.accent_text_color(hex("#ff7800"), false).to_hex()
assert_true(text != "#ff7800") assert_true(text != "#ff7800")
+209 -31
View File
@@ -5,16 +5,21 @@
// //
// Chain entries starting with `APP_LOOKUP_PREFIX` ("app:<key>") ask the GUI // 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 // 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] { 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] { 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 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. /// "Default" toggle: first icon the theme has.
pub fn default_button_icons() -> Array[String] { 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 { pub fn form_factor_icon(form_factor : String, kind : NodeKind) -> String {
match form_factor { match form_factor {
"headphone" => "audio-headphones" "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] { pub fn device_icon_chain(n : Node) -> Array[String] {
let kind = n.kind() let kind = n.kind()
let out : Array[String] = [] 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 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) 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"]) || has_any(n.description, ["webcam", "camera"]) ||
(bus == "usb" && n.description.to_lower().contains("cam")) (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") push_symbolic_first(out, "camera-web")
} }
match (bus, kind) { match (bus, kind) {
@@ -133,12 +236,10 @@ pub fn device_icon_chain(n : Node) -> Array[String] {
("bluetooth", _) => push_symbolic_first(out, "audio-headphones") ("bluetooth", _) => push_symbolic_first(out, "audio-headphones")
_ => () _ => ()
} }
// 3. by direction
match kind { match kind {
Source => push_symbolic_first(out, "audio-input-microphone") Source => push_symbolic_first(out, "audio-input-microphone")
_ => push_symbolic_first(out, "audio-speakers") _ => push_symbolic_first(out, "audio-speakers")
} }
// 4. generic cards, then the placeholder
for f in icon_fallback_device() { for f in icon_fallback_device() {
push_unique(out, f) 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 /// Icon chain for an application stream: prefer real full-colour host app
/// launcher's icon from the installed .desktop files, names derived from the /// icons first (non-symbolic hints, .desktop lookup, direct binary/app_id),
/// binary / app name, then generic ones. /// then any symbolic hints, then crisp bundled fallbacks.
pub fn stream_icon_chain(n : Node) -> Array[String] { pub fn stream_icon_chain(n : Node) -> Array[String] {
let out : Array[String] = [] let out : Array[String] = []
// 1. Non-symbolic icon hints (including absolute file paths).
for h in n.icon_hints { 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) 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] { for key in [n.app_id, n.app_binary, n.app_name] {
if key != "" { if key != "" {
push_unique(out, APP_LOOKUP_PREFIX + 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()] { 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 != "" &&
if key != "" && !key.contains(" ") && !key.contains("/") { !key.contains(" ") &&
!key.contains("/") &&
!key.has_suffix("-symbolic") {
push_unique(out, key) 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 { 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() { for f in icon_fallback_stream() {
push_unique(out, f) push_unique(out, f)
} }
if n.kind() is RecordStream {
push_unique(out, "audio-input-microphone-symbolic")
}
push_unique(out, ICON_MISSING) push_unique(out, ICON_MISSING)
out 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. /// Speaker icon for a volume (linked percent, 100 = 0 dB) and mute state.
pub fn volume_icon(percent : Double, mute : Bool) -> String { pub fn volume_icon(percent : Double, mute : Bool) -> String {
if mute || percent <= 0.0 { if mute || percent <= 0.0 {
"audio-volume-muted-symbolic" "moonmix-volume-muted-symbolic"
} else if percent < 34.0 { } else if percent < 34.0 {
"audio-volume-low-symbolic" "moonmix-volume-low-symbolic"
} else if percent < 67.0 { } else if percent < 67.0 {
"audio-volume-medium-symbolic" "moonmix-volume-medium-symbolic"
} else { } 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. /// Small symbolic icon next to a tab's label.
pub fn Tab::icon(self : Tab) -> String { pub fn Tab::icon(self : Tab) -> String {
match self { match self {
Playback | OutputDevices => "audio-speakers-symbolic" Playback => "moonmix-tab-playback-symbolic"
Recording | InputDevices => "audio-input-microphone-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
View File
@@ -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( let c = @model.device_icon_chain(
dev("Audio/Sink", hints=["audio-card-pci"], form_factor="headphone"), dev("Audio/Sink", hints=["audio-card-pci"], form_factor="headphone"),
) )
assert_eq(c[0], "audio-card-pci-symbolic") assert_eq(c[0], "moonmix-device-headphones-symbolic")
assert_eq(c[1], "audio-card-pci") assert_true(c.contains("audio-card-pci-symbolic"))
assert_eq(c[2], "audio-headphones-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) { let first = fn(ff, cls) {
@model.device_icon_chain(dev(cls, form_factor=ff))[0] @model.device_icon_chain(dev(cls, form_factor=ff))[0]
} }
assert_eq(first("headset", "Audio/Sink"), "audio-headset-symbolic") assert_eq(first("headset", "Audio/Sink"), "moonmix-device-headset-symbolic")
assert_eq(first("speaker", "Audio/Sink"), "audio-speakers-symbolic")
assert_eq( assert_eq(
first("microphone", "Audio/Source"), first("headphone", "Audio/Sink"),
"audio-input-microphone-symbolic", "moonmix-device-headphones-symbolic",
) )
assert_eq(first("webcam", "Audio/Source"), "camera-web-symbolic") assert_eq(first("speaker", "Audio/Sink"), "moonmix-device-speaker-symbolic")
assert_eq(first("handset", "Audio/Sink"), "phone-symbolic") assert_eq(first("hifi", "Audio/Sink"), "moonmix-device-speaker-symbolic")
assert_eq(first("tv", "Audio/Sink"), "video-display-symbolic") assert_eq(first("microphone", "Audio/Source"), "moonmix-device-mic-symbolic")
assert_eq(first("car", "Audio/Source"), "audio-input-microphone-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( let hdmi = @model.device_icon_chain(
dev( dev(
"Audio/Sink", "Audio/Sink",
@@ -54,7 +61,8 @@ test "hdmi, webcam and bluetooth heuristics" {
description="HDMI / DisplayPort", 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( let cam = @model.device_icon_chain(
dev( dev(
"Audio/Source", "Audio/Source",
@@ -62,61 +70,106 @@ test "hdmi, webcam and bluetooth heuristics" {
description="EMEET SmartCam C960 Mono", 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( let bt = @model.device_icon_chain(
dev("Audio/Sink", name="bluez_output.AA_BB.1"), dev("Audio/Sink", name="bluez_output.AA_BB.1"),
) )
assert_eq(bt[0], "audio-headphones-symbolic") assert_eq(bt[0], "moonmix-device-bluetooth-symbolic")
assert_eq( assert_true(bt.contains("audio-headphones-symbolic"))
@model.device_bus(dev("Audio/Sink", name="alsa_output.usb-X.analog-stereo")), let usb = @model.device_icon_chain(
"usb", 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")) let c = @model.device_icon_chain(dev("Audio/Sink"))
assert_eq(c, [ assert_eq(c[0], "moonmix-device-speaker-symbolic")
"audio-speakers-symbolic", "audio-speakers", "audio-card-symbolic", "audio-x-generic-symbolic", assert_true(c.contains("moonmix-device-audio-symbolic"))
"image-missing", 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")) 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") 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( let n = @model.Node::new(
9, 9,
"Stream/Output/Audio", "Stream/Output/Audio",
app_name="Firefox", app_name="Firefox",
app_binary="firefox", app_binary="firefox",
app_id="org.mozilla.firefox", app_id="org.mozilla.firefox",
icon_hints=["firefox-esr"], icon_hints=["applications-multimedia-symbolic", "firefox-esr"],
) )
assert_eq(@model.stream_icon_chain(n), [ assert_eq(@model.stream_icon_chain(n), [
"firefox-esr", "app:org.mozilla.firefox", "app:firefox", "app:Firefox", "org.mozilla.firefox", "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") let with_path = @model.Node::new(
assert_eq(@model.stream_icon_chain(bare), [ 11,
"audio-input-microphone-symbolic", "application-x-executable-symbolic", "audio-x-generic-symbolic", "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", "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" { test "volume icon and chain follow volume and mute" {
assert_eq(@model.volume_icon(100.0, false), "audio-volume-high-symbolic") assert_eq(@model.volume_icon(100.0, false), "moonmix-volume-high-symbolic")
assert_eq(@model.volume_icon(50.0, false), "audio-volume-medium-symbolic") assert_eq(@model.volume_icon(50.0, false), "moonmix-volume-medium-symbolic")
assert_eq(@model.volume_icon(10.0, false), "audio-volume-low-symbolic") assert_eq(@model.volume_icon(10.0, false), "moonmix-volume-low-symbolic")
assert_eq(@model.volume_icon(0.0, false), "audio-volume-muted-symbolic") assert_eq(@model.volume_icon(0.0, false), "moonmix-volume-muted-symbolic")
assert_eq(@model.volume_icon(100.0, true), "audio-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" { test "default button, tab icons, and symbolic check" {
assert_eq(@model.Tab::Playback.icon(), "audio-speakers-symbolic") assert_eq(@model.default_button_icons(), [
assert_eq(@model.Tab::InputDevices.icon(), "audio-input-microphone-symbolic") "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"))
} }
+9
View File
@@ -8,6 +8,8 @@ import {
// Values // Values
pub const APP_LOOKUP_PREFIX : String = "app:" pub const APP_LOOKUP_PREFIX : String = "app:"
pub const FILE_ICON_PREFIX : String = "file:"
pub const ICON_MISSING : String = "image-missing" pub const ICON_MISSING : String = "image-missing"
pub const MAX_PERCENT : Double = 150.0 pub const MAX_PERCENT : Double = 150.0
@@ -26,6 +28,8 @@ pub fn accent_text_color(Rgb, Bool) -> Rgb
pub let black : Rgb pub let black : Rgb
pub fn bundled_form_factor_icon(String, NodeKind) -> String
pub fn clamp_percent(Double) -> Double pub fn clamp_percent(Double) -> Double
pub fn compare_text(String, String) -> Int32 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 icon_fallback_stream() -> Array[String]
pub fn is_symbolic_icon(String) -> Bool
pub fn linear_to_db(Double) -> Double? pub fn linear_to_db(Double) -> Double?
pub fn linear_to_percent(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(Double, Bool) -> String
pub fn volume_icon_chain(Double, Bool) -> Array[String]
pub let white : Rgb pub let white : Rgb
pub fn window_bg(Bool) -> Rgb pub fn window_bg(Bool) -> Rgb
@@ -212,6 +220,7 @@ pub(all) enum Tab {
pub fn Tab::all() -> Array[Self] pub fn Tab::all() -> Array[Self]
pub fn Tab::empty_text(Self) -> String pub fn Tab::empty_text(Self) -> String
pub fn Tab::icon(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::label(Self) -> String
pub fn Tab::node_kind(Self) -> NodeKind pub fn Tab::node_kind(Self) -> NodeKind
+2 -2
View File
@@ -33,8 +33,8 @@ test "device rows" {
assert_eq(ins.length(), 1) assert_eq(ins.length(), 1)
assert_true(ins[0].mute) assert_true(ins[0].mute)
assert_true(ins[0].is_default) assert_true(ins[0].is_default)
assert_eq(ins[0].icons[0], "audio-input-microphone-symbolic") assert_eq(ins[0].icons[0], "moonmix-device-mic-symbolic")
assert_eq(ins[0].volume_icon, "audio-volume-muted-symbolic") assert_eq(ins[0].volume_icon, "moonmix-volume-muted-symbolic")
} }
///| ///|
+61
View File
@@ -45,4 +45,65 @@ else
set -- "$@" --env DBUS_SESSION_BUS_ADDRESS=unix:path=/run/moonmix/no-bus set -- "$@" --env DBUS_SESSION_BUS_ADDRESS=unix:path=/run/moonmix/no-bus
fi fi
# Mount only existing host icon / .desktop directories read-only so GIO and
# GtkIconTheme can resolve real full-colour host app icons without exposing $HOME.
host_root=${MOONMIX_HOST_ROOT:-}
if [ -n "${XDG_DATA_HOME:-}" ]; then
data_home=$XDG_DATA_HOME
elif [ -n "${HOME:-}" ]; then
data_home=$HOME/.local/share
else
data_home=
fi
host_xdg_dirs=
add_xdg_prefix() {
case ":$host_xdg_dirs:" in
*":$1:"*) ;;
*) host_xdg_dirs=${host_xdg_dirs:+$host_xdg_dirs:}$1 ;;
esac
}
if [ -n "$data_home" ]; then
if [ -d "$data_home/icons" ]; then
set -- "$@" --mount "type=bind,src=$data_home/icons,dst=/run/moonmix/host/user/icons,ro"
add_xdg_prefix /run/moonmix/host/user
fi
if [ -d "$data_home/applications" ]; then
set -- "$@" --mount "type=bind,src=$data_home/applications,dst=/run/moonmix/host/user/applications,ro"
add_xdg_prefix /run/moonmix/host/user
fi
if [ -d "$data_home/flatpak/exports/share/icons" ]; then
set -- "$@" --mount "type=bind,src=$data_home/flatpak/exports/share/icons,dst=/run/moonmix/host/flatpak-user/icons,ro"
add_xdg_prefix /run/moonmix/host/flatpak-user
fi
if [ -d "$data_home/flatpak/exports/share/applications" ]; then
set -- "$@" --mount "type=bind,src=$data_home/flatpak/exports/share/applications,dst=/run/moonmix/host/flatpak-user/applications,ro"
add_xdg_prefix /run/moonmix/host/flatpak-user
fi
fi
if [ -d "$host_root/var/lib/flatpak/exports/share/icons" ]; then
set -- "$@" --mount "type=bind,src=$host_root/var/lib/flatpak/exports/share/icons,dst=/run/moonmix/host/flatpak-sys/icons,ro"
add_xdg_prefix /run/moonmix/host/flatpak-sys
fi
if [ -d "$host_root/var/lib/flatpak/exports/share/applications" ]; then
set -- "$@" --mount "type=bind,src=$host_root/var/lib/flatpak/exports/share/applications,dst=/run/moonmix/host/flatpak-sys/applications,ro"
add_xdg_prefix /run/moonmix/host/flatpak-sys
fi
if [ -d "$host_root/usr/share/icons" ]; then
set -- "$@" --mount "type=bind,src=$host_root/usr/share/icons,dst=/run/moonmix/host/usr/icons,ro"
add_xdg_prefix /run/moonmix/host/usr
fi
if [ -d "$host_root/usr/share/pixmaps" ]; then
set -- "$@" --mount "type=bind,src=$host_root/usr/share/pixmaps,dst=/run/moonmix/host/usr/pixmaps,ro"
add_xdg_prefix /run/moonmix/host/usr
fi
if [ -d "$host_root/usr/share/applications" ]; then
set -- "$@" --mount "type=bind,src=$host_root/usr/share/applications,dst=/run/moonmix/host/usr/applications,ro"
add_xdg_prefix /run/moonmix/host/usr
fi
set -- "$@" --env "XDG_DATA_DIRS=${host_xdg_dirs:+$host_xdg_dirs:}/usr/local/share:/usr/share"
exec "$@" "${MOONMIX_IMAGE:-localhost/moonmix:latest}" exec "$@" "${MOONMIX_IMAGE:-localhost/moonmix:latest}"
+32 -3
View File
@@ -90,10 +90,39 @@ DATA=23040000
{ printf 'RIFF'; le32 $((DATA + 36)); printf 'WAVEfmt '; le32 16 { printf 'RIFF'; le32 $((DATA + 36)); printf 'WAVEfmt '; le32 16
printf '\001\000\002\000'; le32 48000; le32 192000; printf '\004\000\020\000' printf '\001\000\002\000'; le32 48000; le32 192000; printf '\004\000\020\000'
printf 'data'; le32 $DATA; head -c $DATA /dev/urandom; } > "$LOGS/noise.wav" printf 'data'; le32 $DATA; head -c $DATA /dev/urandom; } > "$LOGS/noise.wav"
{ pw-play -P '{ application.name = "Test Player" application.icon-name = "applications-multimedia-symbolic" media.name = "Smoke test tone" }' \ # Synthetic desktop app with a full-colour icon so we verify .desktop lookup
# alongside unmapped stream fallbacks.
TEST_XDG="$XDG_RUNTIME_DIR/xdg-data"
mkdir -p "$TEST_XDG/icons/hicolor/scalable/apps" "$TEST_XDG/applications"
cat > "$TEST_XDG/icons/hicolor/scalable/apps/org.example.TestPlayer.svg" <<'SVG'
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48">
<defs>
<linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stop-color="#3b82f6"/>
<stop offset="1" stop-color="#8b5cf6"/>
</linearGradient>
</defs>
<rect x="2" y="2" width="44" height="44" rx="12" fill="url(#g)"/>
<path d="M31 30V13a1.5 1.5 0 0 0-1.9-1.44l-11 3.2A1.5 1.5 0 0 0 17 16.2V33" fill="none" stroke="#ffffff" stroke-width="2.8" stroke-linecap="round" stroke-linejoin="round"/>
<circle cx="27.5" cy="30" r="3.5" fill="#ffffff"/>
<circle cx="13.5" cy="33" r="3.5" fill="#ffffff"/>
</svg>
SVG
cat > "$TEST_XDG/applications/org.example.TestPlayer.desktop" <<'DESK'
[Desktop Entry]
Type=Application
Name=Test Player
Exec=pw-play
Icon=org.example.TestPlayer
DESK
{ pw-play -P '{ application.name = "Test Player" application.id = "org.example.TestPlayer" media.name = "Smoke test tone" }' \
"$LOGS/noise.wav"; echo "pw-play exited with $?"; } >"$LOGS/play.log" 2>&1 & PIDS="$PIDS $!" "$LOGS/noise.wav"; echo "pw-play exited with $?"; } >"$LOGS/play.log" 2>&1 & PIDS="$PIDS $!"
{ pw-play -P '{ application.name = "Fallback Stream" media.name = "Unmapped app stream" }' \
"$LOGS/noise.wav"; echo "pw-play fallback exited with $?"; } >"$LOGS/play-fallback.log" 2>&1 & PIDS="$PIDS $!"
pw-cat --record --raw --rate 48000 --channels 1 --format s16 \ pw-cat --record --raw --rate 48000 --channels 1 --format s16 \
-P '{ application.name = "Test Recorder" application.icon-name = "audio-input-microphone" media.name = "Mic capture" }' \ -P '{ application.name = "Test Recorder" media.name = "Mic capture" }' \
/dev/null >"$LOGS/record.log" 2>&1 & PIDS="$PIDS $!" /dev/null >"$LOGS/record.log" 2>&1 & PIDS="$PIDS $!"
wait_for 'Test Player | .*-> ' || true wait_for 'Test Player | .*-> ' || true
@@ -157,7 +186,7 @@ if [ -n "$SHOTS" ] && [ -x "$GUI" ]; then
if command -v gtk4-broadwayd >/dev/null; then if command -v gtk4-broadwayd >/dev/null; then
gtk4-broadwayd :5 >/dev/null 2>&1 & PIDS="$PIDS $!" gtk4-broadwayd :5 >/dev/null 2>&1 & PIDS="$PIDS $!"
sleep 1 sleep 1
gui() { MOONMIX_ICON_DIR="$ROOT/data/icons" GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 timeout 30 stdbuf -oL "$GUI"; } gui() { XDG_DATA_DIRS="$TEST_XDG:${XDG_DATA_DIRS:-/usr/local/share:/usr/share}" MOONMIX_ICON_DIR="$ROOT/data/icons" GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 timeout 30 stdbuf -oL "$GUI"; }
# Default look: no session bus, so no portal and the theme's own accent. # Default look: no session bus, so no portal and the theme's own accent.
DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/no-bus" MOONMIX_SCREENSHOT="$SHOTS" gui || fail=1 DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/no-bus" MOONMIX_SCREENSHOT="$SHOTS" gui || fail=1
# System accent: a fake org.freedesktop.portal.Settings on a private # System accent: a fake org.freedesktop.portal.Settings on a private
+80 -1
View File
@@ -34,13 +34,25 @@ class ContainerTests(unittest.TestCase):
program = bin_dir / name program = bin_dir / name
program.write_text("#!/bin/sh\n" + body) program.write_text("#!/bin/sh\n" + body)
program.chmod(0o755) program.chmod(0o755)
self.host = self.directory / "host"
self.host.mkdir()
self.empty_home = self.directory / "empty-home"
self.empty_home.mkdir()
self.environment = dict(os.environ) self.environment = dict(os.environ)
for key in ("PIPEWIRE_RUNTIME_DIR", "PIPEWIRE_REMOTE", "MOONMIX_IMAGE"): for key in (
"PIPEWIRE_RUNTIME_DIR",
"PIPEWIRE_REMOTE",
"MOONMIX_IMAGE",
"XDG_DATA_HOME",
"MOONMIX_HOST_ROOT",
):
self.environment.pop(key, None) self.environment.pop(key, None)
self.environment.update( self.environment.update(
PATH=f"{bin_dir}:/usr/bin:/bin", PATH=f"{bin_dir}:/usr/bin:/bin",
HOME=str(self.empty_home),
XDG_RUNTIME_DIR=str(self.runtime), XDG_RUNTIME_DIR=str(self.runtime),
WAYLAND_DISPLAY="wayland-test", WAYLAND_DISPLAY="wayland-test",
MOONMIX_HOST_ROOT=str(self.host),
MOONMIX_TEST_ARGUMENTS=str(self.arguments), MOONMIX_TEST_ARGUMENTS=str(self.arguments),
) )
@@ -200,6 +212,73 @@ class ContainerTests(unittest.TestCase):
self.assertTrue(self.arguments.exists(), result.stderr) self.assertTrue(self.arguments.exists(), result.stderr)
self.assertEqual(self.podman_arguments()[-1], "localhost/moonmix:latest") self.assertEqual(self.podman_arguments()[-1], "localhost/moonmix:latest")
def env_value(self, name):
arguments = self.podman_arguments()
prefix = f"{name}="
for i, arg in enumerate(arguments):
if arg == "--env" and i + 1 < len(arguments) and arguments[i + 1].startswith(prefix):
return arguments[i + 1][len(prefix):]
self.fail(f"missing --env {name}=... in {arguments}")
def test_no_host_icon_mounts_when_directories_missing(self):
self.assertEqual(self.launch().returncode, 0)
self.assertFalse(any("/run/moonmix/host" in m for m in self.mounts()))
self.assertEqual(self.env_value("XDG_DATA_DIRS"), "/usr/local/share:/usr/share")
def test_host_icon_and_desktop_directories_are_mounted_read_only(self):
home = self.directory / "home"
secret = home / ".ssh/id_rsa"
secret.parent.mkdir(parents=True)
secret.write_text("do not mount")
data_home = self.directory / "xdg-data"
expected = [
(data_home / "icons", "/run/moonmix/host/user/icons"),
(data_home / "applications", "/run/moonmix/host/user/applications"),
(data_home / "flatpak/exports/share/icons", "/run/moonmix/host/flatpak-user/icons"),
(data_home / "flatpak/exports/share/applications", "/run/moonmix/host/flatpak-user/applications"),
(self.host / "var/lib/flatpak/exports/share/icons", "/run/moonmix/host/flatpak-sys/icons"),
(self.host / "var/lib/flatpak/exports/share/applications", "/run/moonmix/host/flatpak-sys/applications"),
(self.host / "usr/share/icons", "/run/moonmix/host/usr/icons"),
(self.host / "usr/share/pixmaps", "/run/moonmix/host/usr/pixmaps"),
(self.host / "usr/share/applications", "/run/moonmix/host/usr/applications"),
]
for path, _ in expected:
path.mkdir(parents=True)
self.environment.update(HOME=str(home), XDG_DATA_HOME=str(data_home))
result = self.launch()
self.assertEqual(result.returncode, 0, result.stderr)
mounts = self.mounts()
for src, dst in expected:
self.assertIn(f"type=bind,src={src},dst={dst},ro", mounts)
self.assertFalse(any(str(home) in m for m in mounts))
self.assertEqual(
self.env_value("XDG_DATA_DIRS"),
"/run/moonmix/host/user:/run/moonmix/host/flatpak-user:/run/moonmix/host/flatpak-sys:/run/moonmix/host/usr:/usr/local/share:/usr/share",
)
def test_partial_host_icon_mounts_and_home_fallback(self):
home = self.directory / "home-fallback"
user_icons = home / ".local/share/icons"
sys_pixmaps = self.host / "usr/share/pixmaps"
sys_apps = self.host / "usr/share/applications"
for path in (user_icons, sys_pixmaps, sys_apps):
path.mkdir(parents=True)
self.environment["HOME"] = str(home)
result = self.launch()
self.assertEqual(result.returncode, 0, result.stderr)
mounts = self.mounts()
self.assertEqual(mounts, [
f"type=bind,src={self.runtime}/wayland-test,dst=/run/moonmix/wayland-0,ro",
f"type=bind,src={self.runtime}/pipewire-0,dst=/run/moonmix/pipewire-0,ro",
f"type=bind,src={user_icons},dst=/run/moonmix/host/user/icons,ro",
f"type=bind,src={sys_pixmaps},dst=/run/moonmix/host/usr/pixmaps,ro",
f"type=bind,src={sys_apps},dst=/run/moonmix/host/usr/applications,ro",
])
self.assertEqual(
self.env_value("XDG_DATA_DIRS"),
"/run/moonmix/host/user:/run/moonmix/host/usr:/usr/local/share:/usr/share",
)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()