2014-10-31 18:17:05 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc.
|
2014-04-25 09:49:37 +00:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2013-05-20 13:46:43 +00:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2014-03-16 00:58:59 +00:00
|
|
|
#ifndef ATOM_BROWSER_UI_FILE_DIALOG_H_
|
|
|
|
#define ATOM_BROWSER_UI_FILE_DIALOG_H_
|
2013-05-20 13:46:43 +00:00
|
|
|
|
|
|
|
#include <string>
|
2014-08-06 04:44:02 +00:00
|
|
|
#include <utility>
|
2013-05-20 13:46:43 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2013-09-23 11:22:36 +00:00
|
|
|
#include "base/callback_forward.h"
|
2013-05-20 13:46:43 +00:00
|
|
|
#include "base/files/file_path.h"
|
|
|
|
|
|
|
|
namespace atom {
|
|
|
|
class NativeWindow;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace file_dialog {
|
|
|
|
|
2014-08-06 04:44:02 +00:00
|
|
|
// <description, extensions>
|
|
|
|
typedef std::pair<std::string, std::vector<std::string> > Filter;
|
|
|
|
typedef std::vector<Filter> Filters;
|
|
|
|
|
2013-05-20 13:46:43 +00:00
|
|
|
enum FileDialogProperty {
|
2017-02-12 04:23:27 +00:00
|
|
|
FILE_DIALOG_OPEN_FILE = 1 << 0,
|
|
|
|
FILE_DIALOG_OPEN_DIRECTORY = 1 << 1,
|
|
|
|
FILE_DIALOG_MULTI_SELECTIONS = 1 << 2,
|
|
|
|
FILE_DIALOG_CREATE_DIRECTORY = 1 << 3,
|
|
|
|
FILE_DIALOG_SHOW_HIDDEN_FILES = 1 << 4,
|
|
|
|
FILE_DIALOG_PROMPT_TO_CREATE = 1 << 5,
|
|
|
|
FILE_DIALOG_NO_RESOLVE_ALIASES = 1 << 6,
|
2017-07-18 01:40:57 +00:00
|
|
|
FILE_DIALOG_TREAT_PACKAGE_APP_AS_DIRECTORY = 1 << 7,
|
2013-05-20 13:46:43 +00:00
|
|
|
};
|
|
|
|
|
2018-02-12 18:25:06 +00:00
|
|
|
#if defined(MAS_BUILD)
|
|
|
|
typedef base::Callback<void(
|
|
|
|
bool result,
|
|
|
|
const std::vector<base::FilePath>& paths,
|
|
|
|
const std::vector<std::string>& bookmarkData)> OpenDialogCallback;
|
|
|
|
|
|
|
|
typedef base::Callback<void(
|
|
|
|
bool result,
|
|
|
|
const base::FilePath& path,
|
|
|
|
const std::string& bookmarkData)> SaveDialogCallback;
|
|
|
|
#else
|
|
|
|
typedef base::Callback<void(
|
|
|
|
bool result,
|
|
|
|
const std::vector<base::FilePath>& paths)> OpenDialogCallback;
|
|
|
|
|
|
|
|
typedef base::Callback<void(
|
|
|
|
bool result,
|
|
|
|
const base::FilePath& path)> SaveDialogCallback;
|
|
|
|
#endif
|
2013-09-23 11:22:36 +00:00
|
|
|
|
2017-02-08 01:32:58 +00:00
|
|
|
struct DialogSettings {
|
|
|
|
atom::NativeWindow* parent_window = nullptr;
|
|
|
|
std::string title;
|
2017-02-09 19:25:05 +00:00
|
|
|
std::string message;
|
2017-02-08 01:32:58 +00:00
|
|
|
std::string button_label;
|
2017-02-09 19:25:05 +00:00
|
|
|
std::string name_field_label;
|
2017-02-08 01:32:58 +00:00
|
|
|
base::FilePath default_path;
|
|
|
|
Filters filters;
|
|
|
|
int properties = 0;
|
2017-02-09 19:25:05 +00:00
|
|
|
bool shows_tag_field = true;
|
2017-11-02 21:50:04 +00:00
|
|
|
bool force_detached = false;
|
2018-02-12 18:25:06 +00:00
|
|
|
bool security_scoped_bookmarks = false;
|
2017-02-08 01:32:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bool ShowOpenDialog(const DialogSettings& settings,
|
2013-05-20 13:46:43 +00:00
|
|
|
std::vector<base::FilePath>* paths);
|
|
|
|
|
2017-02-08 01:32:58 +00:00
|
|
|
void ShowOpenDialog(const DialogSettings& settings,
|
2013-09-23 11:22:36 +00:00
|
|
|
const OpenDialogCallback& callback);
|
|
|
|
|
2017-02-08 01:32:58 +00:00
|
|
|
bool ShowSaveDialog(const DialogSettings& settings,
|
2013-05-20 13:46:43 +00:00
|
|
|
base::FilePath* path);
|
|
|
|
|
2017-02-08 01:32:58 +00:00
|
|
|
void ShowSaveDialog(const DialogSettings& settings,
|
2013-09-23 12:08:32 +00:00
|
|
|
const SaveDialogCallback& callback);
|
|
|
|
|
2013-05-20 13:46:43 +00:00
|
|
|
} // namespace file_dialog
|
|
|
|
|
2014-03-16 00:58:59 +00:00
|
|
|
#endif // ATOM_BROWSER_UI_FILE_DIALOG_H_
|