3 * Copyright 2002 the LyX Team
4 * Read the file COPYING
7 * \author John Levon <moz@compsoc.man.ac.uk>
12 #include "support/lyxlib.h"
13 #include "support/os.h"
14 #include "support/filetools.h"
19 #include <boost/bind.hpp>
26 // FIXME: move this stuff out again
27 #include "bufferlist.h"
29 #include "lyxserver.h"
30 #include "BufferView.h"
32 // Dear Lord, deliver us from Evil,
34 #include <boost/shared_ptr.hpp>
35 #include <boost/function/function0.hpp>
36 #include <boost/signals/signal1.hpp>
40 #include "qfont_loader.h"
41 #include "io_callback.h"
43 #include <qapplication.h>
45 #ifndef CXX_GLOBAL_CSTD
53 extern BufferList bufferlist;
55 // FIXME: wrong place !
56 LyXServer * lyxserver;
58 void lyx_gui::parse_init(int & argc, char * argv[])
60 static QApplication a(argc, argv);
64 Image::newImage = boost::bind(&QLImage::newImage);
65 Image::loadableFormats = boost::bind(&QLImage::loadableFormats);
69 void lyx_gui::parse_lyxrc()
76 void lyx_gui::start(string const & batch, vector<string> files)
81 unsigned int width = 690;
82 unsigned int height = 510;
84 QtView view(width, height);
85 view.show(xpos, ypos, "LyX");
90 // FIXME: some code below needs moving
92 lyxserver = new LyXServer(view.getLyXFunc(), lyxrc.lyxpipes);
94 vector<string>::const_iterator cit = files.begin();
95 vector<string>::const_iterator end = files.end();
96 for (; cit != end; ++cit) {
97 Buffer * b = bufferlist.loadLyXFile(*cit);
103 // switch to the last buffer successfully loaded
105 view.view()->buffer(last);
108 // handle the batch commands the user asked for
109 if (!batch.empty()) {
110 view.getLyXFunc()->dispatch(batch);
126 string const lyx_gui::hexname(LColor::color col)
128 QColor color(lcolor.getX11Name(col).c_str());
129 return color.name().latin1();
133 void lyx_gui::update_color(LColor::color)
139 void lyx_gui::update_fonts()
145 bool lyx_gui::font_available(LyXFont const & font)
147 return fontloader.available(font);
152 map<int, io_callback *> io_callbacks;
156 void lyx_gui::set_read_callback(int fd, LyXComm * comm)
158 io_callbacks[fd] = new io_callback(fd, comm);
162 void lyx_gui::remove_read_callback(int fd)
164 map<int, io_callback *>::iterator it = io_callbacks.find(fd);
165 if (it != io_callbacks.end()) {
167 io_callbacks.erase(it);