From ab986e3d9fcaf9fb033a45a21415139923ea8c83 Mon Sep 17 00:00:00 2001 From: diviocity Date: Sun, 1 Nov 2026 19:04:14 +0100 Subject: [PATCH] properly handle -d no_png_icons --- libvendetta/draw.v | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/libvendetta/draw.v b/libvendetta/draw.v index f0ccbe3..63e9b2e 100644 --- a/libvendetta/draw.v +++ b/libvendetta/draw.v @@ -823,6 +823,22 @@ fn icon_bundle_dirs() []string { ] } +// bundled_icon is the path of a PNG in assets/icons, or '' where the layout +// ships none or the build compiled the icons out. +pub fn bundled_icon(name string) string { + $if no_png_icons ? { + return '' + } $else { + for dir_path in icon_bundle_dirs() { + bundle_path := os.join_path(dir_path, name + '.png') + if os.is_file(bundle_path) { + return bundle_path + } + } + return '' + } +} + // resolve_strip_icons maps the icon roles to what the strip's buttons draw: // each bundled PNG's path, or '' where this layout has none (the buttons then // fall to the glyphs). `-d no_png_icons` compiles the resolution out entirely, @@ -833,14 +849,7 @@ fn resolve_strip_icons() map[string]string { return icons } $else { for name in strip_icon_names { - icons[name] = '' - for dir_path in icon_bundle_dirs() { - bundle_path := os.join_path(dir_path, name + '.png') - if os.is_file(bundle_path) { - icons[name] = bundle_path - break - } - } + icons[name] = bundled_icon(name) } return icons } -- 2.56.1