From f08ac07737fe3f0ef5c371c5bb29c90ec79c1b6b Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 11 Jul 2016 13:30:18 +0900 Subject: [PATCH 1/4] mac: Add showHiddenFiles property for showOpenDialog --- atom/browser/ui/file_dialog.h | 9 +++++---- atom/browser/ui/file_dialog_mac.mm | 2 ++ lib/browser/api/dialog.js | 5 +++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/atom/browser/ui/file_dialog.h b/atom/browser/ui/file_dialog.h index b857648161b5..f65204c10e47 100644 --- a/atom/browser/ui/file_dialog.h +++ b/atom/browser/ui/file_dialog.h @@ -23,10 +23,11 @@ typedef std::pair > Filter; typedef std::vector Filters; enum FileDialogProperty { - 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_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, }; typedef base::Callback Date: Mon, 11 Jul 2016 13:47:24 +0900 Subject: [PATCH 2/4] gtk: Set show-hidden property for showHiddenFiles --- atom/browser/ui/file_dialog_gtk.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/atom/browser/ui/file_dialog_gtk.cc b/atom/browser/ui/file_dialog_gtk.cc index eba1813780ad..50c38fe0c38d 100644 --- a/atom/browser/ui/file_dialog_gtk.cc +++ b/atom/browser/ui/file_dialog_gtk.cc @@ -87,12 +87,19 @@ class FileChooserDialog { AddFilters(filters); } - virtual ~FileChooserDialog() { + ~FileChooserDialog() { gtk_widget_destroy(dialog_); if (parent_) parent_->SetEnabled(true); } + void SetupProperties(int properties) { + if (properties & FILE_DIALOG_MULTI_SELECTIONS) + gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog()), TRUE); + if (properties & FILE_DIALOG_SHOW_HIDDEN_FILES) + g_object_set(dialog(), "show-hidden", TRUE, NULL); + } + void RunAsynchronous() { g_signal_connect(dialog_, "delete-event", G_CALLBACK(gtk_widget_hide_on_delete), NULL); @@ -235,9 +242,7 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window, action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; FileChooserDialog open_dialog(action, parent_window, title, button_label, default_path, filters); - if (properties & FILE_DIALOG_MULTI_SELECTIONS) - gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(open_dialog.dialog()), - TRUE); + open_dialog.SetupProperties(properties); gtk_widget_show_all(open_dialog.dialog()); int response = gtk_dialog_run(GTK_DIALOG(open_dialog.dialog())); @@ -261,10 +266,7 @@ void ShowOpenDialog(atom::NativeWindow* parent_window, action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; FileChooserDialog* open_dialog = new FileChooserDialog( action, parent_window, title, button_label, default_path, filters); - if (properties & FILE_DIALOG_MULTI_SELECTIONS) - gtk_file_chooser_set_select_multiple( - GTK_FILE_CHOOSER(open_dialog->dialog()), TRUE); - + open_dialog->SetupProperties(properties); open_dialog->RunOpenAsynchronous(callback); } From fc72df3ba1693a3d7c56fd54d55a011cc39a5498 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 11 Jul 2016 13:49:51 +0900 Subject: [PATCH 3/4] win: Use FOS_FORCESHOWHIDDEN for showHiddenFiles --- atom/browser/ui/file_dialog_win.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/atom/browser/ui/file_dialog_win.cc b/atom/browser/ui/file_dialog_win.cc index 5314b63a45a8..88c847efc8cf 100644 --- a/atom/browser/ui/file_dialog_win.cc +++ b/atom/browser/ui/file_dialog_win.cc @@ -201,6 +201,8 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window, options |= FOS_PICKFOLDERS; if (properties & FILE_DIALOG_MULTI_SELECTIONS) options |= FOS_ALLOWMULTISELECT; + if (properties & FILE_DIALOG_SHOW_HIDDEN_FILES) + options |= FOS_FORCESHOWHIDDEN; FileDialog open_dialog( default_path, title, button_label, filters, options); From 26fe38a296dd89a3a88d9864fad2b47b981c601a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Mon, 11 Jul 2016 13:52:44 +0900 Subject: [PATCH 4/4] docs: showHiddenFiles --- docs/api/dialog.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api/dialog.md b/docs/api/dialog.md index afc32afda467..d71109e9dfdc 100644 --- a/docs/api/dialog.md +++ b/docs/api/dialog.md @@ -32,8 +32,8 @@ The `dialog` module has the following methods: left empty the default label will be used. * `filters` Array * `properties` Array - Contains which features the dialog should use, can - contain `openFile`, `openDirectory`, `multiSelections` and - `createDirectory` + contain `openFile`, `openDirectory`, `multiSelections`, `createDirectory` + and `showHiddenFiles`. * `callback` Function (optional) On success this method returns an array of file paths chosen by the user,