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"
25 #include "support/filetools.h"
32 ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
33 : ControlInset<InsetInclude, InsetInclude::Params>(lv, d)
37 void ControlInclude::applyParamsToInset()
39 inset()->set(params());
40 lv_.view()->updateInset(inset(), true);
44 string const ControlInclude::Browse(string const & in_name, Type in_type)
46 string const title = _("Select document to include");
48 // input TeX, verbatim, or LyX file ?
52 pattern = _("*.tex| LaTeX Documents (*.tex)");
56 pattern = _("*| All files ");
60 pattern = _("*.lyx| LyX Documents (*.lyx)");
64 pair<string, string> dir1(N_("Documents|#o#O"),
65 string(lyxrc.document_path));
67 string const docpath = OnlyPath(params().masterFilename_);
69 return browseRelFile(&lv_, in_name, docpath, title, pattern, dir1);
73 void ControlInclude::load(string const & file)
75 lv_.getLyXFunc()->dispatch(LFUN_CHILDOPEN, file);
79 bool ControlInclude::fileExists(string const & file)
81 string const fileWithAbsPath = MakeAbsPath(file, OnlyPath(params().masterFilename_));
82 if (IsFileReadable(fileWithAbsPath))
85 Alert::alert(_("Specified file doesn't exist !"));