]> git.lyx.org Git - lyx.git/blob - src/main.C
Angus insetindex patch + protect patch from Dekel
[lyx.git] / src / main.C
1 /* This file is part of
2  * ====================================================== 
3  * 
4  *           LyX, The Document Processor
5  *       
6  *          Copyright 1995 Matthias Ettrich
7  *          Copyright 1995-2000 The LyX Team.
8  *
9  * ====================================================== */
10
11 #include <config.h>
12 #include <iostream>
13
14 #ifdef KDEGUI
15 #    include <kapp.h>
16 #endif
17 #ifdef GTKGUI
18 #    include <gnome--/main.h>
19 #endif
20
21 #include FORMS_H_LOCATION
22
23 #include "lyx_main.h"
24 #include "gettext.h"
25 #include "LString.h"
26 #include "support/filetools.h"
27
28
29 // I keep these here so that it will be processed as early in
30 // the compilation process as possible.
31 #if !defined(FL_REVISION) || FL_REVISION < 88 || FL_VERSION != 0
32 #error LyX will not compile with this version of XForms.\
33        Please get version 0.89.\
34        If you want to try to compile anyway, delete this test in src/main.C.
35 #endif
36
37 using std::cerr;
38 using std::endl;
39
40 static int const xforms_include_version = FL_INCLUDE_VERSION;
41
42 int main(int argc, char * argv[])
43 {
44         // Check the XForms version in the forms.h header against
45         // the one in the libforms. If they don't match quit the
46         // execution of LyX. Better with a clean fast exit than
47         // a strange segfault later.
48         // I realize that this check have to be moved when we
49         // support several toolkits, but IMO all the toolkits
50         // should try to have the same kind of check. This could
51         // be done by having a CheckHeaderAndLib function in
52         // all the toolkit implementations, this function is
53         // responsible for notifing the user.
54         // if (!CheckHeaderAndLib()) {
55         //         // header vs. lib version failed
56         //         return 1;
57         // }
58         int xforms_lib_version = fl_library_version(0, 0);
59         if (xforms_include_version != xforms_lib_version) {
60                 cerr << "You are either running LyX with wrong "
61                         "version of a dynamic XForms library\n"
62                         "or you have build LyX with conflicting header "
63                         "and library (different\n"
64                         "versions of XForms. Sorry but there is no point "
65                         "in continuing executing LyX!" << endl;
66                 return 1;
67         }
68
69 #ifdef KDEGUI
70         KApplication a( argc, argv );
71 #endif
72 #ifdef GTKGUI
73         Gnome::Main  a(PACKAGE,VERSION,argc, argv );
74 #endif
75         
76         // lyx_localedir is used by gettext_init() is we have
77         //   i18n support built-in
78         string lyx_localedir = GetEnvPath("LYX_LOCALEDIR");
79         if (lyx_localedir.empty())
80                 lyx_localedir = LOCALEDIR;
81         
82         // initialize for internationalized version *EK*
83         locale_init();
84         gettext_init();
85
86 #ifdef __EMX__
87         _wildcard(&argc, &argv);
88 #endif
89
90         LyX lyx(&argc, argv);
91         return 0; // SUCCESS
92 }