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