diff --git a/ChangeLog b/ChangeLog index 0d97f0459d..60c8ade705 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2000-09-11 Juergen Vigna + * src/lyx_gui.C (runTime): uses global guiruntime variable. + + * src/main.C (main): now GUII defines global guiruntime! + + * src/frontends/gnome/GUIRunTime.C (initApplication): + * src/frontends/kde/GUIRunTime.C (initApplication): + * src/frontends/xforms/GUIRunTime.C (initApplication): + * src/frontends/GUIRunTime.h: added new function initApplication. + * src/spellchecker.C (sc_accept_word): change to add_to_session. * src/vspace.C (nextToken): fixed error with number 0cm as unvalid. diff --git a/src/frontends/GUIRunTime.h b/src/frontends/GUIRunTime.h index 42f6ec10a7..39bac4997b 100644 --- a/src/frontends/GUIRunTime.h +++ b/src/frontends/GUIRunTime.h @@ -23,6 +23,8 @@ class LyXView; */ class GUIRunTime { public: + static + int initApplication(int argc, char * argv[]); /// static void processEvents(); diff --git a/src/frontends/gnome/GUIRunTime.C b/src/frontends/gnome/GUIRunTime.C index 24b53c20d2..3caee52fe7 100644 --- a/src/frontends/gnome/GUIRunTime.C +++ b/src/frontends/gnome/GUIRunTime.C @@ -19,11 +19,59 @@ #include "debug.h" #include +#include "mainapp.h" using std::endl; +// I keep these here so that it will be processed as early in +// the compilation process as possible. +#if !defined(FL_REVISION) || FL_REVISION < 88 || FL_VERSION != 0 +#error LyX will not compile with this version of XForms.\ + Please get version 0.89.\ + If you want to try to compile anyway, delete this test in src/frontends/gnome/GUIRunTime.C. +#endif + extern bool finished; +static int const xforms_include_version = FL_INCLUDE_VERSION; +GLyxAppWin * mainAppWin; + +int GUIRunTime::initApplication(int, char * argv[]) +{ + // Check the XForms version in the forms.h header against + // the one in the libforms. If they don't match quit the + // execution of LyX. Better with a clean fast exit than + // a strange segfault later. + // I realize that this check have to be moved when we + // support several toolkits, but IMO all the toolkits + // should try to have the same kind of check. This could + // be done by having a CheckHeaderAndLib function in + // all the toolkit implementations, this function is + // responsible for notifing the user. + // if (!CheckHeaderAndLib()) { + // // header vs. lib version failed + // return 1; + // } + int xforms_lib_version = fl_library_version(0, 0); + if (xforms_include_version != xforms_lib_version) { + cerr << "You are either running LyX with wrong " + "version of a dynamic XForms library\n" + "or you have build LyX with conflicting header " + "and library (different\n" + "versions of XForms. Sorry but there is no point " + "in continuing executing LyX!" << endl; + return 1; + } + + string app_id(PACKAGE); + string app_version(VERSION); + static Gnome::Main a(app_id, app_version, 1, argv); + static GLyxAppWin appWin; + mainAppWin = &appWin; + + return 0; +} + void GUIRunTime::processEvents() { while(Gnome::Main::instance()->events_pending()) diff --git a/src/frontends/kde/GUIRunTime.C b/src/frontends/kde/GUIRunTime.C index 1228e00f96..cc7c335c5d 100644 --- a/src/frontends/kde/GUIRunTime.C +++ b/src/frontends/kde/GUIRunTime.C @@ -22,8 +22,51 @@ using std::endl; +// For now we need this here as long as we use xforms components! + +// I keep these here so that it will be processed as early in +// the compilation process as possible. +#if !defined(FL_REVISION) || FL_REVISION < 88 || FL_VERSION != 0 +#error LyX will not compile with this version of XForms.\ + Please get version 0.89.\ + If you want to try to compile anyway, delete this test in src/frontends/kde/GUIRunTime.C. +#endif + extern bool finished; +static int const xforms_include_version = FL_INCLUDE_VERSION; + +int GUIRunTime::initApplication(int argc, char * argv[]) +{ + // Check the XForms version in the forms.h header against + // the one in the libforms. If they don't match quit the + // execution of LyX. Better with a clean fast exit than + // a strange segfault later. + // I realize that this check have to be moved when we + // support several toolkits, but IMO all the toolkits + // should try to have the same kind of check. This could + // be done by having a CheckHeaderAndLib function in + // all the toolkit implementations, this function is + // responsible for notifing the user. + // if (!CheckHeaderAndLib()) { + // // header vs. lib version failed + // return 1; + // } + int xforms_lib_version = fl_library_version(0, 0); + if (xforms_include_version != xforms_lib_version) { + cerr << "You are either running LyX with wrong " + "version of a dynamic XForms library\n" + "or you have build LyX with conflicting header " + "and library (different\n" + "versions of XForms. Sorry but there is no point " + "in continuing executing LyX!" << endl; + return 1; + } + + static KApplication a(argc, argv); + + return 0; +} void GUIRunTime::processEvents() { diff --git a/src/frontends/xforms/GUIRunTime.C b/src/frontends/xforms/GUIRunTime.C index c28130b9fe..1b1e2338d3 100644 --- a/src/frontends/xforms/GUIRunTime.C +++ b/src/frontends/xforms/GUIRunTime.C @@ -17,10 +17,48 @@ #include "GUIRunTime.h" #include "debug.h" +// I keep these here so that it will be processed as early in +// the compilation process as possible. +#if !defined(FL_REVISION) || FL_REVISION < 88 || FL_VERSION != 0 +#error LyX will not compile with this version of XForms.\ + Please get version 0.89.\ + If you want to try to compile anyway, delete this test in src/frontends/xforms/GUIRunTime.C. +#endif + using std::endl; extern bool finished; +static int const xforms_include_version = FL_INCLUDE_VERSION; + +int GUIRunTime::initApplication(int argc, char * argv[]) +{ + // Check the XForms version in the forms.h header against + // the one in the libforms. If they don't match quit the + // execution of LyX. Better with a clean fast exit than + // a strange segfault later. + // I realize that this check have to be moved when we + // support several toolkits, but IMO all the toolkits + // should try to have the same kind of check. This could + // be done by having a CheckHeaderAndLib function in + // all the toolkit implementations, this function is + // responsible for notifing the user. + // if (!CheckHeaderAndLib()) { + // // header vs. lib version failed + // return 1; + // } + int xforms_lib_version = fl_library_version(0, 0); + if (xforms_include_version != xforms_lib_version) { + cerr << "You are either running LyX with wrong " + "version of a dynamic XForms library\n" + "or you have build LyX with conflicting header " + "and library (different\n" + "versions of XForms. Sorry but there is no point " + "in continuing executing LyX!" << endl; + return 1; + } + return 0; +} void GUIRunTime::processEvents() { diff --git a/src/lyx_gui.C b/src/lyx_gui.C index a1d1b18265..1008af7151 100644 --- a/src/lyx_gui.C +++ b/src/lyx_gui.C @@ -63,6 +63,7 @@ Combox * combo_language2; extern LyXServer * lyxserver; extern bool finished; // flag, that we are quitting the program extern BufferList bufferlist; +extern GUIRunTime guiruntime; FL_CMD_OPT cmdopt[] = { @@ -570,7 +571,7 @@ void LyXGUI::runTime() { if (!gui) return; - GUIRunTime::runTime(); + guiruntime.runTime(); } diff --git a/src/main.C b/src/main.C index 1cc999e1ef..22e56f1708 100644 --- a/src/main.C +++ b/src/main.C @@ -11,74 +11,23 @@ #include #include -#ifdef KDEGUI -# include -#endif -#ifdef GTKGUI -# include -# include "frontends/gnome/mainapp.h" -GLyxAppWin * mainAppWin; -#endif - -#include FORMS_H_LOCATION - #include "lyx_main.h" #include "gettext.h" #include "LString.h" #include "support/filetools.h" - - -// I keep these here so that it will be processed as early in -// the compilation process as possible. -#if !defined(FL_REVISION) || FL_REVISION < 88 || FL_VERSION != 0 -#error LyX will not compile with this version of XForms.\ - Please get version 0.89.\ - If you want to try to compile anyway, delete this test in src/main.C. -#endif +#include "frontends/GUIRunTime.h" using std::cerr; using std::endl; -static int const xforms_include_version = FL_INCLUDE_VERSION; +GUIRunTime guiruntime; int main(int argc, char * argv[]) { - // Check the XForms version in the forms.h header against - // the one in the libforms. If they don't match quit the - // execution of LyX. Better with a clean fast exit than - // a strange segfault later. - // I realize that this check have to be moved when we - // support several toolkits, but IMO all the toolkits - // should try to have the same kind of check. This could - // be done by having a CheckHeaderAndLib function in - // all the toolkit implementations, this function is - // responsible for notifing the user. - // if (!CheckHeaderAndLib()) { - // // header vs. lib version failed - // return 1; - // } - int xforms_lib_version = fl_library_version(0, 0); - if (xforms_include_version != xforms_lib_version) { - cerr << "You are either running LyX with wrong " - "version of a dynamic XForms library\n" - "or you have build LyX with conflicting header " - "and library (different\n" - "versions of XForms. Sorry but there is no point " - "in continuing executing LyX!" << endl; - return 1; - } + int val = guiruntime.initApplication(argc, argv); + if (val) + return val; -#ifdef KDEGUI - KApplication a( argc, argv ); -#endif -#ifdef GTKGUI - string app_id(PACKAGE); - string app_version(VERSION); - Gnome::Main a(app_id, app_version, 1, argv); //argc, argv ); - GLyxAppWin appWin; - mainAppWin = &appWin; -#endif - // lyx_localedir is used by gettext_init() is we have // i18n support built-in string lyx_localedir = GetEnvPath("LYX_LOCALEDIR");