- string filename = filenm;
-
- if (filename.empty()) {
- // Launch a file browser
- // FIXME UNICODE
- string initpath = lyxrc.document_path;
- string const trypath = buffer_.filePath();
- // If directory is writeable, use this as default.
- if (FileName(trypath).isDirWritable())
- initpath = trypath;
-
- // FIXME UNICODE
- FileDialog dlg(_("Select LyX document to insert"), LFUN_FILE_INSERT);
- dlg.setButton1(_("Documents|#o#O"), from_utf8(lyxrc.document_path));
- dlg.setButton2(_("Examples|#E#e"),
- from_utf8(addPath(package().system_support().absFilename(),
- "examples")));
-
- FileDialog::Result result =
- dlg.open(from_utf8(initpath),
- FileFilterList(_("LyX Documents (*.lyx)")),
- docstring());
-
- if (result.first == FileDialog::Later)
- return;
-
- // FIXME UNICODE
- filename = to_utf8(result.second);
-
- // check selected filename
- if (filename.empty()) {
- // emit message signal.
- message(_("Canceled."));
- return;
- }
- }