From 3bd212e9ee8d0d5c26cb3f9ac1ed12a8d4823947 Mon Sep 17 00:00:00 2001 From: Marcel Gerber Date: Fri, 2 Jan 2015 14:46:37 +0100 Subject: [PATCH 1/2] Support initialDirectory and title in Linux' showOpenDialog --- appshell/appshell_extensions_gtk.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/appshell/appshell_extensions_gtk.cpp b/appshell/appshell_extensions_gtk.cpp index 4cb37ab1f..467a293e1 100644 --- a/appshell/appshell_extensions_gtk.cpp +++ b/appshell/appshell_extensions_gtk.cpp @@ -164,15 +164,21 @@ int32 ShowOpenDialog(bool allowMultipleSelection, CefRefPtr& selectedFiles) { GtkWidget *dialog; - const char* dialog_title = chooseDirectory ? "Open Directory" : "Open File"; + // const char* dialog_title = chooseDirectory ? "Open Directory" : "Open File"; GtkFileChooserAction file_or_directory = chooseDirectory ? GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER : GTK_FILE_CHOOSER_ACTION_OPEN ; - dialog = gtk_file_chooser_dialog_new (dialog_title, + dialog = gtk_file_chooser_dialog_new (title.c_str(), NULL, file_or_directory, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); + if (!initialDirectory.empty()) + { + ExtensionString folderURI = std::string("file:///") + initialDirectory; + gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog), folderURI.c_str()); + } + if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { char *filename; From 2dc15d8db78f4e0ecfc55ced54d27126f5fb48fb Mon Sep 17 00:00:00 2001 From: Marcel Gerber Date: Thu, 8 Jan 2015 16:57:17 +0100 Subject: [PATCH 2/2] Remove unnecessary comment --- appshell/appshell_extensions_gtk.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/appshell/appshell_extensions_gtk.cpp b/appshell/appshell_extensions_gtk.cpp index 467a293e1..e4e456df8 100644 --- a/appshell/appshell_extensions_gtk.cpp +++ b/appshell/appshell_extensions_gtk.cpp @@ -164,7 +164,6 @@ int32 ShowOpenDialog(bool allowMultipleSelection, CefRefPtr& selectedFiles) { GtkWidget *dialog; - // const char* dialog_title = chooseDirectory ? "Open Directory" : "Open File"; GtkFileChooserAction file_or_directory = chooseDirectory ? GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER : GTK_FILE_CHOOSER_ACTION_OPEN ; dialog = gtk_file_chooser_dialog_new (title.c_str(), NULL,