#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"
#include <gtkmm.h>
-#include "LyXGdkImage.h"
-
#include <boost/bind.hpp>
#include <boost/function.hpp>
#include <boost/shared_ptr.hpp>
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 {
} // namespace anon
-class Application: public Gtk::Main
-{
-public:
- ///
- Application(int & argc, char * argv[]): Gtk::Main(argc, argv)
- {}
- ///
- Gui & gui() { return gui_; }
-
-private:
- ///
- GuiImplementation gui_;
-};
+lyx::frontend::Application * theApp;
+GuiApplication * guiApp;
-Application * theApp;
-
-void lyx_gui::exec(int & argc, char * argv[])
+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();
+ 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::start(string const & batch, std::vector<string> const & files,
- unsigned int width, unsigned int height, int posx, int posy, bool)
+LyXView * lyx_gui::create_view(unsigned int width, unsigned int height,
+ int posx, int posy, bool maximize)
{
- int view_id = theApp->gui().newView(width, height);
- GView & view = static_cast<GView &> (theApp->gui().view(view_id));
- theApp->gui().newWorkArea(width, height, 0);
-
- LyX::ref().addLyXView(&view);
-
- 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));
- }
+ return &guiApp->createView(width, height, posx, posy, maximize);
+}
- theApp->run();
- // FIXME: breaks emergencyCleanup
- delete lyxsocket;
- delete lyxserver;
+int lyx_gui::start(LyXView *, string const & batch)
+{
+ 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);
}
{
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;