*
* \file ControlExternal.C
* \author Asger Alstrup
- * \author John Levon
+ * \author John Levon, moz@compsoc.man.ac.uk
* \author Angus Leeming, a.leeming@ic.ac.uk
*/
#pragma implementation
#endif
+#include "ViewBase.h"
+#include "ButtonControllerBase.h"
#include "ControlExternal.h"
#include "buffer.h"
#include "Dialogs.h"
#include "Liason.h"
#include "LyXView.h"
#include "support/filetools.h"
+#include "support/lstrings.h"
#include "frontends/FileDialog.h"
#include "lyx_gui_misc.h" // WriteAlert
+#include "gettext.h"
+#include "BufferView.h"
using std::make_pair;
using std::vector;
}
-void ControlExternal::editExternal()
+void ControlExternal::applyParamsToInset()
{
inset()->setFromParams(params());
- inset()->editExternal();
+ lv_.view()->updateInset(inset(), true);
+}
+
+void ControlExternal::editExternal()
+{
+ // fill the local, controller's copy of the Params struct with
+ // the contents of the dialog's fields.
+ view().apply();
+
+ // Create a local copy of the inset and initialise it with this
+ // params struct.
+ boost::scoped_ptr<InsetExternal> ie;
+ ie.reset(static_cast<InsetExternal *>(inset()->clone(*lv_.buffer())));
+ ie->setFromParams(params());
+
+ ie->editExternal();
}
void ControlExternal::viewExternal()
{
- inset()->setFromParams(params());
- inset()->viewExternal();
+ view().apply();
+
+ boost::scoped_ptr<InsetExternal> ie;
+ ie.reset(static_cast<InsetExternal *>(inset()->clone(*lv_.buffer())));
+ ie->setFromParams(params());
+
+ ie->viewExternal();
}
void ControlExternal::updateExternal()
{
- inset()->setFromParams(params());
- inset()->updateExternal();
+ view().apply();
+
+ boost::scoped_ptr<InsetExternal> ie;
+ ie.reset(static_cast<InsetExternal *>(inset()->clone(*lv_.buffer())));
+ ie->setFromParams(params());
+
+ ie->updateExternal();
}
vector<string> const ControlExternal::getTemplates() const
for (int n = 1; n < i; ++n)
++i1;
- return (*i1).second;
+ return i1->second;
}
// FIXME: a temporary hack until the FileDialog interface is updated
regexp += "|";
- static int once = 0;
+ static int once;
string current_path;
while (1) {
string p = result.second;
- buf = MakeRelPath(input, buf2);
- current_path = OnlyPath(input);
+ buf = MakeRelPath(p, buf2);
+ current_path = OnlyPath(p);
once = 1;
- if (contains(input, "#") ||
- contains(input, "~") ||
- contains(input, "$") ||
- contains(input, "%")) {
+ if (contains(p, "#") ||
+ contains(p, "~") ||
+ contains(p, "$") ||
+ contains(p, "%")) {
WriteAlert(_("Filename can't contain any "
"of these characters:"),
// xgettext:no-c-format