file_dialog.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. // Copyright (c) 2013 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ATOM_BROWSER_UI_FILE_DIALOG_H_
  5. #define ATOM_BROWSER_UI_FILE_DIALOG_H_
  6. #include <string>
  7. #include <utility>
  8. #include <vector>
  9. #include "atom/common/native_mate_converters/file_path_converter.h"
  10. #include "atom/common/promise_util.h"
  11. #include "base/callback_forward.h"
  12. #include "base/files/file_path.h"
  13. #include "native_mate/dictionary.h"
  14. namespace atom {
  15. class NativeWindow;
  16. }
  17. namespace file_dialog {
  18. // <description, extensions>
  19. typedef std::pair<std::string, std::vector<std::string>> Filter;
  20. typedef std::vector<Filter> Filters;
  21. enum FileDialogProperty {
  22. FILE_DIALOG_OPEN_FILE = 1 << 0,
  23. FILE_DIALOG_OPEN_DIRECTORY = 1 << 1,
  24. FILE_DIALOG_MULTI_SELECTIONS = 1 << 2,
  25. FILE_DIALOG_CREATE_DIRECTORY = 1 << 3,
  26. FILE_DIALOG_SHOW_HIDDEN_FILES = 1 << 4,
  27. FILE_DIALOG_PROMPT_TO_CREATE = 1 << 5,
  28. FILE_DIALOG_NO_RESOLVE_ALIASES = 1 << 6,
  29. FILE_DIALOG_TREAT_PACKAGE_APP_AS_DIRECTORY = 1 << 7,
  30. };
  31. struct DialogSettings {
  32. atom::NativeWindow* parent_window = nullptr;
  33. std::string title;
  34. std::string message;
  35. std::string button_label;
  36. std::string name_field_label;
  37. base::FilePath default_path;
  38. Filters filters;
  39. int properties = 0;
  40. bool shows_tag_field = true;
  41. bool force_detached = false;
  42. bool security_scoped_bookmarks = false;
  43. DialogSettings();
  44. DialogSettings(const DialogSettings&);
  45. ~DialogSettings();
  46. };
  47. bool ShowOpenDialogSync(const DialogSettings& settings,
  48. std::vector<base::FilePath>* paths);
  49. void ShowOpenDialog(const DialogSettings& settings,
  50. atom::util::Promise promise);
  51. bool ShowSaveDialogSync(const DialogSettings& settings, base::FilePath* path);
  52. void ShowSaveDialog(const DialogSettings& settings,
  53. atom::util::Promise promise);
  54. } // namespace file_dialog
  55. #endif // ATOM_BROWSER_UI_FILE_DIALOG_H_