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 #include "ControlInclude.h"
18 #include "helper_funcs.h"
20 #include "BufferView.h"
21 #include "funcrequest.h"
26 #include "frontends/Alert.h"
28 #include "support/filetools.h"
35 ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
36 : ControlInset<InsetInclude, InsetInclude::Params>(lv, d)
40 void ControlInclude::applyParamsToInset()
42 inset()->set(params());
43 bufferview()->updateInset(inset(), true);
47 string const ControlInclude::Browse(string const & in_name, Type in_type)
49 string const title = _("Select document to include");
51 // input TeX, verbatim, or LyX file ?
55 pattern = _("*.(tex|lyx)| LaTeX/LyX Documents (*.tex *.lyx)");
59 pattern = _("*| All files (*)");
63 pattern = _("*.(tex|lyx)| LaTeX/LyX Documents (*.tex *.lyx)");
67 pair<string, string> dir1(N_("Documents|#o#O"),
68 string(lyxrc.document_path));
70 string const docpath = OnlyPath(params().masterFilename_);
72 return browseRelFile(&lv_, in_name, docpath, title, pattern, false, dir1);
76 void ControlInclude::load(string const & file)
78 lyxfunc().dispatch(FuncRequest(LFUN_CHILDOPEN, file));
82 bool ControlInclude::fileExists(string const & file)
84 string const fileWithAbsPath
85 = MakeAbsPath(file, OnlyPath(params().masterFilename_));
87 if (IsFileReadable(fileWithAbsPath))