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
21 #include "MenuBackend.h"
24 #include "funcrequest.h"
26 #include "BufferView.h"
27 #include "bufferview_funcs.h"
33 #include "controllers/ControlCommandBuffer.h"
35 #include "support/filetools.h" // OnlyFilename()
37 #include <boost/bind.hpp>
44 string current_layout;
49 autosave_timeout_(new Timeout(5000)),
50 lyxfunc_(new LyXFunc(this)),
51 dialogs_(new Dialogs(*this)),
52 controlcommand_(new ControlCommandBuffer(*this))
54 lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
68 // Start autosave timer
70 autosave_timeout_->timeout.connect(boost::bind(&LyXView::autoSave, this));
71 autosave_timeout_->setTimeout(lyxrc.autosave * 1000);
72 autosave_timeout_->start();
75 intl_->InitKeyMapper(lyxrc.use_kbmap);
79 Buffer * LyXView::buffer() const
81 return bufferview_->buffer();
85 boost::shared_ptr<BufferView> const & LyXView::view() const
91 void LyXView::setLayout(string const & layout)
93 toolbar_->setLayout(layout);
97 void LyXView::updateToolbar()
103 void LyXView::updateMenubar()
109 void LyXView::autoSave()
111 lyxerr[Debug::INFO] << "Running autoSave()" << endl;
113 if (view()->available()) {
114 ::AutoSave(view().get());
119 void LyXView::resetAutosaveTimer()
122 autosave_timeout_->restart();
126 void LyXView::updateLayoutChoice()
128 // don't show any layouts without a buffer
129 if (!view()->buffer()) {
130 toolbar_->clearLayoutList();
134 // update the layout display
135 if (toolbar_->updateLayoutList(buffer()->params.textclass)) {
136 current_layout = buffer()->params.getLyXTextClass().defaultLayoutName();
139 string const & layout =
140 bufferview_->getLyXText()->cursor.par()->layout()->name();
142 if (layout != current_layout) {
143 toolbar_->setLayout(layout);
144 current_layout = layout;
149 void LyXView::updateWindowTitle()
151 static string last_title = "LyX";
152 string maximize_title = "LyX";
153 string minimize_title = "LyX";
155 if (view()->available()) {
156 string const cur_title = buffer()->fileName();
157 if (!cur_title.empty()) {
158 maximize_title += ": " + MakeDisplayPath(cur_title, 30);
159 minimize_title = OnlyFilename(cur_title);
160 if (!buffer()->isClean()) {
161 maximize_title += _(" (changed)");
162 minimize_title += '*';
164 if (buffer()->isReadonly())
165 maximize_title += _(" (read only)");
169 if (maximize_title != last_title) {
170 setWindowTitle(maximize_title, minimize_title);
171 last_title = maximize_title;
176 void LyXView::dispatch(FuncRequest const & req)
178 // substitute the correct BufferView here
180 r.setView(view().get());
181 getLyXFunc().dispatch(r);