]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/Dialogs.C
ws cleanup
[lyx.git] / src / frontends / gnome / Dialogs.C
1 /* This file is part of
2  * ======================================================
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 1995-2001 The LyX Team.
7  *
8  * ======================================================
9  */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "gettext.h"
18
19 #include "Dialogs.h"
20 #include "BufferView.h"
21 #include "gnomeBC.h"
22 #include "Tooltips.h"
23 #include "ControlBibitem.h"
24 #include "ControlBibtex.h"
25 #include "ControlCharacter.h"
26 #include "ControlCitation.h"
27 #include "ControlError.h"
28 #include "ControlInclude.h"
29 #include "ControlLog.h"
30 #include "ControlUrl.h"
31 #include "ControlVCLog.h"
32 #include "ControlTabularCreate.h"
33 #include "ControlERT.h"
34 #include "GUI.h"
35
36 #include "FormUrl.h"
37 #include "FormError.h"
38 #include "FormTabularCreate.h"
39 #include "FormERT.h"
40 /*
41 #include "FormBibitem.h"
42 #include "FormBibtex.h"
43 #include "FormCharacter.h"
44 #include "FormCitation.h"
45 #include "FormLog.h"
46 #include "FormVCLog.h"
47
48 #include "FormDocument.h"
49 #include "FormExternal.h"
50 #include "FormGraphics.h"
51 #include "FormInclude.h"
52 #include "FormIndex.h"
53 #include "FormMathsPanel.h"
54 #include "FormParagraph.h"
55 #include "FormPreamble.h"
56 #include "FormPreferences.h"
57 #include "FormPrint.h"
58 #include "FormRef.h"
59 #include "FormSearch.h"
60 #include "FormTabular.h"
61 #include "FormTabul./arCreate.h"
62 #include "FormToc.h"
63 #include "FormUrl.h"
64 #include "FormMinipage.h"
65 */
66 bool Dialogs::tooltipsEnabled()
67 {
68         return Tooltips::enabled();
69 }
70 Dialogs::Dialogs(LyXView * lv)
71 {
72         add(new GUIUrl<FormUrl, gnomeBC>(*lv, *this));
73         add(new GUIError<FormError, gnomeBC>(*lv, *this));
74         add(new GUITabularCreate<FormTabularCreate, gnomeBC>(*lv, *this));
75         add(new GUIERT<FormERT, gnomeBC>(*lv, *this));
76
77 /*
78         add(new GUIBibitem<FormBibitem, xformsBC>(*lv, *this));
79         add(new GUIBibtex<FormBibtex, xformsBC>(*lv, *this));
80         add(new GUICharacter<FormCharacter, xformsBC>(*lv, *this));
81         //add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
82         add(new GUILog<FormLog, xformsBC>(*lv, *this));
83         add(new GUIVCLog<FormVCLog, xformsBC>(*lv, *this));
84
85         // For now we use the gnome non MVC dialogs
86         add(new FormCitation(lv, this));
87
88         add(new FormDocument(lv, this));
89         add(new FormExternal(lv, this));
90         add(new FormGraphics(lv, this));
91         add(new FormInclude(lv, this));
92         add(new FormIndex(lv, this));
93         add(new FormMathsPanel(lv, this));
94         add(new FormParagraph(lv, this));
95         add(new FormPreamble(lv, this));
96         add(new FormPreferences(lv, this));
97         add(new FormPrint(lv, this));
98         add(new FormRef(lv, this));
99         add(new FormSearch(lv, this));
100         add(new FormTabular(lv, this));
101         add(new FormTabularCreate(lv, this));
102         add(new FormToc(lv, this));
103         add(new FormUrl(lv, this));
104         add(new FormMinipage(lv, this));
105 */
106
107         // reduce the number of connections needed in
108         // dialogs by a simple connection here.
109         hideAll.connect(hideBufferDependent.slot());
110 }
111
112 /*****************************************************************************
113
114 Q.  WHY does Dialogs::Dialogs pass `this' to dialog constructors?
115
116 A.  To avoid a segfault.
117     The dialog constructors need to connect to their
118     respective showSomeDialog signal(*) but in order to do
119     that they need to get the address of the Dialogs instance
120     from LyXView::getDialogs().  However, since the Dialogs
121     instance is still being constructed at that time
122     LyXView::getDialogs() will *not* return the correct
123     address because it hasn't finished being constructed.
124     A Catch-22 situation (or is that the chicken and the egg...).
125     So to get around the problem we pass the address of
126     the newly created Dialogs instance using `this'.
127
128 (*) -- I'm using signals exclusively to guarantee that the gui code
129        remains hidden from the rest of the system.  In fact the only
130        header related to dialogs that anything in the non-gui-specific
131        code gets to see is Dialogs.h!  Even Dialogs.h doesn't know what a
132        FormCopyright class looks like or that its even going to be used!
133
134        No other gui dialog headers are seen outside of the gui-specific
135        directories!  This ensures that the gui is completely separate from
136        the rest of LyX.  All this through the use of a few simple signals.
137        BUT, the price is that during construction we need to connect the
138        implementations show() method to the showSomeDialog signal and this
139        requires that we have an instance of Dialogs and the problem mentioned
140        above.
141
142        Almost all other dialogs should be able to operate using the same style
143        of signalling used for Copyright.  Exceptions should be handled
144        by adding a specific show or update signal.  For example, spellchecker
145        needs to set the next suspect word and its options/replacements so we
146        need a:
147                  Signal0<void> updateSpellChecker;
148
149        Since we would have to have a
150                  Signal0<void> showSpellChecker;
151
152        in order to just see the spellchecker and let the user push the [Start]
153        button then the updateSpellChecker signal will make the SpellChecker
154        dialog get the new word and replacements list from LyX.  If you really,
155        really wanted to you could define a signal that would pass the new
156        word and replacements:
157                  Signal2<void, string, vector<string> > updateSpellChecker;
158
159        (or something similar) but, why bother when the spellchecker can get
160        it anyway with a LyXFunc call or two.  Besides if someone extends
161        what a dialog does then they also have to change code in the rest of
162        LyX to pass more parameters or get the extra info via a function
163        call anyway.  Thus reducing the independence of the two code bases.
164
165        We don't need a separate update signal for each dialog because most of
166        them will be changed only when the buffer is changed (either by closing
167        the current open buffer or switching to another buffer in the current
168        LyXView -- different BufferView same LyXView or same BufferView same
169        LyXView).
170
171        So we minimise signals but maximise independence and programming
172        simplicity, understandability and maintainability.  It's also
173        extremely easy to add support for Qt or gtk-- because they use
174        signals already. Guis that use callbacks, like xforms, must have their
175        code wrapped up like that in the form_copyright.[Ch] which is awkward
176        but will at least allow multiple instances of the same dialog.
177
178        LyXFuncs will be used for requesting/setting LyX internal info.  This
179        will ensure that scripts or LyXServer-connected applications can all
180        have access to the same calls as the internal user-interface.
181
182 ******************************************************************************/