]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlInclude.C
Merge natbib branch into head
[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 "gettext.h"
26
27 #include "helper_funcs.h"
28 #include "lyxrc.h"
29
30 using std::pair;
31 using std::make_pair;
32 using SigC::slot;
33
34 ControlInclude::ControlInclude(LyXView & lv, Dialogs & d)
35         : ControlInset<InsetInclude, InsetInclude::Params>(lv, d)
36 {
37         d_.showInclude.connect(slot(this, &ControlInclude::showInset));
38 }
39
40
41 void ControlInclude::applyParamsToInset()
42 {
43         inset()->set(params());
44         lv_.view()->updateInset(inset(), true);
45 }
46
47
48 string const ControlInclude::Browse(string const & in_name, Type in_type)
49 {
50         string const title = N_("Select document to include");
51
52         string pattern;
53                    
54         // input TeX, verbatim, or LyX file ?
55         switch (in_type) {
56         case INPUT:
57             pattern = _("*.tex| LaTeX Documents (*.tex)");
58             break;
59
60         case VERBATIM:
61             pattern = _("*| All files ");
62             break;
63
64         case INCLUDE:
65             pattern = _("*.lyx| LyX Documents (*.lyx)");
66             break;
67         }
68         
69         pair<string, string> dir1(N_("Documents"), string(lyxrc.document_path));
70
71         return browseFile(&lv_, in_name, title, pattern, dir1,
72                           make_pair(string(), string()));
73 }