]> git.lyx.org Git - lyx.git/blobdiff - src/lyxfunc.C
more cursor dispatch
[lyx.git] / src / lyxfunc.C
index 51fe3b7ae6e31ecd13280b6119b31461b8133aa1..eee8bb805e99b32a84bb66e41fb365caf3489c8c 100644 (file)
 #include "ParagraphParameters.h"
 #include "undo.h"
 
+#include "insets/insetbox.h"
+#include "insets/insetbranch.h"
 #include "insets/insetcommand.h"
+#include "insets/insetert.h"
 #include "insets/insetexternal.h"
+#include "insets/insetfloat.h"
+#include "insets/insetgraphics.h"
+#include "insets/insetnote.h"
 #include "insets/insettabular.h"
 #include "insets/insetvspace.h"
-
-#include "mathed/math_cursor.h"
+#include "insets/insetwrap.h"
 
 #include "frontends/Alert.h"
 #include "frontends/Dialogs.h"
@@ -70,6 +75,7 @@
 #include "support/FileInfo.h"
 #include "support/filetools.h"
 #include "support/forkedcontr.h"
+#include "support/globbing.h"
 #include "support/path.h"
 #include "support/path_defines.h"
 #include "support/tostr.h"
@@ -86,6 +92,7 @@ using lyx::support::AddName;
 using lyx::support::AddPath;
 using lyx::support::bformat;
 using lyx::support::ChangeExtension;
+using lyx::support::FileFilterList;
 using lyx::support::FileInfo;
 using lyx::support::FileSearch;
 using lyx::support::ForkedcallsController;
@@ -109,6 +116,7 @@ using lyx::support::os::getTmpDir;
 
 using std::endl;
 using std::make_pair;
+using std::pair;
 using std::string;
 using std::istringstream;
 
@@ -147,21 +155,14 @@ void LyXFunc::handleKeyFunc(kb_action action)
        // actions
        keyseq.clear();
        // copied verbatim from do_accent_char
+       view()->cursor().resetAnchor();
        view()->update();
-       view()->getLyXText()->selection.cursor = view()->getLyXText()->cursor;
 }
 
 
-void LyXFunc::processKeySym(LyXKeySymPtr keysym,
-                           key_modifier::state state)
+void LyXFunc::processKeySym(LyXKeySymPtr keysym, key_modifier::state state)
 {
-       string argument;
-
-       if (lyxerr.debugging(Debug::KEY)) {
-               lyxerr << "KeySym is "
-                      << keysym->getSymbolName()
-                      << endl;
-       }
+       lyxerr[Debug::KEY] << "KeySym is " << keysym->getSymbolName() << endl;
 
        // Do nothing if we have nothing (JMarc)
        if (!keysym->isOK()) {
@@ -247,11 +248,11 @@ void LyXFunc::processKeySym(LyXKeySymPtr keysym,
                if (encoded_last_key != 0) {
                        string arg;
                        arg += encoded_last_key;
-
-                       dispatch(FuncRequest(view(), LFUN_SELFINSERT, arg));
-
-                       lyxerr[Debug::KEY] << "SelfInsert arg[`"
-                                  << argument << "']" << endl;
+                       lyxerr << "SelfInsert arg[`"
+                                  << arg << "']" << endl;
+                       dispatch(FuncRequest(LFUN_SELFINSERT, arg));
+                       lyxerr[Debug::KEY]
+                               << "SelfInsert arg[`" << arg << "']" << endl;
                }
        } else {
                dispatch(func);
@@ -312,7 +313,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                }
        }
 
-       UpdatableInset * tli = view()->cursor().innerInset();
+       UpdatableInset * tli = view()->cursor().inset()
+               ? view()->cursor().inset()->asUpdatableInset() : 0;
        InsetTabular * tab = view()->cursor().innerInsetTabular();
 
        // I would really like to avoid having this switch and rather try to
@@ -334,7 +336,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                if (tab && tab->hasSelection())
                        disable = false;
                else
-                       disable = !mathcursor && !view()->getLyXText()->selection.set();
+                       disable = !view()->cursor().inMathed() && !view()->cursor().selection();
                break;
 
        case LFUN_RUNCHKTEX:
@@ -370,10 +372,10 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
 
        case LFUN_TABULAR_FEATURE:
 #if 0
-               if (mathcursor) {
+               if (view()->cursor().inMathed()) {
                        // FIXME: check temporarily disabled
                        // valign code
-                       char align = mathcursor->valign();
+                       char align = mathcursor::valign();
                        if (align == '\0') {
                                disable = true;
                                break;
@@ -390,7 +392,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                } else {
                        disable = true;
 
-                       char align = mathcursor->halign();
+                       char align = mathcursor::halign();
                        if (align == '\0') {
                                disable = true;
                                break;
@@ -405,7 +407,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                        }
                        flag.setOnOff(ev.argument[0] == align);
 
-                       disable = !mathcursor->halign();
+                       disable = !mathcursor::halign();
                        break;
                }
 
@@ -461,7 +463,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
 
        case LFUN_INSET_SETTINGS: {
                disable = true;
-               UpdatableInset * inset = view()->cursor().innerInset();
+               UpdatableInset * inset = view()->cursor().inset()
+                       ? view()->cursor().inset()->asUpdatableInset() : 0;
 
                if (!inset)
                        break;
@@ -482,9 +485,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                        case InsetOld::FLOAT_CODE:
                                disable = ev.argument != "float";
                                break;
-                       case InsetOld::MINIPAGE_CODE:
-                               disable = ev.argument != "minipage";
-                               break;
                        case InsetOld::WRAP_CODE:
                                disable = ev.argument != "wrap";
                                break;
@@ -504,8 +504,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
        }
 
        case LFUN_MATH_MUTATE:
-               if (mathcursor)
-                       //flag.setOnOff(mathcursor->formula()->hullType() == ev.argument);
+               if (view()->cursor().inMathed())
+                       //flag.setOnOff(mathcursor::formula()->hullType() == ev.argument);
                        flag.setOnOff(false);
                else
                        disable = true;
@@ -518,7 +518,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
        case LFUN_MATH_NONUMBER:
        case LFUN_MATH_NUMBER:
        case LFUN_MATH_EXTERN:
-               disable = !mathcursor;
+               disable = !view()->cursor().inMathed();
                break;
 
        case LFUN_DIALOG_SHOW: {
@@ -536,8 +536,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                        disable = !Exporter::IsExportable(*buf, "dvi") ||
                                lyxrc.print_command == "none";
                } else if (name == "character") {
-                       UpdatableInset * tli = view()->cursor().innerInset();
-                       disable = tli && tli->lyxCode() == InsetOld::ERT_CODE;
+                       InsetBase * inset = view()->cursor().inset();
+                       disable = inset && inset->lyxCode() == InsetOld::ERT_CODE;
                } else if (name == "vclog") {
                        disable = !buf->lyxvc().inUse();
                } else if (name == "latexlog") {
@@ -558,6 +558,10 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                        code = InsetOld::BIBITEM_CODE;
                else if (ev.argument == "bibtex")
                        code = InsetOld::BIBTEX_CODE;
+               else if (ev.argument == "box")
+                       code = InsetOld::BOX_CODE;
+               else if (ev.argument == "branch")
+                       code = InsetOld::BRANCH_CODE;
                else if (ev.argument == "citation")
                        code = InsetOld::CITE_CODE;
                else if (ev.argument == "ert")
@@ -574,8 +578,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                        code = InsetOld::INDEX_CODE;
                else if (ev.argument == "label")
                        code = InsetOld::LABEL_CODE;
-               else if (ev.argument == "minipage")
-                       code = InsetOld::MINIPAGE_CODE;
+               else if (ev.argument == "note")
+                       code = InsetOld::NOTE_CODE;
                else if (ev.argument == "ref")
                        code = InsetOld::REF_CODE;
                else if (ev.argument == "toc")
@@ -600,9 +604,6 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
        case LFUN_INSET_MARGINAL:
                code = InsetOld::MARGIN_CODE;
                break;
-       case LFUN_INSET_MINIPAGE:
-               code = InsetOld::MINIPAGE_CODE;
-               break;
        case LFUN_INSET_FLOAT:
        case LFUN_INSET_WIDE_FLOAT:
                code = InsetOld::FLOAT_CODE;
@@ -647,7 +648,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                code = InsetOld::OPTARG_CODE;
                break;
        case LFUN_ENVIRONMENT_INSERT:
-               code = InsetOld::MINIPAGE_CODE;
+               code = InsetOld::BOX_CODE;
                break;
        case LFUN_INDEX_INSERT:
                code = InsetOld::INDEX_CODE;
@@ -676,13 +677,13 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                break;
        case LFUN_SPACE_INSERT:
                // slight hack: we know this is allowed in math mode
-               if (!mathcursor)
+               if (!view()->cursor().inMathed())
                        code = InsetOld::SPACE_CODE;
                break;
        case LFUN_INSET_DIALOG_SHOW: {
-               InsetOld * inset = view()->getLyXText()->getInset();
+               InsetBase * inset = view()->cursor().nextInset();
                disable = !inset;
-               if (!disable) {
+               if (inset) {
                        code = inset->lyxCode();
                        if (!(code == InsetOld::INCLUDE_CODE
                                || code == InsetOld::BIBTEX_CODE
@@ -728,7 +729,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
 
 #ifdef LOCK
        // the font related toggles
-       if (!mathcursor) {
+       if (!view()->cursor().inMathed()) {
                LyXFont const & font = view()->getLyXText()->real_current_font;
                switch (ev.action) {
                case LFUN_EMPH:
@@ -753,7 +754,7 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
                        break;
                }
        } else {
-               string tc = mathcursor->getLastCode();
+               string tc = mathcursor::getLastCode();
                switch (ev.action) {
                case LFUN_BOLD:
                        flag.setOnOff(tc == "mathbf");
@@ -819,29 +820,21 @@ bool ensureBufferClean(BufferView * bv)
 } //namespace anon
 
 
-void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
+void LyXFunc::dispatch(FuncRequest const & cmd, bool verbose)
 {
-       string argument = func.argument;
-       kb_action action = func.action;
+       string argument = cmd.argument;
+       kb_action action = cmd.action;
 
-       //lyxerr[Debug::ACTION] << "LyXFunc::dispatch: cmd: " << func << endl;
-       lyxerr << "LyXFunc::dispatch: cmd: " << func << endl;
+       lyxerr[Debug::ACTION] << "LyXFunc::dispatch: cmd: " << cmd << endl;
+       //lyxerr << "*** LyXFunc::dispatch: cmd: " << cmd << endl;
 
        // we have not done anything wrong yet.
        errorstat = false;
        dispatch_buffer.erase();
-
-#ifdef NEW_DISPATCHER
-       // We try do call the most specific dispatcher first:
-       //  1. the lockinginset's dispatch
-       //  2. the bufferview's dispatch
-       //  3. the lyxview's dispatch
-#endif
-
        selection_possible = false;
 
        // We cannot use this function here
-       if (getStatus(func).disabled()) {
+       if (getStatus(cmd).disabled()) {
                lyxerr[Debug::ACTION] << "LyXFunc::dispatch: "
                       << lyxaction.getActionName(action)
                       << " [" << action << "] is disabled at this location"
@@ -872,13 +865,16 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                        if (!argument.empty()) {
                                last_search = argument;
                                searched_string = argument;
-                       } else {
+                       } else
                                searched_string = last_search;
-                       }
-                       bool fw = (action == LFUN_WORDFINDFORWARD);
-                       if (!searched_string.empty())
-                               lyx::find::find(view(), searched_string,
-                                               true, false, fw);
+
+                       if (searched_string.empty())
+                               break;
+
+                       bool const fw = action == LFUN_WORDFINDFORWARD;
+                       string const data =
+                               lyx::find::find2string(searched_string, true, false, fw);
+                       view()->dispatch(FuncRequest(LFUN_WORD_FIND, data));
                        break;
                }
 
@@ -1156,11 +1152,9 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                                                                << " found." << endl;
                        }
 
-                       par.lockPath(view());
-                       LyXText * lt = par.text(*view()->buffer());
-
                        // Set the cursor
-                       lt->setCursor(par.pit(), 0);
+                       view()->setCursor(par, 0);
+
                        view()->switchKeyMap();
                        owner->view_state_changed();
 
@@ -1178,27 +1172,17 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                        setErrorMessage(N_("This is only allowed in math mode!"));
                        break;
 
-               // passthrough hat and underscore outside mathed:
-               case LFUN_SUBSCRIPT:
-                       dispatch(FuncRequest(view(), LFUN_SELFINSERT, "_"));
-                       break;
-
-               case LFUN_SUPERSCRIPT:
-                       dispatch(FuncRequest(view(), LFUN_SELFINSERT, "^"));
-                       break;
-
                case LFUN_DIALOG_SHOW: {
-                       string const name = func.getArg(0);
-                       string data = trim(func.argument.substr(name.size()));
+                       string const name = cmd.getArg(0);
+                       string data = trim(cmd.argument.substr(name.size()));
 
                        if (name == "character") {
                                data = freefont2string();
                                if (!data.empty())
                                        owner->getDialogs().show("character", data);
-                       } else if (name == "document")
+                       }
+                       else if (name == "document")
                                owner->getDialogs().showDocument();
-                       else if (name == "findreplace")
-                               owner->getDialogs().showSearch();
                        else if (name == "forks")
                                owner->getDialogs().showForks();
                        else if (name == "preamble")
@@ -1209,29 +1193,76 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                                owner->getDialogs().showPrint();
                        else if (name == "spellchecker")
                                owner->getDialogs().showSpellchecker();
+
+                       else if (name == "latexlog") {
+                               pair<Buffer::LogType, string> const logfile =
+                                       owner->buffer()->getLogName();
+                               switch (logfile.first) {
+                               case Buffer::latexlog:
+                                       data = "latex ";
+                                       break;
+                               case Buffer::buildlog:
+                                       data = "literate ";
+                                       break;
+                               }
+                               data += logfile.second;
+                               owner->getDialogs().show("log", data);
+                       }
+                       else if (name == "vclog") {
+                               string const data = "vc " +
+                                       owner->buffer()->lyxvc().getLogFile();
+                               owner->getDialogs().show("log", data);
+                       }
                        else
                                owner->getDialogs().show(name, data);
                        break;
                }
 
                case LFUN_DIALOG_SHOW_NEW_INSET: {
-                       string const & name = argument;
-                       string data;
+                       string const name = cmd.getArg(0);
+                       string data = trim(cmd.argument.substr(name.size()));
                        if (name == "bibitem" ||
-                                       name == "bibtex" ||
-                                       name == "include" ||
-                                       name == "index" ||
-                                       name == "ref" ||
-                                       name == "toc" ||
-                                       name == "url") {
+                           name == "bibtex" ||
+                           name == "include" ||
+                           name == "index" ||
+                           name == "label" ||
+                           name == "ref" ||
+                           name == "toc" ||
+                           name == "url") {
                                InsetCommandParams p(name);
                                data = InsetCommandMailer::params2string(name, p);
+                       } else if (name == "box") {
+                               // \c data == "Boxed" || "Frameless" etc
+                               InsetBoxParams p(data);
+                               data = InsetBoxMailer::params2string(p);
+                       } else if (name == "branch") {
+                               InsetBranchParams p;
+                               data = InsetBranchMailer::params2string(p);
                        } else if (name == "citation") {
                                InsetCommandParams p("cite");
                                data = InsetCommandMailer::params2string(name, p);
+                       } else if (name == "ert") {
+                               data = InsetERTMailer::params2string(InsetCollapsable::Open);
+                       } else if (name == "external") {
+                               InsetExternalParams p;
+                               Buffer const & buffer = *owner->buffer();
+                               data = InsetExternalMailer::params2string(p, buffer);
+                       } else if (name == "float") {
+                               InsetFloatParams p;
+                               data = InsetFloatMailer::params2string(p);
+                       } else if (name == "graphics") {
+                               InsetGraphicsParams p;
+                               Buffer const & buffer = *owner->buffer();
+                               data = InsetGraphicsMailer::params2string(p, buffer);
+                       } else if (name == "note") {
+                               InsetNoteParams p;
+                               data = InsetNoteMailer::params2string(p);
                        } else if (name == "vspace") {
                                VSpace space;
                                data = InsetVSpaceMailer::params2string(space);
+                       } else if (name == "wrap") {
+                               InsetWrapParams p;
+                               data = InsetWrapMailer::params2string(p);
                        }
                        owner->getDialogs().show(name, data, 0);
                        break;
@@ -1241,9 +1272,9 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                        break;
 
                case LFUN_INSET_DIALOG_SHOW: {
-                       InsetOld * inset = view()->getLyXText()->getInset();
+                       InsetBase * inset = view()->cursor().nextInset();
                        if (inset)
-                               inset->dispatch(FuncRequest(view(), LFUN_INSET_DIALOG_SHOW));
+                               inset->dispatch(view()->cursor(), FuncRequest(LFUN_INSET_DIALOG_SHOW));
                        break;
                }
 
@@ -1252,9 +1283,8 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                        // Can only update a dialog connected to an existing inset
                        InsetBase * inset = owner->getDialogs().getOpenInset(name);
                        if (inset) {
-                               FuncRequest fr(view(), LFUN_INSET_DIALOG_UPDATE,
-                                                                func.argument);
-                               inset->dispatch(fr);
+                               FuncRequest fr(LFUN_INSET_DIALOG_UPDATE, cmd.argument);
+                               inset->dispatch(view()->cursor(), fr);
                        } else if (name == "paragraph") {
                                dispatch(FuncRequest(LFUN_PARAGRAPH_UPDATE));
                        }
@@ -1356,7 +1386,8 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                                (lyx_name == lcolor.getLyXName(LColor::graphicsbg) &&
                                 x11_name != lcolor.getX11Name(LColor::graphicsbg));
 
-                       if (!lcolor.setColor(lyx_name, x11_name)) {
+                       LColor::color col = lcolor.getFromLyXName(lyx_name);
+                       if (!lcolor.setColor(col, x11_name)) {
                                setErrorMessage(
                                        bformat(_("Set-color \"%1$s\" failed "
                                                                "- color is undefined or "
@@ -1391,45 +1422,43 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
                        break;
 
                case LFUN_EXTERNAL_EDIT:
-                       InsetExternal().dispatch(FuncRequest(view(), action, argument));
+                       InsetExternal().dispatch(view()->cursor(), FuncRequest(action, argument));
                        break;
 
-               default: {
-                               DispatchResult result =
-                                       view()->cursor().dispatch(FuncRequest(func, view()));
-                               if (result.dispatched())
-                                       lyxerr << "dispatched by Cursor::dispatch()" << endl;
-                               else
-                                       lyxerr << "### NOT DISPATCHED BY Cursor::dispatch() ###" << endl;
-                               break;
-                       }
+               default:
+                       DispatchResult res = view()->cursor().dispatch(cmd);
+                       if (!res.dispatched());
+                               view()->dispatch(cmd);
+                       break;
                }
        }
 
-       view()->owner()->updateLayoutChoice();
+       if (!view()->cursor().inMathed())
+               view()->owner()->updateLayoutChoice();
 
        if (view()->available()) {
                view()->fitCursor();
                view()->update();
                view()->cursor().updatePos();
                // if we executed a mutating lfun, mark the buffer as dirty
-               if (!getStatus(func).disabled()
-                   && !lyxaction.funcHasFlag(func.action, LyXAction::NoBuffer)
-                   && !lyxaction.funcHasFlag(func.action, LyXAction::ReadOnly))
+               if (!getStatus(cmd).disabled()
+                   && !lyxaction.funcHasFlag(cmd.action, LyXAction::NoBuffer)
+                   && !lyxaction.funcHasFlag(cmd.action, LyXAction::ReadOnly))
                        view()->buffer()->markDirty();
        }
 
-       sendDispatchMessage(getMessage(), func, verbose);
+       if (!view()->cursor().inMathed())
+               sendDispatchMessage(getMessage(), cmd, verbose);
 }
 
 
 void LyXFunc::sendDispatchMessage(string const & msg,
-                                 FuncRequest const & func, bool verbose)
+                                 FuncRequest const & cmd, bool verbose)
 {
        owner->updateMenubar();
        owner->updateToolbar();
 
-       if (func.action == LFUN_SELFINSERT || !verbose) {
+       if (cmd.action == LFUN_SELFINSERT || !verbose) {
                lyxerr[Debug::ACTION] << "dispatch msg is " << msg << endl;
                if (!msg.empty())
                        owner->message(msg);
@@ -1440,23 +1469,23 @@ void LyXFunc::sendDispatchMessage(string const & msg,
        if (!dispatch_msg.empty())
                dispatch_msg += ' ';
 
-       string comname = lyxaction.getActionName(func.action);
+       string comname = lyxaction.getActionName(cmd.action);
 
        bool argsadded = false;
 
-       if (!func.argument.empty()) {
-               if (func.action != LFUN_UNKNOWN_ACTION) {
-                       comname += ' ' + func.argument;
+       if (!cmd.argument.empty()) {
+               if (cmd.action != LFUN_UNKNOWN_ACTION) {
+                       comname += ' ' + cmd.argument;
                        argsadded = true;
                }
        }
 
-       string const shortcuts = toplevel_keymap->findbinding(func);
+       string const shortcuts = toplevel_keymap->findbinding(cmd);
 
        if (!shortcuts.empty()) {
                comname += ": " + shortcuts;
-       } else if (!argsadded && !func.argument.empty()) {
-               comname += ' ' + func.argument;
+       } else if (!argsadded && !cmd.argument.empty()) {
+               comname += ' ' + cmd.argument;
        }
 
        if (!comname.empty()) {
@@ -1518,7 +1547,8 @@ void LyXFunc::menuNew(string const & name, bool fromTemplate)
 
                FileDialog::Result result =
                        fileDlg.open(lyxrc.template_path,
-                                      _("*.lyx| LyX Documents (*.lyx)"));
+                                    FileFilterList(_("LyX Documents (*.lyx)")),
+                                    string());
 
                if (result.first == FileDialog::Later)
                        return;
@@ -1554,7 +1584,8 @@ void LyXFunc::open(string const & fname)
 
                FileDialog::Result result =
                        fileDlg.open(initpath,
-                                      _("*.lyx| LyX Documents (*.lyx)"));
+                                    FileFilterList(_("LyX Documents (*.lyx)")),
+                                    string());
 
                if (result.first == FileDialog::Later)
                        return;
@@ -1627,12 +1658,13 @@ void LyXFunc::doImport(string const & argument)
                        make_pair(string(_("Examples|#E#e")),
                                  string(AddPath(system_lyxdir(), "examples"))));
 
-               string const extension = "*." + formats.extension(format)
-                       + "| " + formats.prettyName(format)
+               string const filter = formats.prettyName(format)
                        + " (*." + formats.extension(format) + ')';
 
-               FileDialog::Result result = fileDlg.open(initpath,
-                                                          extension);
+               FileDialog::Result result =
+                       fileDlg.open(initpath,
+                                    FileFilterList(filter),
+                                    string());
 
                if (result.first == FileDialog::Later)
                        return;
@@ -1698,7 +1730,7 @@ void LyXFunc::closeBuffer()
 // Each "owner" should have it's own message method. lyxview and
 // the minibuffer would use the minibuffer, but lyxserver would
 // send an ERROR signal to its client.  Alejandro 970603
-// This func is bit problematic when it comes to NLS, to make the
+// This function is bit problematic when it comes to NLS, to make the
 // lyx servers client be language indepenent we must not translate
 // strings sent to this func.
 void LyXFunc::setErrorMessage(string const & m) const