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"
28 #include "lyxtextclasslist.h"
34 #include "controllers/ControlCommandBuffer.h"
36 #include "support/filetools.h" // OnlyFilename()
38 #include <boost/bind.hpp>
45 string current_layout;
50 lyxerr[Debug::INIT] << "Initializing LyXFunc" << endl;
52 lyxfunc_.reset(new LyXFunc(this));
53 intl_.reset(new Intl);
55 // Give the timeout some default sensible value.
56 autosave_timeout_.reset(new Timeout(5000));
58 dialogs_.reset(new Dialogs(this));
59 controlcommand_.reset(new ControlCommandBuffer(*getLyXFunc()));
73 // Start autosave timer
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 BufferView * LyXView::view() const
91 return bufferview_.get();
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()
127 if (!view()->buffer() && menubackend.hasMenu("main_nobuffer")) {
128 menubar_->set("main_nobuffer");
130 menubar_->set("main");
137 Intl * LyXView::getIntl() const
143 void LyXView::autoSave()
145 lyxerr[Debug::INFO] << "Running autoSave()" << endl;
147 if (view()->available()) {
153 void LyXView::resetAutosaveTimer()
156 autosave_timeout_->restart();
160 void LyXView::updateLayoutChoice()
162 // don't show any layouts without a buffer
163 if (!view()->buffer()) {
164 toolbar_->clearLayoutList();
168 // update the layout display
169 if (toolbar_->updateLayoutList(buffer()->params.textclass)) {
170 current_layout = textclasslist[buffer()->params.textclass].defaultLayoutName();
173 string const & layout =
174 bufferview_->getLyXText()->cursor.par()->layout()->name();
176 if (layout != current_layout) {
177 toolbar_->setLayout(layout);
178 current_layout = layout;
183 void LyXView::updateWindowTitle()
185 static string last_title = "LyX";
186 string title = "LyX";
187 string icon_title = "LyX";
189 if (view()->available()) {
190 string const cur_title = buffer()->fileName();
191 if (!cur_title.empty()) {
192 title += ": " + MakeDisplayPath(cur_title, 30);
193 if (!buffer()->isLyxClean())
194 title += _(" (changed)");
195 if (buffer()->isReadonly())
196 title += _(" (read only)");
197 // Show only the filename if it's available
198 icon_title = OnlyFilename(cur_title);
202 if (title != last_title) {
203 setWindowTitle(title, icon_title);