Browse Source

:apple: Add treatPackageasDirectory as an option

Shubham 7 years ago
parent
commit
b25a1d10a2

+ 1 - 0
atom/browser/ui/file_dialog.h

@@ -30,6 +30,7 @@ enum FileDialogProperty {
   FILE_DIALOG_SHOW_HIDDEN_FILES  = 1 << 4,
   FILE_DIALOG_PROMPT_TO_CREATE   = 1 << 5,
   FILE_DIALOG_NO_RESOLVE_ALIASES = 1 << 6,
+  FILE_DIALOG_TREAT_PACKAGE_APP_AS_DIRECTORY = 1 << 7,
 };
 
 typedef base::Callback<void(

+ 2 - 1
atom/browser/ui/file_dialog_mac.mm

@@ -93,7 +93,6 @@ void SetupDialog(NSSavePanel* dialog,
 
 void SetupDialogForProperties(NSOpenPanel* dialog, int properties) {
   [dialog setCanChooseFiles:(properties & FILE_DIALOG_OPEN_FILE)];
-  [dialog setTreatsFilePackagesAsDirectories:YES];
   if (properties & FILE_DIALOG_OPEN_DIRECTORY)
     [dialog setCanChooseDirectories:YES];
   if (properties & FILE_DIALOG_CREATE_DIRECTORY)
@@ -104,6 +103,8 @@ void SetupDialogForProperties(NSOpenPanel* dialog, int properties) {
     [dialog setShowsHiddenFiles:YES];
   if (properties & FILE_DIALOG_NO_RESOLVE_ALIASES)
     [dialog setResolvesAliases:NO];
+  if (properties & FILE_DIALOG_TREAT_PACKAGE_APP_AS_DIRECTORY)
+    [dialog setTreatsFilePackagesAsDirectories:YES];
 }
 
 // Run modal dialog with parent window and return user's choice.

+ 2 - 0
docs/api/dialog.md

@@ -46,6 +46,8 @@ The `dialog` module has the following methods:
     * `noResolveAliases` - Disable the automatic alias (symlink) path
       resolution.  Selected aliases will now return the alias path instead of
       their target path. _macOS_
+    * `treatPackageAsDirectory` - Treats file package(for example Electron.app)
+      as a directory instead of file
   * `message` String (optional) _macOS_ - Message to display above input
     boxes.
 * `callback` Function (optional)

+ 2 - 1
lib/browser/api/dialog.js

@@ -11,7 +11,8 @@ const fileDialogProperties = {
   createDirectory: 1 << 3,
   showHiddenFiles: 1 << 4,
   promptToCreate: 1 << 5,
-  noResolveAliases: 1 << 6
+  noResolveAliases: 1 << 6,
+  treatPackageAsDirectory: 1 << 7
 }
 
 const messageBoxTypes = ['none', 'info', 'warning', 'error', 'question']