mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
make it compile again
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15132 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
ebaaff58fa
commit
063994371e
@ -59,7 +59,7 @@ void add_el(Gtk::Box::BoxList & list, Gtk::Box & box, bool shrink)
|
||||
} // namespace anon
|
||||
|
||||
|
||||
GView::GView(Gui & owner) : LyXView(owner)
|
||||
GView::GView() : LyXView()
|
||||
{
|
||||
// The physical store for the boxes making up the layout.
|
||||
box_store_.push_back(BoxPtr(new Gtk::VBox));
|
||||
|
@ -35,7 +35,7 @@ public:
|
||||
Center
|
||||
};
|
||||
|
||||
GView(Gui & owner);
|
||||
GView();
|
||||
~GView();
|
||||
|
||||
Gtk::Box & getBox(Position pos);
|
||||
|
@ -493,36 +493,5 @@ bool GWorkArea::onKeyPress(GdkEventKey * event)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void GWorkArea::onClipboardGet(Gtk::SelectionData & /*selection_data*/,
|
||||
guint /*info*/)
|
||||
{
|
||||
lyx::docstring const sel = view_.view()->requestSelection();
|
||||
if (!sel.empty())
|
||||
view_.gui().selection().put(sel);
|
||||
}
|
||||
|
||||
|
||||
void GWorkArea::onClipboardClear()
|
||||
{
|
||||
// clearSelection();
|
||||
}
|
||||
|
||||
|
||||
void GWorkArea::haveSelection(bool toHave)
|
||||
{
|
||||
if (toHave) {
|
||||
Glib::RefPtr<Gtk::Clipboard> clipboard =
|
||||
Gtk::Clipboard::get(GDK_SELECTION_PRIMARY);
|
||||
std::vector<Gtk::TargetEntry> listTargets;
|
||||
listTargets.push_back(Gtk::TargetEntry("UTF8_STRING"));
|
||||
clipboard->set(listTargets,
|
||||
sigc::mem_fun(const_cast<GWorkArea&>(*this),
|
||||
&GWorkArea::onClipboardGet),
|
||||
sigc::mem_fun(const_cast<GWorkArea&>(*this),
|
||||
&GWorkArea::onClipboardClear));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
@ -82,8 +82,6 @@ public:
|
||||
ColorHandler & getColorHandler();
|
||||
|
||||
virtual void setScrollbarParams(int height, int pos, int line_height);
|
||||
/// a selection exists
|
||||
virtual void haveSelection(bool);
|
||||
void inputCommit(gchar * str);
|
||||
|
||||
LyXView & view()
|
||||
@ -100,8 +98,6 @@ private:
|
||||
bool onButtonRelease(GdkEventButton * event);
|
||||
bool onMotionNotify(GdkEventMotion * event);
|
||||
bool onKeyPress(GdkEventKey * event);
|
||||
void onClipboardGet(Gtk::SelectionData & selection_data, guint info);
|
||||
void onClipboardClear();
|
||||
LyXView & view_;
|
||||
Gtk::HBox hbox_;
|
||||
Gtk::DrawingArea workArea_;
|
||||
|
125
src/frontends/gtk/GuiApplication.C
Normal file
125
src/frontends/gtk/GuiApplication.C
Normal file
@ -0,0 +1,125 @@
|
||||
/**
|
||||
* \file qt4/GuiApplication.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 "GuiApplication.h"
|
||||
|
||||
#include "GView.h"
|
||||
#include "GuiWorkArea.h"
|
||||
#include "GtkmmX.h"
|
||||
|
||||
#include "BufferView.h"
|
||||
|
||||
#include "graphics/LoaderQueue.h"
|
||||
|
||||
#include "support/lstrings.h"
|
||||
#include "support/os.h"
|
||||
#include "support/package.h"
|
||||
|
||||
#include "lyx_main.h"
|
||||
#include "lyxrc.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include <gtkmm.h>
|
||||
|
||||
#include "LyXGdkImage.h"
|
||||
|
||||
|
||||
using lyx::support::subst;
|
||||
|
||||
using std::string;
|
||||
using std::endl;
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
/// estimate DPI from X server
|
||||
int getDPI()
|
||||
{
|
||||
//TODO use GDK instead
|
||||
Screen * scr = ScreenOfDisplay(getDisplay(), getScreen());
|
||||
return int(((HeightOfScreen(scr) * 25.4 / HeightMMOfScreen(scr)) +
|
||||
(WidthOfScreen(scr) * 25.4 / WidthMMOfScreen(scr))) / 2);
|
||||
}
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
GuiApplication::GuiApplication(int & argc, char ** argv)
|
||||
: Gtk::Main(argc, argv), Application(argc, argv)
|
||||
{
|
||||
using namespace lyx::graphics;
|
||||
Image::newImage = boost::bind(&LyXGdkImage::newImage);
|
||||
Image::loadableFormats = boost::bind(&LyXGdkImage::loadableFormats);
|
||||
|
||||
// needs to be done before reading lyxrc
|
||||
lyxrc.dpi = getDPI();
|
||||
|
||||
LoaderQueue::setPriority(10,100);
|
||||
}
|
||||
|
||||
|
||||
Clipboard& GuiApplication::clipboard()
|
||||
{
|
||||
return clipboard_;
|
||||
}
|
||||
|
||||
|
||||
Selection& GuiApplication::selection()
|
||||
{
|
||||
return selection_;
|
||||
}
|
||||
|
||||
|
||||
int const GuiApplication::exec()
|
||||
{
|
||||
run();
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void GuiApplication::exit(int /*status*/)
|
||||
{
|
||||
// FIXME: Don't ignore status
|
||||
guiApp->quit();
|
||||
}
|
||||
|
||||
|
||||
// FIXME: this whole method needs to be moved to Application.
|
||||
LyXView & GuiApplication::createView(unsigned int width,
|
||||
unsigned int height,
|
||||
int posx, int posy,
|
||||
bool maximize)
|
||||
{
|
||||
// FIXME: for now we assume that there is only one LyXView with id = 0.
|
||||
/*int workArea_id_ =*/ gui().newWorkArea(width, height, 0);
|
||||
//WorkArea * workArea_ = & theApp->gui().workArea(workArea_id_);
|
||||
|
||||
int view_id = gui().newView(width, height);
|
||||
GView & view = static_cast<GView &>(gui().view(view_id));
|
||||
|
||||
lyxfunc_.reset(new LyXFunc(&view));
|
||||
|
||||
LyX::ref().addLyXView(&view);
|
||||
|
||||
view.show();
|
||||
view.init();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
80
src/frontends/gtk/GuiApplication.h
Normal file
80
src/frontends/gtk/GuiApplication.h
Normal file
@ -0,0 +1,80 @@
|
||||
/**
|
||||
* \file gtk/GuiApplication.h
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef GTK_APPLICATION_H
|
||||
#define GTK_APPLICATION_H
|
||||
|
||||
#include "GuiClipboard.h"
|
||||
#include "GuiImplementation.h"
|
||||
#include "GuiSelection.h"
|
||||
#include "xftFontLoader.h"
|
||||
|
||||
#include "frontends/Application.h"
|
||||
|
||||
#include <gtkmm.h>
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
||||
class BufferView;
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
|
||||
class GuiWorkArea;
|
||||
|
||||
/// The Gtk main application class
|
||||
/**
|
||||
There should be only one instance of this class. No Gtk object
|
||||
initialisation should be done before the instanciation of this class.
|
||||
|
||||
\todo The work areas handling could be moved to a base virtual class
|
||||
comon to all frontends.
|
||||
*/
|
||||
class GuiApplication : public Gtk::Main, public Application
|
||||
{
|
||||
public:
|
||||
GuiApplication(int & argc, char ** argv);
|
||||
|
||||
/// Method inherited from \c Application class
|
||||
//@{
|
||||
virtual Clipboard& clipboard();
|
||||
virtual Selection& selection();
|
||||
virtual int const exec();
|
||||
virtual Gui & gui() { return gui_; }
|
||||
virtual void exit(int status);
|
||||
//@}
|
||||
|
||||
///
|
||||
xftFontLoader & fontLoader() { return font_loader_; }
|
||||
|
||||
///
|
||||
LyXView & createView(unsigned int width, unsigned int height,
|
||||
int posx, int posy, bool maximize);
|
||||
|
||||
private:
|
||||
///
|
||||
GuiImplementation gui_;
|
||||
///
|
||||
GuiClipboard clipboard_;
|
||||
///
|
||||
GuiSelection selection_;
|
||||
///
|
||||
xftFontLoader font_loader_;
|
||||
}; // GuiApplication
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
||||
extern lyx::frontend::GuiApplication * guiApp;
|
||||
|
||||
|
||||
#endif // GTK_APPLICATION_H
|
@ -32,7 +32,7 @@ namespace frontend {
|
||||
|
||||
int GuiImplementation::newView(unsigned int /*w*/, unsigned int /*h*/)
|
||||
{
|
||||
view_.reset(new GView(*this));
|
||||
view_.reset(new GView);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -42,7 +42,6 @@ int GuiImplementation::newWorkArea(unsigned int w, unsigned int h, int /*view_id
|
||||
old_work_area_.reset(new GWorkArea(*view_.get(), w, h));
|
||||
old_screen_.reset(new GScreen(*old_work_area_.get()));
|
||||
work_area_.reset(new GuiWorkArea(old_screen_.get(), old_work_area_.get()));
|
||||
selection_.reset(new GuiSelection(old_work_area_.get()));
|
||||
|
||||
// FIXME BufferView creation should be independant of WorkArea creation
|
||||
buffer_views_[0].reset(new BufferView(view_.get()));
|
||||
@ -54,7 +53,6 @@ int GuiImplementation::newWorkArea(unsigned int w, unsigned int h, int /*view_id
|
||||
|
||||
void GuiImplementation::destroyWorkArea(int /*id*/)
|
||||
{
|
||||
selection_.reset();
|
||||
work_area_.reset();
|
||||
old_work_area_.reset();
|
||||
old_screen_.reset();
|
||||
|
@ -18,8 +18,6 @@
|
||||
#include "GScreen.h"
|
||||
#include "GWorkArea.h"
|
||||
|
||||
#include "GuiClipboard.h"
|
||||
#include "GuiSelection.h"
|
||||
#include "GuiWorkArea.h"
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
@ -41,16 +39,6 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
lyx::frontend::Clipboard & clipboard()
|
||||
{
|
||||
return clipboard_;
|
||||
}
|
||||
|
||||
lyx::frontend::Selection & selection()
|
||||
{
|
||||
return *selection_;
|
||||
}
|
||||
|
||||
int newView(unsigned int w, unsigned int h);
|
||||
|
||||
LyXView & view(int /*id*/)
|
||||
@ -73,10 +61,6 @@ public:
|
||||
void destroyWorkArea(int /*id*/);
|
||||
|
||||
private:
|
||||
///
|
||||
GuiClipboard clipboard_;
|
||||
///
|
||||
boost::shared_ptr<GuiSelection> selection_;
|
||||
///
|
||||
boost::shared_ptr<GuiWorkArea> work_area_;
|
||||
///
|
||||
|
@ -21,8 +21,14 @@
|
||||
#endif
|
||||
|
||||
#include "GuiSelection.h"
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "debug.h"
|
||||
|
||||
#include "frontends/Application.h"
|
||||
#include "frontends/Gui.h"
|
||||
#include "frontends/LyXView.h"
|
||||
|
||||
#include <gtkmm.h>
|
||||
|
||||
using std::endl;
|
||||
@ -50,5 +56,38 @@ void GuiSelection::put(docstring const & str)
|
||||
clipboard->set_text(utf8);
|
||||
}
|
||||
|
||||
|
||||
void GuiSelection::onClipboardGet(Gtk::SelectionData & /*selection_data*/,
|
||||
guint /*info*/)
|
||||
{
|
||||
// FIXME: This assumes only one LyXView
|
||||
lyx::docstring const sel = theApp->gui().view(0).view()->requestSelection();
|
||||
if (!sel.empty())
|
||||
put(sel);
|
||||
}
|
||||
|
||||
|
||||
void GuiSelection::onClipboardClear()
|
||||
{
|
||||
// FIXME: This assumes only one LyXView
|
||||
theApp->gui().view(0).view()->clearSelection();
|
||||
}
|
||||
|
||||
|
||||
void GuiSelection::haveSelection(bool toHave)
|
||||
{
|
||||
if (toHave) {
|
||||
Glib::RefPtr<Gtk::Clipboard> clipboard =
|
||||
Gtk::Clipboard::get(GDK_SELECTION_PRIMARY);
|
||||
std::vector<Gtk::TargetEntry> listTargets;
|
||||
listTargets.push_back(Gtk::TargetEntry("UTF8_STRING"));
|
||||
clipboard->set(listTargets,
|
||||
sigc::mem_fun(const_cast<GuiSelection&>(*this),
|
||||
&GuiSelection::onClipboardGet),
|
||||
sigc::mem_fun(const_cast<GuiSelection&>(*this),
|
||||
&GuiSelection::onClipboardClear));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace frontend
|
||||
} // namespace lyx
|
||||
|
@ -14,7 +14,8 @@
|
||||
|
||||
#include "frontends/Selection.h"
|
||||
|
||||
#include "GWorkArea.h"
|
||||
#include <gtkmm.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
namespace lyx {
|
||||
namespace frontend {
|
||||
@ -25,28 +26,22 @@ namespace frontend {
|
||||
class GuiSelection: public lyx::frontend::Selection
|
||||
{
|
||||
public:
|
||||
GuiSelection(GWorkArea * work_area)
|
||||
: old_work_area_(work_area)
|
||||
{
|
||||
}
|
||||
GuiSelection() {}
|
||||
|
||||
virtual ~GuiSelection() {}
|
||||
|
||||
/** Selection overloaded methods
|
||||
*/
|
||||
//@{
|
||||
void haveSelection(bool own)
|
||||
{
|
||||
old_work_area_->haveSelection(own);
|
||||
}
|
||||
void haveSelection(bool own);
|
||||
|
||||
docstring const get() const;
|
||||
|
||||
void put(docstring const & str);
|
||||
//@}
|
||||
|
||||
private:
|
||||
GWorkArea * old_work_area_;
|
||||
void onClipboardGet(Gtk::SelectionData & selection_data, guint info);
|
||||
void onClipboardClear();
|
||||
};
|
||||
|
||||
} // namespace frontend
|
||||
|
@ -138,6 +138,8 @@ libgtk_la_SOURCES = \
|
||||
LyXKeySymFactory.C \
|
||||
ghelpers.C \
|
||||
ghelpers.h \
|
||||
GuiApplication.C \
|
||||
GuiApplication.h \
|
||||
GuiImplementation.h \
|
||||
GuiImplementation.C \
|
||||
io_callback.C \
|
||||
|
@ -37,17 +37,16 @@
|
||||
#include "io_callback.h"
|
||||
|
||||
// FIXME: move this stuff out again
|
||||
#include "bufferlist.h"
|
||||
#include "lyxfunc.h"
|
||||
#include "lyxserver.h"
|
||||
#include "lyxsocket.h"
|
||||
#include "BufferView.h"
|
||||
|
||||
#include "GuiApplication.h"
|
||||
#include "GuiImplementation.h"
|
||||
#include "GView.h"
|
||||
#include "GtkmmX.h"
|
||||
|
||||
#include "xftFontLoader.h"
|
||||
#include "GWorkArea.h"
|
||||
|
||||
#include "support/lyxlib.h"
|
||||
@ -57,8 +56,6 @@
|
||||
|
||||
#include <gtkmm.h>
|
||||
|
||||
#include "LyXGdkImage.h"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
@ -77,16 +74,11 @@ using lyx::support::package;
|
||||
|
||||
using lyx::frontend::colorCache;
|
||||
using lyx::frontend::Gui;
|
||||
using lyx::frontend::GuiApplication;
|
||||
using lyx::frontend::GuiImplementation;
|
||||
using lyx::frontend::GView;
|
||||
|
||||
|
||||
extern BufferList bufferlist;
|
||||
|
||||
// FIXME: wrong place !
|
||||
LyXServer * lyxserver;
|
||||
LyXServerSocket * lyxsocket;
|
||||
|
||||
bool lyx_gui::use_gui = true;
|
||||
|
||||
namespace {
|
||||
@ -102,34 +94,13 @@ int getDPI()
|
||||
|
||||
} // namespace anon
|
||||
|
||||
class Application: public Gtk::Main
|
||||
{
|
||||
public:
|
||||
///
|
||||
Application(int & argc, char * argv[]): Gtk::Main(argc, argv)
|
||||
{}
|
||||
///
|
||||
Gui & gui() { return gui_; }
|
||||
|
||||
private:
|
||||
///
|
||||
GuiImplementation gui_;
|
||||
};
|
||||
|
||||
Application * theApp;
|
||||
lyx::frontend::Application * theApp;
|
||||
GuiApplication * guiApp;
|
||||
|
||||
int lyx_gui::exec(int & argc, char * argv[])
|
||||
{
|
||||
theApp = new Application(argc, argv);
|
||||
|
||||
using namespace lyx::graphics;
|
||||
Image::newImage = boost::bind(&LyXGdkImage::newImage);
|
||||
Image::loadableFormats = boost::bind(&LyXGdkImage::loadableFormats);
|
||||
|
||||
locale_init();
|
||||
|
||||
// must do this /before/ lyxrc gets read
|
||||
lyxrc.dpi = getDPI();
|
||||
guiApp = new GuiApplication(argc, argv);
|
||||
theApp = guiApp;
|
||||
|
||||
return LyX::ref().exec2(argc, argv);
|
||||
}
|
||||
@ -141,47 +112,21 @@ void lyx_gui::parse_lyxrc()
|
||||
|
||||
|
||||
LyXView * lyx_gui::create_view(unsigned int width, unsigned int height,
|
||||
int /*posx*/, int /*posy*/, bool)
|
||||
int posx, int posy, bool maximize)
|
||||
{
|
||||
int view_id = theApp->gui().newView(width, height);
|
||||
GView & view = static_cast<GView &> (theApp->gui().view(view_id));
|
||||
theApp->gui().newWorkArea(width, height, 0);
|
||||
|
||||
LyX::ref().addLyXView(&view);
|
||||
|
||||
view.show();
|
||||
view.init();
|
||||
|
||||
return &view;
|
||||
return &guiApp->createView(width, height, posx, posy, maximize);
|
||||
}
|
||||
|
||||
|
||||
int lyx_gui::start(LyXView * view, string const & batch)
|
||||
int lyx_gui::start(LyXView *, string const & batch)
|
||||
{
|
||||
// FIXME: server code below needs moving
|
||||
|
||||
lyxserver = new LyXServer(&view->getLyXFunc(), lyxrc.lyxpipes);
|
||||
lyxsocket = new LyXServerSocket(&view->getLyXFunc(),
|
||||
os::internal_path(package().temp_dir() + "/lyxsocket"));
|
||||
|
||||
// handle the batch commands the user asked for
|
||||
if (!batch.empty()) {
|
||||
view->getLyXFunc().dispatch(lyxaction.lookupFunc(batch));
|
||||
}
|
||||
|
||||
theApp->run();
|
||||
|
||||
// FIXME: breaks emergencyCleanup
|
||||
delete lyxsocket;
|
||||
delete lyxserver;
|
||||
return EXIT_SUCCESS;
|
||||
return guiApp->start(batch);
|
||||
}
|
||||
|
||||
|
||||
void lyx_gui::exit(int /*status*/)
|
||||
void lyx_gui::exit(int status)
|
||||
{
|
||||
// FIXME: Don't ignore status
|
||||
theApp->quit();
|
||||
guiApp->exit(status);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user