3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
9 * Full author contact details are available in file CREDITS
15 #pragma implementation
24 #include "MenuBackend.h"
27 #include "funcrequest.h"
29 #include "BufferView.h"
30 #include "bufferview_funcs.h"
36 #include "controllers/ControlCommandBuffer.h"
38 #include "support/filetools.h" // OnlyFilename()
40 #include <boost/bind.hpp>
47 string current_layout;
52 autosave_timeout_(new Timeout(5000)),
53 lyxfunc_(new LyXFunc(this)),
54 dialogs_(new Dialogs(*this)),
55 controlcommand_(new ControlCommandBuffer(getLyXFunc()))
57 lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
71 // Start autosave timer
73 autosave_timeout_->timeout.connect(boost::bind(&LyXView::autoSave, this));
74 autosave_timeout_->setTimeout(lyxrc.autosave * 1000);
75 autosave_timeout_->start();
78 intl_->InitKeyMapper(lyxrc.use_kbmap);
82 Buffer * LyXView::buffer() const
84 return bufferview_->buffer();
88 boost::shared_ptr<BufferView> const & LyXView::view() const
94 void LyXView::setLayout(string const & layout)
96 toolbar_->setLayout(layout);
100 void LyXView::updateToolbar()
106 void LyXView::updateMenubar()
112 void LyXView::autoSave()
114 lyxerr[Debug::INFO] << "Running autoSave()" << endl;
116 if (view()->available()) {
117 ::AutoSave(view().get());
122 void LyXView::resetAutosaveTimer()
125 autosave_timeout_->restart();
129 void LyXView::updateLayoutChoice()
131 // don't show any layouts without a buffer
132 if (!view()->buffer()) {
133 toolbar_->clearLayoutList();
137 // update the layout display
138 if (toolbar_->updateLayoutList(buffer()->params.textclass)) {
139 current_layout = buffer()->params.getLyXTextClass().defaultLayoutName();
142 string const & layout =
143 bufferview_->getLyXText()->cursor.par()->layout()->name();
145 if (layout != current_layout) {
146 toolbar_->setLayout(layout);
147 current_layout = layout;
152 void LyXView::updateWindowTitle()
154 static string last_title = "LyX";
155 string maximize_title = "LyX";
156 string minimize_title = "LyX";
158 if (view()->available()) {
159 string const cur_title = buffer()->fileName();
160 if (!cur_title.empty()) {
161 maximize_title += ": " + MakeDisplayPath(cur_title, 30);
162 minimize_title = OnlyFilename(cur_title);
163 if (!buffer()->isClean()) {
164 maximize_title += _(" (changed)");
165 minimize_title += '*';
167 if (buffer()->isReadonly())
168 maximize_title += _(" (read only)");
172 if (maximize_title != last_title) {
173 setWindowTitle(maximize_title, minimize_title);
174 last_title = maximize_title;
179 void LyXView::dispatch(FuncRequest const & req)
181 // substitute the correct BufferView here
183 r.setView(view().get());
184 getLyXFunc().dispatch(r);