]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/gtk/lyx_gui.C
Get rid of "Display Tooltips" option in ui, it's not implemented
[lyx.git] / src / frontends / gtk / lyx_gui.C
index 3f190d6b5dcfbbedd85cb0a4de60629d02d43d92..4218311c76cb454d2c1cd2f72c84e427547b23b7 100644 (file)
  */
 
 #include <config.h>
-#include <gtkmm.h>
 
 #include "lyx_gui.h"
 
-#include "support/lyxlib.h"
-#include "support/os.h"
-#include "support/filetools.h"
-#include "support/path_defines.h"
-
 #include "debug.h"
+#include "funcrequest.h"
 #include "gettext.h"
 
+#include "LColor.h"
+#include "LyXAction.h"
 #include "lyx_main.h"
 #include "lyxrc.h"
 #include "lyxfont.h"
 #include "graphics/LoaderQueue.h"
 
+#include "io_callback.h"
+
 // FIXME: move this stuff out again
 #include "bufferlist.h"
 #include "buffer_funcs.h"
 #include "lyxfunc.h"
 #include "lyxserver.h"
+#include "lyxsocket.h"
 #include "BufferView.h"
 
 #include "GView.h"
 #include "xftFontLoader.h"
 #include "GWorkArea.h"
 
-#include "Lsstream.h"
-#include <iomanip>
-#include <fcntl.h>
-#include <boost/bind.hpp>
-
 //just for xforms
 #include "lyx_forms.h"
 #include "xformsImage.h"
 #include "xforms_helpers.h"
 
+#include "support/lyxlib.h"
+#include "support/os.h"
+#include "support/filetools.h"
+#include "support/path_defines.h"
+
+#include <gtkmm.h>
+
+#include <boost/bind.hpp>
+#include <boost/function.hpp>
+#include <boost/shared_ptr.hpp>
+
+#include <fcntl.h>
+
+#include <sstream>
+#include <iomanip>
+
+namespace os = lyx::support::os;
+
+using std::ostringstream;
+using std::string;
+
+using lyx::frontend::colorCache;
+using lyx::frontend::GView;
+using lyx::frontend::XformsColor;
+
+
 extern BufferList bufferlist;
 
 // FIXME: wrong place !
 LyXServer * lyxserver;
+LyXServerSocket * lyxsocket;
 
 bool lyx_gui::use_gui = true;
 
@@ -104,13 +126,13 @@ int LyX_XErrHandler(Display * display, XErrorEvent * xeev) {
        if (xeev->error_code == BadWindow) {
                lyxerr << "BadWindow received !" << std::endl;
                lyxerr << "If you're using xforms 1.0 or greater, "
-                      << " please report this to lyx-devel@lists.lyx.org" 
+                      << " please report this to lyx-devel@lists.lyx.org"
                       << std::endl;
                return 0;
        }
 
        // emergency cleanup
-       LyX::emergencyCleanup();
+       LyX::cref().emergencyCleanup();
 
        // Get the reason for the crash.
        char etxt[513];
@@ -306,32 +328,26 @@ void lyx_gui::start(string const & batch, std::vector<string> const & files)
        start_xforms();
        // just for debug
        XSynchronize(getDisplay(), true);
-       GView view;
+
+       boost::shared_ptr<GView> view_ptr(new GView);
+       LyX::ref().addLyXView(view_ptr);
+
+       GView & view = *view_ptr.get();
        view.show();
        view.init();
 
-       Buffer * last = 0;
-
-       // FIXME: some code below needs moving
+       // FIXME: server code below needs moving
 
        lyxserver = new LyXServer(&view.getLyXFunc(), lyxrc.lyxpipes);
+       lyxsocket = new LyXServerSocket(&view.getLyXFunc(),
+                         os::slashify_path(os::getTmpDir() + "/lyxsocket"));
 
-       std::vector<string>::const_iterator cit = files.begin();
-       std::vector<string>::const_iterator end = files.end();
-       for (; cit != end; ++cit) {
-               Buffer * b = bufferlist.newBuffer(*cit);
-               if (loadLyXFile(b, *cit))
-                       last = b;
-       }
-
-       // switch to the last buffer successfully loaded
-       if (last) {
-               view.view()->buffer(last);
-       }
+       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(batch);
+               view.getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
        }
 
        // enter the event loop
@@ -342,6 +358,7 @@ void lyx_gui::start(string const & batch, std::vector<string> const & files)
        }
 
        // FIXME: breaks emergencyCleanup
+       delete lyxsocket;
        delete lyxserver;
 }
 
@@ -352,14 +369,27 @@ void lyx_gui::exit()
 }
 
 
-FuncStatus lyx_gui::getStatus(FuncRequest const & /*ev*/)
+FuncStatus lyx_gui::getStatus(FuncRequest const & ev)
 {
-       // Nothing interesting to do here
-       return FuncStatus();
+       FuncStatus flag;
+       switch (ev.action) {
+       // Add this back if the gtk doc prefs dialog includes preamble - jcs
+       /*case LFUN_DIALOG_SHOW:
+               if (ev.argument == "preamble")
+                       flag.unknown(true);
+               break;*/
+       case LFUN_TOOLTIPS_TOGGLE:
+               flag.unknown(true);
+               break;
+       default:
+               break;
+       }
+
+       return flag;
 }
 
 
-string const lyx_gui::hexname(LColor::color col)
+string const lyx_gui::hexname(LColor_color col)
 {
        Gdk::Color gdkColor;
        Gdk::Color * gclr = colorCache.getColor(col);
@@ -381,7 +411,7 @@ string const lyx_gui::hexname(LColor::color col)
 }
 
 
-void lyx_gui::update_color(LColor::color /*col*/)
+void lyx_gui::update_color(LColor_color /*col*/)
 {
        colorCache.clear();
 }
@@ -401,32 +431,21 @@ bool lyx_gui::font_available(LyXFont const & font)
 
 namespace {
 
+std::map<int, boost::shared_ptr<io_callback> > callbacks;
 
-bool readCallback(Glib::IOCondition /*condition*/, LyXComm * comm)
-{
-       comm->read_ready();
-       return true;
-}
-
-
-std::map<int, SigC::Connection> gReadCallbackMap;
-
-}
+} // NS anon
 
 
-void lyx_gui::set_read_callback(int fd, LyXComm * comm)
+void lyx_gui::register_socket_callback(int fd,
+                                      boost::function<void()> func)
 {
-       gReadCallbackMap[fd] = Glib::signal_io().connect(
-               SigC::bind(SigC::slot(readCallback), comm),
-               fd,
-               Glib::IO_IN);
+       callbacks[fd] = boost::shared_ptr<io_callback>(new io_callback(fd, func));
 }
 
 
-void lyx_gui::remove_read_callback(int fd)
+void lyx_gui::unregister_socket_callback(int fd)
 {
-       gReadCallbackMap[fd].disconnect();
-       gReadCallbackMap.erase(fd);
+       callbacks.erase(fd);
 }