]> git.lyx.org Git - features.git/blobdiff - src/frontends/gtk/lyx_gui.C
This commit creates a new "frontends/lyx_gui.C" that contains all functions that...
[features.git] / src / frontends / gtk / lyx_gui.C
index c993dd4fbcc955afa768d05d26cbdd30eb820e5a..3de8d1872a4ca0e7567c51da4d9d6adfe2fcdcae 100644 (file)
 #include "io_callback.h"
 
 // FIXME: move this stuff out again
-#include "bufferlist.h"
 #include "lyxfunc.h"
 #include "lyxserver.h"
 #include "lyxsocket.h"
 #include "BufferView.h"
 
+#include "GuiApplication.h"
+#include "GuiImplementation.h"
 #include "GView.h"
 #include "GtkmmX.h"
 
-#include "xftFontLoader.h"
 #include "GWorkArea.h"
 
 #include "support/lyxlib.h"
@@ -56,8 +56,6 @@
 
 #include <gtkmm.h>
 
-#include "LyXGdkImage.h"
-
 #include <boost/bind.hpp>
 #include <boost/function.hpp>
 #include <boost/shared_ptr.hpp>
@@ -75,17 +73,12 @@ using std::string;
 using lyx::support::package;
 
 using lyx::frontend::colorCache;
+using lyx::frontend::Gui;
+using lyx::frontend::GuiApplication;
+using lyx::frontend::GuiImplementation;
 using lyx::frontend::GView;
 
 
-extern BufferList bufferlist;
-
-// FIXME: wrong place !
-LyXServer * lyxserver;
-LyXServerSocket * lyxsocket;
-
-bool lyx_gui::use_gui = true;
-
 namespace {
 
 /// estimate DPI from X server
@@ -99,84 +92,20 @@ int getDPI()
 
 } // namespace anon
 
+GuiApplication * guiApp;
 
-void lyx_gui::exec(int & argc, char * argv[])
+int lyx_gui::exec(int & argc, char * argv[])
 {
-       new Gtk::Main(argc, argv);
-
-       using namespace lyx::graphics;
-       Image::newImage = boost::bind(&LyXGdkImage::newImage);
-       Image::loadableFormats = boost::bind(&LyXGdkImage::loadableFormats);
-
-       locale_init();
+       guiApp = new GuiApplication(argc, argv);
+       theApp = guiApp;
 
-       // must do this /before/ lyxrc gets read
-       lyxrc.dpi = getDPI();
-
-       LyX::ref().exec2(argc, argv);
+       return LyX::ref().exec2(argc, argv);
 }
 
 
-void lyx_gui::parse_lyxrc()
+void lyx_gui::exit(int status)
 {
-}
-
-
-void lyx_gui::start(string const & batch, std::vector<string> const & files,
-                   unsigned int width, unsigned int height, int posx, int posy)
-{
-       boost::shared_ptr<GView> view_ptr(new GView);
-       LyX::ref().addLyXView(view_ptr);
-
-       GView & view = *view_ptr.get();
-       view.show();
-       view.init();
-
-       // FIXME: server code below needs moving
-
-       lyxserver = new LyXServer(&view.getLyXFunc(), lyxrc.lyxpipes);
-       lyxsocket = new LyXServerSocket(&view.getLyXFunc(),
-                         os::internal_path(package().temp_dir() + "/lyxsocket"));
-
-       for_each(files.begin(), files.end(),
-                bind(&BufferView::loadLyXFile, view.view(), _1, true));
-
-       // handle the batch commands the user asked for
-       if (!batch.empty()) {
-               view.getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
-       }
-
-       Gtk::Main::run();
-
-       // FIXME: breaks emergencyCleanup
-       delete lyxsocket;
-       delete lyxserver;
-}
-
-
-void lyx_gui::exit(int /*status*/)
-{
-       // FIXME: Don't ignore status
-       Gtk::Main::quit();
-}
-
-
-FuncStatus lyx_gui::getStatus(FuncRequest const & ev)
-{
-       FuncStatus flag;
-       switch (ev.action) {
-       case LFUN_DIALOG_SHOW:
-               if (ev.argument == "preamble")
-                       flag.unknown(true);
-               break;
-       case LFUN_TOOLTIPS_TOGGLE:
-               flag.unknown(true);
-               break;
-       default:
-               break;
-       }
-
-       return flag;
+       guiApp->exit(status);
 }
 
 
@@ -261,24 +190,6 @@ void lyx_gui::unregister_socket_callback(int fd)
 }
 
 
-string const lyx_gui::roman_font_name()
-{
-       return "times";
-}
-
-
-string const lyx_gui::sans_font_name()
-{
-       return "helvetica";
-}
-
-
-string const lyx_gui::typewriter_font_name()
-{
-       return "courier";
-}
-
-
 void lyx_gui::sync_events()
 {
        // FIXME