Allow creating new folders from directory choosers on Linux and macOS - #44
Open
amitbar05 wants to merge 2 commits into
Open
Allow creating new folders from directory choosers on Linux and macOS#44amitbar05 wants to merge 2 commits into
amitbar05 wants to merge 2 commits into
Conversation
wxDD_DIR_MUST_EXIST (and wxDirPickerCtrl's default wxDIRP_DIR_MUST_EXIST) map to gtk_file_chooser_set_create_folders(FALSE) on wxGTK and setCanCreateDirectories:NO on macOS, hiding the "New Folder" button that the Windows folder picker always shows. The flag has no other effect on a folder chooser (only an existing directory can ever be selected), so remove it for consistent behaviour across platforms. Also fix wxDirPickerCtrl constructions in full_config_dialog.cc and gpu_config_panel.h that passed wxDD_DIR_MUST_EXIST as the window ID rather than as a style. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The previous fix (1315fb2) cleared wxDIRP_DIR_MUST_EXIST on the wxDirPickerCtrl style, assuming this would propagate to the browse dialog's style like it does for a plain wxDirDialog. It doesn't: on wxGTK, wxDirPickerCtrl is backed by a native wxDirButton (wrapping GtkFileChooserButton), whose GetDialogStyle() override unconditionally ORs in wxDD_DIR_MUST_EXIST: // GtkFileChooserButton does not support GTK_FILE_CHOOSER_CREATE_FOLDER // thus we must ensure that the wxDD_DIR_MUST_EXIST style was given long GetDialogStyle() const wxOVERRIDE { return (wxGenericDirButton::GetDialogStyle() | wxDD_DIR_MUST_EXIST); } (wx/gtk/filepicker.h). So every wxDirPickerCtrl-based folder field (New Film's "Create in folder", the Preferences folder pickers, KDM/ DKDM output folders, the GPU binary location) was still stuck without a "New Folder" button, regardless of the style passed at construction. This is a structural limitation of GtkFileChooserButton, not something fixable via style flags. DCP-o-matic already has its own DirPickerCtrl (a plain button that pops a real wxDirDialog) for exactly this reason on Windows; extend DCPOMATIC_USE_OWN_PICKER to __WXGTK__ too, and wire up the two remaining native-only sites (locations_preferences_page.cc, grok/gpu_config_panel.h) that had no own-picker branch yet. macOS is untouched: wxDirPickerCtrl there falls through to wxGenericDirButton, which has no such override, so the original style-flag fix already works fine there. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Owner
|
Is this just about fixing an inconsistency between platforms? Why would you want to create a folder when you have decided to add a DCP to a project? |
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.
Problem
On Linux none of the "choose a folder" dialogs offer a way to create a new folder — e.g. File → Open, "Add DCP"/"Add folder", the New Film "Create in folder" browser, and the KDM/DKDM output folder pickers. The same applies on macOS. On Windows the native folder picker always shows a "New folder" button, so the platforms are inconsistent.
Cause
The dialogs are created with
wxDD_DIR_MUST_EXIST, and thewxDirPickerCtrls use wx's default style, which includeswxDIRP_DIR_MUST_EXIST. wxWidgets maps this flag to disabling folder creation in the native chooser:src/gtk/dirdlg.cpp):gtk_file_chooser_set_create_folders(GTK_FILE_CHOOSER(m_widget), !HasFlag(wxDD_DIR_MUST_EXIST));— this hides GTK's "Create Folder" button and the context-menu "New Folder" entry.src/osx/cocoa/dirdlg.mm):[oPanel setCanCreateDirectories:YES]only when the flag is absent.A folder chooser can only ever return an existing directory, so the flag's only practical effect is hiding the New Folder affordance on GTK and macOS.
Change (first commit)
wxDD_DIR_MUST_EXISTfrom allwxDirDialog/DirDialogcall sites (where it was the entire style, usewxDD_DEFAULT_STYLE).wxDIRP_DEFAULT_STYLE & ~wxDIRP_DIR_MUST_EXISTto thewxDirPickerCtrls (this keepswxDIRP_USE_TEXTCTRLon the platforms whose default includes it).full_config_dialog.ccandgrok/gpu_config_panel.hwere passingwxDD_DIR_MUST_EXISTas the second constructor argument, i.e. as the window ID rather than a style; these now usewxID_ANYand an explicit style.Testing (first commit)
Ubuntu 26.04, wxGTK 3.2.9: verified before/after on the player's "Select DCP to open" dialog — the "Create Folder" button appears with the change. Also verified with a minimal wx test program that this flag alone toggles the button on this stack, and that the picker-based dialogs ("Select a directory") are governed by the same property. Windows behaviour is unchanged (the flag was already ignored there).
Update — second commit
The claim above that picker-based dialogs are governed by the same property as a plain
wxDirDialogturned out to be wrong for GTK, caught by testing the real built app rather than only a synthetic harness. On wxGTK,wxDirPickerCtrlis backed by a nativewxDirButton(wx/gtk/filepicker.h) wrappingGtkFileChooserButton, which unconditionally forceswxDD_DIR_MUST_EXISTon its browse dialog regardless of the picker's own style:So every
wxDirPickerCtrl-based folder field (New Film's "Create in folder", the Preferences folder pickers, KDM/DKDM output folders, the GPU binary location) was still stuck without "New Folder", regardless of the first commit's style change — this is a structural limitation ofGtkFileChooserButton, not something fixable via style flags.DCP-o-matic already has its own
DirPickerCtrl(a plain button that pops a realwxDirDialog, which the first commit's fix does work correctly on) for exactly this reason on Windows (DCPOMATIC_USE_OWN_PICKER). This commit extends that macro to__WXGTK__too, and adds the own-picker branch to the two files that didn't have one yet (locations_preferences_page.cc,grok/gpu_config_panel.h). macOS is untouched:wxDirPickerCtrlthere falls through to the genericwxGenericDirButtonimplementation, which has no such override, so the original style-flag fix already works fine there.Verified end-to-end on the real built app (not just a synthetic harness), Ubuntu 26.04 / wxGTK 3.2.9: New Film's folder picker, Preferences → Locations, and Preferences → GPU all show "New Folder" and support Ctrl+Shift+N now.
🤖 Generated with Claude Code