]> git.lyx.org Git - features.git/blob - src/frontends/controllers/ControlInclude.C
4d018f0916e6d9f822d7fb6ca86cc7e5dfb3d140
[features.git] / src / frontends / controllers / ControlInclude.C
1 /**
2  * \file ControlInclude.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author Alejandro Aguilar Sierra
7  * \author John Levon, moz@compsoc.man.ac.uk
8  * \author Angus Leeming, a.leeming@.ac.uk
9  */
10
11 #include <config.h>
12 #include <utility>
13
14 #ifdef __GNUG__
15 #pragma implementation
16 #endif
17
18 #include "ViewBase.h"
19 #include "ButtonControllerBase.h"
20 #include "ControlInclude.h"
21 #include "ControlInset.tmpl"
22 #include "buffer.h"
23 #include "BufferView.h"
24 #include "Dialogs.h"
25 #include "LyXView.h"
26 #include "lyxfunc.h"
27 #include "gettext.h"
28 #include "helper_funcs.h"
29 #include "lyxrc.h"
30 #include "support/filetools.h"
31
32 using std::pair;
33 using std::make_pair;
34 using SigC::slot;
35
36 ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
37         : ControlInset<InsetInclude, InsetInclude::Params>(lv, d)
38 {
39         d_.showInclude.connect(slot(this, &ControlInclude::showInset));
40 }
41
42
43 void ControlInclude::applyParamsToInset()
44 {
45         inset()->set(params());
46         lv_.view()->updateInset(inset(), true);
47 }
48
49
50 string const ControlInclude::Browse(string const & in_name, Type in_type)
51 {
52         string const title = _("Select document to include");
53
54         // input TeX, verbatim, or LyX file ?
55         string pattern;            
56         switch (in_type) {
57         case INPUT:
58             pattern = _("*.tex| LaTeX Documents (*.tex)");
59             break;
60
61         case VERBATIM:
62             pattern = _("*| All files ");
63             break;
64
65         case INCLUDE:
66             pattern = _("*.lyx| LyX Documents (*.lyx)");
67             break;
68         }
69         
70         pair<string, string> dir1(N_("Documents|#o#O"),
71                                   string(lyxrc.document_path));
72
73         string const docpath = OnlyPath(params().masterFilename_);
74         
75         return browseRelFile(&lv_, in_name, docpath, title, pattern, dir1);
76 }
77
78
79 void ControlInclude::load(string const & file)
80 {
81         lv_.getLyXFunc()->dispatch(LFUN_CHILDOPEN, file);
82 }