Hello,
This is the continuation of my BufferView/LyXView cleanup.
This patch compiles but I did not test it yet because of my math compile
problems (any news on that front?)
So, this patch replaces BufferView->LyXView->getDialogs().[show,
update()] with BufferView signal emissions.
The associated WorkArea is then responsible to connect these signals to
its LyXView parent.
Comments?
Index: BufferView.h
===================================================================
--- BufferView.h (revision 15038)
+++ BufferView.h (working copy)
@@ -217,6 +217,22 @@
/// 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();
Index: frontends/LyXView.C
===================================================================
--- frontends/LyXView.C (revision 15038)
+++ frontends/LyXView.C (working copy)
@@ -83,6 +83,7 @@
lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
}
+
LyXView::~LyXView()
{
}
@@ -219,6 +220,28 @@
}
+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);
@@ -228,6 +251,33 @@
}
+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();
Index: frontends/LyXView.h
===================================================================
--- frontends/LyXView.h (revision 15038)
+++ frontends/LyXView.h (working copy)
@@ -165,6 +165,11 @@
/// 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).
/**
@@ -214,6 +219,27 @@
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);
Index: frontends/WorkArea.C
===================================================================
--- frontends/WorkArea.C (revision 15038)
+++ frontends/WorkArea.C (working copy)
@@ -159,8 +159,10 @@
void WorkArea::setBufferView(BufferView * buffer_view)
{
- if (buffer_view_)
+ if (buffer_view_) {
message_connection_.disconnect();
+ lyx_view_.disconnectBufferView();
+ }
hideCursor();
buffer_view_ = buffer_view;
@@ -168,6 +170,8 @@
message_connection_ = buffer_view_->message.connect(
boost::bind(&WorkArea::displayMessage, this, _1));
+
+ lyx_view_.connectBufferView(*buffer_view);
}
Index: insets/mailinset.C
===================================================================
--- insets/mailinset.C (revision 15038)
+++ insets/mailinset.C (working copy)
@@ -24,7 +24,7 @@
void MailInset::showDialog(BufferView * bv) const
{
BOOST_ASSERT(bv);
- bv->owner()->getDialogs().show(name(), inset2string(*bv->buffer()),
+ bv->showInsetDialog(name(), inset2string(*bv->buffer()),
&inset());
}
@@ -32,9 +32,7 @@
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()));
}
Index: mathed/InsetMathHull.C
===================================================================
--- mathed/InsetMathHull.C (revision 15038)
+++ mathed/InsetMathHull.C (working copy)
@@ -1081,7 +1081,7 @@
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);
Index: mathed/InsetMathNest.C
===================================================================
--- mathed/InsetMathNest.C (revision 15038)
+++ mathed/InsetMathNest.C (working copy)
@@ -939,7 +939,7 @@
RefInset tmp(name);
data = tmp.createDialogStr(name);
}
- cur.bv().owner()->getDialogs().show(name, data, 0);
+ cur.bv().showInsetDialog(name, data, 0);
break;
}
@@ -1126,7 +1126,7 @@
if (cmd.button() == mouse_button::button3) {
// try to dispatch to enclosed insets first
- cur.bv().owner()->getDialogs().show("mathpanel");
+ cur.bv().showDialog("mathpanel");
return;
}
Index: mathed/InsetMathRef.C
===================================================================
--- mathed/InsetMathRef.C (revision 15038)
+++ mathed/InsetMathRef.C (working copy)
@@ -73,8 +73,7 @@
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;
}
@@ -87,7 +86,7 @@
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();
Index: text3.C
===================================================================
--- text3.C (revision 15038)
+++ text3.C (working copy)
@@ -1091,14 +1091,14 @@
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;
}
@@ -1111,7 +1111,7 @@
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);
@@ -1146,7 +1146,7 @@
if (doInsertInset(cur, this, cmd, false, true))
cur.posRight();
else
- bv->owner()->getDialogs().show("tabularcreate");
+ bv->showDialog("tabularcreate");
break;
@@ -1351,13 +1351,11 @@
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);
@@ -1365,7 +1363,7 @@
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;
}
@@ -1438,7 +1436,7 @@
arg = cur.selectionAsString(false);
}
}
- bv->owner()->getDialogs().show("thesaurus", lyx::to_utf8(arg));
+ bv->showDialogWithData("thesaurus", lyx::to_utf8(arg));
break;
}