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 <leeming@lyx.org>
14 #pragma implementation
17 #include "ControlInclude.h"
19 #include "helper_funcs.h"
21 #include "BufferView.h"
22 #include "funcrequest.h"
27 #include "frontends/Alert.h"
29 #include "support/filetools.h"
36 ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
37 : ControlInset<InsetInclude, InsetInclude::Params>(lv, d)
41 void ControlInclude::applyParamsToInset()
43 inset()->set(params());
44 bufferview()->updateInset(inset(), true);
48 string const ControlInclude::Browse(string const & in_name, Type in_type)
50 string const title = _("Select document to include");
52 // input TeX, verbatim, or LyX file ?
56 pattern = _("*.tex| LaTeX Documents (*.tex)");
60 pattern = _("*| All files ");
64 pattern = _("*.lyx| LyX Documents (*.lyx)");
68 pair<string, string> dir1(N_("Documents|#o#O"),
69 string(lyxrc.document_path));
71 string const docpath = OnlyPath(params().masterFilename_);
73 return browseRelFile(&lv_, in_name, docpath, title, pattern, dir1);
77 void ControlInclude::load(string const & file)
79 lyxfunc().dispatch(FuncRequest(LFUN_CHILDOPEN, file));
83 bool ControlInclude::fileExists(string const & file)
85 string const fileWithAbsPath
86 = MakeAbsPath(file, OnlyPath(params().masterFilename_));
88 if (params().noload) {
90 if (prefixIs(file, "../") || prefixIs(file, "/"))
91 Alert::alert(_("Warning!"),
92 _("On some systems, with this options only relative path names"),
93 _("inside the master file dir are allowed. You might get a LaTeX error!"));
96 if (IsFileReadable(fileWithAbsPath))
100 Alert::alert(_("Warning!"), _("Specified file doesn't exist"));