Hello,
This patch is purely mechanical and get rid of lyx_gui.[Ch].
Only qt4 is guaranted to compile and work. I did not remove gtk and qt3
lyx_gui.C because they might be needed to complete the header
declarations in "GuiApplication.C".
Will commit soon.
Log:
- lyx_gui::use_gui transfered to lyx::use_gui in lyx_main.C
- all remaining lyx_gui functions transfered to Application and
corresponding GuiApplication implementations.
Abdel.
Index: development/scons/scons_manifest.py
===================================================================
--- development/scons/scons_manifest.py (revision 15305)
+++ development/scons/scons_manifest.py (working copy)
@@ -448,7 +448,6 @@
WorkArea.h
guiapi.h
key_state.h
- lyx_gui.h
mouse_state.h
nullpainter.h
''')
@@ -464,7 +463,6 @@
Toolbars.C
WorkArea.C
guiapi.C
- lyx_gui.C
nullpainter.C
''')
@@ -956,7 +954,6 @@
iconpalette.C
lcolorcache.C
lengthcombo.C
- lyx_gui.C
panelstack.C
qcoloritem.C
qfont_loader.C
@@ -1337,7 +1334,6 @@
FloatPlacement.C
iconpalette.C
lengthcombo.C
- lyx_gui.C
panelstack.C
qfontexample.C
qsetborder.C
Index: src/BranchList.C
===================================================================
--- src/BranchList.C (revision 15305)
+++ src/BranchList.C (working copy)
@@ -12,7 +12,9 @@
#include "BranchList.h"
#include "LColor.h"
-#include "frontends/lyx_gui.h"
+
+#include "frontends/Application.h"
+
#include <algorithm>
using std::string;
@@ -20,7 +22,7 @@
Branch::Branch()
{
- lyx_gui::getRGBColor(LColor::background, color_);
+ theApp->getRgbColor(LColor::background, color_);
}
@@ -69,7 +71,7 @@
color_ = lyx::RGBColor(c);
else
// no color set or invalid color - use normal background
- lyx_gui::getRGBColor(LColor::background, color_);
+ theApp->getRgbColor(LColor::background, color_);
}
Index: src/frontends/Alert.C
===================================================================
--- src/frontends/Alert.C (revision 15305)
+++ src/frontends/Alert.C (working copy)
@@ -14,7 +14,6 @@
#include "Alert_pimpl.h"
#include "debug.h"
-#include "lyx_gui.h"
using lyx::docstring;
@@ -25,13 +24,16 @@
namespace lyx {
+
+extern bool use_gui;
+
namespace frontend {
int Alert::prompt(docstring const & title, docstring const & question,
int default_button, int escape_button,
docstring const & b1, docstring const & b2, docstring const &
b3)
{
- if (!lyx_gui::use_gui || lyxerr.debugging()) {
+ if (!lyx::use_gui || lyxerr.debugging()) {
lyxerr << lyx::to_utf8(title) << '\n'
<< "----------------------------------------\n"
<< lyx::to_utf8(question) << endl;
@@ -42,7 +44,7 @@
case 1: lyxerr << lyx::to_utf8(b2) << endl;
case 2: lyxerr << lyx::to_utf8(b3) << endl;
}
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return default_button;
}
@@ -54,35 +56,35 @@
void Alert::warning(docstring const & title, docstring const & message)
{
- if (!lyx_gui::use_gui || lyxerr.debugging())
+ if (!lyx::use_gui || lyxerr.debugging())
lyxerr << "Warning: " << lyx::to_utf8(title) << '\n'
<< "----------------------------------------\n"
<< lyx::to_utf8(message) << endl;
- if (lyx_gui::use_gui)
+ if (lyx::use_gui)
warning_pimpl(title, message);
}
void Alert::error(docstring const & title, docstring const & message)
{
- if (!lyx_gui::use_gui || lyxerr.debugging())
+ if (!lyx::use_gui || lyxerr.debugging())
lyxerr << "Error: " << lyx::to_utf8(title) << '\n'
<< "----------------------------------------\n"
<< lyx::to_utf8(message) << endl;
- if (lyx_gui::use_gui)
+ if (lyx::use_gui)
error_pimpl(title, message);
}
void Alert::information(docstring const & title, docstring const & message)
{
- if (!lyx_gui::use_gui || lyxerr.debugging())
+ if (!lyx::use_gui || lyxerr.debugging())
lyxerr << lyx::to_utf8(title) << '\n'
<< "----------------------------------------\n"
<< lyx::to_utf8(message) << endl;
- if (lyx_gui::use_gui)
+ if (lyx::use_gui)
information_pimpl(title, message);
}
@@ -90,12 +92,12 @@
pair<bool, docstring> const Alert::askForText(docstring const & msg,
docstring const & dflt)
{
- if (!lyx_gui::use_gui || lyxerr.debugging()) {
+ if (!lyx::use_gui || lyxerr.debugging()) {
lyxerr << "----------------------------------------\n"
<< lyx::to_utf8(msg) << '\n'
<< "Assuming answer is " << lyx::to_utf8(dflt) << '\n'
<< "----------------------------------------" << endl;
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return make_pair<bool, docstring>(true, dflt);
}
Index: src/frontends/Application.C
===================================================================
--- src/frontends/Application.C (revision 15305)
+++ src/frontends/Application.C (working copy)
@@ -32,6 +32,8 @@
#include "support/os.h"
#include "support/package.h"
+#include <boost/scoped_ptr.hpp>
+#include <boost/shared_ptr.hpp>
using lyx::support::package;
@@ -139,7 +141,6 @@
return exec();
}
-
} // namespace frontend
@@ -185,3 +186,4 @@
{
return theApp->selection();
}
+
Index: src/frontends/Application.h
===================================================================
--- src/frontends/Application.h (revision 15305)
+++ src/frontends/Application.h (working copy)
@@ -11,7 +11,7 @@
#ifndef LYX_APPLICATION_H
#define LYX_APPLICATION_H
-#include <boost/scoped_ptr.hpp>
+#include <boost/function.hpp>
#include <string>
@@ -21,8 +21,12 @@
class LyXServer;
class LyXServerSocket;
class LyXView;
+class LColor_color;
namespace lyx {
+
+struct RGBColor;
+
namespace frontend {
struct Application_pimpl;
@@ -62,6 +66,10 @@
*/
virtual void exit(int status) = 0;
+ /**
+ * Synchronise all pending events.
+ */
+ virtual void syncEvents() = 0;
///
virtual Clipboard & clipboard() = 0;
///
@@ -78,6 +86,36 @@
/// return a suitable monospaced font name.
virtual std::string const typewriterFontName() = 0;
+ /**
+ * Given col, fills r, g, b in the range 0-255.
+ * The function returns true if successful.
+ * It returns false on failure and sets r, g, b to 0.
+ */
+ virtual bool getRgbColor(LColor_color col, lyx::RGBColor & rgbcol) = 0;
+
+ /** Eg, passing LColor::black returns "000000",
+ * passing LColor::white returns "ffffff".
+ */
+ virtual std::string const hexName(LColor_color col) = 0;
+
+ /**
+ * update an altered GUI color
+ */
+ virtual void updateColor(LColor_color col) = 0;
+
+ /**
+ * add a callback for socket read notification
+ * @param fd socket descriptor (file/socket/etc)
+ */
+ virtual void registerSocketCallback(
+ int fd, boost::function<void()> func) = 0;
+
+ /**
+ * remove a I/O read callback
+ * @param fd socket descriptor (file/socket/etc)
+ */
+ virtual void unregisterSocketCallback(int fd) = 0;
+
///
LyXFunc & lyxFunc();
LyXFunc const & lyxFunc() const;
@@ -108,6 +146,9 @@
}; // Application
} // namespace frontend
+
+lyx::frontend::Application * createApplication(int & argc, char * argv[]);
+
} // namespace lyx
extern lyx::frontend::Application * theApp;
Index: src/frontends/gtk/GuiApplication.C
===================================================================
--- src/frontends/gtk/GuiApplication.C (revision 15305)
+++ src/frontends/gtk/GuiApplication.C (working copy)
@@ -49,6 +49,8 @@
namespace {
+std::map<int, boost::shared_ptr<io_callback> > callbacks;
+
/// estimate DPI from X server
int getDPI()
{
@@ -62,6 +64,12 @@
namespace lyx {
+
+lyx::frontend::Application * createApplication(int & argc, char * argv[])
+{
+ return new GuiApplication(argc, argv);
+}
+
namespace frontend {
GuiApplication::GuiApplication(int & argc, char ** argv)
@@ -122,5 +130,72 @@
}
+void GuiApplication::syncEvents()
+{
+ // FIXME
+}
+
+
+bool GuiApplication::getRgbColor(LColor_color col,
+ lyx::RGBColor
& rgbcol)
+{
+ Gdk::Color gdkColor;
+ Gdk::Color * gclr = colorCache.getColor(col);
+ if (!gclr) {
+ gclr = &gdkColor;
+ if(!gclr->parse(lcolor.getX11Name(col))) {
+ rgbcol.r = 0;
+ rgbcol.g = 0;
+ rgbcol.b = 0;
+ return false;
+ }
+ }
+
+ // Note that X stores the RGB values in the range 0 - 65535
+ // whilst we require them in the range 0 - 255.
+ rgbcol.r = gclr->get_red() / 256;
+ rgbcol.g = gclr->get_green() / 256;
+ rgbcol.b = gclr->get_blue() / 256;
+ return true;
+}
+
+
+string const GuiApplication::hexName(LColor_color col)
+{
+ lyx::RGBColor rgbcol;
+ if (!getRGBColor(col, rgbcol)) {
+ lyxerr << "X can't find color for \"" << lcolor.getLyXName(col)
+ << '"' << std::endl;
+ return string();
+ }
+
+ std::ostringstream os;
+
+ os << std::setbase(16) << std::setfill('0')
+ << std::setw(2) << rgbcol.r
+ << std::setw(2) << rgbcol.g
+ << std::setw(2) << rgbcol.b;
+
+ return os.str();
+}
+
+
+void GuiApplication::updateColor(LColor_color)
+{
+ colorCache.clear();
+}
+
+
+void GuiApplication::registerSocketCallback(int fd, boost::function<void()>
func)
+{
+ callbacks[fd] = boost::shared_ptr<io_callback>(new io_callback(fd,
func));
+}
+
+
+void GuiApplication::unregisterSocketCallback(int fd)
+{
+ callbacks.erase(fd);
+}
+
} // namespace frontend
} // namespace lyx
Index: src/frontends/gtk/GuiApplication.h
===================================================================
--- src/frontends/gtk/GuiApplication.h (revision 15305)
+++ src/frontends/gtk/GuiApplication.h (working copy)
@@ -57,6 +57,12 @@
virtual std::string const romanFontName();
virtual std::string const sansFontName();
virtual std::string const typewriterFontName();
+ virtual bool getRgbColor(LColor_color col, lyx::RGBColor & rgbcol);
+ virtual std::string const hexName(LColor_color col);
+ virtual void updateColor(LColor_color col);
+ virtual void registerSocketCallback(
+ int fd, boost::function<void()> func);
+ virtual void unregisterSocketCallback(int fd);
//@}
///
Index: src/frontends/gtk/Makefile.am
===================================================================
--- src/frontends/gtk/Makefile.am (revision 15305)
+++ src/frontends/gtk/Makefile.am (working copy)
@@ -144,7 +144,6 @@
GuiImplementation.C \
io_callback.C \
io_callback.h \
- lyx_gui.C \
xftFontLoader.C \
xftFontLoader.h \
xftFontMetrics.C
Index: src/frontends/gtk/xftFontLoader.C
===================================================================
--- src/frontends/gtk/xftFontLoader.C (revision 15305)
+++ src/frontends/gtk/xftFontLoader.C (working copy)
@@ -26,7 +26,6 @@
#include "GtkmmX.h"
#include "frontends/LyXView.h"
-#include "frontends/lyx_gui.h"
#include "support/convert.h"
#include "support/lstrings.h"
@@ -39,6 +38,10 @@
using std::endl;
using std::string;
+namespace lyx {
+extern bool use_gui;
+}
+
// The global fontLoader
xftFontLoader fontLoader;
@@ -189,7 +192,7 @@
bool xftFontLoader::available(LyXFont const & f)
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return false;
static std::vector<bool> cache_set(LyXFont::NUM_FAMILIES, false);
Index: src/frontends/lyx_gui.C
===================================================================
--- src/frontends/lyx_gui.C (revision 15305)
+++ src/frontends/lyx_gui.C (working copy)
@@ -1,27 +0,0 @@
-/**
- * \file frontends/lyx_gui.C
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "lyx_gui.h"
-
-#include "Application.h"
-
-using std::string;
-
-lyx::frontend::Application * theApp;
-
-
-namespace lyx_gui {
-
-bool use_gui = true;
-
-}; // namespace lyx_gui
Index: src/frontends/lyx_gui.h
===================================================================
--- src/frontends/lyx_gui.h (revision 15305)
+++ src/frontends/lyx_gui.h (working copy)
@@ -1,80 +0,0 @@
-// -*- C++ -*-
-/**
- * \file lyx_gui.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author John Levon
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef LYX_GUI_H
-#define LYX_GUI_H
-
-
-#include "FuncStatus.h"
-
-#include <boost/function.hpp>
-
-#include <string>
-#include <vector>
-
-class Dialogs;
-class LColor_color;
-class LyXFont;
-class LyXComm;
-class FuncRequest;
-class LyXView;
-namespace lyx {
-struct RGBColor;
-}
-
-/// GUI interaction
-namespace lyx_gui {
-
-/// are we using the GUI at all
-extern bool use_gui;
-
-/**
- * Enter the main event loop (\sa LyX::exec2)
- */
-int exec(int & argc, char * argv[]);
-
-/**
- * Synchronise all pending events.
- */
-void sync_events();
-
-/**
- * Given col, fills r, g, b in the range 0-255.
- * The function returns true if successful.
- * It returns false on failure and sets r, g, b to 0.
- */
-bool getRGBColor(LColor_color col, lyx::RGBColor & rgbcol);
-
-/** Eg, passing LColor::black returns "000000",
- * passing LColor::white returns "ffffff".
- */
-std::string const hexname(LColor_color col);
-
-/**
- * update an altered GUI color
- */
-void update_color(LColor_color col);
-
-/**
- * add a callback for socket read notification
- * @param fd socket descriptor (file/socket/etc)
- */
-void register_socket_callback(int fd, boost::function<void()> func);
-
-/**
- * remove a I/O read callback
- * @param fd socket descriptor (file/socket/etc)
- */
-void unregister_socket_callback(int fd);
-
-} // namespace lyx_gui
-
-#endif // LYX_GUI_H
Index: src/frontends/Makefile.am
===================================================================
--- src/frontends/Makefile.am (revision 15305)
+++ src/frontends/Makefile.am (working copy)
@@ -42,8 +42,6 @@
guiapi.h \
guiapi.C \
key_state.h \
- lyx_gui.C \
- lyx_gui.h \
mouse_state.h \
nullpainter.C \
nullpainter.h
Index: src/frontends/qt3/GuiApplication.C
===================================================================
--- src/frontends/qt3/GuiApplication.C (revision 15305)
+++ src/frontends/qt3/GuiApplication.C (working copy)
@@ -19,6 +19,7 @@
#include "qt_helpers.h"
#include "QLImage.h"
+#include "socket_callback.h"
#include "graphics/LoaderQueue.h"
@@ -60,6 +61,8 @@
namespace {
+map<int, shared_ptr<socket_callback> > socket_callbacks;
+
int getDPI()
{
QWidget w;
@@ -71,6 +74,14 @@
namespace lyx {
+
+lyx::frontend::Application * createApplication(int & argc, char * argv[])
+{
+ GuiApplication app(argc, argv);
+
+ return &app;
+}
+
namespace frontend {
GuiApplication::GuiApplication(int & argc, char ** argv)
@@ -191,6 +202,60 @@
}
+void GuiApplication::syncEvents()
+{
+ // This is the ONLY place where processEvents may be called.
+ // During screen update/ redraw, this method is disabled to
+ // prevent keyboard events being handed to the LyX core, where
+ // they could cause re-entrant calls to screen update.
+#if QT_VERSION >= 0x030100
+ qApp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput);
+#endif
+}
+
+
+bool GuiApplication::getRgbColor(LColor_color col,
+ lyx::RGBColor
& rgbcol)
+{
+ QColor const & qcol = lcolorcache.get(col);
+ if (!qcol.isValid()) {
+ rgbcol.r = 0;
+ rgbcol.g = 0;
+ rgbcol.b = 0;
+ return false;
+ }
+ rgbcol.r = qcol.red();
+ rgbcol.g = qcol.green();
+ rgbcol.b = qcol.blue();
+ return true;
+}
+
+
+string const GuiApplication::hexName(LColor_color col)
+{
+ return ltrim(fromqstr(lcolorcache.get(col).name()), "#");
+}
+
+
+void GuiApplication::updateColor(LColor_color)
+{
+ // FIXME: Bleh, can't we just clear them all at once ?
+ lcolorcache.clear();
+}
+
+
+void GuiApplication::registerSocketCallback(int fd, boost::function<void()>
func)
+{
+ socket_callbacks[fd] = shared_ptr<socket_callback>(new
socket_callback(fd, func));
+}
+
+
+void GuiApplication::unregisterSocketCallback(int fd)
+{
+ socket_callbacks.erase(fd);
+}
+
+
////////////////////////////////////////////////////////////////////////
// X11 specific stuff goes here...
#ifdef Q_WS_X11
Index: src/frontends/qt3/GuiApplication.h
===================================================================
--- src/frontends/qt3/GuiApplication.h (revision 15305)
+++ src/frontends/qt3/GuiApplication.h (working copy)
@@ -63,6 +63,12 @@
virtual std::string const romanFontName();
virtual std::string const sansFontName();
virtual std::string const typewriterFontName();
+ virtual bool getRgbColor(LColor_color col, lyx::RGBColor & rgbcol);
+ virtual std::string const hexName(LColor_color col);
+ virtual void updateColor(LColor_color col);
+ virtual void registerSocketCallback(
+ int fd, boost::function<void()> func);
+ virtual void unregisterSocketCallback(int fd);
//@}
///
Index: src/frontends/qt3/GuiFontMetrics.C
===================================================================
--- src/frontends/qt3/GuiFontMetrics.C (revision 15305)
+++ src/frontends/qt3/GuiFontMetrics.C (working copy)
@@ -17,8 +17,6 @@
#include "language.h"
-#include "frontends/lyx_gui.h"
-
#include "support/unicode.h"
using lyx::char_type;
@@ -28,6 +26,9 @@
namespace lyx {
+
+extern bool use_gui;
+
namespace frontend {
@@ -45,7 +46,7 @@
int GuiFontMetrics::maxAscent() const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
return metrics_.ascent();
}
@@ -53,7 +54,7 @@
int GuiFontMetrics::maxDescent() const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
// We add 1 as the value returned by QT is different than X
// See http://doc.trolltech.com/2.3/qfontmetrics.html#200b74
@@ -63,7 +64,7 @@
int GuiFontMetrics::ascent(char_type c) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
QRect const & r = metrics_.boundingRect(ucs4_to_qchar(c));
// Qt/Win 3.2.1nc (at least) corrects the GetGlyphOutlineA|W y
@@ -79,7 +80,7 @@
int GuiFontMetrics::descent(char_type c) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
QRect const & r = metrics_.boundingRect(ucs4_to_qchar(c));
// Qt/Win 3.2.1nc (at least) corrects the GetGlyphOutlineA|W y
@@ -95,7 +96,7 @@
int GuiFontMetrics::lbearing(char_type c) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
return metrics_.leftBearing(ucs4_to_qchar(c));
}
@@ -103,7 +104,7 @@
int GuiFontMetrics::rbearing(char_type c) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
// Qt rbearing is from the right edge of the char's width().
@@ -114,7 +115,7 @@
int GuiFontMetrics::smallcapsWidth(QString const & s) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
int w = 0;
@@ -134,7 +135,7 @@
int GuiFontMetrics::width(char_type const * s, size_t ls) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return ls;
QString const ucs2 = toqstr(s, ls);
Index: src/frontends/qt3/Makefile.am
===================================================================
--- src/frontends/qt3/Makefile.am (revision 15305)
+++ src/frontends/qt3/Makefile.am (working copy)
@@ -86,7 +86,6 @@
Qt2BC.C Qt2BC.h \
QtLyXView.h \
checkedwidgets.C checkedwidgets.h \
- lyx_gui.C \
lcolorcache.h lcolorcache.C \
panelstack.h panelstack.C \
qcoloritem.h qcoloritem.C \
Index: src/frontends/qt3/qfont_loader.C
===================================================================
--- src/frontends/qt3/qfont_loader.C (revision 15305)
+++ src/frontends/qt3/qfont_loader.C (working copy)
@@ -17,8 +17,6 @@
#include "debug.h"
#include "lyxrc.h"
-#include "frontends/lyx_gui.h"
-
#include "support/convert.h"
#include "support/filetools.h"
#include "support/lstrings.h"
@@ -46,7 +44,11 @@
using std::vector;
using std::string;
+namespace lyx {
+extern bool use_gui;
+}
+
GuiFontLoader::~GuiFontLoader() {
}
@@ -290,7 +292,7 @@
bool GuiFontLoader::available(LyXFont const & f)
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return false;
static vector<int> cache_set(LyXFont::NUM_FAMILIES, false);
Index: src/frontends/qt3/QLPopupMenu.C
===================================================================
--- src/frontends/qt3/QLPopupMenu.C (revision 15305)
+++ src/frontends/qt3/QLPopupMenu.C (working copy)
@@ -20,7 +20,7 @@
#include "MenuBackend.h"
-#include "frontends/lyx_gui.h"
+#include "frontends/Application.h"
#include "support/lstrings.h"
@@ -94,7 +94,7 @@
{
// make sure the interface is repainted correctly (in case the
// action needs a long time, like File>Open).
- lyx_gui::sync_events();
+ theApp->syncEvents();
#ifdef Q_WS_MACX
if (index >= indexOffset) {
MenuItem mi = owner_->backend().getMenu("LyX")[index -
indexOffset];
Index: src/frontends/qt3/QMathDialog.C
===================================================================
--- src/frontends/qt3/QMathDialog.C (revision 15305)
+++ src/frontends/qt3/QMathDialog.C (working copy)
@@ -18,7 +18,7 @@
#include "controllers/ControlMath.h"
-#include "frontends/lyx_gui.h"
+#include "frontends/Application.h"
#include <qwidgetstack.h>
#include <qcombobox.h>
@@ -55,7 +55,7 @@
w_->resize(viewport()->width(), w_->height());
// force the resize to get accurate scrollbar
- lyx_gui::sync_events();
+ theApp->syncEvents();
resizeContents(w_->width(), w_->height());
}
private:
Index: src/frontends/qt3/QPrefs.C
===================================================================
--- src/frontends/qt3/QPrefs.C (revision 15305)
+++ src/frontends/qt3/QPrefs.C (working copy)
@@ -47,7 +47,6 @@
#include "controllers/helper_funcs.h"
#include "frontends/Application.h"
-#include "frontends/lyx_gui.h"
#include <qcheckbox.h>
#include "qcoloritem.h"
Index: src/frontends/qt3/QViewSource.C
===================================================================
--- src/frontends/qt3/QViewSource.C (revision 15305)
+++ src/frontends/qt3/QViewSource.C (working copy)
@@ -14,7 +14,6 @@
#include "QViewSource.h"
#include "QViewSourceDialog.h"
#include "qt_helpers.h"
-#include "lyx_gui.h"
#include "frontends/Application.h"
Index: src/frontends/qt4/GuiApplication.C
===================================================================
--- src/frontends/qt4/GuiApplication.C (revision 15305)
+++ src/frontends/qt4/GuiApplication.C (working copy)
@@ -16,6 +16,7 @@
#include "qt_helpers.h"
#include "QLImage.h"
+#include "socket_callback.h"
#include "graphics/LoaderQueue.h"
@@ -24,9 +25,10 @@
#include "support/package.h"
#include "BufferView.h"
+#include "Color.h"
+#include "debug.h"
#include "lyx_main.h"
#include "lyxrc.h"
-#include "debug.h"
#include <QApplication>
#include <QClipboard>
@@ -67,7 +69,25 @@
} // namespace anon
+lyx::frontend::GuiApplication * guiApp;
+
namespace lyx {
+
+lyx::frontend::Application * createApplication(int & argc, char * argv[])
+{
+ // FIXME: it would be great if we could just do:
+ //return new lyx::frontend::GuiApplication(argc, argv);
+
+#if defined(Q_WS_WIN) && !defined(Q_CYGWIN_WIN)
+ static lyx::frontend::GuiApplication app(argc, argv);
+#else
+ lyx::frontend::GuiApplication app(argc, argv);
+#endif
+
+ return &app;
+}
+
+
namespace frontend {
GuiApplication::GuiApplication(int & argc, char ** argv)
@@ -132,6 +152,8 @@
lyxrc.dpi = getDPI();
LoaderQueue::setPriority(10,100);
+
+ guiApp = this;
}
@@ -189,6 +211,58 @@
}
+void GuiApplication::syncEvents()
+{
+ // This is the ONLY place where processEvents may be called.
+ // During screen update/ redraw, this method is disabled to
+ // prevent keyboard events being handed to the LyX core, where
+ // they could cause re-entrant calls to screen update.
+ processEvents(QEventLoop::ExcludeUserInputEvents);
+}
+
+
+bool GuiApplication::getRgbColor(LColor_color col,
+ lyx::RGBColor
& rgbcol)
+{
+ QColor const & qcol = color_cache_.get(col);
+ if (!qcol.isValid()) {
+ rgbcol.r = 0;
+ rgbcol.g = 0;
+ rgbcol.b = 0;
+ return false;
+ }
+ rgbcol.r = qcol.red();
+ rgbcol.g = qcol.green();
+ rgbcol.b = qcol.blue();
+ return true;
+}
+
+
+string const GuiApplication::hexName(LColor_color col)
+{
+ return lyx::support::ltrim(fromqstr(color_cache_.get(col).name()), "#");
+}
+
+
+void GuiApplication::updateColor(LColor_color)
+{
+ // FIXME: Bleh, can't we just clear them all at once ?
+ color_cache_.clear();
+}
+
+
+void GuiApplication::registerSocketCallback(int fd, boost::function<void()>
func)
+{
+ socket_callbacks_[fd] =
+ boost::shared_ptr<socket_callback>(new socket_callback(fd,
func));
+}
+
+
+void GuiApplication::unregisterSocketCallback(int fd)
+{
+ socket_callbacks_.erase(fd);
+}
+
////////////////////////////////////////////////////////////////////////
// X11 specific stuff goes here...
#ifdef Q_WS_X11
Index: src/frontends/qt4/GuiApplication.h
===================================================================
--- src/frontends/qt4/GuiApplication.h (revision 15305)
+++ src/frontends/qt4/GuiApplication.h (working copy)
@@ -32,6 +32,7 @@
///////////////////////////////////////////////////////////////
class BufferView;
+class socket_callback;
namespace lyx {
namespace frontend {
@@ -61,9 +62,16 @@
virtual int const exec();
virtual Gui & gui() { return gui_; }
virtual void exit(int status);
+ void syncEvents();
virtual std::string const romanFontName();
virtual std::string const sansFontName();
virtual std::string const typewriterFontName();
+ virtual bool getRgbColor(LColor_color col, lyx::RGBColor & rgbcol);
+ virtual std::string const hexName(LColor_color col);
+ virtual void updateColor(LColor_color col);
+ virtual void registerSocketCallback(
+ int fd, boost::function<void()> func);
+ virtual void unregisterSocketCallback(int fd);
//@}
///
@@ -83,6 +91,8 @@
GuiFontLoader font_loader_;
///
ColorCache color_cache_;
+ ///
+ std::map<int, boost::shared_ptr<socket_callback> > socket_callbacks_;
#ifdef Q_WS_X11
public:
Index: src/frontends/qt4/GuiFontLoader.C
===================================================================
--- src/frontends/qt4/GuiFontLoader.C (revision 15305)
+++ src/frontends/qt4/GuiFontLoader.C (working copy)
@@ -17,8 +17,6 @@
#include "debug.h"
#include "lyxrc.h"
-#include "frontends/lyx_gui.h"
-
#include "support/convert.h"
#include "support/filetools.h"
#include "support/lstrings.h"
@@ -45,6 +43,9 @@
namespace lyx {
+
+extern bool use_gui;
+
namespace frontend {
GuiFontLoader::~GuiFontLoader() {
@@ -303,7 +304,7 @@
bool GuiFontLoader::available(LyXFont const & f)
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return false;
static vector<int> cache_set(LyXFont::NUM_FAMILIES, false);
Index: src/frontends/qt4/GuiFontMetrics.C
===================================================================
--- src/frontends/qt4/GuiFontMetrics.C (revision 15305)
+++ src/frontends/qt4/GuiFontMetrics.C (working copy)
@@ -17,8 +17,6 @@
#include "language.h"
-#include "frontends/lyx_gui.h"
-
#include "support/unicode.h"
using lyx::char_type;
@@ -26,8 +24,10 @@
using std::string;
+namespace lyx {
-namespace lyx {
+extern bool use_gui;
+
namespace frontend {
@@ -45,7 +45,7 @@
int GuiFontMetrics::maxAscent() const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
return metrics_.ascent();
}
@@ -53,7 +53,7 @@
int GuiFontMetrics::maxDescent() const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
// We add 1 as the value returned by QT is different than X
// See http://doc.trolltech.com/2.3/qfontmetrics.html#200b74
@@ -63,7 +63,7 @@
int GuiFontMetrics::ascent(char_type c) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
QRect const & r = metrics_.boundingRect(ucs4_to_qchar(c));
// Qt/Win 3.2.1nc (at least) corrects the GetGlyphOutlineA|W y
@@ -79,7 +79,7 @@
int GuiFontMetrics::descent(char_type c) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
QRect const & r = metrics_.boundingRect(ucs4_to_qchar(c));
// Qt/Win 3.2.1nc (at least) corrects the GetGlyphOutlineA|W y
@@ -95,7 +95,7 @@
int GuiFontMetrics::lbearing(char_type c) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
return metrics_.leftBearing(ucs4_to_qchar(c));
}
@@ -103,7 +103,7 @@
int GuiFontMetrics::rbearing(char_type c) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
// Qt rbearing is from the right edge of the char's width().
@@ -114,7 +114,7 @@
int GuiFontMetrics::smallcapsWidth(QString const & s) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return 1;
int w = 0;
@@ -134,7 +134,7 @@
int GuiFontMetrics::width(char_type const * s, size_t ls) const
{
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
return ls;
QString ucs2;
Index: src/frontends/qt4/lyx_gui.C
===================================================================
--- src/frontends/qt4/lyx_gui.C (revision 15305)
+++ src/frontends/qt4/lyx_gui.C (working copy)
@@ -1,154 +0,0 @@
-/**
- * \file qt4/lyx_gui.C
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author unknown
- * \author John Levon
- * \author Abdelrazak Younes
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#include <config.h>
-
-#include "lyx_gui.h"
-
-// FIXME: move this stuff out again
-#include "Color.h"
-#include "funcrequest.h"
-#include "LColor.h"
-#include "lyx_main.h"
-#include "LyXAction.h"
-#include "lyxfunc.h"
-#include "lyxrc.h"
-
-
-#include "support/lstrings.h"
-
-#include "GuiView.h"
-#include "QLImage.h"
-#include "qt_helpers.h"
-#include "socket_callback.h"
-#include "GuiApplication.h"
-
-#include <QApplication>
-#include <QEventLoop>
-#include <QTranslator>
-#include <QTextCodec>
-#include <QLocale>
-#include <QLibraryInfo>
-
-#include <boost/bind.hpp>
-#include <boost/shared_ptr.hpp>
-
-
-using lyx::support::ltrim;
-
-using lyx::frontend::GuiImplementation;
-using lyx::frontend::GuiView;
-using lyx::frontend::GuiApplication;
-
-using boost::shared_ptr;
-
-using std::map;
-using std::vector;
-using std::string;
-
-lyx::frontend::GuiApplication * guiApp;
-
-namespace {
-
-map<int, shared_ptr<socket_callback> > socket_callbacks;
-
-} // namespace anon
-
-namespace lyx_gui {
-
-int exec(int & argc, char * argv[])
-{
- /*
- FIXME : Abdel 29/05/2006 ([EMAIL PROTECTED])
- reorganize this code. In particular make sure that this
- advice from Qt documentation is respected:
-
- Since the QApplication object does so much initialization, it
- must be created before any other objects related to the user
- interface are created.
-
- Right now this is not the case, I suspect that a number of global
variables
- contains Qt object that are initialized before the passage through
- parse_init(). This might also explain the message displayed by Qt
- that caused the hanging:
-
- QObject::killTimer: timers cannot be stopped from another thread
-
- I hope that the problem will disappear automagically when we get rid of
- lyx_gui entirely, thus using theApp directly throughout the code for
LyXFunc,
- Clipboard and Selection access.
- */
-
-#if defined(Q_WS_WIN) && !defined(Q_CYGWIN_WIN)
- static GuiApplication app(argc, argv);
-#else
- GuiApplication app(argc, argv);
-#endif
-
- guiApp = &app;
- theApp = guiApp;
-
- return LyX::ref().exec2(argc, argv);
-}
-
-
-void sync_events()
-{
- // This is the ONLY place where processEvents may be called.
- // During screen update/ redraw, this method is disabled to
- // prevent keyboard events being handed to the LyX core, where
- // they could cause re-entrant calls to screen update.
- guiApp->processEvents(QEventLoop::ExcludeUserInputEvents);
-}
-
-
-bool getRGBColor(LColor_color col, lyx::RGBColor & rgbcol)
-{
- QColor const & qcol = guiApp->colorCache().get(col);
- if (!qcol.isValid()) {
- rgbcol.r = 0;
- rgbcol.g = 0;
- rgbcol.b = 0;
- return false;
- }
- rgbcol.r = qcol.red();
- rgbcol.g = qcol.green();
- rgbcol.b = qcol.blue();
- return true;
-}
-
-
-string const hexname(LColor_color col)
-{
- return ltrim(fromqstr(guiApp->colorCache().get(col).name()), "#");
-}
-
-
-void update_color(LColor_color)
-{
- // FIXME: Bleh, can't we just clear them all at once ?
- guiApp->colorCache().clear();
-}
-
-
-void register_socket_callback(int fd, boost::function<void()> func)
-{
- socket_callbacks[fd] = shared_ptr<socket_callback>(new
socket_callback(fd, func));
-}
-
-
-void unregister_socket_callback(int fd)
-{
- socket_callbacks.erase(fd);
-}
-
-}; // namespace lyx_gui
Index: src/frontends/qt4/Makefile.am
===================================================================
--- src/frontends/qt4/Makefile.am (revision 15305)
+++ src/frontends/qt4/Makefile.am (working copy)
@@ -84,7 +84,6 @@
QWrap.C QWrap.h \
Qt2BC.C Qt2BC.h \
checkedwidgets.C checkedwidgets.h \
- lyx_gui.C \
panelstack.h panelstack.C \
qfontexample.h qfontexample.C \
qlkey.h \
Index: src/frontends/qt4/QLPopupMenu.C
===================================================================
--- src/frontends/qt4/QLPopupMenu.C (revision 15305)
+++ src/frontends/qt4/QLPopupMenu.C (working copy)
@@ -23,7 +23,6 @@
#include "qt_helpers.h"
#include "MenuBackend.h"
-#include "frontends/lyx_gui.h"
#include "support/lstrings.h"
#include "debug.h"
Index: src/frontends/qt4/QMathDialog.C
===================================================================
--- src/frontends/qt4/QMathDialog.C (revision 15305)
+++ src/frontends/qt4/QMathDialog.C (working copy)
@@ -25,7 +25,7 @@
#include "iconpalette.h"
#include "qt_helpers.h"
#include "controllers/ControlMath.h"
-#include "frontends/lyx_gui.h"
+
#include "support/filetools.h"
using std::string;
Index: src/frontends/qt4/QPrefs.C
===================================================================
--- src/frontends/qt4/QPrefs.C (revision 15305)
+++ src/frontends/qt4/QPrefs.C (working copy)
@@ -27,8 +27,6 @@
#include "controllers/frnt_lang.h"
#include "controllers/helper_funcs.h"
-#include "frontends/lyx_gui.h"
-
using namespace Ui;
namespace lyx {
Index: src/frontends/qt4/QPrefsDialog.C
===================================================================
--- src/frontends/qt4/QPrefsDialog.C (revision 15305)
+++ src/frontends/qt4/QPrefsDialog.C (working copy)
@@ -29,7 +29,7 @@
#include "controllers/helper_funcs.h"
#include "frontends/Alert.h"
-#include "frontends/lyx_gui.h"
+#include "frontends/Application.h"
#include "QPrefsDialog.h"
#include "QPrefs.h"
Index: src/frontends/WorkArea.C
===================================================================
--- src/frontends/WorkArea.C (revision 15305)
+++ src/frontends/WorkArea.C (working copy)
@@ -19,7 +19,6 @@
#include "frontends/FontMetrics.h"
#include "funcrequest.h"
-#include "lyx_gui.h"
#include "lyxfunc.h"
#include "Painter.h"
Index: src/graphics/PreviewLoader.C
===================================================================
--- src/graphics/PreviewLoader.C (revision 15305)
+++ src/graphics/PreviewLoader.C (working copy)
@@ -24,7 +24,7 @@
#include "outputparams.h"
#include "paragraph.h"
-#include "frontends/lyx_gui.h" // hexname
+#include "frontends/Application.h" // hexName
#include "insets/inset.h"
@@ -500,8 +500,8 @@
cs << pconverter_->command << ' ' << pconverter_->to << ' '
<< support::quoteName(latexfile) << ' '
<< int(font_scaling_factor_) << ' '
- << lyx_gui::hexname(LColor::preview) << ' '
- << lyx_gui::hexname(LColor::background);
+ << theApp->hexName(LColor::preview) << ' '
+ << theApp->hexName(LColor::background);
string const command = support::libScriptSearch(cs.str());
Index: src/insets/insetexternal.C
===================================================================
--- src/insets/insetexternal.C (revision 15305)
+++ src/insets/insetexternal.C (working copy)
@@ -22,6 +22,7 @@
#include "debug.h"
#include "dispatchresult.h"
#include "exporter.h"
+#include "FuncStatus.h"
#include "funcrequest.h"
#include "gettext.h"
#include "LaTeXFeatures.h"
@@ -31,8 +32,6 @@
#include "metricsinfo.h"
#include "outputparams.h"
-#include "frontends/lyx_gui.h"
-
#include "graphics/PreviewLoader.h"
#include "support/filetools.h"
@@ -58,6 +57,9 @@
using std::ostringstream;
using std::vector;
+namespace lyx {
+extern bool use_gui;
+}
namespace {
@@ -563,7 +565,7 @@
if (gparams.display == graphics::DefaultDisplay)
gparams.display = lyxrc.display_graphics;
// Override the above if we're not using a gui
- if (!lyx_gui::use_gui)
+ if (!lyx::use_gui)
gparams.display = graphics::NoDisplay;
return gparams;
Index: src/insets/insetgraphicsParams.C
===================================================================
--- src/insets/insetgraphicsParams.C (revision 15305)
+++ src/insets/insetgraphicsParams.C (working copy)
@@ -17,8 +17,6 @@
#include "lyxlex.h"
#include "lyxrc.h"
-#include "frontends/lyx_gui.h"
-
#include "graphics/GraphicsParams.h"
#include "support/convert.h"
@@ -35,6 +33,10 @@
using std::ostream;
+namespace lyx {
+extern bool use_gui;
+}
+
InsetGraphicsParams::InsetGraphicsParams()
{
init();
@@ -322,7 +324,7 @@
}
// Override the above if we're not using a gui
- if (!lyx_gui::use_gui) {
+ if (!lyx::use_gui) {
pars.display = lyx::graphics::NoDisplay;
}
Index: src/lyx_cb.C
===================================================================
--- src/lyx_cb.C (revision 15305)
+++ src/lyx_cb.C (working copy)
@@ -34,7 +34,6 @@
#include "frontends/Alert.h"
#include "frontends/Application.h"
#include "frontends/FileDialog.h"
-#include "frontends/lyx_gui.h"
#include "support/filefilterlist.h"
#include "support/filetools.h"
@@ -94,6 +93,9 @@
// this should be static, but I need it in buffer.C
bool quitting; // flag, that we are quitting the program
+namespace lyx {
+extern bool use_gui;
+}
//
// Menu callbacks
@@ -192,7 +194,7 @@
{
lyxerr[Debug::INFO] << "Running QuitLyX." << endl;
- if (lyx_gui::use_gui) {
+ if (lyx::use_gui) {
if (!noask && !theBufferList().quitWriteAll())
return;
@@ -216,11 +218,12 @@
Alert::warning(_("Unable to remove temporary directory"), msg);
}
- if (lyx_gui::use_gui)
+ if (lyx::use_gui) {
theApp->exit(0);
- // Restore original font resources after Application is destroyed.
- lyx::support::restoreFontResources();
+ // Restore original font resources after Application is
destroyed.
+ lyx::support::restoreFontResources();
+ }
}
Index: src/lyx_main.C
===================================================================
--- src/lyx_main.C (revision 15305)
+++ src/lyx_main.C (working copy)
@@ -42,7 +42,6 @@
#include "frontends/Alert.h"
#include "frontends/Application.h"
-#include "frontends/lyx_gui.h"
#include "frontends/LyXView.h"
#include "support/environment.h"
@@ -93,9 +92,22 @@
#endif
-// convenient to have it here.
+/// convenient to have it here.
boost::scoped_ptr<kb_keymap> toplevel_keymap;
+///
+lyx::frontend::Application * theApp;
+
+namespace lyx {
+
+/// are we using the GUI at all?
+/**
+* We default to true and this is changed to false when the export feature is
used.
+*/
+bool use_gui = true;
+
+}
+
namespace {
// Filled with the command line arguments "foo" of "-sysdir foo" or
@@ -109,7 +121,7 @@
// FIXME: We should not directly call exit(), since it only
// guarantees a return to the system, no application cleanup.
// This may cause troubles with not executed destructors.
- if (lyx_gui::use_gui) {
+ if (lyx::use_gui) {
theApp->exit(status);
// Restore original font resources after Application is
destroyed.
lyx::support::restoreFontResources();
@@ -235,19 +247,23 @@
{
// Here we need to parse the command line. At least
// we need to parse for "-dbg" and "-help"
- lyx_gui::use_gui = easyParse(argc, argv);
+ easyParse(argc, argv);
lyx::support::init_package(argv[0], cl_system_support, cl_user_support,
lyx::support::top_build_dir_is_one_level_up);
// Start the real execution loop.
- if (lyx_gui::use_gui) {
+ if (lyx::use_gui) {
// Force adding of font path _before_ Application is initialized
lyx::support::addFontResources();
- return lyx_gui::exec(argc, argv);
+ theApp = lyx::createApplication(argc, argv);
}
- else
- return exec2(argc, argv);
+ else {
+ // FIXME: create a ConsoleApplication
+ theApp = 0;
+ }
+
+ return exec2(argc, argv);
}
@@ -323,7 +339,7 @@
files.clear(); // the files are already loaded
}
- if (lyx_gui::use_gui) {
+ if (lyx::use_gui) {
// determine windows size and position, from lyxrc and/or
session
// initial geometry
unsigned int width = 690;
@@ -518,15 +534,15 @@
if (lyxrc.roman_font_name.empty())
lyxrc.roman_font_name =
- lyx_gui::use_gui? theApp->romanFontName(): "serif";
+ lyx::use_gui? theApp->romanFontName(): "serif";
if (lyxrc.sans_font_name.empty())
lyxrc.sans_font_name =
- lyx_gui::use_gui? theApp->sansFontName(): "sans";
+ lyx::use_gui? theApp->sansFontName(): "sans";
if (lyxrc.typewriter_font_name.empty())
lyxrc.typewriter_font_name =
- lyx_gui::use_gui? theApp->typewriterFontName():
"monospace";
+ lyx::use_gui? theApp->typewriterFontName(): "monospace";
//
// Read configuration files
@@ -551,7 +567,7 @@
reconfigureUserLyXDir();
// no need for a splash when there is no GUI
- if (!lyx_gui::use_gui) {
+ if (!lyx::use_gui) {
first_start = false;
}
@@ -582,7 +598,7 @@
if (!LyXSetStyle())
return false;
- if (lyx_gui::use_gui) {
+ if (lyx::use_gui) {
// Set up bindings
toplevel_keymap.reset(new kb_keymap);
defaultKeyBindings(toplevel_keymap.get());
@@ -920,7 +936,6 @@
namespace {
-bool is_gui = true;
string batch;
/// return the the number of arguments consumed
@@ -1015,7 +1030,7 @@
exit(1);
}
batch = "buffer-export " + type;
- is_gui = false;
+ lyx::use_gui = true;
return 1;
}
@@ -1038,7 +1053,7 @@
} // namespace anon
-bool LyX::easyParse(int & argc, char * argv[])
+void LyX::easyParse(int & argc, char * argv[])
{
std::map<string, cmd_helper> cmdmap;
@@ -1082,6 +1097,4 @@
}
batch_command = batch;
-
- return is_gui;
}
Index: src/lyx_main.h
===================================================================
--- src/lyx_main.h (revision 15305)
+++ src/lyx_main.h (working copy)
@@ -39,9 +39,9 @@
* Execute LyX. The startup sequence is as follows:
* -# LyX::exec()
* -# LyX::priv_exec()
- * -# lyx_gui::exec()
+ * -# lyx::createApplication()
* -# LyX::exec2()
- * Step 3 is omitted if no gui is wanted. We need lyx_gui::exec()
+ * Step 3 is omitted if no gui is wanted. We need
lyx::createApplication()
* only to create the QApplication object in the qt frontend. All
* attempts with static and dynamically allocated QApplication
* objects lead either to harmless error messages on exit
@@ -97,8 +97,8 @@
bool readLanguagesFile(std::string const & name);
/// read the given encodings file
bool readEncodingsFile(std::string const & name);
- /// parsing of non-gui LyX options. Returns true if gui
- bool easyParse(int & argc, char * argv[]);
+ /// parsing of non-gui LyX options.
+ void easyParse(int & argc, char * argv[]);
/// shows up a parsing error on screen
void printError(ErrorItem const &);
Index: src/lyxfunc.C
===================================================================
--- src/lyxfunc.C (revision 15305)
+++ src/lyxfunc.C (working copy)
@@ -36,6 +36,7 @@
#include "exporter.h"
#include "format.h"
#include "funcrequest.h"
+#include "FuncStatus.h"
#include "gettext.h"
#include "importer.h"
#include "insetiterator.h"
@@ -77,7 +78,6 @@
#include "frontends/Dialogs.h"
#include "frontends/FileDialog.h"
#include "frontends/FontLoader.h"
-#include "frontends/lyx_gui.h"
#include "frontends/LyXKeySym.h"
#include "frontends/LyXView.h"
#include "frontends/Menubar.h"
@@ -146,6 +146,9 @@
// (alkis)
extern tex_accent_struct get_accent(kb_action action);
+namespace lyx {
+extern bool use_gui;
+}
namespace {
@@ -1000,7 +1003,7 @@
boost::tie(view()->cursor().pit(),
view()->cursor().pos()) );
// save bookmarks to .lyx/session
view()->saveSavedPositions();
- }
+ }
quitLyX(argument == "force");
break;
@@ -1377,7 +1380,7 @@
break;
}
- lyx_gui::update_color(lcolor.getFromLyXName(lyx_name));
+ theApp->updateColor(lcolor.getFromLyXName(lyx_name));
if (graphicsbg_changed) {
#ifdef WITH_WARNINGS
@@ -1855,7 +1858,7 @@
string const lyxfile = changeExtension(filename, ".lyx");
// Check if the document already is open
- if (lyx_gui::use_gui && theBufferList().exists(lyxfile)) {
+ if (lyx::use_gui && theBufferList().exists(lyxfile)) {
if (!theBufferList().close(theBufferList().getBuffer(lyxfile),
true)) {
owner->message(_("Canceled."));
return;
Index: src/lyxserver.C
===================================================================
--- src/lyxserver.C (revision 15305)
+++ src/lyxserver.C (working copy)
@@ -44,7 +44,7 @@
#include "funcrequest.h"
#include "LyXAction.h"
#include "lyxfunc.h"
-#include "frontends/lyx_gui.h"
+#include "frontends/Application.h"
#include "support/lstrings.h"
#include "support/lyxlib.h"
@@ -189,7 +189,8 @@
}
if (!write) {
- lyx_gui::register_socket_callback(fd,
boost::bind(&LyXComm::read_ready, this));
+ theApp->registerSocketCallback(fd,
+ boost::bind(&LyXComm::read_ready, this));
}
return fd;
@@ -202,7 +203,7 @@
return;
if (!write) {
- lyx_gui::unregister_socket_callback(fd);
+ theApp->unregisterSocketCallback(fd);
}
if (::close(fd) < 0) {
Index: src/lyxsocket.C
===================================================================
--- src/lyxsocket.C (revision 15305)
+++ src/lyxsocket.C (working copy)
@@ -21,7 +21,7 @@
#include "LyXAction.h"
#include "lyxfunc.h"
-#include "frontends/lyx_gui.h"
+#include "frontends/Application.h"
#include "support/environment.h"
#include "support/lyxlib.h"
@@ -61,7 +61,7 @@
// Needed by lyxclient
lyx::support::setEnv("LYXSOCKET", address_);
- lyx_gui::register_socket_callback(
+ theApp->registerSocketCallback(
fd_,
boost::bind(&LyXServerSocket::serverCallback, this)
);
@@ -75,7 +75,7 @@
LyXServerSocket::~LyXServerSocket()
{
if (fd_ != -1) {
- lyx_gui::unregister_socket_callback(fd_);
+ theApp->unregisterSocketCallback(fd_);
if (::close(fd_) != 0)
lyxerr << "lyx: Server socket " << fd_
<< " IO error on closing: " << strerror(errno);
@@ -111,7 +111,7 @@
// Register the new client.
clients[client_fd] =
shared_ptr<LyXDataSocket>(new LyXDataSocket(client_fd));
- lyx_gui::register_socket_callback(
+ theApp->registerSocketCallback(
client_fd,
boost::bind(&LyXServerSocket::dataCallback,
this, client_fd)
@@ -209,7 +209,7 @@
lyxerr << "lyx: Data socket " << fd_
<< " IO error on closing: " << strerror(errno);
- lyx_gui::unregister_socket_callback(fd_);
+ theApp->unregisterSocketCallback(fd_);
lyxerr[Debug::LYXSERVER] << "lyx: Data socket " << fd_ << " quitting."
<< endl;
}