]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlGraphics.C
implement getLabelList
[lyx.git] / src / frontends / controllers / ControlGraphics.C
1 /* This file is part of
2  * ====================================================== 
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 2001 The LyX Team.
7  *
8  * ======================================================
9  *
10  * \file ControlGraphics.C
11  * \author Angus Leeming <a.leeming@ic.ac.uk>
12  */
13
14 #include <config.h> 
15
16 #ifdef __GNUG__
17 #pragma implementation
18 #endif 
19
20 #include "ControlGraphics.h"
21 #include "buffer.h"
22 #include "Dialogs.h"
23 #include "lyxfunc.h"
24 #include "LyXView.h"
25
26 #include "insets/insetgraphics.h"
27
28 #include "support/FileInfo.h"  // for FileInfo
29 #include "helper_funcs.h"      // for browseFile
30 #include "support/filetools.h" // for AddName
31
32 using std::pair;
33 using std::make_pair;
34
35 ControlGraphics::ControlGraphics(LyXView & lv, Dialogs & d)
36         : ControlInset<InsetGraphics, InsetGraphicsParams>(lv, d)
37 {
38         d_.showGraphics.connect(SigC::slot(this, &ControlGraphics::showInset));
39 }
40
41
42 InsetGraphicsParams const ControlGraphics::getParams(string const &)
43 {
44         return InsetGraphicsParams();
45 }
46
47
48 InsetGraphicsParams const
49 ControlGraphics::getParams(InsetGraphics const & inset)
50 {
51         return inset.getParams();
52 }
53
54
55 void ControlGraphics::applyParamsToInset()
56 {
57         // Set the parameters in the inset, it also returns true if the new
58         // parameters are different from what was in the inset already.
59         bool changed = inset()->setParams(params());
60         // Tell LyX we've got a change, and mark the document dirty,
61         // if it changed.
62         lv_.view()->updateInset(inset(), changed);
63 }
64
65
66 void ControlGraphics::applyParamsNoInset()
67 {}
68
69
70 // We need these in the file browser.
71 extern string system_lyxdir;
72 extern string user_lyxdir;
73
74 string const ControlGraphics::Browse(string const & in_name)
75 {
76         string const title = N_("Graphics");
77         // FIXME: currently we need the second '|' to prevent mis-interpretation 
78         string const pattern = "*.(ps|png)|";
79
80         // Does user clipart directory exist?
81         string clipdir = AddName (user_lyxdir, "clipart");
82         FileInfo fileInfo(clipdir);
83         if (!(fileInfo.isOK() && fileInfo.isDir()))
84                 // No - bail out to system clipart directory
85                 clipdir = AddName (system_lyxdir, "clipart");
86         pair<string, string> dir1(N_("Clipart"), clipdir);
87         
88         // Show the file browser dialog
89         return browseFile(&lv_, in_name, title, pattern, dir1,
90                           make_pair(string(), string()));
91 }