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
15 #pragma implementation
19 #include "ButtonControllerBase.h"
20 #include "ControlInclude.h"
21 #include "ControlInset.tmpl"
24 #include "BufferView.h"
29 #include "helper_funcs.h"
31 #include "support/filetools.h"
37 ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
38 : ControlInset<InsetInclude, InsetInclude::Params>(lv, d)
40 d_.showInclude.connect(slot(this, &ControlInclude::showInset));
44 void ControlInclude::applyParamsToInset()
46 inset()->set(params());
47 lv_.view()->updateInset(inset(), true);
51 string const ControlInclude::Browse(string const & in_name, Type in_type)
53 string const title = _("Select document to include");
55 // input TeX, verbatim, or LyX file ?
59 pattern = _("*.tex| LaTeX Documents (*.tex)");
63 pattern = _("*| All files ");
67 pattern = _("*.lyx| LyX Documents (*.lyx)");
71 pair<string, string> dir1(N_("Documents|#o#O"),
72 string(lyxrc.document_path));
74 string const docpath = OnlyPath(params().masterFilename_);
76 return browseRelFile(&lv_, in_name, docpath, title, pattern, dir1);
80 void ControlInclude::load(string const & file)
82 lv_.getLyXFunc()->dispatch(LFUN_CHILDOPEN, file);
86 bool const ControlInclude::fileExists(string const & file)
88 string const fileWithAbsPath = MakeAbsPath(file, OnlyPath(params().masterFilename_));
89 if (IsFileReadable(fileWithAbsPath))
92 Alert::alert(_("File doesn't exists!"));