2 * \file ControlInclude.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Alejandro Aguilar Sierra
8 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS.
15 #include "ControlInclude.h"
16 #include "helper_funcs.h"
18 #include "funcrequest.h"
22 #include "support/filetools.h"
26 using namespace lyx::support;
31 ControlInclude::ControlInclude(Dialog & parent)
32 : Dialog::Controller(parent)
36 bool ControlInclude::initialiseParams(string const & data)
38 InsetInclude::Params params;
39 InsetIncludeMailer::string2params(data, params);
40 inset_.reset(new InsetInclude(params));
45 void ControlInclude::clearParams()
51 void ControlInclude::dispatchParams()
53 InsetInclude::Params p = params();
54 string const lfun = InsetIncludeMailer::params2string(p);
55 kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
59 void ControlInclude::setParams(InsetInclude::Params const & params)
64 string const ControlInclude::Browse(string const & in_name, Type in_type)
66 string const title = _("Select document to include");
68 // input TeX, verbatim, or LyX file ?
72 pattern = _("*.(tex|lyx)| LaTeX/LyX Documents (*.tex *.lyx)");
76 pattern = _("*| All files (*)");
80 pattern = _("*.(tex|lyx)| LaTeX/LyX Documents (*.tex *.lyx)");
84 pair<string, string> dir1(N_("Documents|#o#O"),
85 string(lyxrc.document_path));
87 string const docpath = OnlyPath(params().masterFilename_);
89 return browseRelFile(in_name, docpath, title, pattern, false, dir1);
93 void ControlInclude::load(string const & file)
95 kernel().dispatch(FuncRequest(LFUN_CHILDOPEN, file));
99 bool ControlInclude::fileExists(string const & file)
101 string const fileWithAbsPath
102 = MakeAbsPath(file, OnlyPath(params().masterFilename_));
104 if (IsFileReadable(fileWithAbsPath))