]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/controllers/ControlInclude.C
Add a buffer_path arg to InsetGraphicsMailer's params2string, string2params.
[lyx.git] / src / frontends / controllers / ControlInclude.C
index 050b92d96148009d5a2ae8d82abc81fc094a9d26..3f4af1cece46378c7054ae5d71fd93c57387e839 100644 (file)
@@ -1,50 +1,66 @@
 /**
  * \file ControlInclude.C
- * Copyright 2001 the LyX Team
- * Read the file COPYING
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
  * \author Alejandro Aguilar Sierra
- * \author John Levon, moz@compsoc.man.ac.uk
- * \author Angus Leeming <leeming@lyx.org>
+ * \author John Levon
+ * \author Angus Leeming
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
 
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
 #include "ControlInclude.h"
-
 #include "helper_funcs.h"
 
-#include "BufferView.h"
 #include "funcrequest.h"
 #include "gettext.h"
-#include "lyxfunc.h"
 #include "lyxrc.h"
 
-#include "frontends/Alert.h"
-
 #include "support/filetools.h"
 
 #include <utility>
 
+using namespace lyx::support;
+
 using std::pair;
 
 
-ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
-       : ControlInset<InsetInclude, InsetInclude::Params>(lv, d)
+ControlInclude::ControlInclude(Dialog & parent)
+       : Dialog::Controller(parent)
 {}
 
 
-void ControlInclude::applyParamsToInset()
+bool ControlInclude::initialiseParams(string const & data)
+{
+       InsetInclude::Params params;
+       InsetIncludeMailer::string2params(data, params);
+       inset_.reset(new InsetInclude(params));
+       return true;
+}
+
+
+void ControlInclude::clearParams()
+{
+       inset_.reset();
+}
+
+
+void ControlInclude::dispatchParams()
 {
-       inset()->set(params());
-       bufferview()->updateInset(inset(), true);
+       InsetInclude::Params p = params();
+       string const lfun = InsetIncludeMailer::params2string(p);
+       kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
 }
 
 
+void ControlInclude::setParams(InsetInclude::Params const & params)
+{
+       inset_->set(params);
+}
+
 string const ControlInclude::Browse(string const & in_name, Type in_type)
 {
        string const title = _("Select document to include");
@@ -53,15 +69,15 @@ string const ControlInclude::Browse(string const & in_name, Type in_type)
        string pattern;
        switch (in_type) {
        case INPUT:
-           pattern = _("*.tex| LaTeX Documents (*.tex)");
+           pattern = _("*.(tex|lyx)| LaTeX/LyX Documents (*.tex *.lyx)");
            break;
 
        case VERBATIM:
-           pattern = _("*| All files ");
+           pattern = _("*| All files (*)");
            break;
 
        case INCLUDE:
-           pattern = _("*.lyx| LyX Documents (*.lyx)");
+           pattern = _("*.(tex|lyx)| LaTeX/LyX Documents (*.tex *.lyx)");
            break;
        }
 
@@ -70,13 +86,13 @@ string const ControlInclude::Browse(string const & in_name, Type in_type)
 
        string const docpath = OnlyPath(params().masterFilename_);
 
-       return browseRelFile(&lv_, in_name, docpath, title, pattern, dir1);
+       return browseRelFile(in_name, docpath, title, pattern, false, dir1);
 }
 
 
 void ControlInclude::load(string const & file)
 {
-       lyxfunc().dispatch(FuncRequest(LFUN_CHILDOPEN, file));
+       kernel().dispatch(FuncRequest(LFUN_CHILDOPEN, file));
 }
 
 
@@ -85,18 +101,8 @@ bool ControlInclude::fileExists(string const & file)
        string const fileWithAbsPath
                = MakeAbsPath(file, OnlyPath(params().masterFilename_));
 
-       if (params().noload) {
-
-               if (prefixIs(file, "../") || prefixIs(file, "/"))
-                       Alert::alert(_("Warning!"),
-                               _("On some systems, with this options only relative path names"),
-                               _("inside the master file dir are allowed. You might get a LaTeX error!"));
-       }
-
        if (IsFileReadable(fileWithAbsPath))
                return true;
-       
-       else
-               Alert::alert(_("Warning!"), _("Specified file doesn't exist"));
-               return false;
+
+       return false;
 }