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