The inset dialogs now have this interface in frontends/Dialogs.h: class Dialogs { public: /** name == "bibtex", "citation" etc data is generated by the Inset::write method, to be read by the Inset::read method in the frontends. inset is stored. On a subsequent Apply from the frontends, the stored inset will be modified. If no inset is stored, then a new one will be created at the current cursor position. */ void show(string const & name, string const & data, InsetBase * inset); /** name == "citation", "bibtex" etc. Update the contents of the dialog. */ void update(string const & name, string const & data); /// void Dialogs::hide(string const & name); /// If the dialog is connected to an inset, then diaconnect it. void disconnect(string const & name); /// InsetBase * getOpenInset(string const & name) const; };
which suggests the corresponding LFUNs LFUN_DIALOG_SHOW "name" LFUN_DIALOG_UPDATE "name" LFUN_DIALOG_HIDE "name" LFUN_DIALOG_DISCONNECT "name" (getOpenInset is used by the core only; it shouldn't have an LFUN.) All fine and dandy. However, I'm unhappy with the name for this because "Apply" suggests that the inset exists already and, as you can see, sometimes we create one, sometimes we modify one. The functionality is correct; it's not the frontends business what we do here but I would like a more elgant name. Any suggestions? case LFUN_CITATION_APPLY: { stringstream data(ev.argument); LyXLex lex(0,0); lex.setStream(data); InsetCommandParams params; params.read(lex); InsetBase * base = owner_->getDialogs().getOpenDialog("citation"); InsetCitation * inset = static_cast<InsetCitation *>(base); if (inset) { inset->setParams(params); } else { inset = new InsetCitation(params); if (!insertInset(inset)) { delete inset; break; } else { inset->setLoadingBuffer(bv_->buffer(), false); } } updateInset(inset, true); } break; Also, the dialog can be opened in two different circumstances; to show the contents of an existing inset and to enable the user to input the params for a new inset. 'LFUN_DIALOG_SHOW "name"' is unable to differentiate. Should I have 'LFUN_DIALOG_SHOW "name" "next"/"new"' to open the next inset after the current cursor position/an empty dialog. Or should I have two separate LFUNs? An uninspired, -- Angus