Skip to content
This repository was archived by the owner on Sep 2, 2021. It is now read-only.

Commit 89977a9

Browse files
committed
Merge pull request #496 from MarcelGerber/linux-open-dialog
Support initialDirectory and title in Linux' showOpenDialog
2 parents d9b1cae + 2dc15d8 commit 89977a9

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

appshell/appshell_extensions_gtk.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,15 +164,20 @@ int32 ShowOpenDialog(bool allowMultipleSelection,
164164
CefRefPtr<CefListValue>& selectedFiles)
165165
{
166166
GtkWidget *dialog;
167-
const char* dialog_title = chooseDirectory ? "Open Directory" : "Open File";
168167
GtkFileChooserAction file_or_directory = chooseDirectory ? GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER : GTK_FILE_CHOOSER_ACTION_OPEN ;
169-
dialog = gtk_file_chooser_dialog_new (dialog_title,
168+
dialog = gtk_file_chooser_dialog_new (title.c_str(),
170169
NULL,
171170
file_or_directory,
172171
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
173172
GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
174173
NULL);
175174

175+
if (!initialDirectory.empty())
176+
{
177+
ExtensionString folderURI = std::string("file:///") + initialDirectory;
178+
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (dialog), folderURI.c_str());
179+
}
180+
176181
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
177182
{
178183
char *filename;

0 commit comments

Comments
 (0)