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"
27 #include "support/globbing.h"
36 using support::FileFilterList;
37 using support::IsFileReadable;
38 using support::MakeAbsPath;
39 using support::OnlyPath;
43 ControlInclude::ControlInclude(Dialog & parent)
44 : Dialog::Controller(parent)
48 bool ControlInclude::initialiseParams(string const & data)
50 InsetIncludeMailer::string2params(data, params_);
55 void ControlInclude::clearParams()
57 params_ = InsetCommandParams();
61 void ControlInclude::dispatchParams()
63 string const lfun = InsetIncludeMailer::params2string(params_);
64 kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
68 void ControlInclude::setParams(InsetCommandParams const & params)
74 string const ControlInclude::browse(string const & in_name, Type in_type) const
76 string const title = _("Select document to include");
78 // input TeX, verbatim, or LyX file ?
79 FileFilterList filters;
83 filters = FileFilterList(_("LaTeX/LyX Documents (*.tex *.lyx)"));
89 pair<string, string> dir1(N_("Documents|#o#O"),
90 string(lyxrc.document_path));
92 string const docpath = OnlyPath(kernel().buffer().fileName());
94 return browseRelFile(in_name, docpath, title,
95 filters, false, dir1);
99 void ControlInclude::load(string const & file)
101 kernel().dispatch(FuncRequest(LFUN_CHILDOPEN, file));
105 bool ControlInclude::fileExists(string const & file)
107 string const fileWithAbsPath
109 OnlyPath(kernel().buffer().fileName()));
111 if (IsFileReadable(fileWithAbsPath))
117 } // namespace frontend