From 6fe9d0fdc543f22bf55978397f1fb410a96fb788 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Thu, 13 Mar 2014 14:01:34 +0800 Subject: [PATCH] gtk: Implement synchronous open dialog. --- browser/ui/file_dialog_gtk.cc | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/browser/ui/file_dialog_gtk.cc b/browser/ui/file_dialog_gtk.cc index 4e5cca75ed..94c9d53c09 100644 --- a/browser/ui/file_dialog_gtk.cc +++ b/browser/ui/file_dialog_gtk.cc @@ -136,7 +136,22 @@ bool ShowOpenDialog(atom::NativeWindow* parent_window, const base::FilePath& default_path, int properties, std::vector* paths) { - return false; + GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN; + if (properties & FILE_DIALOG_OPEN_DIRECTORY) + action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; + FileChooserDialog open_dialog(action, parent_window, title, default_path); + if (properties & FILE_DIALOG_MULTI_SELECTIONS) + gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(open_dialog.dialog()), + TRUE); + + gtk_widget_show_all(open_dialog.dialog()); + int response = gtk_dialog_run(GTK_DIALOG(open_dialog.dialog())); + if (response == GTK_RESPONSE_ACCEPT) { + *paths = open_dialog.GetFileNames(); + return true; + } else { + return false; + } } void ShowOpenDialog(atom::NativeWindow* parent_window,