Skip to content

Commit b579832

Browse files
authored
feat: add dontAddToRecent to windows showOpenDialog (electron#19669)
1 parent fee84de commit b579832

File tree

4 files changed

+14
-8
lines changed

4 files changed

+14
-8
lines changed

docs/api/dialog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ The `dialog` module has the following methods:
4848
their target path.
4949
* `treatPackageAsDirectory` _macOS_ - Treat packages, such as `.app` folders,
5050
as a directory instead of a file.
51+
* `dontAddToRecent` _Windows_ - Do not add the item being opened to the recent documents list.
5152
* `message` String (optional) _macOS_ - Message to display above input
5253
boxes.
5354
* `securityScopedBookmarks` Boolean (optional) _macOS_ _mas_ - Create [security scoped bookmarks](https://developer.apple.com/library/content/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html#//apple_ref/doc/uid/TP40011183-CH3-SW16) when packaged for the Mac App Store.
@@ -108,6 +109,7 @@ dialog.showOpenDialogSync(mainWindow, {
108109
their target path.
109110
* `treatPackageAsDirectory` _macOS_ - Treat packages, such as `.app` folders,
110111
as a directory instead of a file.
112+
* `dontAddToRecent` _Windows_ - Do not add the item being opened to the recent documents list.
111113
* `message` String (optional) _macOS_ - Message to display above input
112114
boxes.
113115
* `securityScopedBookmarks` Boolean (optional) _macOS_ _mas_ - Create [security scoped bookmarks](https://developer.apple.com/library/content/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html#//apple_ref/doc/uid/TP40011183-CH3-SW16) when packaged for the Mac App Store.

lib/browser/api/dialog.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ const fileDialogProperties = {
88
openFile: 1 << 0,
99
openDirectory: 1 << 1,
1010
multiSelections: 1 << 2,
11-
createDirectory: 1 << 3,
11+
createDirectory: 1 << 3, // macOS
1212
showHiddenFiles: 1 << 4,
13-
promptToCreate: 1 << 5,
14-
noResolveAliases: 1 << 6,
15-
treatPackageAsDirectory: 1 << 7
13+
promptToCreate: 1 << 5, // Windows
14+
noResolveAliases: 1 << 6, // macOS
15+
treatPackageAsDirectory: 1 << 7, // macOS
16+
dontAddToRecent: 1 << 8 // Windows
1617
}
1718

1819
const normalizeAccessKey = (text) => {

shell/browser/ui/file_dialog.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,12 @@ enum FileDialogProperty {
2828
FILE_DIALOG_OPEN_FILE = 1 << 0,
2929
FILE_DIALOG_OPEN_DIRECTORY = 1 << 1,
3030
FILE_DIALOG_MULTI_SELECTIONS = 1 << 2,
31-
FILE_DIALOG_CREATE_DIRECTORY = 1 << 3,
31+
FILE_DIALOG_CREATE_DIRECTORY = 1 << 3, // macOS
3232
FILE_DIALOG_SHOW_HIDDEN_FILES = 1 << 4,
33-
FILE_DIALOG_PROMPT_TO_CREATE = 1 << 5,
34-
FILE_DIALOG_NO_RESOLVE_ALIASES = 1 << 6,
35-
FILE_DIALOG_TREAT_PACKAGE_APP_AS_DIRECTORY = 1 << 7,
33+
FILE_DIALOG_PROMPT_TO_CREATE = 1 << 5, // Windows
34+
FILE_DIALOG_NO_RESOLVE_ALIASES = 1 << 6, // macOS
35+
FILE_DIALOG_TREAT_PACKAGE_APP_AS_DIRECTORY = 1 << 7, // macOS
36+
FILE_DIALOG_DONT_ADD_TO_RECENT = 1 << 8, // Windows
3637
};
3738

3839
struct DialogSettings {

shell/browser/ui/file_dialog_win.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,8 @@ bool ShowOpenDialogSync(const DialogSettings& settings,
234234
options |= FOS_FORCESHOWHIDDEN;
235235
if (settings.properties & FILE_DIALOG_PROMPT_TO_CREATE)
236236
options |= FOS_CREATEPROMPT;
237+
if (settings.properties & FILE_DIALOG_DONT_ADD_TO_RECENT)
238+
options |= FOS_DONTADDTORECENT;
237239
file_open_dialog->SetOptions(options);
238240

239241
ApplySettings(file_open_dialog, settings);

0 commit comments

Comments
 (0)