3 * Read the file COPYING
5 * \author Lars Gullik Bjønnes
8 * Full author contact details are available in file CREDITS
14 #pragma implementation
23 #include "MenuBackend.h"
26 #include "funcrequest.h"
28 #include "BufferView.h"
29 #include "bufferview_funcs.h"
35 #include "controllers/ControlCommandBuffer.h"
37 #include "support/filetools.h" // OnlyFilename()
39 #include <boost/bind.hpp>
46 string current_layout;
51 autosave_timeout_(new Timeout(5000)),
52 lyxfunc_(new LyXFunc(this)),
53 dialogs_(new Dialogs(*this)),
54 controlcommand_(new ControlCommandBuffer(getLyXFunc()))
56 lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
70 // Start autosave timer
72 autosave_timeout_->timeout.connect(boost::bind(&LyXView::autoSave, this));
73 autosave_timeout_->setTimeout(lyxrc.autosave * 1000);
74 autosave_timeout_->start();
77 intl_->InitKeyMapper(lyxrc.use_kbmap);
81 Buffer * LyXView::buffer() const
83 return bufferview_->buffer();
87 boost::shared_ptr<BufferView> const & LyXView::view() const
93 void LyXView::setLayout(string const & layout)
95 toolbar_->setLayout(layout);
99 void LyXView::updateToolbar()
105 void LyXView::updateMenubar()
111 void LyXView::autoSave()
113 lyxerr[Debug::INFO] << "Running autoSave()" << endl;
115 if (view()->available()) {
116 ::AutoSave(view().get());
121 void LyXView::resetAutosaveTimer()
124 autosave_timeout_->restart();
128 void LyXView::updateLayoutChoice()
130 // don't show any layouts without a buffer
131 if (!view()->buffer()) {
132 toolbar_->clearLayoutList();
136 // update the layout display
137 if (toolbar_->updateLayoutList(buffer()->params.textclass)) {
138 current_layout = buffer()->params.getLyXTextClass().defaultLayoutName();
141 string const & layout =
142 bufferview_->getLyXText()->cursor.par()->layout()->name();
144 if (layout != current_layout) {
145 toolbar_->setLayout(layout);
146 current_layout = layout;
151 void LyXView::updateWindowTitle()
153 static string last_title = "LyX";
154 string title = "LyX";
155 string icon_title = "LyX";
157 if (view()->available()) {
158 string const cur_title = buffer()->fileName();
159 if (!cur_title.empty()) {
160 title += ": " + MakeDisplayPath(cur_title, 30);
161 if (!buffer()->isClean())
162 title += _(" (changed)");
163 if (buffer()->isReadonly())
164 title += _(" (read only)");
165 // Show only the filename if it's available
166 icon_title = OnlyFilename(cur_title);
170 if (title != last_title) {
171 setWindowTitle(title, icon_title);
177 void LyXView::dispatch(FuncRequest const & req)
179 // substitute the correct BufferView here
181 r.setView(view().get());
182 getLyXFunc().dispatch(r);