Skip to content

Allow creating new folders from directory choosers on Linux and macOS - #44

Open
amitbar05 wants to merge 2 commits into
cth103:mainfrom
amitbar05:allow-create-folder-in-dir-dialogs
Open

Allow creating new folders from directory choosers on Linux and macOS#44
amitbar05 wants to merge 2 commits into
cth103:mainfrom
amitbar05:allow-create-folder-in-dir-dialogs

Conversation

@amitbar05

@amitbar05 amitbar05 commented Jul 16, 2026

Copy link
Copy Markdown

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 the wxDirPickerCtrls use wx's default style, which includes wxDIRP_DIR_MUST_EXIST. wxWidgets maps this flag to disabling folder creation in the native chooser:

  • wxGTK (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.
  • wxOSX (src/osx/cocoa/dirdlg.mm): [oPanel setCanCreateDirectories:YES] only when the flag is absent.
  • wxMSW: the flag has no effect on the folder picker — "New folder" is always shown.

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)

  • Drop wxDD_DIR_MUST_EXIST from all wxDirDialog/DirDialog call sites (where it was the entire style, use wxDD_DEFAULT_STYLE).
  • Pass wxDIRP_DEFAULT_STYLE & ~wxDIRP_DIR_MUST_EXIST to the wxDirPickerCtrls (this keeps wxDIRP_USE_TEXTCTRL on the platforms whose default includes it).
  • full_config_dialog.cc and grok/gpu_config_panel.h were passing wxDD_DIR_MUST_EXIST as the second constructor argument, i.e. as the window ID rather than a style; these now use wxID_ANY and 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 wxDirDialog turned out to be wrong for GTK, caught by testing the real built app rather than only a synthetic harness. On wxGTK, wxDirPickerCtrl is backed by a native wxDirButton (wx/gtk/filepicker.h) wrapping GtkFileChooserButton, which unconditionally forces wxDD_DIR_MUST_EXIST on its browse dialog regardless of the picker's own style:

// 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);
}

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 of GtkFileChooserButton, not something fixable via style flags.

DCP-o-matic already has its own DirPickerCtrl (a plain button that pops a real wxDirDialog, 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: wxDirPickerCtrl there falls through to the generic wxGenericDirButton implementation, 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

amitbar05 and others added 2 commits July 16, 2026 23:21
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>
@cth103

cth103 commented Jul 16, 2026

Copy link
Copy Markdown
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?

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