00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00030 #include <FFThread.hpp>
00031
00032 #include <StaticCenter.hpp>
00033 #include <RunningOptions.hpp>
00034
00035 #include <cstddef>
00036
00037 #include <string>
00038 #include <fstream>
00039
00040 #ifdef HAVE_GUI_LIBS
00041 #include <GUI.hpp>
00042
00043 GUI* gui = 0;
00044 #endif // HAVE_GUI_LIBS
00045
00046 #include <iostream>
00047
00048 #include <CommandLineParser.hpp>
00049
00050 #ifdef Q_WS_X11
00051 #include <X11/Xlib.h>
00052 #endif // Q_WS_X11
00053
00054
00055 static StaticCenter staticCenter;
00056
00057 int main (int argc, char *argv[])
00058 {
00059 #ifdef HAVE_GUI_LIBS
00060 #ifdef Q_WS_X11
00061 Display* display
00062 = XOpenDisplay(getenv( "DISPLAY" ));
00063 if (display != 0) {
00064 XCloseDisplay(display);
00065 RunningOptions::instance().setDisplay(true);
00066 }
00067 #else // Q_WS_X11
00068
00069 RunningOptions::instance().setDisplay(true);
00070 #endif // Q_WS_X11
00071 #endif // HAVE_GUI_LIBS
00072
00073 CommandLineParser arguments(argc, argv);
00074 RunningOptions::instance().setVerbosity(arguments.verbosityLevel());
00075
00076 #ifdef HAVE_GUI_LIBS
00077 gui = new GUI(argc, argv);
00078 #endif // HAVE_GUI_LIBS
00079
00080 if (not(RunningOptions::instance().useGUI())) {
00081 std::ifstream fin(arguments.filename().c_str());
00082
00083 if (not(fin)) {
00084 std::cerr << "Error: cannot open file \""
00085 << arguments.filename() << "\"\n";
00086 return 1;
00087 }
00088
00089 FFThread mainThread;
00090 mainThread.setInput(fin);
00091 mainThread.start();
00092 }
00093
00094 #ifdef HAVE_GUI_LIBS
00095 if (gui != 0) delete gui;
00096 #endif // HAVE_GUI_LIBS
00097
00098 return 0;
00099 }