]> git.lyx.org Git - lyx.git/blob - src/main.C
1cc999e1ef0a5f166b8eaa5336fef0d87ec28ce4
[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 #    include "frontends/gnome/mainapp.h"
20 GLyxAppWin * mainAppWin;
21 #endif
22
23 #include FORMS_H_LOCATION
24
25 #include "lyx_main.h"
26 #include "gettext.h"
27 #include "LString.h"
28 #include "support/filetools.h"
29
30
31 // I keep these here so that it will be processed as early in
32 // the compilation process as possible.
33 #if !defined(FL_REVISION) || FL_REVISION < 88 || FL_VERSION != 0
34 #error LyX will not compile with this version of XForms.\
35        Please get version 0.89.\
36        If you want to try to compile anyway, delete this test in src/main.C.
37 #endif
38
39 using std::cerr;
40 using std::endl;
41
42 static int const xforms_include_version = FL_INCLUDE_VERSION;
43
44 int main(int argc, 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 #ifdef KDEGUI
72         KApplication a( argc, argv );
73 #endif
74 #ifdef GTKGUI
75         string app_id(PACKAGE);
76         string app_version(VERSION);
77         Gnome::Main  a(app_id, app_version, 1, argv); //argc, argv );
78         GLyxAppWin   appWin;
79         mainAppWin = &appWin;
80 #endif
81         
82         // lyx_localedir is used by gettext_init() is we have
83         //   i18n support built-in
84         string lyx_localedir = GetEnvPath("LYX_LOCALEDIR");
85         if (lyx_localedir.empty())
86                 lyx_localedir = LOCALEDIR;
87         
88         // initialize for internationalized version *EK*
89         locale_init();
90         gettext_init();
91
92 #ifdef __EMX__
93         _wildcard(&argc, &argv);
94 #endif
95
96         LyX lyx(&argc, argv);
97         return 0; // SUCCESS
98 }