Skip to content

Applications window: natural-size row buttons, menu button toggles in place - #234

Open
kacperpaczos wants to merge 2 commits into
Dvlv:masterfrom
kacperpaczos:fix/app-row-buttons
Open

Applications window: natural-size row buttons, menu button toggles in place#234
kacperpaczos wants to merge 2 commits into
Dvlv:masterfrom
kacperpaczos:fix/app-row-buttons

Conversation

@kacperpaczos

@kacperpaczos kacperpaczos commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Fixes #232, fixes #233

Two things about the rows in the applications window, in the same block of on_show_applications_clicked.

Each application is an expander row

The rows held Run, Add To Menu / Remove From Menu (and the binaries' Remove) as pill buttons with fixed width_requests and a gtk::Separator between them - stretched to the row's full height and lined up in columns, the list read as a table of oversized buttons, and the app name was squeezed into what was left (#232). Dropping the pills for natural-size buttons (first commit) turned out not to be enough: Remove From Menu is wider than Add To Menu, so neighbouring rows' buttons stopped lining up and the suffix came out ragged.

So the row stops holding buttons altogether (second commit): each application is an AdwExpanderRow that collapsed shows only the icon, the name and the arrow - every row identical, the name gets the full width, nothing to align - and what can be done with the app lives in activatable rows inside it: Run, and the menu row below. The one trade-off: running an app is now two clicks (expand, then Run) instead of one. The binaries' Remove stays a suffix button (valign: center, no pill) - it is the row's only action and is the same width in every row.

One menu row that follows the menu

Which of Add To Menu / Remove From Menu an app got was decided once, when the list was built, from whether <box>-<desktop file>.desktop existed on the host at that moment; after a click the heading said "App Exported!" but the row still offered Add To Menu until the window was reopened (#233). The action is now one row: on activation it exports or removes depending on the current state, then re-reads the host's applications directory and retitles itself from what the menu actually holds. The confirmation text is only written when that changed, so it can't say "App Exported!" when nothing was. The two old handlers collapse into toggle_app_in_menu + set_menu_row_title.

The host file name (<box>-<desktop file>.desktop, what distrobox-export writes - desktop_home_file="${container_name}-$(basename "${desktop_file}")" in distrobox-export) was assembled inline in get_apps_in_box; it is now exported_desktop_file_name, shared with the new is_app_exported, with a unit test pinning the format. All four labels are the same literal gettext strings as before, so existing translations carry over.

Before / after

Same stub data on a virtual display: four desktop files in the box, one of them (Zutty) already exported.

Before - pills stretched to the row height, separator between them, fixed widths:
before

After - a uniform list, one row per app:
after

Expanded - the app's actions as rows inside:
after expanded

Activating Add To Menu on Text Editor - the host now has second-org.gnome.TextEditor.desktop and the same row now reads Remove From Menu:
after add

…and activating it again - the file is gone and the row is back to Add To Menu:
after remove

(The faint dashes above "Exported Binaries" in the expanded shots are an artifact of the cairo software renderer the virtual display uses, not part of the change.)

Testing

  • cargo test: 6 passed (the new one pins exported_desktop_file_name to distrobox-export's naming).
  • End to end with a stub distrobox whose distrobox-export --app creates/deletes the host desktop file: the file list on disk and the row title agree after each activation, as in the captures above.
  • The Flatpak branch of the host read (ls via flatpak-spawn) is the existing get_host_desktop_files, unchanged; I only tested the native path.

One thing I did not add: if the export command fails (the file never appears), the row stays on Add To Menu and no confirmation is written - which is at least truthful, but there is no error message either. Happy to add one if you'd like it in this PR.

… place

The Run / Add To Menu / Remove buttons in the applications window carried
the pill style plus fixed width requests and a separator, so they were
stretched to the row's height and to column widths - the list read as a
table of oversized buttons, and the app name was squeezed into the space
left over. They now keep their natural size, centred in the row, like any
other suffix button in a boxed list.

Add To Menu and Remove From Menu were two separate buttons chosen once,
from whether the exported desktop file existed when the window opened, so
after a click the heading said "App Exported!" while the row still offered
Add To Menu until the window was reopened. One button now does both: after
each click it re-reads the host's applications directory and is relabelled
from what the menu actually holds, and the confirmation is only written
when that changed.

The host file name (<box>-<desktop file>.desktop, what distrobox-export
writes) is factored into one helper shared by the list and the toggle, with
a unit test pinning it.
Natural-size buttons in the row still came out ragged: Remove From Menu
is wider than Add To Menu, so neighbouring rows' Run buttons stopped
lining up and the suffix read as a jagged table. Instead of trying to
align buttons, the row stops holding them: each application is an
AdwExpanderRow that collapsed shows only the icon, the name and the
arrow - every row identical, the name gets the full width - and its
actions are activatable rows inside: Run, and the Add To Menu / Remove
From Menu row, which keeps being retitled from what the host menu
actually holds after each activation.

The binaries' Remove stays a suffix button: it is the row's only action
and is the same width in every row.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant