Manage folders from the sidebar: rename, recolour, delete #6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
Sessions live in folders, one level deep. Folders are created with
Ctrl+Shift+Dor the New menu (
win.folder-newincrates/terminalko/src/window.rs), and thesidebar renders each as an
adw::SidebarSectionwith the folder's name as itstitle (
rebuild_sidebar).The model already supports everything needed
(
crates/terminalko-config/src/session.rs):Folder::set_nameFolder::set_colourStore::delete_folder(id, keep_sessions)delete_folderis covered by two tests. Nothing in the UI calls any of them.The gap
A folder can be created and then never changed: no rename, no colour, no delete.
A typo in a folder name is permanent, and an unwanted folder cannot be removed.
Approach
adw::SidebarSection::set_menu_modelexists, so each section can carry its ownmenu — and because the menu is built per section, the folder's id can be baked
into the action targets. That avoids the problem
AdwSidebarotherwise has:connect_setup_menuhands over aSidebarItem, never a section, so there is noother way to know which folder was clicked.
In
rebuild_sidebar, where each section is built:with window actions taking the folder id as a string parameter:
win.folder-rename(id)— the same prompt dialogrename_sessionuseswin.folder-colour(id, colour)— a submenu likecolour_menu(); note thisneeds two values, so either use a single string such as
"id/colour"(assession-new-containeralready does forruntime/name) or a tuple variantwin.folder-delete(id)— must ask, and must ask which: deleting a folderwith sessions in it is two different operations. An
AdwAlertDialogwith threeresponses (Cancel / Keep sessions / Delete sessions) maps onto
delete_folder(id, keep_sessions)directlyAfter any of these, call
rebuild_sidebarandrefresh_accents— a folder'scolour is inherited by sessions that have none of their own, and open pages show
it.
Acceptance criteria
menu, and each survives restarting the application.
do what they say —
Store::delete_folderalready implements both.colour of their own, including any page open at the time.
stop it; the session becomes unfiled or is deleted, per the answer.
./build-aux/ci.shand./build-aux/smoke.shpass.docs/spec/session-sidebar.mddescribes the folder menu.Notes
CONTRIBUTING.mdbefore consulting any GPL terminal for reference.crates/terminalko-config/src/session.rs(headless,GSETTINGS_BACKEND=memory) — the model side is already covered, so most newtests belong in whatever helper builds the menu.