Use real icons: per-device/app icon chains, volume icons, app icon
CI / check (pull_request) Failing after 9s
CI / native (pull_request) Successful in 1m5s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
SpriteandClaude Sonnet 5.5 committed 2026-11-23 00:43:28 +00:00
1 parent 92ae5cdbfe
commit cf8bab0d36
21 files changed
+658 -70

No files matched your search

+51 -3
View File
@@ -77,8 +77,13 @@ extern "C" fn ffi_scrolled_new(child : Widget) -> Widget = "mm_gtk_scrolled_new"
extern "C" fn ffi_notebook_new(tag : Int32) -> Widget = "mm_gtk_notebook_new"
///|
#borrow(label)
extern "C" fn ffi_notebook_append(nb : Widget, child : Widget, label : Bytes) = "mm_gtk_notebook_append"
#borrow(label, icon)
extern "C" fn ffi_notebook_append(
nb : Widget,
child : Widget,
label : Bytes,
icon : Bytes,
) = "mm_gtk_notebook_append"
///|
extern "C" fn ffi_notebook_set_page(nb : Widget, i : Int32) = "mm_gtk_notebook_set_page"
@@ -105,6 +110,14 @@ extern "C" fn ffi_image_new(icon : Bytes, size : Int32) -> Widget = "mm_gtk_imag
#borrow(icon)
extern "C" fn ffi_image_set_icon(img : Widget, icon : Bytes) = "mm_gtk_image_set_icon"
///|
#borrow(name)
extern "C" fn ffi_has_icon(name : Bytes) -> Int32 = "mm_gtk_has_icon"
///|
#borrow(key)
extern "C" fn ffi_app_icon(key : Bytes) -> Bytes = "mm_gtk_app_icon"
///|
extern "C" fn ffi_scale_new(max : Double, norm : Double, tag : Int32) -> Widget = "mm_gtk_scale_new"
@@ -339,8 +352,9 @@ pub fn Widget::append_page(
self : Widget,
child : Widget,
label : String,
icon~ : String = "",
) -> Unit {
ffi_notebook_append(self, child, cstr(label))
ffi_notebook_append(self, child, cstr(label), cstr(icon))
}
///|
@@ -476,3 +490,37 @@ pub fn Widget::set_valign_center(self : Widget) -> Unit {
pub fn Widget::save_png(self : Widget, path : String) -> Bool {
ffi_save_png(self, cstr(path)) != 0
}
///|
/// Does the current icon theme have this icon?
pub fn has_icon(name : String) -> Bool {
ffi_has_icon(cstr(name)) != 0
}
///|
/// Icon of the installed application matching `key` (desktop id, binary or
/// name) per its .desktop file, "" if there is none or the theme lacks it.
pub fn app_icon(key : String) -> String {
@utf8.decode_lossy(ffi_app_icon(cstr(key)))
}
///|
/// 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
/// entry is returned if nothing matches, so the result is never empty.
pub fn resolve_icon(chain : Array[String]) -> String {
for name in chain {
if name.has_prefix("app:") {
let icon = app_icon(name[4:].to_string())
if icon != "" {
return icon
}
} else if has_icon(name) {
return name
}
}
match chain.last() {
Some(n) => n
None => "image-missing"
}
}