3 * Copyright 1995-2002 the LyX Team
4 * Read the file COPYING
6 * \author Lars Gullik Bjornes
7 * \author John Levon <moz@compsoc.man.ac.uk>
13 #pragma implementation
22 #include "MenuBackend.h"
25 #include "funcrequest.h"
27 #include "BufferView.h"
28 #include "bufferview_funcs.h"
34 #include "controllers/ControlCommandBuffer.h"
36 #include "support/filetools.h" // OnlyFilename()
38 #include <boost/bind.hpp>
45 string current_layout;
50 autosave_timeout_(new Timeout(5000)),
51 lyxfunc_(new LyXFunc(this)),
52 dialogs_(new Dialogs(*this)),
53 controlcommand_(new ControlCommandBuffer(getLyXFunc()))
55 lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
69 // Start autosave timer
71 autosave_timeout_->timeout.connect(boost::bind(&LyXView::autoSave, this));
72 autosave_timeout_->setTimeout(lyxrc.autosave * 1000);
73 autosave_timeout_->start();
76 intl_->InitKeyMapper(lyxrc.use_kbmap);
80 Buffer * LyXView::buffer() const
82 return bufferview_->buffer();
86 boost::shared_ptr<BufferView> const & LyXView::view() const
92 void LyXView::setLayout(string const & layout)
94 toolbar_->setLayout(layout);
98 void LyXView::updateToolbar()
104 void LyXView::updateMenubar()
110 void LyXView::autoSave()
112 lyxerr[Debug::INFO] << "Running autoSave()" << endl;
114 if (view()->available()) {
115 ::AutoSave(view().get());
120 void LyXView::resetAutosaveTimer()
123 autosave_timeout_->restart();
127 void LyXView::updateLayoutChoice()
129 // don't show any layouts without a buffer
130 if (!view()->buffer()) {
131 toolbar_->clearLayoutList();
135 // update the layout display
136 if (toolbar_->updateLayoutList(buffer()->params.textclass)) {
137 current_layout = buffer()->params.getLyXTextClass().defaultLayoutName();
140 string const & layout =
141 bufferview_->getLyXText()->cursor.par()->layout()->name();
143 if (layout != current_layout) {
144 toolbar_->setLayout(layout);
145 current_layout = layout;
150 void LyXView::updateWindowTitle()
152 static string last_title = "LyX";
153 string title = "LyX";
154 string icon_title = "LyX";
156 if (view()->available()) {
157 string const cur_title = buffer()->fileName();
158 if (!cur_title.empty()) {
159 title += ": " + MakeDisplayPath(cur_title, 30);
160 if (!buffer()->isClean())
161 title += _(" (changed)");
162 if (buffer()->isReadonly())
163 title += _(" (read only)");
164 // Show only the filename if it's available
165 icon_title = OnlyFilename(cur_title);
169 if (title != last_title) {
170 setWindowTitle(title, icon_title);
176 void LyXView::dispatch(FuncRequest const & req)
178 // substitute the correct BufferView here
180 r.setView(view().get());
181 getLyXFunc().dispatch(r);