Skip to content

places-sidebar: Add user-defined bookmark groups - #3856

Closed
BerziOnline wants to merge 1 commit into
linuxmint:masterfrom
BerziOnline:bookmark-sidebar-groups
Closed

BerziOnline wants to merge 1 commit into
linuxmint:masterfrom
BerziOnline:bookmark-sidebar-groups

Conversation

@BerziOnline

Copy link
Copy Markdown

Summary

Adds user-defined bookmark groups to the Places sidebar. Users can create their own sidebar sections (e.g. "LAN" for network mounts, "Work" for project folders) and move bookmarks into them via the context menu or by drag and drop. Without any groups the sidebar looks and behaves exactly as before.

Related: #2489 ("Customize Sidebar - allow adding Groups", closed as stale without a decision).

Motivation

With several network mounts (cifs/sshfs via fstab) and work folders, the single "Bookmarks" section becomes long and mixed. Grouping them keeps the sidebar readable, similar to how "My Computer", "Bookmarks", "Devices" and "Network" are already separated.

Behaviour

  • Right-click a bookmark or a group heading → New group…, Rename group…, Delete group.
    Deleting a group never deletes bookmarks or files; its bookmarks return to "Bookmarks".
  • Right-click a bookmark → Move to group ▸ (choosing "Bookmarks" removes the assignment).
  • Drag a bookmark onto a group heading to move it there; drop above/below a bookmark inside a group to reorder.
  • Groups appear between "Bookmarks" and "Devices" and can be collapsed; the collapsed state is persisted.
  • No groups file → unchanged sidebar.

Storage and compatibility

  • The bookmarks themselves stay in the GTK bookmarks file (~/.config/gtk-3.0/bookmarks), so GTK file choosers and other applications keep seeing the normal flat list.
  • Nemo stores only its own metadata in ~/.config/nemo/bookmark-groups (GKeyFile): group order, display names, member URIs in order, collapsed state.
  • Assignments of bookmarks that are removed are pruned, but only after the bookmarks file was read completely and validly, so a missing or half-written bookmarks file never wipes the groups.

What changed where

File Change
src/nemo-bookmark-groups.{c,h} (new, GLib only) Small model for the groups file: load/save (g_key_file_save_to_file, which writes atomically), get_ids, create, rename, delete, find (group of a URI), move (assign/reorder a URI, incl. "before" position; moving an item before itself is a no-op), prune (drop URIs that are no longer bookmarks). No GTK dependency, so it is unit-testable.
src/nemo-places-sidebar.c New column PLACES_SIDEBAR_COLUMN_GROUP_ID and section type SECTION_BOOKMARK_GROUP.
update_places(): loads the groups file, leaves grouped bookmarks out of the normal "Bookmarks" section and renders one heading per group via the new add_bookmark_groups() (between Bookmarks and Devices).
Context menus: append_group_menu() / group_menu_activate() add New/Rename/Delete and "Move to group"; group headings get their own menu in bookmarks_button_press_event_cb(); group items are removed again from the shared popup so they never leak into device/network menus.
Drag and drop: get_drag_type() and compute_drop_position() accept group rows/headings as targets; the source row is resolved from the drag data (get_drag_source_iter()), not from the selection; reorder_group_bookmark() updates the groups file for moves into, within and out of groups.
Expand/collapse: update_expanded_state() / restore_expand_state_foreach() persist the per-group collapsed state.
groups_changed_cb(): a directory monitor on ~/.config/nemo/ refreshes the sidebar when the file changes, including atomic renames (other_file).
src/nemo-bookmark-list.c prune_bookmark_groups() is called after deleting bookmarks and after loading the list; load_files_thread() marks a load as authoritative only if the file was read and is valid UTF-8 with valid URIs.
src/meson.build Adds the new source file to nemoCommon_sources and to nemo-connect-server, which also compiles nemo-bookmark-list.c.
test/test-bookmark-groups.c, test/meson.build Unit tests (GLib test framework): create/rename/delete, move incl. reordering and "move before itself", pruning, load/save round trip.

New user-visible strings use _(); no po/ changes are included (translations go through Launchpad).

Testing

  • Built and tested on Linux Mint 22.3 (zena) against the 6.6.3 tag, packaged as a local .deb, installed and used on a real Cinnamon desktop; rollback to the stock package verified.
  • meson test "Bookmark groups": all tests pass. This branch is rebased onto current master (e5b6cfc) and builds there without warnings; the two conflicts were in bookmarks_button_press_event_cb() (now uses GDK_BUTTON_SECONDARY/GDK_BUTTON_MIDDLE) and test/meson.build.
  • Headless UI test under Xvfb with the packaged build: groups rendered, context menus (bookmark and device menu), drag and drop between groups, external atomic rewrite of the groups file, missing/invalid bookmarks file keeps assignments, deleted bookmark is pruned, original layout without groups file — all passed.

Notes

  • Drag and drop is limited to the sidebar itself (GTK_TARGET_SAME_WIDGET), as for the existing bookmark reordering. Reordering whole groups by drag and drop is not part of this PR.
  • This change was developed with the help of an AI coding assistant and reviewed and tested by me, including an independent review pass. Happy to adjust anything to fit the project's preferences.

Users can create, rename and delete groups in the Places sidebar and move
bookmarks into them via a context submenu or drag and drop. Bookmarks stay
in the GTK bookmarks file; Nemo stores only the group membership, order and
collapsed state in ~/.config/nemo/bookmark-groups (GKeyFile). Without that
file the sidebar is unchanged.

Related: linuxmint#2489
@mtwebster

Copy link
Copy Markdown
Member

No thanks, we think the current sidebar behavior is sufficient - you can drag bookmarks between the Computer and Bookmarks section also.

@mtwebster mtwebster closed this Oct 12, 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.

2 participants