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"
20 #include "funcrequest.h"
24 #include "insets/insetinclude.h"
26 #include "support/filetools.h"
30 using lyx::support::IsFileReadable;
31 using lyx::support::MakeAbsPath;
32 using lyx::support::OnlyPath;
37 ControlInclude::ControlInclude(Dialog & parent)
38 : Dialog::Controller(parent)
42 bool ControlInclude::initialiseParams(string const & data)
44 InsetIncludeMailer::string2params(data, params_);
49 void ControlInclude::clearParams()
51 params_ = InsetCommandParams();
55 void ControlInclude::dispatchParams()
57 string const lfun = InsetIncludeMailer::params2string(params_);
58 kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
62 void ControlInclude::setParams(InsetCommandParams const & params)
68 string const ControlInclude::Browse(string const & in_name, Type in_type)
70 string const title = _("Select document to include");
72 // input TeX, verbatim, or LyX file ?
76 pattern = _("*.(tex|lyx)| LaTeX/LyX Documents (*.tex *.lyx)");
80 pattern = _("*| All files (*)");
84 pattern = _("*.(tex|lyx)| LaTeX/LyX Documents (*.tex *.lyx)");
88 pair<string, string> dir1(N_("Documents|#o#O"),
89 string(lyxrc.document_path));
91 string const docpath = OnlyPath(kernel().buffer().fileName());
93 return browseRelFile(in_name, docpath, title, pattern, false, dir1);
97 void ControlInclude::load(string const & file)
99 kernel().dispatch(FuncRequest(LFUN_CHILDOPEN, file));
103 bool ControlInclude::fileExists(string const & file)
105 string const fileWithAbsPath
107 OnlyPath(kernel().buffer().fileName()));
109 if (IsFileReadable(fileWithAbsPath))