Skip to content

Show a coloured bar in the box header - #204

Open
kacperpaczos wants to merge 3 commits into
Dvlv:masterfrom
kacperpaczos:feat/distro-color-badge
Open

Show a coloured bar in the box header#204
kacperpaczos wants to merge 3 commits into
Dvlv:masterfrom
kacperpaczos:feat/distro-color-badge

Conversation

@kacperpaczos

@kacperpaczos kacperpaczos commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

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_COLOURS in utils), so they can't drift apart, and get_distro_img shrank 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-logo wordmark from /usr/share/pixmaps) rendered badly at 32 px — so the bar is the whole feature.

Screenshot (stub distrobox list output, Fedora box focused — blue bar; this capture predates dropping the logo, so ignore the small wordmark next to the bar):

coloured bar

Testing

Verified against a stub distrobox emitting 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 and cargo fmt --check results are identical to master.

@Dvlv

Dvlv commented Aug 22, 2026

Copy link
Copy Markdown
Owner

Hello, I like this change but it's got conflicts now, would you mind solving them please?

BoxBuddy Contributor and others added 2 commits August 22, 2026 20:12
…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.
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
kacperpaczos force-pushed the feat/distro-color-badge branch from b05369c to bfee3f1 Compare August 23, 2026 08:11
@kacperpaczos kacperpaczos changed the title Show a coloured bar and distro logo in the box header Show a coloured bar in the box header Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A coloured bar and distro logo in the box header, instead of the dot

2 participants