]> git.lyx.org Git - lyx.git/blob - src/frontends/gnome/GUIRunTime.C
d87fee67b7040dd34aa0b4a385d5fc9b5f3410e2
[lyx.git] / src / frontends / gnome / GUIRunTime.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *           Copyright 2000 The LyX Team.
7  *
8  *======================================================*/
9
10 #include <config.h>
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include FORMS_H_LOCATION
17
18 #include "GUIRunTime.h"
19 #include "debug.h"
20
21 #include <gnome--/main.h>
22 #include "mainapp.h"
23
24 using std::endl;
25
26 // I keep these here so that it will be processed as early in
27 // the compilation process as possible.
28 #if !defined(FL_REVISION) || FL_REVISION < 88 || FL_VERSION != 0
29 #error LyX will not compile with this version of XForms.\
30        Please get version 0.89.\
31        If you want to try to compile anyway, delete this test in src/frontends/gnome/GUIRunTime.C.
32 #endif
33
34 extern bool finished;
35
36 namespace {
37
38 int const xforms_include_version = FL_INCLUDE_VERSION;
39
40 } // namespace anon
41
42 GLyxAppWin * mainAppWin;
43
44 int GUIRunTime::initApplication(int, char * argv[])
45 {
46         // Check the XForms version in the forms.h header against
47         // the one in the libforms. If they don't match quit the
48         // execution of LyX. Better with a clean fast exit than
49         // a strange segfault later.
50         // I realize that this check have to be moved when we
51         // support several toolkits, but IMO all the toolkits
52         // should try to have the same kind of check. This could
53         // be done by having a CheckHeaderAndLib function in
54         // all the toolkit implementations, this function is
55         // responsible for notifing the user.
56         // if (!CheckHeaderAndLib()) {
57         //         // header vs. lib version failed
58         //         return 1;
59         // }
60         int xforms_lib_version = fl_library_version(0, 0);
61         if (xforms_include_version != xforms_lib_version) {
62                 cerr << "You are either running LyX with wrong "
63                         "version of a dynamic XForms library\n"
64                         "or you have build LyX with conflicting header "
65                         "and library (different\n"
66                         "versions of XForms. Sorry but there is no point "
67                         "in continuing executing LyX!" << endl;
68                 return 1;
69         }
70
71         // I belive that this should be done at a later stage, in
72         // lyx_gui, the same place as xforms does the same. (Lgb)
73         static string app_id(PACKAGE);
74         static string app_version(VERSION);
75         static Gnome::Main  a(app_id, app_version, 1, argv);
76         static GLyxAppWin   appWin;
77         mainAppWin = &appWin;
78
79         return 0;
80 }
81
82 void GUIRunTime::processEvents() 
83 {
84         while(Gnome::Main::instance()->events_pending())
85                 Gnome::Main::instance()->iteration(FALSE);
86 }
87
88
89 void GUIRunTime::runTime()
90 {
91         XEvent ev;
92         while (!finished) {
93                 processEvents();
94                 if (fl_check_forms() == FL_EVENT) {
95                         lyxerr << "LyX: This shouldn't happen..." << endl;
96                         fl_XNextEvent(&ev);
97                 }
98         }
99 }
100
101
102 void GUIRunTime::setDefaults()
103 {
104         FL_IOPT cntl;
105         cntl.buttonFontSize = FL_NORMAL_SIZE;
106         cntl.browserFontSize = FL_NORMAL_SIZE;
107         cntl.labelFontSize = FL_NORMAL_SIZE;
108         cntl.choiceFontSize = FL_NORMAL_SIZE;
109         cntl.inputFontSize = FL_NORMAL_SIZE;
110         cntl.menuFontSize  = FL_NORMAL_SIZE;
111         cntl.borderWidth = -1;
112         cntl.vclass = FL_DefaultVisual;
113         fl_set_defaults(FL_PDVisual
114                         | FL_PDButtonFontSize
115                         | FL_PDBrowserFontSize
116                         | FL_PDLabelFontSize
117                         | FL_PDChoiceFontSize
118                         | FL_PDInputFontSize
119                         | FL_PDMenuFontSize
120                         | FL_PDBorderWidth, &cntl);
121 }