]> git.lyx.org Git - features.git/commitdiff
the lyxserver modifications
authorLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 22 Jul 2004 13:44:40 +0000 (13:44 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Thu, 22 Jul 2004 13:44:40 +0000 (13:44 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8842 a592a061-630c-0410-9148-cb99ea01b6c8

16 files changed:
src/ChangeLog
src/frontends/ChangeLog
src/frontends/gtk/ChangeLog
src/frontends/gtk/Makefile.am
src/frontends/gtk/io_callback.C [new file with mode: 0644]
src/frontends/gtk/io_callback.h [new file with mode: 0644]
src/frontends/gtk/lyx_gui.C
src/frontends/lyx_gui.h
src/frontends/qt2/ChangeLog
src/frontends/qt2/Makefile.dialogs
src/frontends/qt2/io_callback.C [deleted file]
src/frontends/qt2/io_callback.h [deleted file]
src/frontends/qt2/lyx_gui.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/lyx_gui.C
src/lyxserver.C

index 926fa454ecb0d8f7c651f1cf6148055aba40e634..a6b1fa2d08de7c8df2a0d0815c9119f7e35569b0 100644 (file)
@@ -1,3 +1,8 @@
+2004-07-22  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * lyxserver.C (startPipe): call register_socket_callback
+       (endPipe): call unregister_socket_callback
+
 2004-07-21  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * lyxsocket.C (LyXServerSocket): reduce max outstanding clients to 3
index 797133d05c3f8ad4185b93e86f2abdc85a744ac6..0535f6123b1683b04549068f3020e0bdda07c2a5 100644 (file)
@@ -1,3 +1,8 @@
+2004-07-22  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * lyx_gui.h (set_read_callback,remove_read_callback): remove
+       declaration
+
 2004-06-18  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * screen.C (fitCursor): Use Debug::DEBUG
index fee29d308341703081c4ea67b29291069ecb021b..50a6880344599bea749d3d3abef83cabb3a78a67 100644 (file)
@@ -1,3 +1,12 @@
+2004-07-22  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * lyx_gui.C (register_socket_callback,unregister_socket_callback):
+       implement
+       (set_read_callback,remove_read_callback): remove implementation
+
+       * io_callback.[Ch]: new files
+       * Makefile.am (libgtk_la_SOURCES): handle them
+
 2004-07-21  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * lyx_gui.C (register_socket_callback): add stub
index 5d5898be937928a7aeaea58ebfc7c53217e1ee5a..efebc5b8e828376fc071d0ba4031c92bbc9923ad 100644 (file)
@@ -47,6 +47,8 @@ libgtk_la_SOURCES = \
        GView.C \
        IdSc.h \
        IdSc.C \
+       io_callback.h \
+       io_callback.C \
        Dialogs.C \
        GAboutlyx.h \
        GAboutlyx.C \
diff --git a/src/frontends/gtk/io_callback.C b/src/frontends/gtk/io_callback.C
new file mode 100644 (file)
index 0000000..d5b507c
--- /dev/null
@@ -0,0 +1,28 @@
+/**
+ * \file io_callback.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author João Luis M. Assirati
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#include <config.h>
+
+#include "io_callback.h"
+
+
+io_callback::io_callback(int fd, boost::function<void()> func)
+       : func_(func)
+{
+       conn_ = Glib::signal_io().connect(SigC::slot(*this, &io_callback::data_received), fd, Glib::IO_IN);
+}
+
+
+bool io_callback::data_received(Glib::IOCondition /*condition*/)
+{
+       func_();
+       return true;
+}
diff --git a/src/frontends/gtk/io_callback.h b/src/frontends/gtk/io_callback.h
new file mode 100644 (file)
index 0000000..24da391
--- /dev/null
@@ -0,0 +1,41 @@
+// -*- C++ -*-
+/**
+ * \file io_callback.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * \author John Levon
+ * \author João Luis M. Assirati
+ *
+ * Full author contact details are available in file CREDITS.
+ */
+
+#ifndef IO_CALLBACK_H
+#define IO_CALLBACK_H
+
+
+#include <gtkmm.h>
+
+#include <boost/function.hpp>
+
+
+/**
+ * io_callback - a simple wrapper for asynchronous socket notification
+ *
+ * This is used by the lyxsocket to notice the socket is ready to be
+ * connected/read.
+ *
+ */
+class io_callback : public SigC::Object {
+public:
+       /// connect a connection notification from the LyXServerSocket
+       io_callback(int fd, boost::function<void()> func);
+private:
+        bool data_received(Glib::IOCondition);
+       /// our notifier
+       SigC::Connection conn_;
+       /// The callback function
+       boost::function<void()> func_;
+};
+
+#endif // IO_CALLBACK_H
index ac996808b3eb9d626811de3c72d788c563fdd8d7..6c4f31cf9db070eec89fd46b99bd6e142bc434f0 100644 (file)
@@ -31,6 +31,8 @@
 #include "lyxfont.h"
 #include "graphics/LoaderQueue.h"
 
+#include "io_callback.h"
+
 // FIXME: move this stuff out again
 #include "bufferlist.h"
 #include "buffer_funcs.h"
@@ -50,6 +52,7 @@
 #include <fcntl.h>
 #include <boost/bind.hpp>
 #include <boost/function.hpp>
+#include <boost/shared_ptr.hpp>
 
 //just for xforms
 #include "lyx_forms.h"
@@ -414,44 +417,24 @@ 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);
 }
 
 
-void lyx_gui::register_socket_callback(int /*fd*/,
-                                      boost::function<void()> /*func*/)
-{}
-
-
-void lyx_gui::unregister_socket_callback(int /*fd*/)
-{}
-
-
 string const lyx_gui::roman_font_name()
 {
        return "times";
index 3ce1729ff8ff2528fa7ffe011c06d34eba96f744..153c46fa5421b808323ce76791a6bbbb46b4ab5e 100644 (file)
@@ -95,16 +95,15 @@ void update_fonts();
 bool font_available(LyXFont const & font);
 
 /**
- * add a callback for I/O read notification
+ * add a callback for socket read notification
+ * @param fd socket descriptor (file/socket/etc)
  */
-void set_read_callback(int fd, LyXComm * comm);
 void register_socket_callback(int fd, boost::function<void()> func);
 
 /**
  * remove a I/O read callback
- * @param fd file descriptor
+ * @param fd socket descriptor (file/socket/etc)
  */
-void remove_read_callback(int fd);
 void unregister_socket_callback(int fd);
 
 } // namespace lyx_gui
index 13f19787acaf0c42a127bdc0238195166dee70c6..90064bf3dd3c90b28b4332599e194b6d6b2bff5e 100644 (file)
@@ -1,3 +1,10 @@
+2004-07-22  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * lyx_gui.C (set_read_callback,remove_read_callback): delete funcs 
+
+       * Makefile.dialogs (MOCFILES): remove io_callback.[Ch]
+       * io_callback.[Ch]: delete files
+
 2004-07-21  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * socket_callback.C (data_received): simplify
index 9ca2495d4520b02a968d7eda9242b71fb9d803ad..1b1ada508d26ecb648c5c242651689e75e08484c 100644 (file)
@@ -74,7 +74,6 @@ MOCFILES = \
        FileDialog_private.C FileDialog_private.h \
        floatplacement.C floatplacement.h \
        iconpalette.C iconpalette.h \
-       io_callback.C io_callback.h \
        lengthcombo.C lengthcombo.h \
        panelstack.C panelstack.h \
        QAboutDialog.C QAboutDialog.h \
diff --git a/src/frontends/qt2/io_callback.C b/src/frontends/qt2/io_callback.C
deleted file mode 100644 (file)
index 643516a..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-/**
- * \file io_callback.C
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author unknown
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-// Qt defines a macro 'signals' that clashes with a boost namespace.
-#include "lyxserver.h"
-
-#include "io_callback.h"
-
-io_callback::io_callback(int fd, LyXComm * comm)
-       : comm_(comm)
-{
-       sn_.reset(new QSocketNotifier(fd, QSocketNotifier::Read, this));
-       connect(sn_.get(), SIGNAL(activated(int)), this, SLOT(data_received()));
-}
-
-
-void io_callback::data_received()
-{
-       comm_->read_ready();
-}
diff --git a/src/frontends/qt2/io_callback.h b/src/frontends/qt2/io_callback.h
deleted file mode 100644 (file)
index 9b6f7dd..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-// -*- C++ -*-
-/**
- * \file io_callback.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author unknown
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef IO_CALLBACK_H
-#define IO_CALLBACK_H
-
-
-#include <qobject.h>
-#include <qsocketnotifier.h>
-#include <boost/scoped_ptr.hpp>
-
-class LyXComm;
-
-/**
- * io_callback - a simple wrapper for asynchronous pipe notification
- *
- * This is used by the lyxserver to notice the pipe is ready to be
- * read.
- *
- * FIXME: this code apparently will not work on Windows.
- */
-class io_callback : public QObject {
-       Q_OBJECT
-public:
-       /// connect a read ready notification for fd to the LyXComm
-       io_callback(int fd, LyXComm * comm);
-public slots:
-       void data_received();
-private:
-       /// our notifier
-       boost::scoped_ptr<QSocketNotifier> sn_;
-
-       LyXComm * comm_;
-};
-
-#endif // IO_CALLBACK_H
index 7c4e874b9e65f42343d5e62006443b042a62078d..ecc714b1d2eaee47daa4073177d16c561f9c8524 100644 (file)
@@ -38,7 +38,6 @@
 #include <boost/shared_ptr.hpp>
 
 #include "QtView.h"
-#include "io_callback.h"
 #include "lcolorcache.h"
 #include "qfont_loader.h"
 #include "QLImage.h"
@@ -80,7 +79,6 @@ float getDPI()
        return 0.5 * (pdm.logicalDpiX() + pdm.logicalDpiY());
 }
 
-map<int, io_callback *> io_callbacks;
 map<int, shared_ptr<socket_callback> > socket_callbacks;
 
 } // namespace anon
@@ -288,22 +286,6 @@ bool font_available(LyXFont const & font)
 }
 
 
-void set_read_callback(int fd, LyXComm * comm)
-{
-       io_callbacks[fd] = new io_callback(fd, comm);
-}
-
-
-void remove_read_callback(int fd)
-{
-       map<int, io_callback *>::iterator it = io_callbacks.find(fd);
-       if (it != io_callbacks.end()) {
-               delete it->second;
-               io_callbacks.erase(it);
-       }
-}
-
-
 void register_socket_callback(int fd, boost::function<void()> func)
 {
        socket_callbacks[fd] = shared_ptr<socket_callback>(new socket_callback(fd, func));
index e9daf80c893c2609e0b547506cf25ffe54ae9313..2d68b73f020a3decc55a2571d5752ccc93f77709 100644 (file)
@@ -1,3 +1,8 @@
+2004-07-22  Lars Gullik Bjonnes  <larsbj@gullik.net>
+
+       * lyx_gui.C (C_read_callback, set_read_callback,
+       remove_read_callback): delete funcs 
+
 2004-07-21  Lars Gullik Bjonnes  <larsbj@gullik.net>
 
        * lyx_gui.C (register_socket_callback): new func
index c9c27233e3073e121c2542af7b3bc23cb8c2a955..d4579ab0485a0d39034aeff40c538fe630a38b13 100644 (file)
@@ -388,28 +388,6 @@ bool font_available(LyXFont const & font)
        return fontloader.available(font);
 }
 
-namespace {
-
-extern "C"
-void C_read_callback(int, void * data)
-{
-       LyXComm * comm = static_cast<LyXComm *>(data);
-       comm->read_ready();
-}
-
-}
-
-
-void set_read_callback(int fd, LyXComm * comm)
-{
-       fl_add_io_callback(fd, FL_READ, C_read_callback, comm);
-}
-
-void remove_read_callback(int fd)
-{
-       fl_remove_io_callback(fd, FL_READ, C_read_callback);
-}
-
 
 namespace {
 
index d258cb5474e5621c99c32672b106137bedb602c0..093239d507e826a1de1a897de6eca41ba319cbcc 100644 (file)
@@ -48,6 +48,8 @@
 #include "support/lyxlib.h"
 #include "frontends/lyx_gui.h"
 
+#include <boost/bind.hpp>
+
 #include <cerrno>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -205,7 +207,7 @@ int LyXComm::startPipe(string const & filename, bool write)
        }
 
        if (!write) {
-               lyx_gui::set_read_callback(fd, this);
+               lyx_gui::register_socket_callback(fd, boost::bind(&LyXComm::read_ready, *this));
        }
 
        return fd;
@@ -218,7 +220,7 @@ void LyXComm::endPipe(int & fd, string const & filename, bool write)
                return;
 
        if (!write) {
-               lyx_gui::remove_read_callback(fd);
+               lyx_gui::unregister_socket_callback(fd);
        }
 
 #ifdef __EMX__