Skip to content

Keep the card on an empty section of the applications page - #242

Open
kacperpaczos wants to merge 3 commits into
Dvlv:masterfrom
kacperpaczos:fix/empty-section-islands
Open

Keep the card on an empty section of the applications page#242
kacperpaczos wants to merge 3 commits into
Dvlv:masterfrom
kacperpaczos:fix/empty-section-islands

Conversation

@kacperpaczos

Copy link
Copy Markdown
Contributor

Stacked on #238, because the Commands section it also fixes comes from there; the other two sections are on master today and have the same problem.

A adw::PreferencesGroup with rows in it draws as a card. An empty one here called set_description(...) instead, which renders the message as bare text under the heading with no card at all. On a box that has, say, commands but no applications and no exported binaries, the result is one section sitting in an island between two that look like they failed to load rather than two that are simply empty.

The message now goes in a row inside the group - dimmed, not activatable, no suffix - so a section keeps its shape whether or not it has anything in it. The three strings are unchanged, so existing translations carry over, and nothing else about those sections moves.

empty sections keeping their card

Above: a box with one command, no applications and no exported binaries - all three sections now read the same way.

Testing

cargo test: 22 pass, unchanged - this is a presentation fix with no logic to test.

On a virtual display with a stub distrobox reporting a box that has commands but neither applications nor exported binaries, the two empty sections draw their card with the message inside. Worth noting for review: a box with nothing at all still takes the existing whole-page empty state (build_empty_state_page), which this does not touch.

BoxBuddy could export an application to the host menu, but not a command
to the host terminal, and a command that exists both on the host and in a
box could only shadow one with the other.

The Exported Binaries section gains an "Add Command…" button. The command
is resolved inside the box first; if nothing on the host answers to that
name it is a plain `distrobox-export --bin`, exactly as before. When the
host already has one - its own binary, an earlier distrobox export, or a
chooser BoxBuddy wrote before - the dialog offers to replace it with a
chooser: a small self-contained bash script in ~/.local/bin that asks, at
invocation time, which one to run.

The chooser prints a numbered menu on stderr and reads the answer from
/dev/tty, so it never eats the program's own stdin. Scripts and pipes must
not block on a prompt, so with no terminal it runs the first target
silently, and BOXBUDDY_DISPATCH=host|<box> picks one outright. Adding the
same command from another box folds that box into the existing chooser
rather than replacing it.

The file carries distrobox's own `# distrobox_binary` and `# name: <box>`
markers next to BoxBuddy's, so `distrobox-export --list-binaries` still
finds the command and `--delete` still removes it; without them distrobox
would quietly lose sight of a command it had exported. The binaries list
skips entries that are choosers so they are not listed twice.

Nothing else knows about the chooser: the file is the whole state, and it
keeps working if BoxBuddy is uninstalled.
A tool installed inside a box was invisible in BoxBuddy: the applications
list only ever enumerates `.desktop` files, and a command line tool has
none. The Applications page now has a Commands section listing what the
box itself holds, each with an "Add to Terminal" button that opens the
existing add-command dialog with the name filled in.

The scan covers `/usr/local/bin` and `/opt/*/bin`, and `$HOME/.local/bin`
only when the box has a home of its own - distrobox shares the host's home
by default, so scanning it there would list the host's own tools as though
they lived in the box. `/usr/bin` is left out: between the base image and
distrobox's first-run setup it holds hundreds of entries with nothing to
tell a user install apart from them.

The add-command dialog gains a "Name on host" field. `distrobox-export`
always keeps the command's own name, so a different one can only be a
chooser, and a chooser is now written even with nothing in the way - with
a single target it runs it without asking. This is what lets the same tool
from several boxes sit on the host as separate profiles: `claude` from two
boxes becomes `claude-work` and `claude-personal`, each entering its own
box. The generated script therefore separates the host-facing name from
the command run inside the box, and the marker records both.

docs/tips.md explains using a box's own home directory to keep an
application's settings and logins separate while the host's files stay
reachable, and the new-box form now says the same thing where the choice
is actually made.
A section of the applications page with rows in it draws as a card. An
empty one called set_description instead, which puts the message as bare
text under the heading with no card at all - so on a box with, say,
commands but no applications, one section sat in an island between two
that looked like they had failed to load.

The message now goes in a row inside the group, dimmed and not
activatable, so the section keeps its shape whether or not it has
anything in it. Same three strings as before, so translations carry over.
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.

1 participant