mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 18:08:10 +00:00
the lyxserver modifications
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8842 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
cfd21e6a2a
commit
d9bf52e7c5
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 \
|
||||
|
28
src/frontends/gtk/io_callback.C
Normal file
28
src/frontends/gtk/io_callback.C
Normal file
@ -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;
|
||||
}
|
41
src/frontends/gtk/io_callback.h
Normal file
41
src/frontends/gtk/io_callback.h
Normal file
@ -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
|
@ -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)
|
||||
} // NS anon
|
||||
|
||||
|
||||
void lyx_gui::register_socket_callback(int fd,
|
||||
boost::function<void()> func)
|
||||
{
|
||||
comm->read_ready();
|
||||
return true;
|
||||
callbacks[fd] = boost::shared_ptr<io_callback>(new io_callback(fd, func));
|
||||
}
|
||||
|
||||
|
||||
std::map<int, SigC::Connection> gReadCallbackMap;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void lyx_gui::set_read_callback(int fd, LyXComm * comm)
|
||||
void lyx_gui::unregister_socket_callback(int fd)
|
||||
{
|
||||
gReadCallbackMap[fd] = Glib::signal_io().connect(
|
||||
SigC::bind(SigC::slot(readCallback), comm),
|
||||
fd,
|
||||
Glib::IO_IN);
|
||||
callbacks.erase(fd);
|
||||
}
|
||||
|
||||
|
||||
void lyx_gui::remove_read_callback(int fd)
|
||||
{
|
||||
gReadCallbackMap[fd].disconnect();
|
||||
gReadCallbackMap.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";
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 \
|
||||
|
@ -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();
|
||||
}
|
@ -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
|
@ -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));
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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__
|
||||
|
Loading…
Reference in New Issue
Block a user