]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/Dialogs3.C
Minipage is no more (long live the box inset)
[lyx.git] / src / frontends / gnome / Dialogs3.C
1 /**
2  * \file qt2/Dialogs3.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "Dialogs.h"
14 #include "Dialog.h"
15
16 #include "ControlBibitem.h"
17 #include "ControlBibtex.h"
18 #include "ControlCitation.h"
19 #include "ControlError.h"
20 #include "ControlERT.h"
21 #include "ControlIndex.h"
22 #include "ControlRef.h"
23 #include "ControlToc.h"
24 #include "ControlUrl.h"
25
26 #include "FormBibitem.h"
27 #include "forms/form_bibitem.h"
28
29 #include "FormBibtex.h"
30 #include "forms/form_bibtex.h"
31
32 #include "FormCitation.h"
33 #include "forms/form_citation.h"
34
35 #include "GError.h"
36 #include "GERT.h"
37
38 #include "FormIndex.h"
39 #include "forms/form_index.h"
40
41 #include "FormRef.h"
42 #include "forms/form_ref.h"
43
44 #include "FormToc.h"
45 #include "forms/form_toc.h"
46
47 #include "GUrl.h"
48
49 #include "gnomeBC.h"
50 #include "ButtonController.h"
51
52
53 typedef ButtonController<OkCancelPolicy, gnomeBC>
54         OkCancelBC;
55
56 typedef ButtonController<OkCancelReadOnlyPolicy, gnomeBC>
57         OkCancelReadOnlyBC;
58
59 typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, gnomeBC>
60         NoRepeatedApplyReadOnlyBC;
61
62
63 namespace {
64
65 char const * const dialognames[] = { "bibitem", "bibtex", "citation",
66                                      "error", "ert", "index", "ref",
67                                      "toc", "url" };
68
69 char const * const * const end_dialognames =
70         dialognames + (sizeof(dialognames) / sizeof(char *));
71
72 struct cmpCStr {
73         cmpCStr(char const * name) : name_(name) {}
74         bool operator()(char const * other) {
75                 return strcmp(other, name_) == 0;
76         }
77 private:
78         char const * name_;
79 };
80
81
82 } // namespace anon
83
84
85 bool Dialogs::isValidName(string const & name) const
86 {
87         return std::find_if(dialognames, end_dialognames,
88                             cmpCStr(name.c_str())) != end_dialognames;
89 }
90
91
92 Dialog * Dialogs::build(string const & name)
93 {
94         if (!isValidName(name))
95                 return 0;
96
97         Dialog * dialog = new Dialog(lyxview_, name);
98
99         if (name == "bibitem") {
100                 dialog->setController(new ControlBibitem(*dialog));
101                 dialog->setView(new FormBibitem(*dialog));
102                 dialog->setButtonController(new OkCancelReadOnlyBC);
103         } else if (name == "bibtex") {
104                 dialog->setController(new ControlBibtex(*dialog));
105                 dialog->setView(new FormBibtex(*dialog));
106                 dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
107         } else if (name == "citation") {
108                 dialog->setController(new ControlCitation(*dialog));
109                 dialog->setView(new FormCitation(*dialog));
110                 dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
111         } else if (name == "error") {
112                 dialog->setController(new ControlError(*dialog));
113                 dialog->setView(new GError(*dialog));
114                 dialog->setButtonController(new OkCancelBC);
115         } else if (name == "ert") {
116                 dialog->setController(new ControlERT(*dialog));
117                 dialog->setView(new GERT(*dialog));
118                 dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
119         } else if (name == "index") {
120                 dialog->setController(new ControlIndex(*dialog));
121                 dialog->setView(new FormIndex(*dialog));
122                 dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
123         } else if (name == "ref") {
124                 dialog->setController(new ControlRef(*dialog));
125                 dialog->setView(new FormRef(*dialog));
126                 dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
127         } else if (name == "toc") {
128                 dialog->setController(new ControlToc(*dialog));
129                 dialog->setView(new FormToc(*dialog));
130                 dialog->setButtonController(new OkCancelBC);
131         } else if (name == "url") {
132                 dialog->setController(new ControlUrl(*dialog));
133                 dialog->setView(new GURL(*dialog));
134                 dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
135         }
136
137         return dialog;
138 }
139
140
141 void Dialogs::toggleTooltips()
142 {
143         Tooltips::toggleEnabled();
144 }
145
146
147 bool Dialogs::tooltipsEnabled()
148 {
149         return Tooltips::enabled();
150 }