file_dialog.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 "base/callback_forward.h"
  10. #include "base/files/file_path.h"
  11. namespace atom {
  12. class NativeWindow;
  13. }
  14. namespace file_dialog {
  15. // <description, extensions>
  16. typedef std::pair<std::string, std::vector<std::string> > Filter;
  17. typedef std::vector<Filter> Filters;
  18. enum FileDialogProperty {
  19. FILE_DIALOG_OPEN_FILE = 1 << 0,
  20. FILE_DIALOG_OPEN_DIRECTORY = 1 << 1,
  21. FILE_DIALOG_MULTI_SELECTIONS = 1 << 2,
  22. FILE_DIALOG_CREATE_DIRECTORY = 1 << 3,
  23. FILE_DIALOG_SHOW_HIDDEN_FILES = 1 << 4,
  24. };
  25. typedef base::Callback<void(
  26. bool result, const std::vector<base::FilePath>& paths)> OpenDialogCallback;
  27. typedef base::Callback<void(
  28. bool result, const base::FilePath& path)> SaveDialogCallback;
  29. bool ShowOpenDialog(atom::NativeWindow* parent_window,
  30. const std::string& title,
  31. const std::string& button_label,
  32. const base::FilePath& default_path,
  33. const Filters& filters,
  34. int properties,
  35. std::vector<base::FilePath>* paths);
  36. void ShowOpenDialog(atom::NativeWindow* parent_window,
  37. const std::string& title,
  38. const std::string& button_label,
  39. const base::FilePath& default_path,
  40. const Filters& filters,
  41. int properties,
  42. const OpenDialogCallback& callback);
  43. bool ShowSaveDialog(atom::NativeWindow* parent_window,
  44. const std::string& title,
  45. const std::string& button_label,
  46. const base::FilePath& default_path,
  47. const Filters& filters,
  48. base::FilePath* path);
  49. void ShowSaveDialog(atom::NativeWindow* parent_window,
  50. const std::string& title,
  51. const std::string& button_label,
  52. const base::FilePath& default_path,
  53. const Filters& filters,
  54. const SaveDialogCallback& callback);
  55. } // namespace file_dialog
  56. #endif // ATOM_BROWSER_UI_FILE_DIALOG_H_