Show a coloured bar in the box header - #204
Open
kacperpaczos wants to merge 3 commits into
Open
Conversation
Owner
|
Hello, I like this change but it's got conflicts now, would you mind solving them please? |
…logo make_box_tab used to render a unicode dot coloured via Pango markup as the distro marker in the box header. The dot is fine for the narrow notebook tab on the left but reads weakly in the wider header where the box name, status and stop button already live. This adds two helpers to utils: - get_distro_color returns the brand colour as a CSS string, sharing the same lookup table get_distro_img was already using so the two markers can never disagree. - get_distro_icon_name maps distro short names to freedesktop icon names that the major icon themes ship (ubuntu-logo, fedora-logo, archlinux-logo, opensuse-logo, manjaro-logo, linuxmint-logo, ...). Returns None for distros we have no logo for. In make_box_tab, the old page_img label is replaced with a horizontal Box holding a 4-px rounded coloured bar (CSS background-color set via an inline CssProvider so no stylesheet file is needed) and, if the icon theme has it, a 32-px distro logo next to it. Either piece can be absent without breaking the layout - the bar is always rendered, the logo is best-effort and silently skipped if the theme does not ship it.
Every box tab registered its own CssProvider, and every provider defined the same .distro-color-bar class, so each newly built tab repainted every existing bar with its own colour - with a Fedora box and an Ubuntu box open, the Fedora bar came out Ubuntu orange. The providers were also never removed, and load_boxes runs on every refresh, so they piled up on the display for as long as the app ran. One provider now carries a class per distro, generated from the same colour table as the tab dot - which get_distro_img now genuinely shares, instead of keeping a second copy of - and is loaded into the display once. Each bar just picks its class, and an unknown distro falls back to the base black. load_from_string replaces the deprecated load_from_data while in the area.
kacperpaczos
force-pushed
the
feat/distro-color-badge
branch
from
August 22, 2026 18:31
73137f5 to
f78f1d4
Compare
The logo was looked up under names like ubuntu-logo or fedora-logo, which the common icon themes do not ship (Papirus and friends use distributor-logo-<name>); the one hit in practice is a Fedora host, where fedora-logo resolves to the wordmark in /usr/share/pixmaps and comes out squeezed to 32 px next to the title. Not worth a mapping table. The bar alone is the feature; it is appended straight into the title row now that there is nothing next to it.
kacperpaczos
force-pushed
the
feat/distro-color-badge
branch
from
August 23, 2026 08:11
b05369c to
bfee3f1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #201
Replaces the Unicode dot in the box header with a CSS-coloured bar in the distro's brand colour; an unknown distro falls back to a black bar. The tab strip keeps its dot.
Both markers draw from one colour table now (
DISTRO_COLOURSin utils), so they can't drift apart, andget_distro_imgshrank to a one-liner in the process.One implementation note worth calling out for review: the bar's CSS is loaded into the display once, behind a
std::sync::Once, with a class per distro. My first version registered a provider per box, and since every provider defined the same class, whichever box rendered last repainted every bar with its own colour — a Fedora box came out Ubuntu orange. If you ever want more per-distro styling, the generated-classes approach extends naturally.An earlier revision also tried to show a distro logo next to the bar, looked up by icon name. That's gone: the common themes don't ship those names, and the one place it resolved (a Fedora host's
fedora-logowordmark from/usr/share/pixmaps) rendered badly at 32 px — so the bar is the whole feature.Screenshot (stub
distrobox listoutput, Fedora box focused — blue bar; this capture predates dropping the logo, so ignore the small wordmark next to the bar):Testing
Verified against a stub
distroboxemitting one Fedora and one Ubuntu box: the focused Fedora tab shows the Fedora-blue bar (the last-provider bug used to turn it orange in exactly this setup). Warning, clippy andcargo fmt --checkresults are identical to master.