2 * \file ControlInclude.C
3 * Copyright 2001 the LyX Team
4 * Read the file COPYING
6 * \author Alejandro Aguilar Sierra
7 * \author John Levon, moz@compsoc.man.ac.uk
8 * \author Angus Leeming, a.leeming@.ac.uk
14 #pragma implementation
17 #include "ControlInclude.h"
19 #include "BufferView.h"
22 #include "helper_funcs.h"
24 #include "funcrequest.h"
26 #include "support/filetools.h"
33 ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
34 : ControlInset<InsetInclude, InsetInclude::Params>(lv, d)
38 void ControlInclude::applyParamsToInset()
40 inset()->set(params());
41 bufferview()->updateInset(inset(), true);
45 string const ControlInclude::Browse(string const & in_name, Type in_type)
47 string const title = _("Select document to include");
49 // input TeX, verbatim, or LyX file ?
53 pattern = _("*.tex| LaTeX Documents (*.tex)");
57 pattern = _("*| All files ");
61 pattern = _("*.lyx| LyX Documents (*.lyx)");
65 pair<string, string> dir1(N_("Documents|#o#O"),
66 string(lyxrc.document_path));
68 string const docpath = OnlyPath(params().masterFilename_);
70 return browseRelFile(&lv_, in_name, docpath, title, pattern, dir1);
74 void ControlInclude::load(string const & file)
76 lyxfunc().dispatch(FuncRequest(LFUN_CHILDOPEN, file));
80 bool ControlInclude::fileExists(string const & file)
82 string const fileWithAbsPath
83 = MakeAbsPath(file, OnlyPath(params().masterFilename_));
85 if (params().noload) {
87 if (prefixIs(file, "../") || prefixIs(file, "/"))
88 Alert::alert(_("Warning!"),
89 _("On some systems, with this options only relative path names"),
90 _("inside the master file dir are allowed. You might get a LaTeX error!"));
93 if (IsFileReadable(fileWithAbsPath))
97 Alert::alert(_("Warning!"), _("Specified file doesn't exist"));