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