]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/LyXView.C
hopefully fix tex2lyx linking.
[lyx.git] / src / frontends / LyXView.C
index e700434499d257f6b6c8b94c171f1681bee7cb96..fa6da758ada39808ba6f217ad806a71ab338950c 100644 (file)
@@ -68,11 +68,11 @@ string current_layout;
 
 
 LyXView::LyXView(int id)
-       : id_(id), work_area_(0),
+       : work_area_(0),
          toolbars_(new Toolbars(*this)),
          autosave_timeout_(new Timeout(5000)),
          dialogs_(new Dialogs(*this)),
-         controlcommand_(new ControlCommandBuffer(*this))
+         controlcommand_(new ControlCommandBuffer(*this)), id_(id)
 {
        // Start autosave timer
        if (lyxrc.autosave) {
@@ -105,6 +105,8 @@ Buffer * LyXView::buffer() const
 
 void LyXView::setBuffer(Buffer * b)
 {
+       busy(true);
+
        if (work_area_->bufferView().buffer())
                disconnectBuffer();
 
@@ -129,12 +131,16 @@ void LyXView::setBuffer(Buffer * b)
        updateLayoutChoice();
        updateWindowTitle();
        updateStatusBar();
+       updateTab();
+       busy(false);
        work_area_->redraw();
 }
 
 
 bool LyXView::loadLyXFile(string const & filename, bool tolastfiles)
 {
+       busy(true);
+
        if (work_area_->bufferView().buffer())
                disconnectBuffer();
 
@@ -144,11 +150,13 @@ bool LyXView::loadLyXFile(string const & filename, bool tolastfiles)
        updateToolbars();
        updateLayoutChoice();
        updateWindowTitle();
+       updateTab();
        if (loaded) {
                connectBuffer(*work_area_->bufferView().buffer());
                showErrorList("Parse");
        }
        updateStatusBar();
+       busy(false);
        work_area_->redraw();
        return loaded;
 }
@@ -161,7 +169,7 @@ void LyXView::connectBuffer(Buffer & buf)
 
        bufferChangedConnection_ =
                buf.changed.connect(
-                       boost::bind(&WorkArea::redraw, work_area_));
+                       boost::bind(&WorkArea::redraw, work_area_, _1));
 
        errorsConnection_ =
                buf.errors.connect(
@@ -281,10 +289,15 @@ BufferView * LyXView::view() const
 
 void LyXView::updateToolbars()
 {
-       bool const math = work_area_->bufferView().cursor().inMathed();
+       bool const math =
+               work_area_->bufferView().cursor().inMathed();
        bool const table =
                lyx::getStatus(FuncRequest(LFUN_LAYOUT_TABULAR)).enabled();
-       toolbars_->update(math, table);
+       bool const review =
+               lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).enabled() &&
+               lyx::getStatus(FuncRequest(LFUN_CHANGES_TRACK)).onoff(true);
+               
+       toolbars_->update(math, table, review);
        // update redaonly status of open dialogs. This could also be in
        // updateMenubar(), but since updateToolbars() and updateMenubar()
        // are always called together it is only here.
@@ -292,6 +305,26 @@ void LyXView::updateToolbars()
 }
 
 
+ToolbarBackend::Flags LyXView::getToolbarState(string const & name)
+{
+       return toolbars_->getToolbarState(name);
+}
+
+
+void LyXView::toggleToolbarState(string const & name)
+{
+       // it is possible to get current toolbar status like this,...
+       // but I decide to obey the order of ToolbarBackend::flags
+       // and disregard real toolbar status.
+       // toolbars_->saveToolbarInfo();
+       //
+       // toggle state on/off/auto
+       toolbars_->toggleToolbarState(name);
+       // update toolbar
+       updateToolbars();
+}
+
+
 void LyXView::updateMenubar()
 {
        menubar_->update();
@@ -342,7 +375,6 @@ void LyXView::updateLayoutChoice()
 
 void LyXView::updateWindowTitle()
 {
-       static docstring last_title = lyx::from_ascii("LyX");
        docstring maximize_title = lyx::from_ascii("LyX");
        docstring minimize_title = lyx::from_ascii("LyX");
 
@@ -360,10 +392,7 @@ void LyXView::updateWindowTitle()
                }
        }
 
-       if (maximize_title != last_title) {
-               setWindowTitle(maximize_title, minimize_title);
-               last_title = maximize_title;
-       }
+       setWindowTitle(maximize_title, minimize_title);
 }