X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Ffrontends%2Fgtk%2Flyx_gui.C;h=23d3de2c878fbbf317217222d57df5192350571b;hb=063994371eb9d3465ddeda0a41aa450f891043be;hp=3076e741f8afa1b3794781a75e637e5f0df656e6;hpb=ebaaff58fad6299f19bfd65157b5deabf6925fcf;p=lyx.git diff --git a/src/frontends/gtk/lyx_gui.C b/src/frontends/gtk/lyx_gui.C index 3076e741f8..23d3de2c87 100644 --- a/src/frontends/gtk/lyx_gui.C +++ b/src/frontends/gtk/lyx_gui.C @@ -37,17 +37,16 @@ #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" @@ -57,8 +56,6 @@ #include -#include "LyXGdkImage.h" - #include #include #include @@ -77,16 +74,11 @@ 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 { @@ -102,34 +94,13 @@ int getDPI() } // namespace anon -class Application: public Gtk::Main -{ -public: - /// - Application(int & argc, char * argv[]): Gtk::Main(argc, argv) - {} - /// - Gui & gui() { return gui_; } - -private: - /// - GuiImplementation gui_; -}; - -Application * theApp; +lyx::frontend::Application * theApp; +GuiApplication * guiApp; int lyx_gui::exec(int & argc, char * argv[]) { - theApp = new Application(argc, argv); - - using namespace lyx::graphics; - Image::newImage = boost::bind(&LyXGdkImage::newImage); - Image::loadableFormats = boost::bind(&LyXGdkImage::loadableFormats); - - locale_init(); - - // must do this /before/ lyxrc gets read - lyxrc.dpi = getDPI(); + guiApp = new GuiApplication(argc, argv); + theApp = guiApp; return LyX::ref().exec2(argc, argv); } @@ -141,47 +112,21 @@ void lyx_gui::parse_lyxrc() LyXView * lyx_gui::create_view(unsigned int width, unsigned int height, - int /*posx*/, int /*posy*/, bool) + int posx, int posy, bool maximize) { - int view_id = theApp->gui().newView(width, height); - GView & view = static_cast (theApp->gui().view(view_id)); - theApp->gui().newWorkArea(width, height, 0); - - LyX::ref().addLyXView(&view); - - view.show(); - view.init(); - - return &view; + return &guiApp->createView(width, height, posx, posy, maximize); } -int lyx_gui::start(LyXView * view, string const & batch) +int lyx_gui::start(LyXView *, string const & batch) { - // 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")); - - // handle the batch commands the user asked for - if (!batch.empty()) { - view->getLyXFunc().dispatch(lyxaction.lookupFunc(batch)); - } - - theApp->run(); - - // FIXME: breaks emergencyCleanup - delete lyxsocket; - delete lyxserver; - return EXIT_SUCCESS; + return guiApp->start(batch); } -void lyx_gui::exit(int /*status*/) +void lyx_gui::exit(int status) { - // FIXME: Don't ignore status - theApp->quit(); + guiApp->exit(status); }