]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlInclude.C
b81f539ea5c185efbe4faf681003dd2ed0afba17
[lyx.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 "buffer.h"
22 #include "BufferView.h"
23 #include "Dialogs.h"
24 #include "LyXView.h"
25 #include "lyxfunc.h"
26 #include "gettext.h"
27
28 #include "helper_funcs.h"
29 #include "lyxrc.h"
30
31 using std::pair;
32 using std::make_pair;
33 using SigC::slot;
34
35 ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
36         : ControlInset<InsetInclude, InsetInclude::Params>(lv, d)
37 {
38         d_.showInclude.connect(slot(this, &ControlInclude::showInset));
39 }
40
41
42 void ControlInclude::applyParamsToInset()
43 {
44         inset()->set(params());
45         lv_.view()->updateInset(inset(), true);
46 }
47
48
49 string const ControlInclude::Browse(string const & in_name, Type in_type)
50 {
51         string const title = N_("Select document to include");
52
53         string pattern;
54                    
55         // input TeX, verbatim, or LyX file ?
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"), string(lyxrc.document_path));
71
72         return browseFile(&lv_, in_name, title, pattern, dir1,
73                           make_pair(string(), string()));
74 }
75
76
77 void ControlInclude::load(string const & file)
78 {
79         lv_.getLyXFunc()->dispatch(LFUN_CHILDOPEN, file);
80 }