Add Native File Chooser Dialog integration for Nemo and XDG Desktop Portals#3786
Open
Twilight0 wants to merge 3 commits into
Open
Add Native File Chooser Dialog integration for Nemo and XDG Desktop Portals#3786Twilight0 wants to merge 3 commits into
Twilight0 wants to merge 3 commits into
Conversation
- Registered and implemented D-Bus interface org.Nemo.FileChooser to bridge XDG Desktop Portal file choosing requests. - Added custom GTK 3 nemo-file-chooser-dialog using a premium, multi-pane UI layout: * Left panel: Places sidebar showing system bookmarks, mounts, and recent paths. * Center panel: Dynamic GtkStack supporting Grid View, List View, and Compact View modes. * Right panel: Interactive preview pane detailing metadata and showing visual thumbnails. - Added dedicated header bar action buttons: * Create Folder button (symbolic icon folder-new-symbolic) placed next to navigation. * Toggle Location Entry button (symbolic icon document-edit-symbolic) to switch path navigation bar into a text path entry. * Up button (symbolic icon go-up-symbolic) placed between forward button and create folder button. - Integrated Ctrl+L shortcut to toggle path text entry mode and escape key to close it. - Implemented folder creation modal triggered via both the header button and context menu. - Kept the path entry input text dynamically synchronized with current directories during sidebar, back/forward, or list navigation. - Managed Up button sensitivity dynamically based on the existence of a parent directory (disabled at root folder /). - Implemented support for directory selection mode (SELECT_FOLDER): * Added boolean directory input argument to OpenFile D-Bus method signature. * Dynamically changes the dialog's acceptance button label to '_Select' in folder selection mode. * Filters out non-directory files to display only folders inside directory listings in SELECT_FOLDER mode. * Implemented fallback returns to choose the current directory if accept is triggered without choosing subfolders. - Implemented high-quality cached video (mp4) and image thumbnail lookup by querying the Freedesktop.org thumbnail path schema asynchronously. - Optimized zooming layout by linking Ctrl+Scroll events (supporting smooth scroll wheel inputs) to re-evaluate list store icons and adjust spacing in all view modes. - Added explicit tooltips on hover for layout toggle buttons and preserved standard scrolling. - Integrated clickable header sorting (Name, Size, Type, Modified) in List View: * Uses a custom comparison function ensuring folders are always clustered first (matching upstream Nemo behaviour). * Added Type (description lookup) and Modified (date/timestamp) columns. * Temporarily suspends sorting during directory enumeration to optimize batch inserts and prevent lag. - Enhanced List View column usability: * Made columns resizable by user dragging. * Created a right-click context menu on headers to toggle visibility of Size, Type, and Modified columns. - Implemented files area background right-click context menu: * Provides a check item for toggling hidden files (starts with dot '.'). * Provides a Sort By submenu containing radio options for Name, Size, Type, and Date Modified. * Includes Create Folder, Show in File Manager, Copy Location, Refresh, and Properties actions. * Connected Ctrl+H shortcut to toggle display of hidden files on keyboard input.
The ok_button in nemo-file-chooser-dialog.glade is configured with a response ID of -5 (GTK_RESPONSE_OK) instead of -3 (GTK_RESPONSE_ACCEPT). Update the open and save dialog response handlers in nemo-file-chooser-dbus.c to accept both GTK_RESPONSE_ACCEPT and GTK_RESPONSE_OK, ensuring that selected URIs/paths are properly returned to the portal caller when the dialog is accepted.
Allows D-Bus activation of Nemo (running in background via --no-default-window) when a client application calls the org.Nemo.FileChooser interface, removing manual daemon startup requirements.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview & Rationale
Currently, Cinnamon environments running sandboxed Flatpaks or host applications rely on basic or external file chooser portals. These defaults lack visual coherence with the rest of the Cinnamon desktop and Nemo.
This Pull Request implements a custom, fully-featured native file chooser dialog for Nemo, exported over D-Bus via the
org.Nemo.FileChooserservice. When paired with the accompanying changes inxdg-desktop-portal-xapp, this allows all application file-picking requests (from GitKraken, Web Browsers, Flatpaks, etc.) to use a premium, native-feeling Nemo file selection interface.Features Implemented
1. Unified Multi-Pane Layout
GtkPlacesSidebar), ensuring user bookmarks, network mounts, removable media, and recent paths are instantly accessible.2. Directory Selection (
SELECT_FOLDER/GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)_Selectrather than_Open./home/user/Projects/nemo) and clicks Select without highlighting a specific sub-folder, the dialog correctly falls back and returns the URI of the current folder.3. Navigation & Context Enhancements
/).Ctrl+Lshortcut. SupportsEscapeto return to breadcrumbs.Ctrl+Hto toggle hidden files andCtrl+Lto edit the location path text.4. D-Bus Daemon Integration
org.Nemo.FileChooserD-Bus XML specification to support folder selection:OpenFilemethod signature updated to(sasbbs)to accept thedirectoryboolean.nemo-file-chooser-dbus.cto accept bothGTK_RESPONSE_ACCEPT(-3) andGTK_RESPONSE_OK(-5), resolving empty return values when using the Glade-definedok_button.Testing Verification