2002-06-12 02:54:19 +00:00
|
|
|
|
/**
|
2007-04-26 04:02:55 +00:00
|
|
|
|
* \file LyXView.cpp
|
2002-09-05 15:14:23 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-21 17:27:08 +00:00
|
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2002-11-27 10:30:28 +00:00
|
|
|
|
* \author John Levon
|
2002-09-05 14:10:50 +00:00
|
|
|
|
*
|
2003-08-23 00:17:00 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
2002-06-12 02:54:19 +00:00
|
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2002-06-12 02:54:19 +00:00
|
|
|
|
#include "LyXView.h"
|
2003-09-05 10:55:42 +00:00
|
|
|
|
#include "Dialogs.h"
|
|
|
|
|
#include "Timeout.h"
|
2004-04-29 09:54:59 +00:00
|
|
|
|
#include "Toolbars.h"
|
2003-09-05 10:55:42 +00:00
|
|
|
|
#include "Menubar.h"
|
2006-07-03 22:31:51 +00:00
|
|
|
|
#include "WorkArea.h"
|
2006-12-02 17:39:31 +00:00
|
|
|
|
#include "Gui.h"
|
2003-09-05 10:55:42 +00:00
|
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Buffer.h"
|
2007-06-19 14:56:52 +00:00
|
|
|
|
#include "buffer_funcs.h"
|
2007-06-04 14:09:51 +00:00
|
|
|
|
#include "BufferList.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "BufferParams.h"
|
2003-09-05 10:55:42 +00:00
|
|
|
|
#include "BufferView.h"
|
|
|
|
|
#include "bufferview_funcs.h"
|
2007-04-26 14:56:30 +00:00
|
|
|
|
#include "Cursor.h"
|
1999-10-07 18:44:17 +00:00
|
|
|
|
#include "debug.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "ErrorList.h"
|
|
|
|
|
#include "FuncRequest.h"
|
2003-09-05 10:55:42 +00:00
|
|
|
|
#include "gettext.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Intl.h"
|
2007-04-28 20:44:46 +00:00
|
|
|
|
#include "callback.h"
|
2007-06-19 14:56:52 +00:00
|
|
|
|
#include "LyX.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "LyXFunc.h"
|
|
|
|
|
#include "LyXRC.h"
|
2007-04-29 23:33:02 +00:00
|
|
|
|
#include "Text.h"
|
2000-09-14 17:53:12 +00:00
|
|
|
|
#include "MenuBackend.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Paragraph.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2002-07-19 20:56:31 +00:00
|
|
|
|
#include "controllers/ControlCommandBuffer.h"
|
2003-09-05 10:55:42 +00:00
|
|
|
|
|
2006-07-14 21:47:48 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2002-06-12 02:54:19 +00:00
|
|
|
|
#include "support/filetools.h" // OnlyFilename()
|
2001-12-10 20:06:59 +00:00
|
|
|
|
|
2002-05-29 16:21:03 +00:00
|
|
|
|
#include <boost/bind.hpp>
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2005-04-26 10:30:24 +00:00
|
|
|
|
#ifdef HAVE_SYS_TIME_H
|
|
|
|
|
# include <sys/time.h>
|
|
|
|
|
#endif
|
2005-01-19 15:26:41 +00:00
|
|
|
|
#ifdef HAVE_UNISTD_H
|
2005-01-20 15:38:14 +00:00
|
|
|
|
# include <unistd.h>
|
2005-01-19 15:26:41 +00:00
|
|
|
|
#endif
|
2001-12-10 20:06:59 +00:00
|
|
|
|
|
2006-12-02 16:07:15 +00:00
|
|
|
|
using frontend::WorkArea;
|
2006-06-26 16:55:35 +00:00
|
|
|
|
|
2006-12-02 16:07:15 +00:00
|
|
|
|
using support::bformat;
|
|
|
|
|
using support::FileName;
|
|
|
|
|
using support::makeDisplayPath;
|
|
|
|
|
using support::onlyFilename;
|
2003-09-09 22:13:45 +00:00
|
|
|
|
|
2000-03-28 02:18:55 +00:00
|
|
|
|
using std::endl;
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2000-03-28 02:18:55 +00:00
|
|
|
|
|
2004-05-19 15:11:37 +00:00
|
|
|
|
using lyx::frontend::ControlCommandBuffer;
|
2003-09-05 10:55:42 +00:00
|
|
|
|
|
2002-03-02 16:39:54 +00:00
|
|
|
|
string current_layout;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-07-03 22:31:51 +00:00
|
|
|
|
|
2006-10-23 16:29:24 +00:00
|
|
|
|
LyXView::LyXView(int id)
|
2006-10-26 08:01:48 +00:00
|
|
|
|
: work_area_(0),
|
2006-06-26 16:55:35 +00:00
|
|
|
|
toolbars_(new Toolbars(*this)),
|
2002-08-13 14:40:38 +00:00
|
|
|
|
autosave_timeout_(new Timeout(5000)),
|
2002-08-15 17:48:53 +00:00
|
|
|
|
dialogs_(new Dialogs(*this)),
|
2006-10-26 08:01:48 +00:00
|
|
|
|
controlcommand_(new ControlCommandBuffer(*this)), id_(id)
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2006-09-29 23:10:17 +00:00
|
|
|
|
// Start autosave timer
|
|
|
|
|
if (lyxrc.autosave) {
|
|
|
|
|
autosave_timeout_->timeout.connect(boost::bind(&LyXView::autoSave, this));
|
|
|
|
|
autosave_timeout_->setTimeout(lyxrc.autosave * 1000);
|
|
|
|
|
autosave_timeout_->start();
|
|
|
|
|
}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-09-19 13:36:20 +00:00
|
|
|
|
|
2006-07-08 20:24:32 +00:00
|
|
|
|
LyXView::~LyXView()
|
|
|
|
|
{
|
2006-12-22 02:57:25 +00:00
|
|
|
|
disconnectBuffer();
|
2006-07-08 20:24:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-23 16:29:24 +00:00
|
|
|
|
// FIXME, there's only one WorkArea per LyXView possible for now.
|
2006-07-03 22:31:51 +00:00
|
|
|
|
void LyXView::setWorkArea(WorkArea * work_area)
|
2006-06-26 16:55:35 +00:00
|
|
|
|
{
|
2007-01-02 10:36:34 +00:00
|
|
|
|
BOOST_ASSERT(work_area);
|
2006-07-03 22:31:51 +00:00
|
|
|
|
work_area_ = work_area;
|
2006-10-23 16:29:24 +00:00
|
|
|
|
work_area_ids_.clear();
|
|
|
|
|
work_area_ids_.push_back(work_area_->id());
|
2006-06-26 16:55:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2007-01-05 13:31:34 +00:00
|
|
|
|
// FIXME, there's only one WorkArea per LyXView possible for now.
|
|
|
|
|
WorkArea const * LyXView::currentWorkArea() const
|
|
|
|
|
{
|
|
|
|
|
return work_area_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME, there's only one WorkArea per LyXView possible for now.
|
|
|
|
|
WorkArea * LyXView::currentWorkArea()
|
|
|
|
|
{
|
|
|
|
|
return work_area_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
|
Buffer * LyXView::buffer() const
|
|
|
|
|
{
|
2007-01-02 10:36:34 +00:00
|
|
|
|
BOOST_ASSERT(work_area_);
|
2006-07-03 22:31:51 +00:00
|
|
|
|
return work_area_->bufferView().buffer();
|
2000-04-08 17:02:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-06-19 14:56:52 +00:00
|
|
|
|
void LyXView::setBuffer(Buffer * b, bool child_document)
|
2006-07-13 16:37:55 +00:00
|
|
|
|
{
|
2006-10-26 13:29:10 +00:00
|
|
|
|
busy(true);
|
|
|
|
|
|
2007-01-02 10:36:34 +00:00
|
|
|
|
BOOST_ASSERT(work_area_);
|
2007-06-19 14:56:52 +00:00
|
|
|
|
Buffer * oldBuffer = work_area_->bufferView().buffer();
|
|
|
|
|
// parentfilename will be used in case when we switch to a child
|
|
|
|
|
// document (hence when child_document is true)
|
|
|
|
|
string parentfilename;
|
|
|
|
|
if (oldBuffer) {
|
|
|
|
|
parentfilename = oldBuffer->fileName();
|
2006-07-14 21:47:48 +00:00
|
|
|
|
disconnectBuffer();
|
2007-06-19 14:56:52 +00:00
|
|
|
|
}
|
2006-07-14 21:47:48 +00:00
|
|
|
|
|
2007-06-04 14:09:51 +00:00
|
|
|
|
if (!b && theBufferList().empty())
|
2006-08-17 21:46:52 +00:00
|
|
|
|
getDialogs().hideBufferDependent();
|
|
|
|
|
|
2006-07-13 16:37:55 +00:00
|
|
|
|
work_area_->bufferView().setBuffer(b);
|
2006-08-17 21:46:52 +00:00
|
|
|
|
|
2007-06-19 17:04:09 +00:00
|
|
|
|
//FIXME This would be a little simpler if setBuffer returned the buffer.
|
2007-06-19 14:56:52 +00:00
|
|
|
|
Buffer * newBuffer = work_area_->bufferView().buffer();
|
|
|
|
|
if (newBuffer) {
|
2007-06-19 17:04:09 +00:00
|
|
|
|
if (child_document && newBuffer->getMasterBuffer() != oldBuffer) {
|
2007-06-19 14:56:52 +00:00
|
|
|
|
// Set the parent name of the child document.
|
|
|
|
|
// This makes insertion of citations and references in the child work,
|
|
|
|
|
// when the target is in the parent or another child document.
|
|
|
|
|
newBuffer->setParentName(parentfilename);
|
2007-06-19 17:04:09 +00:00
|
|
|
|
// Update the labels and section numbering to the new master Buffer.
|
2007-06-19 14:56:52 +00:00
|
|
|
|
updateLabels(*newBuffer->getMasterBuffer());
|
2007-06-19 17:04:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-06-29 10:31:51 +00:00
|
|
|
|
if (!b && oldBuffer && oldBuffer->getMasterBuffer() != oldBuffer)
|
|
|
|
|
// We are closing oldBuffer which was a child document so we
|
|
|
|
|
// must update the labels and section numbering of its master
|
|
|
|
|
// Buffer.
|
|
|
|
|
updateLabels(*oldBuffer->getMasterBuffer());
|
|
|
|
|
|
2007-06-19 17:04:09 +00:00
|
|
|
|
connectBuffer(*newBuffer);
|
2007-06-19 14:56:52 +00:00
|
|
|
|
|
2006-08-17 21:46:52 +00:00
|
|
|
|
// Buffer-dependent dialogs should be updated or
|
|
|
|
|
// hidden. This should go here because some dialogs (eg ToC)
|
|
|
|
|
// require bv_->text.
|
|
|
|
|
getDialogs().updateBufferDependent(true);
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-24 07:55:46 +00:00
|
|
|
|
if (quitting)
|
|
|
|
|
return;
|
|
|
|
|
|
2006-07-13 16:37:55 +00:00
|
|
|
|
updateMenubar();
|
|
|
|
|
updateToolbars();
|
2006-08-24 16:55:31 +00:00
|
|
|
|
updateLayoutChoice();
|
2006-07-13 16:37:55 +00:00
|
|
|
|
updateWindowTitle();
|
2006-10-22 10:51:59 +00:00
|
|
|
|
updateStatusBar();
|
2006-10-31 14:12:46 +00:00
|
|
|
|
updateTab();
|
2006-10-26 13:29:10 +00:00
|
|
|
|
busy(false);
|
2006-10-22 10:51:59 +00:00
|
|
|
|
work_area_->redraw();
|
2006-07-13 16:37:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-06-19 14:56:52 +00:00
|
|
|
|
bool LyXView::loadLyXFile(FileName const & filename, bool tolastfiles,
|
|
|
|
|
bool child_document, bool auto_open)
|
2006-07-13 16:37:55 +00:00
|
|
|
|
{
|
2006-10-26 13:29:10 +00:00
|
|
|
|
busy(true);
|
|
|
|
|
|
2007-01-02 10:36:34 +00:00
|
|
|
|
BOOST_ASSERT(work_area_);
|
2007-06-19 14:56:52 +00:00
|
|
|
|
string parentfilename;
|
|
|
|
|
Buffer * oldBuffer = work_area_->bufferView().buffer();
|
|
|
|
|
if (oldBuffer)
|
|
|
|
|
parentfilename = oldBuffer->fileName();
|
|
|
|
|
|
2007-06-19 16:03:47 +00:00
|
|
|
|
Buffer * newBuffer = checkAndLoadLyXFile(filename);
|
2007-06-19 14:56:52 +00:00
|
|
|
|
|
2007-06-19 16:03:47 +00:00
|
|
|
|
if (!newBuffer) {
|
2007-06-19 14:56:52 +00:00
|
|
|
|
message(_("Document not loaded."));
|
2007-06-19 16:03:47 +00:00
|
|
|
|
updateStatusBar();
|
|
|
|
|
busy(false);
|
|
|
|
|
work_area_->redraw();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (child_document && newBuffer != oldBuffer) {
|
|
|
|
|
// Set the parent name of the child document.
|
|
|
|
|
// This makes insertion of citations and references in the child work,
|
|
|
|
|
// when the target is in the parent or another child document.
|
|
|
|
|
newBuffer->setParentName(parentfilename);
|
|
|
|
|
message(bformat(_("Opening child document %1$s..."),
|
|
|
|
|
makeDisplayPath(filename.absFilename())));
|
|
|
|
|
}
|
|
|
|
|
|
2007-06-19 17:04:09 +00:00
|
|
|
|
// Update the labels and section numbering.
|
|
|
|
|
updateLabels(*newBuffer->getMasterBuffer());
|
|
|
|
|
|
2007-06-19 16:03:47 +00:00
|
|
|
|
bool const parse_error = !newBuffer->errorList("Parse").empty();
|
|
|
|
|
if (parse_error || !auto_open) {
|
|
|
|
|
setBuffer(newBuffer, child_document);
|
|
|
|
|
showErrorList("Parse");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// scroll to the position when the file was last closed
|
|
|
|
|
if (!auto_open && lyxrc.use_lastfilepos) {
|
|
|
|
|
pit_type pit;
|
|
|
|
|
pos_type pos;
|
|
|
|
|
boost::tie(pit, pos) = LyX::ref().session().lastFilePos().load(filename);
|
|
|
|
|
// if successfully move to pit (returned par_id is not zero),
|
|
|
|
|
// update metrics and reset font
|
|
|
|
|
if (work_area_->bufferView().moveToPosition(pit, pos, 0, 0).get<1>()) {
|
|
|
|
|
if (work_area_->bufferView().fitCursor())
|
|
|
|
|
work_area_->bufferView().updateMetrics(false);
|
|
|
|
|
newBuffer->text().setCurrentFont(work_area_->bufferView().cursor());
|
2007-06-19 17:04:09 +00:00
|
|
|
|
updateMenubar();
|
|
|
|
|
updateToolbars();
|
|
|
|
|
updateLayoutChoice();
|
|
|
|
|
updateStatusBar();
|
|
|
|
|
work_area_->redraw();
|
2007-06-19 16:03:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (tolastfiles)
|
|
|
|
|
LyX::ref().session().lastFiles().add(filename);
|
|
|
|
|
|
2006-10-26 13:29:10 +00:00
|
|
|
|
busy(false);
|
2007-06-19 14:56:52 +00:00
|
|
|
|
return true;
|
2006-07-13 16:37:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2006-07-14 21:47:48 +00:00
|
|
|
|
|
|
|
|
|
void LyXView::connectBuffer(Buffer & buf)
|
|
|
|
|
{
|
2006-07-15 22:43:37 +00:00
|
|
|
|
if (errorsConnection_.connected())
|
2006-07-14 21:47:48 +00:00
|
|
|
|
disconnectBuffer();
|
|
|
|
|
|
2007-01-02 10:36:34 +00:00
|
|
|
|
BOOST_ASSERT(work_area_);
|
2006-10-22 10:51:59 +00:00
|
|
|
|
bufferChangedConnection_ =
|
|
|
|
|
buf.changed.connect(
|
2006-11-20 14:42:18 +00:00
|
|
|
|
boost::bind(&WorkArea::redraw, work_area_));
|
2006-10-22 10:51:59 +00:00
|
|
|
|
|
2007-03-12 11:23:41 +00:00
|
|
|
|
bufferStructureChangedConnection_ =
|
2007-05-17 19:19:37 +00:00
|
|
|
|
buf.getMasterBuffer()->structureChanged.connect(
|
2007-03-12 11:23:41 +00:00
|
|
|
|
boost::bind(&LyXView::updateToc, this));
|
|
|
|
|
|
2006-07-15 22:43:37 +00:00
|
|
|
|
errorsConnection_ =
|
|
|
|
|
buf.errors.connect(
|
|
|
|
|
boost::bind(&LyXView::showErrorList, this, _1));
|
2006-07-14 21:47:48 +00:00
|
|
|
|
|
|
|
|
|
messageConnection_ =
|
|
|
|
|
buf.message.connect(
|
|
|
|
|
boost::bind(&LyXView::message, this, _1));
|
|
|
|
|
|
|
|
|
|
busyConnection_ =
|
|
|
|
|
buf.busy.connect(
|
|
|
|
|
boost::bind(&LyXView::busy, this, _1));
|
|
|
|
|
|
|
|
|
|
titleConnection_ =
|
|
|
|
|
buf.updateTitles.connect(
|
|
|
|
|
boost::bind(&LyXView::updateWindowTitle, this));
|
|
|
|
|
|
|
|
|
|
timerConnection_ =
|
|
|
|
|
buf.resetAutosaveTimers.connect(
|
|
|
|
|
boost::bind(&LyXView::resetAutosaveTimer, this));
|
|
|
|
|
|
|
|
|
|
readonlyConnection_ =
|
|
|
|
|
buf.readonly.connect(
|
|
|
|
|
boost::bind(&LyXView::showReadonly, this, _1));
|
|
|
|
|
|
|
|
|
|
closingConnection_ =
|
|
|
|
|
buf.closing.connect(
|
2007-06-19 14:56:52 +00:00
|
|
|
|
boost::bind(&LyXView::setBuffer, this, (Buffer *)0, false));
|
2006-07-14 21:47:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LyXView::disconnectBuffer()
|
|
|
|
|
{
|
2006-10-22 10:51:59 +00:00
|
|
|
|
errorsConnection_.disconnect();
|
|
|
|
|
bufferChangedConnection_.disconnect();
|
2007-03-12 11:23:41 +00:00
|
|
|
|
bufferStructureChangedConnection_.disconnect();
|
2006-07-14 21:47:48 +00:00
|
|
|
|
messageConnection_.disconnect();
|
|
|
|
|
busyConnection_.disconnect();
|
|
|
|
|
titleConnection_.disconnect();
|
|
|
|
|
timerConnection_.disconnect();
|
|
|
|
|
readonlyConnection_.disconnect();
|
|
|
|
|
closingConnection_.disconnect();
|
2006-09-26 10:06:46 +00:00
|
|
|
|
layout_changed_connection_.disconnect();
|
2006-07-14 21:47:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-19 13:36:20 +00:00
|
|
|
|
void LyXView::connectBufferView(BufferView & bv)
|
|
|
|
|
{
|
|
|
|
|
show_dialog_connection_ = bv.showDialog.connect(
|
|
|
|
|
boost::bind(&LyXView::showDialog, this, _1));
|
|
|
|
|
show_dialog_with_data_connection_ = bv.showDialogWithData.connect(
|
|
|
|
|
boost::bind(&LyXView::showDialogWithData, this, _1, _2));
|
|
|
|
|
show_inset_dialog_connection_ = bv.showInsetDialog.connect(
|
|
|
|
|
boost::bind(&LyXView::showInsetDialog, this, _1, _2, _3));
|
|
|
|
|
update_dialog_connection_ = bv.updateDialog.connect(
|
|
|
|
|
boost::bind(&LyXView::updateDialog, this, _1, _2));
|
2006-09-26 10:06:46 +00:00
|
|
|
|
layout_changed_connection_ = bv.layoutChanged.connect(
|
|
|
|
|
boost::bind(&Toolbars::setLayout, toolbars_.get(), _1));
|
2006-09-19 13:36:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LyXView::disconnectBufferView()
|
|
|
|
|
{
|
|
|
|
|
show_dialog_connection_.disconnect();
|
|
|
|
|
show_dialog_with_data_connection_.disconnect();
|
|
|
|
|
show_inset_dialog_connection_.disconnect();
|
|
|
|
|
update_dialog_connection_.disconnect();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-08-13 16:16:43 +00:00
|
|
|
|
void LyXView::showErrorList(string const & error_type)
|
2006-07-14 21:47:48 +00:00
|
|
|
|
{
|
2006-08-13 16:16:43 +00:00
|
|
|
|
ErrorList & el = buffer()->errorList(error_type);
|
|
|
|
|
if (!el.empty()) {
|
|
|
|
|
getDialogs().show("errorlist", error_type);
|
2006-07-14 21:47:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-19 13:36:20 +00:00
|
|
|
|
void LyXView::showDialog(string const & name)
|
|
|
|
|
{
|
|
|
|
|
getDialogs().show(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-18 08:44:44 +00:00
|
|
|
|
void LyXView::showDialogWithData(string const & name, string const & data)
|
2006-09-19 13:36:20 +00:00
|
|
|
|
{
|
|
|
|
|
getDialogs().show(name, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LyXView::showInsetDialog(string const & name, string const & data,
|
2007-04-29 13:39:47 +00:00
|
|
|
|
Inset * inset)
|
2006-09-19 13:36:20 +00:00
|
|
|
|
{
|
2006-10-02 15:40:39 +00:00
|
|
|
|
getDialogs().show(name, data, inset);
|
2006-09-19 13:36:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LyXView::updateDialog(string const & name, string const & data)
|
|
|
|
|
{
|
|
|
|
|
if (getDialogs().visible(name))
|
|
|
|
|
getDialogs().update(name, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-07-14 21:47:48 +00:00
|
|
|
|
void LyXView::showReadonly(bool)
|
|
|
|
|
{
|
|
|
|
|
updateWindowTitle();
|
|
|
|
|
getDialogs().updateBufferDependent(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-06-26 16:55:35 +00:00
|
|
|
|
BufferView * LyXView::view() const
|
2000-04-08 17:02:02 +00:00
|
|
|
|
{
|
2007-01-02 10:36:34 +00:00
|
|
|
|
BOOST_ASSERT(work_area_);
|
2006-07-03 22:31:51 +00:00
|
|
|
|
return &work_area_->bufferView();
|
2000-04-08 17:02:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-03-12 11:23:41 +00:00
|
|
|
|
void LyXView::updateToc()
|
|
|
|
|
{
|
|
|
|
|
updateDialog("toc", "");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-04-29 09:54:59 +00:00
|
|
|
|
void LyXView::updateToolbars()
|
2000-07-25 10:46:18 +00:00
|
|
|
|
{
|
2007-01-02 10:36:34 +00:00
|
|
|
|
BOOST_ASSERT(work_area_);
|
2006-10-29 22:50:24 +00:00
|
|
|
|
bool const math =
|
|
|
|
|
work_area_->bufferView().cursor().inMathed();
|
2003-04-10 14:08:06 +00:00
|
|
|
|
bool const table =
|
2006-10-11 17:24:46 +00:00
|
|
|
|
lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
|
2006-10-29 22:50:24 +00:00
|
|
|
|
bool const review =
|
|
|
|
|
lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
|
|
|
|
|
lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
|
2007-05-28 22:27:45 +00:00
|
|
|
|
|
2006-10-29 22:50:24 +00:00
|
|
|
|
toolbars_->update(math, table, review);
|
2005-04-13 09:43:58 +00:00
|
|
|
|
// update redaonly status of open dialogs. This could also be in
|
|
|
|
|
// updateMenubar(), but since updateToolbars() and updateMenubar()
|
|
|
|
|
// are always called together it is only here.
|
|
|
|
|
getDialogs().checkStatus();
|
2000-07-25 10:46:18 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-04-19 19:43:15 +00:00
|
|
|
|
ToolbarInfo::Flags LyXView::getToolbarState(string const & name)
|
2006-11-02 18:59:33 +00:00
|
|
|
|
{
|
|
|
|
|
return toolbars_->getToolbarState(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-06-06 13:52:31 +00:00
|
|
|
|
void LyXView::toggleToolbarState(string const & name, bool allowauto)
|
2006-11-02 16:01:36 +00:00
|
|
|
|
{
|
|
|
|
|
// it is possible to get current toolbar status like this,...
|
|
|
|
|
// but I decide to obey the order of ToolbarBackend::flags
|
|
|
|
|
// and disregard real toolbar status.
|
|
|
|
|
// toolbars_->saveToolbarInfo();
|
|
|
|
|
//
|
|
|
|
|
// toggle state on/off/auto
|
2007-06-06 13:52:31 +00:00
|
|
|
|
toolbars_->toggleToolbarState(name, allowauto);
|
2006-11-02 16:01:36 +00:00
|
|
|
|
// update toolbar
|
|
|
|
|
updateToolbars();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-21 17:27:08 +00:00
|
|
|
|
void LyXView::updateMenubar()
|
2000-07-24 13:53:19 +00:00
|
|
|
|
{
|
2002-06-12 02:54:19 +00:00
|
|
|
|
menubar_->update();
|
2000-07-24 13:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2000-04-08 17:02:02 +00:00
|
|
|
|
|
2002-06-12 11:34:13 +00:00
|
|
|
|
void LyXView::autoSave()
|
1999-09-27 18:44:28 +00:00
|
|
|
|
{
|
2007-04-01 10:09:49 +00:00
|
|
|
|
LYXERR(Debug::INFO) << "Running autoSave()" << endl;
|
2002-06-12 11:34:13 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
if (view()->buffer())
|
|
|
|
|
lyx::autoSave(view());
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
void LyXView::resetAutosaveTimer()
|
|
|
|
|
{
|
2000-03-12 10:35:05 +00:00
|
|
|
|
if (lyxrc.autosave)
|
2002-06-12 02:54:19 +00:00
|
|
|
|
autosave_timeout_->restart();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LyXView::updateLayoutChoice()
|
|
|
|
|
{
|
2005-02-08 13:18:05 +00:00
|
|
|
|
// Don't show any layouts without a buffer
|
2002-06-12 02:54:19 +00:00
|
|
|
|
if (!view()->buffer()) {
|
2004-04-29 09:54:59 +00:00
|
|
|
|
toolbars_->clearLayoutList();
|
2002-03-21 17:27:08 +00:00
|
|
|
|
return;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2005-02-08 13:18:05 +00:00
|
|
|
|
// Update the layout display
|
2004-04-29 09:54:59 +00:00
|
|
|
|
if (toolbars_->updateLayoutList(buffer()->params().textclass)) {
|
2007-04-29 19:53:54 +00:00
|
|
|
|
current_layout = buffer()->params().getTextClass().defaultLayoutName();
|
2001-08-03 18:28:11 +00:00
|
|
|
|
}
|
2002-03-02 16:39:54 +00:00
|
|
|
|
|
2007-01-02 10:36:34 +00:00
|
|
|
|
BOOST_ASSERT(work_area_);
|
2007-06-11 16:38:45 +00:00
|
|
|
|
string const & layout = work_area_->bufferView().cursor().
|
|
|
|
|
innerParagraph().layout()->name();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2001-12-05 23:16:13 +00:00
|
|
|
|
if (layout != current_layout) {
|
2004-04-29 09:54:59 +00:00
|
|
|
|
toolbars_->setLayout(layout);
|
1999-09-27 18:44:28 +00:00
|
|
|
|
current_layout = layout;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
1999-12-16 06:43:25 +00:00
|
|
|
|
void LyXView::updateWindowTitle()
|
|
|
|
|
{
|
2006-09-11 08:54:10 +00:00
|
|
|
|
docstring maximize_title = lyx::from_ascii("LyX");
|
|
|
|
|
docstring minimize_title = lyx::from_ascii("LyX");
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-09-16 14:00:13 +00:00
|
|
|
|
if (view()->buffer()) {
|
2001-04-17 15:15:59 +00:00
|
|
|
|
string const cur_title = buffer()->fileName();
|
2002-02-16 15:59:55 +00:00
|
|
|
|
if (!cur_title.empty()) {
|
2006-10-11 19:40:50 +00:00
|
|
|
|
maximize_title += ": " + makeDisplayPath(cur_title, 30);
|
2006-09-11 08:54:10 +00:00
|
|
|
|
minimize_title = lyx::from_utf8(onlyFilename(cur_title));
|
2002-09-11 18:05:42 +00:00
|
|
|
|
if (!buffer()->isClean()) {
|
2006-09-11 08:54:10 +00:00
|
|
|
|
maximize_title += _(" (changed)");
|
|
|
|
|
minimize_title += lyx::char_type('*');
|
2002-09-11 18:05:42 +00:00
|
|
|
|
}
|
1999-11-09 23:52:04 +00:00
|
|
|
|
if (buffer()->isReadonly())
|
2006-09-11 08:54:10 +00:00
|
|
|
|
maximize_title += _(" (read only)");
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-06-12 02:54:19 +00:00
|
|
|
|
|
2006-11-05 15:34:18 +00:00
|
|
|
|
setWindowTitle(maximize_title, minimize_title);
|
2007-01-28 22:27:26 +00:00
|
|
|
|
updateTab();
|
1999-09-27 18:44:28 +00:00
|
|
|
|
}
|
2002-08-13 17:43:40 +00:00
|
|
|
|
|
|
|
|
|
|
2004-01-15 17:34:44 +00:00
|
|
|
|
void LyXView::dispatch(FuncRequest const & cmd)
|
2002-08-13 17:43:40 +00:00
|
|
|
|
{
|
2006-10-12 14:58:57 +00:00
|
|
|
|
theLyXFunc().setLyXView(this);
|
2006-10-11 17:24:46 +00:00
|
|
|
|
lyx::dispatch(cmd);
|
2002-08-13 17:43:40 +00:00
|
|
|
|
}
|
2003-10-14 21:30:23 +00:00
|
|
|
|
|
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
Buffer const * const LyXView::updateInset(Inset const * inset) const
|
2003-10-14 21:30:23 +00:00
|
|
|
|
{
|
|
|
|
|
Buffer const * buffer_ptr = 0;
|
|
|
|
|
if (inset) {
|
2007-01-02 10:36:34 +00:00
|
|
|
|
BOOST_ASSERT(work_area_);
|
2007-01-18 21:47:27 +00:00
|
|
|
|
work_area_->scheduleRedraw();
|
2007-01-16 15:16:09 +00:00
|
|
|
|
|
|
|
|
|
buffer_ptr = work_area_->bufferView().buffer();
|
2003-10-14 21:30:23 +00:00
|
|
|
|
}
|
|
|
|
|
return buffer_ptr;
|
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|