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;
38 ControlInclude::ControlInclude(Dialog & parent)
39 : Dialog::Controller(parent)
43 bool ControlInclude::initialiseParams(string const & data)
45 InsetIncludeMailer::string2params(data, params_);
50 void ControlInclude::clearParams()
52 params_ = InsetCommandParams();
56 void ControlInclude::dispatchParams()
58 string const lfun = InsetIncludeMailer::params2string(params_);
59 kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, lfun));
63 void ControlInclude::setParams(InsetCommandParams const & params)
69 string const ControlInclude::Browse(string const & in_name, Type in_type)
71 string const title = _("Select document to include");
73 // input TeX, verbatim, or LyX file ?
77 pattern = _("*.(tex|lyx)| LaTeX/LyX Documents (*.tex *.lyx)");
81 pattern = _("*| All files (*)");
85 pattern = _("*.(tex|lyx)| 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, pattern, false, dir1);
98 void ControlInclude::load(string const & file)
100 kernel().dispatch(FuncRequest(LFUN_CHILDOPEN, file));
104 bool ControlInclude::fileExists(string const & file)
106 string const fileWithAbsPath
108 OnlyPath(kernel().buffer().fileName()));
110 if (IsFileReadable(fileWithAbsPath))