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
16 #pragma implementation
19 #include "ControlInclude.h"
21 #include "helper_funcs.h"
23 #include "BufferView.h"
24 #include "funcrequest.h"
29 #include "frontends/Alert.h"
31 #include "support/filetools.h"
38 ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
39 : ControlInset<InsetInclude, InsetInclude::Params>(lv, d)
43 void ControlInclude::applyParamsToInset()
45 inset()->set(params());
46 bufferview()->updateInset(inset(), true);
50 string const ControlInclude::Browse(string const & in_name, Type in_type)
52 string const title = _("Select document to include");
54 // input TeX, verbatim, or LyX file ?
58 pattern = _("*.(tex|lyx)| LaTeX/LyX Documents (*.tex *.lyx)");
62 pattern = _("*| All files (*)");
66 pattern = _("*.(tex|lyx)| LaTeX/LyX Documents (*.tex *.lyx)");
70 pair<string, string> dir1(N_("Documents|#o#O"),
71 string(lyxrc.document_path));
73 string const docpath = OnlyPath(params().masterFilename_);
75 return browseRelFile(&lv_, in_name, docpath, title, pattern, dir1);
79 void ControlInclude::load(string const & file)
81 lyxfunc().dispatch(FuncRequest(LFUN_CHILDOPEN, file));
85 bool ControlInclude::fileExists(string const & file)
87 string const fileWithAbsPath
88 = MakeAbsPath(file, OnlyPath(params().masterFilename_));
90 if (IsFileReadable(fileWithAbsPath))