case LFUN_CHANGES_MERGE:
if (lyx::find::findNextChange(this))
- owner_->getDialogs().show("changes");
+ showDialog("changes");
break;
case LFUN_ALL_CHANGES_ACCEPT: {
} else {
cursor_.setCursor(doc_iterator_begin(buffer_->inset()));
if (lyx::find::findNextChange(this)) {
- owner_->getDialogs().show("changes");
+ showDialog("changes");
return;
}
/// This signal is emitted when some message shows up.
boost::signal<void(lyx::docstring)> message;
+ /// This signal is emitted when some dialog needs to be shown.
+ boost::signal<void(std::string name)> showDialog;
+
+ /// This signal is emitted when some dialog needs to be shown with
+ /// some data
+ boost::signal<void(std::string name,
+ std::string data)> showDialogWithData;
+
+ /// This signal is emitted when some inset dialogs needs to be shown.
+ boost::signal<void(std::string name, std::string data,
+ InsetBase * inset)> showInsetDialog;
+
+ /// This signal is emitted when some dialogs needs to be updated.
+ boost::signal<void(std::string name,
+ std::string data)> updateDialog;
+
private:
///
bool multiParSel();
lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
}
+
LyXView::~LyXView()
{
}
}
+void LyXView::connectBufferView(BufferView & bv)
+{
+ show_dialog_connection_ = bv.showDialog.connect(
+ boost::bind(&LyXView::showDialog, this, _1));
+ show_dialog_with_data_connection_ = bv.showDialogWithData.connect(
+ boost::bind(&LyXView::showDialogWithData, this, _1, _2));
+ show_inset_dialog_connection_ = bv.showInsetDialog.connect(
+ boost::bind(&LyXView::showInsetDialog, this, _1, _2, _3));
+ update_dialog_connection_ = bv.updateDialog.connect(
+ boost::bind(&LyXView::updateDialog, this, _1, _2));
+}
+
+
+void LyXView::disconnectBufferView()
+{
+ show_dialog_connection_.disconnect();
+ show_dialog_with_data_connection_.disconnect();
+ show_inset_dialog_connection_.disconnect();
+ update_dialog_connection_.disconnect();
+}
+
+
void LyXView::showErrorList(string const & error_type)
{
ErrorList & el = buffer()->errorList(error_type);
}
+void LyXView::showDialog(string const & name)
+{
+ getDialogs().show(name);
+}
+
+
+void LyXView::showDialogWithData(string const & name,
+ string const & data)
+{
+ getDialogs().show(name, data);
+}
+
+
+void LyXView::showInsetDialog(string const & name, string const & data,
+ InsetBase * inset)
+{
+ getDialogs().show(name, data, 0);
+}
+
+
+void LyXView::updateDialog(string const & name, string const & data)
+{
+ if (getDialogs().visible(name))
+ getDialogs().update(name, data);
+}
+
+
void LyXView::showReadonly(bool)
{
updateWindowTitle();
/// show the error list to the user
void showErrorList(std::string const &);
+ /// connect to signals in the given BufferView
+ void connectBufferView(BufferView & bv);
+ /// disconnect from signals in the given BufferView
+ void disconnectBufferView();
+
protected:
/// current work area (screen view of a BufferView).
/**
void connectBuffer(Buffer & buf);
/// disconnect from signals in the given buffer
void disconnectBuffer();
+
+ /// BufferView messages signal connection
+ //@{
+ boost::signals::connection message_connection_;
+ boost::signals::connection show_dialog_connection_;
+ boost::signals::connection show_dialog_with_data_connection_;
+ boost::signals::connection show_inset_dialog_connection_;
+ boost::signals::connection update_dialog_connection_;
+ //@}
+
+ /// Bind methods for BufferView messages signal connection
+ //@{
+ void showDialog(std::string const & name);
+ void showDialogWithData(std::string const & name,
+ std::string const & data);
+ void showInsetDialog(std::string const & name,
+ std::string const & data, InsetBase * inset);
+ void updateDialog(std::string const & name,
+ std::string const & data);
+ //@}
+
/// notify readonly status
void showReadonly(bool);
void WorkArea::setBufferView(BufferView * buffer_view)
{
- if (buffer_view_)
+ if (buffer_view_) {
message_connection_.disconnect();
+ lyx_view_.disconnectBufferView();
+ }
hideCursor();
buffer_view_ = buffer_view;
message_connection_ = buffer_view_->message.connect(
boost::bind(&WorkArea::displayMessage, this, _1));
+
+ lyx_view_.connectBufferView(*buffer_view);
}
void MailInset::showDialog(BufferView * bv) const
{
BOOST_ASSERT(bv);
- bv->owner()->getDialogs().show(name(), inset2string(*bv->buffer()),
+ bv->showInsetDialog(name(), inset2string(*bv->buffer()),
&inset());
}
void MailInset::updateDialog(BufferView * bv) const
{
BOOST_ASSERT(bv);
- if (bv->owner()->getDialogs().visible(name()))
- bv->owner()->getDialogs().update(name(),
- inset2string(*bv->buffer()));
+ bv->updateDialog(name(), inset2string(*bv->buffer()));
}
class LyXFunc : public boost::signals::trackable {
public:
///
- explicit LyXFunc(LyXView *);
+ explicit LyXFunc(LyXView * lv = 0);
/// LyX dispatcher, executes lyx actions.
void dispatch(FuncRequest const &);
string const data = InsetCommandMailer::params2string("label", p);
if (cmd.argument().empty())
- cur.bv().owner()->getDialogs().show("label", data, 0);
+ cur.bv().showInsetDialog("label", data, 0);
else {
FuncRequest fr(LFUN_INSET_INSERT, data);
dispatch(cur, fr);
RefInset tmp(name);
data = tmp.createDialogStr(name);
}
- cur.bv().owner()->getDialogs().show(name, data, 0);
+ cur.bv().showInsetDialog(name, data, 0);
break;
}
if (cmd.button() == mouse_button::button3) {
// try to dispatch to enclosed insets first
- cur.bv().owner()->getDialogs().show("mathpanel");
+ cur.bv().showDialog("mathpanel");
return;
}
case LFUN_INSET_DIALOG_UPDATE: {
string const data = createDialogStr("ref");
- if (cur.bv().owner()->getDialogs().visible("ref"))
- cur.bv().owner()->getDialogs().update("ref", data);
+ cur.bv().updateDialog("ref", data);
break;
}
if (cmd.button() == mouse_button::button1) {
// Eventually trigger dialog with button 3, not 1
string const data = createDialogStr("ref");
- cur.bv().owner()->getDialogs().show("ref", data, this);
+ cur.bv().showInsetDialog("ref", data, this);
break;
}
cur.undispatched();
lyxerr << "Undefined result from gettext" << endl;
translated = from_ascii(tmp);
} else if (msg == tmp) {
- lyxerr << "Same as entered returned" << endl;
+ //lyxerr << "Same as entered returned" << endl;
translated = from_ascii(tmp);
} else {
lyxerr << "We got a translation" << endl;
case LFUN_URL_INSERT: {
InsetCommandParams p("url");
string const data = InsetCommandMailer::params2string("url", p);
- bv->owner()->getDialogs().show("url", data, 0);
+ bv->showInsetDialog("url", data, 0);
break;
}
case LFUN_HTML_INSERT: {
InsetCommandParams p("htmlurl");
string const data = InsetCommandMailer::params2string("url", p);
- bv->owner()->getDialogs().show("url", data, 0);
+ bv->showInsetDialog("url", data, 0);
break;
}
string const data = InsetCommandMailer::params2string("label", p);
if (cmd.argument().empty()) {
- bv->owner()->getDialogs().show("label", data, 0);
+ bv->showInsetDialog("label", data, 0);
} else {
FuncRequest fr(LFUN_INSET_INSERT, data);
dispatch(cur, fr);
if (doInsertInset(cur, this, cmd, false, true))
cur.posRight();
else
- bv->owner()->getDialogs().show("tabularcreate");
+ bv->showDialog("tabularcreate");
break;
string data;
params2string(cur.paragraph(), data);
data = "show\n" + data;
- bv->owner()->getDialogs().show("paragraph", data);
+ bv->showDialogWithData("paragraph", data);
break;
}
case LFUN_PARAGRAPH_UPDATE: {
- if (!bv->owner()->getDialogs().visible("paragraph"))
- break;
string data;
params2string(cur.paragraph(), data);
bool const accept = !cur.inset().forceDefaultParagraphs(cur.idx());
data = "update " + convert<string>(accept) + '\n' + data;
- bv->owner()->getDialogs().update("paragraph", data);
+ bv->updateDialog("paragraph", data);
break;
}
arg = cur.selectionAsString(false);
}
}
- bv->owner()->getDialogs().show("thesaurus", lyx::to_utf8(arg));
+ bv->showDialogWithData("thesaurus", lyx::to_utf8(arg));
break;
}