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"
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 lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
51 lyxfunc_.reset(new LyXFunc(this));
52 intl_.reset(new Intl);
54 // Give the timeout some default sensible value.
55 autosave_timeout_.reset(new Timeout(5000));
57 dialogs_.reset(new Dialogs(this));
58 controlcommand_.reset(new ControlCommandBuffer(*getLyXFunc()));
72 // Start autosave timer
74 autosave_timeout_->timeout.connect(boost::bind(&LyXView::autoSave, this));
75 autosave_timeout_->setTimeout(lyxrc.autosave * 1000);
76 autosave_timeout_->start();
79 intl_->InitKeyMapper(lyxrc.use_kbmap);
83 Buffer * LyXView::buffer() const
85 return bufferview_->buffer();
89 boost::shared_ptr<BufferView> const & LyXView::view() const
95 Toolbar * LyXView::getToolbar() const
97 return toolbar_.get();
101 void LyXView::setLayout(string const & layout)
103 toolbar_->setLayout(layout);
107 void LyXView::updateToolbar()
113 LyXFunc * LyXView::getLyXFunc() const
115 return lyxfunc_.get();
119 Menubar * LyXView::getMenubar() const
121 return menubar_.get();
125 void LyXView::updateMenubar()
131 Intl * LyXView::getIntl() const
137 void LyXView::autoSave()
139 lyxerr[Debug::INFO] << "Running autoSave()" << endl;
141 if (view()->available()) {
142 ::AutoSave(view().get());
147 void LyXView::resetAutosaveTimer()
150 autosave_timeout_->restart();
154 void LyXView::updateLayoutChoice()
156 // don't show any layouts without a buffer
157 if (!view()->buffer()) {
158 toolbar_->clearLayoutList();
162 // update the layout display
163 if (toolbar_->updateLayoutList(buffer()->params.textclass)) {
164 current_layout = buffer()->params.getLyXTextClass().defaultLayoutName();
167 string const & layout =
168 bufferview_->getLyXText()->cursor.par()->layout()->name();
170 if (layout != current_layout) {
171 toolbar_->setLayout(layout);
172 current_layout = layout;
177 void LyXView::updateWindowTitle()
179 static string last_title = "LyX";
180 string title = "LyX";
181 string icon_title = "LyX";
183 if (view()->available()) {
184 string const cur_title = buffer()->fileName();
185 if (!cur_title.empty()) {
186 title += ": " + MakeDisplayPath(cur_title, 30);
187 if (!buffer()->isClean())
188 title += _(" (changed)");
189 if (buffer()->isReadonly())
190 title += _(" (read only)");
191 // Show only the filename if it's available
192 icon_title = OnlyFilename(cur_title);
196 if (title != last_title) {
197 setWindowTitle(title, icon_title);