]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/LyXView.C
hopefully fix tex2lyx linking.
[lyx.git] / src / frontends / LyXView.C
index bc20576f6db201c1fa4fd394bf9d29739cb3edee..fa6da758ada39808ba6f217ad806a71ab338950c 100644 (file)
@@ -67,12 +67,12 @@ using lyx::frontend::ControlCommandBuffer;
 string current_layout;
 
 
-LyXView::LyXView()
+LyXView::LyXView(int id)
        : 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) {
@@ -88,9 +88,12 @@ LyXView::~LyXView()
 }
 
 
+// FIXME, there's only one WorkArea per LyXView possible for now.
 void LyXView::setWorkArea(WorkArea * work_area)
 {
        work_area_ = work_area;
+       work_area_ids_.clear();
+       work_area_ids_.push_back(work_area_->id());
 }
 
 
@@ -102,6 +105,8 @@ Buffer * LyXView::buffer() const
 
 void LyXView::setBuffer(Buffer * b)
 {
+       busy(true);
+
        if (work_area_->bufferView().buffer())
                disconnectBuffer();
 
@@ -118,17 +123,24 @@ void LyXView::setBuffer(Buffer * b)
                connectBuffer(*work_area_->bufferView().buffer());
        }
 
+       if (quitting)
+               return;
+
        updateMenubar();
        updateToolbars();
        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();
 
@@ -138,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;
 }
@@ -155,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(
@@ -275,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.
@@ -286,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();
@@ -336,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");
 
@@ -354,15 +392,18 @@ void LyXView::updateWindowTitle()
                }
        }
 
-       if (maximize_title != last_title) {
-               setWindowTitle(maximize_title, minimize_title);
-               last_title = maximize_title;
-       }
+       setWindowTitle(maximize_title, minimize_title);
 }
 
 
 void LyXView::dispatch(FuncRequest const & cmd)
 {
+       if (cmd.action == LFUN_WINDOW_CLOSE) {
+               close();
+               closed(id_);
+               return;
+       }
+
        theLyXFunc().setLyXView(this);
        lyx::dispatch(cmd);
 }