mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-23 05:25:26 +00:00
shuffle code around
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21653 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
fa07bad49c
commit
dac06728cb
17
src/LyX.cpp
17
src/LyX.cpp
@ -48,7 +48,6 @@
|
||||
|
||||
#include "frontends/alert.h"
|
||||
#include "frontends/Application.h"
|
||||
#include "frontends/Gui.h"
|
||||
#include "frontends/LyXView.h"
|
||||
|
||||
#include "support/environment.h"
|
||||
@ -375,22 +374,6 @@ void LyX::setGuiLanguage(std::string const & language)
|
||||
}
|
||||
|
||||
|
||||
Buffer const * LyX::updateInset(Inset const * inset) const
|
||||
{
|
||||
if (quitting || !inset)
|
||||
return 0;
|
||||
return application().gui().updateInset(inset);
|
||||
}
|
||||
|
||||
|
||||
void LyX::hideDialogs(std::string const & name, Inset * inset) const
|
||||
{
|
||||
if (quitting || !use_gui)
|
||||
return;
|
||||
application().gui().hideDialogs(name, inset);
|
||||
}
|
||||
|
||||
|
||||
int LyX::exec(int & argc, char * argv[])
|
||||
{
|
||||
// Here we need to parse the command line. At least
|
||||
|
@ -101,13 +101,6 @@ public:
|
||||
///
|
||||
frontend::LyXView * newLyXView();
|
||||
|
||||
/** redraw \c inset in all the BufferViews in which it is currently
|
||||
* visible. If successful return a pointer to the owning Buffer.
|
||||
*/
|
||||
Buffer const * updateInset(Inset const *) const;
|
||||
|
||||
void hideDialogs(std::string const & name, Inset * inset) const;
|
||||
|
||||
/// Execute batch commands if available.
|
||||
void execBatchCommands();
|
||||
|
||||
|
@ -1562,7 +1562,9 @@ void LyXFunc::dispatch(FuncRequest const & cmd)
|
||||
}
|
||||
|
||||
case LFUN_DIALOG_HIDE: {
|
||||
LyX::cref().hideDialogs(argument, 0);
|
||||
if (quitting || !use_gui)
|
||||
break;
|
||||
theApp()->gui().hideDialogs(argument, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include "MetricsInfo.h"
|
||||
|
||||
#include "frontends/Painter.h"
|
||||
#include "frontends/Application.h"
|
||||
#include "frontends/Gui.h"
|
||||
|
||||
#include "support/convert.h"
|
||||
|
||||
@ -44,10 +46,11 @@
|
||||
|
||||
namespace lyx {
|
||||
|
||||
extern bool quitting;
|
||||
|
||||
class InsetName {
|
||||
public:
|
||||
InsetName(std::string const & n, InsetCode c)
|
||||
: name(n), code(c) {}
|
||||
InsetName(std::string const & n, InsetCode c) : name(n), code(c) {}
|
||||
std::string name;
|
||||
InsetCode code;
|
||||
};
|
||||
@ -382,4 +385,12 @@ void Inset::setDimCache(MetricsInfo const & mi, Dimension const & dim) const
|
||||
mi.base.bv->coordCache().insets().add(this, dim);
|
||||
}
|
||||
|
||||
|
||||
Buffer const * Inset::updateFrontend() const
|
||||
{
|
||||
if (quitting)
|
||||
return 0;
|
||||
return theApp()->gui().updateInset(this);
|
||||
}
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -353,6 +353,8 @@ public:
|
||||
/// Update the counters of this inset and of its contents
|
||||
virtual void updateLabels(Buffer const &, ParIterator const &) {}
|
||||
|
||||
/// Updates the inset's dialog
|
||||
virtual Buffer const * updateFrontend() const;
|
||||
|
||||
public:
|
||||
/// returns LyX code associated with the inset. Used for TOC, ...)
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "FuncRequest.h"
|
||||
#include "gettext.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "LyX.h"
|
||||
#include "Lexer.h"
|
||||
#include "LyXRC.h"
|
||||
#include "MetricsInfo.h"
|
||||
@ -65,6 +64,8 @@ string defaultTemplateName;
|
||||
|
||||
namespace lyx {
|
||||
|
||||
extern bool use_gui;
|
||||
|
||||
namespace external {
|
||||
|
||||
TempName::TempName()
|
||||
@ -89,8 +90,7 @@ TempName::~TempName()
|
||||
}
|
||||
|
||||
|
||||
TempName &
|
||||
TempName::operator=(TempName const & other)
|
||||
TempName & TempName::operator=(TempName const & other)
|
||||
{
|
||||
if (this != &other)
|
||||
tempname_ = TempName()();
|
||||
@ -385,8 +385,7 @@ bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex)
|
||||
break;
|
||||
|
||||
default:
|
||||
lex.printError("ExternalInset::read: "
|
||||
"Wrong tag: $$Token");
|
||||
lex.printError("ExternalInset::read: Wrong tag: $$Token");
|
||||
read_error = true;
|
||||
break;
|
||||
}
|
||||
@ -437,7 +436,7 @@ InsetExternal::~InsetExternal()
|
||||
|
||||
void InsetExternal::statusChanged() const
|
||||
{
|
||||
LyX::cref().updateInset(this);
|
||||
updateFrontend();
|
||||
}
|
||||
|
||||
|
||||
@ -633,8 +632,9 @@ void InsetExternal::setParams(InsetExternalParams const & p,
|
||||
|
||||
button_ptr->update(getScreenLabel(params_, buffer), true);
|
||||
break;
|
||||
}
|
||||
|
||||
} case RENDERGRAPHIC: {
|
||||
case RENDERGRAPHIC: {
|
||||
RenderGraphic * graphic_ptr = renderer_->asGraphic();
|
||||
if (!graphic_ptr) {
|
||||
renderer_.reset(new RenderGraphic(this));
|
||||
@ -644,8 +644,9 @@ void InsetExternal::setParams(InsetExternalParams const & p,
|
||||
graphic_ptr->update(get_grfx_params(params_));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
} case RENDERPREVIEW: {
|
||||
case RENDERPREVIEW: {
|
||||
RenderMonitoredPreview * preview_ptr =
|
||||
renderer_->asMonitoredPreview();
|
||||
if (!preview_ptr) {
|
||||
@ -667,16 +668,15 @@ void InsetExternal::setParams(InsetExternalParams const & p,
|
||||
|
||||
void InsetExternal::fileChanged() const
|
||||
{
|
||||
Buffer const * const buffer_ptr = LyX::cref().updateInset(this);
|
||||
if (!buffer_ptr)
|
||||
Buffer const * const buffer = updateFrontend();
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
RenderMonitoredPreview * const ptr = renderer_->asMonitoredPreview();
|
||||
BOOST_ASSERT(ptr);
|
||||
|
||||
Buffer const & buffer = *buffer_ptr;
|
||||
ptr->removePreview(buffer);
|
||||
add_preview_and_start_loading(*ptr, *this, buffer);
|
||||
ptr->removePreview(*buffer);
|
||||
add_preview_and_start_loading(*ptr, *this, *buffer);
|
||||
}
|
||||
|
||||
|
||||
|
@ -770,14 +770,13 @@ Inset::DisplayType InsetInclude::display() const
|
||||
|
||||
void InsetInclude::fileChanged() const
|
||||
{
|
||||
Buffer const * const buffer_ptr = LyX::cref().updateInset(this);
|
||||
if (!buffer_ptr)
|
||||
Buffer const * const buffer = updateFrontend();
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
Buffer const & buffer = *buffer_ptr;
|
||||
preview_->removePreview(buffer);
|
||||
add_preview(*preview_.get(), *this, buffer);
|
||||
preview_->startLoading(buffer);
|
||||
preview_->removePreview(*buffer);
|
||||
add_preview(*preview_.get(), *this, *buffer);
|
||||
preview_->startLoading(*buffer);
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,7 +14,9 @@
|
||||
|
||||
#include "BufferView.h"
|
||||
#include "debug.h"
|
||||
#include "LyX.h"
|
||||
|
||||
#include "frontends/Application.h"
|
||||
#include "frontends/Gui.h"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
@ -40,7 +42,7 @@ void MailInset::updateDialog(BufferView * bv) const
|
||||
|
||||
void MailInset::hideDialog() const
|
||||
{
|
||||
LyX::cref().hideDialogs(name(), &inset());
|
||||
theApp()->gui().hideDialogs(name(), &inset());
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,26 +31,17 @@
|
||||
|
||||
namespace lyx {
|
||||
|
||||
using support::onlyFilename;
|
||||
|
||||
using std::string;
|
||||
|
||||
|
||||
RenderGraphic::RenderGraphic(Inset const * inset)
|
||||
{
|
||||
loader_.connect(boost::bind(&LyX::updateInset,
|
||||
boost::cref(LyX::cref()), inset));
|
||||
loader_.connect(boost::bind(&Inset::updateFrontend, inset));
|
||||
}
|
||||
|
||||
|
||||
RenderGraphic::RenderGraphic(RenderGraphic const & other,
|
||||
Inset const * inset)
|
||||
: RenderBase(other),
|
||||
loader_(other.loader_),
|
||||
params_(other.params_)
|
||||
RenderGraphic::RenderGraphic(RenderGraphic const & other, Inset const * inset)
|
||||
: RenderBase(other), loader_(other.loader_), params_(other.params_)
|
||||
{
|
||||
loader_.connect(boost::bind(&LyX::updateInset,
|
||||
boost::cref(LyX::cref()), inset));
|
||||
loader_.connect(boost::bind(&Inset::updateFrontend, inset));
|
||||
}
|
||||
|
||||
|
||||
@ -64,9 +55,8 @@ void RenderGraphic::update(graphics::Params const & params)
|
||||
{
|
||||
params_ = params;
|
||||
|
||||
if (!params_.filename.empty()) {
|
||||
if (!params_.filename.empty())
|
||||
loader_.reset(params_.filename, params_);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -155,12 +145,10 @@ void RenderGraphic::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
msgFont.setFamily(SANS_FAMILY);
|
||||
|
||||
// FIXME UNICODE
|
||||
docstring const justname =
|
||||
from_utf8(onlyFilename(params_.filename.absFilename()));
|
||||
docstring const justname = from_utf8(params_.filename.onlyFileName());
|
||||
if (!justname.empty()) {
|
||||
msgFont.setSize(FONT_SIZE_FOOTNOTE);
|
||||
font_width = theFontMetrics(msgFont)
|
||||
.width(justname);
|
||||
font_width = theFontMetrics(msgFont).width(justname);
|
||||
}
|
||||
|
||||
docstring const msg = statusMessage(params_, loader_.status());
|
||||
@ -206,7 +194,7 @@ void RenderGraphic::draw(PainterInfo & pi, int x, int y) const
|
||||
// Print the file name.
|
||||
FontInfo msgFont = pi.base.font;
|
||||
msgFont.setFamily(SANS_FAMILY);
|
||||
string const justname = onlyFilename(params_.filename.absFilename());
|
||||
std::string const justname = params_.filename.onlyFileName();
|
||||
|
||||
if (!justname.empty()) {
|
||||
msgFont.setSize(FONT_SIZE_FOOTNOTE);
|
||||
|
@ -240,13 +240,12 @@ void RenderPreview::imageReady(graphics::PreviewImage const & pimage)
|
||||
{
|
||||
// Check the current snippet is the same as that previewed.
|
||||
if (snippet_ == pimage.snippet())
|
||||
LyX::cref().updateInset(parent_);
|
||||
parent_->updateFrontend();
|
||||
}
|
||||
|
||||
|
||||
RenderMonitoredPreview::RenderMonitoredPreview(Inset const * inset)
|
||||
: RenderPreview(inset),
|
||||
monitor_(FileName(), 2000)
|
||||
: RenderPreview(inset), monitor_(FileName(), 2000)
|
||||
{}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user