]> git.lyx.org Git - lyx.git/blobdiff - src/LyXView.C
layout as string
[lyx.git] / src / LyXView.C
index 5b913c99ac8d2df2e997aff4c4494810fbc65b19..e1510008b747e0c993a91d8a5e3ad04a28442b56 100644 (file)
 #include "gettext.h"
 #include "lyxfunc.h"
 #include "BufferView.h"
+#include "lyxtextclasslist.h"
 
 #include "frontends/Dialogs.h"
 #include "frontends/Toolbar.h"
+#include "frontends/Timeout.h"
 #include "frontends/Menubar.h"
 
 #include "support/filetools.h"        // OnlyFilename()
 #include <unistd.h>
 
 using std::endl;
-using lyx::layout_type;
 
 extern void AutoSave(BufferView *);
 extern void QuitLyX();
 
-layout_type current_layout = 0;
+string current_layout;
 
 
 LyXView::LyXView()
@@ -54,10 +55,10 @@ LyXView::LyXView()
 
        intl = new Intl;
 
+       // Give the timeout some default sensible value.
+       autosave_timeout = new Timeout(5000);
+
        dialogs_ = new Dialogs(this);
-       // temporary until all dialogs moved into Dialogs.
-       dialogs_->updateBufferDependent
-               .connect(SigC::slot(&updateAllVisibleBufferRelatedDialogs));
        dialogs_->hideBufferDependent
                .connect(SigC::slot(&CloseAllBufferRelatedDialogs));
        Dialogs::redrawGUI.connect(SigC::slot(this, &LyXView::redraw));
@@ -73,6 +74,7 @@ LyXView::~LyXView()
        delete minibuffer;
        delete lyxfunc;
        delete intl;
+       delete autosave_timeout;
        delete dialogs_;
 }
 
@@ -102,7 +104,7 @@ Toolbar * LyXView::getToolbar() const
 }
 
 
-void LyXView::setLayout(layout_type layout)
+void LyXView::setLayout(string const & layout)
 {
        toolbar->setLayout(layout);
 }
@@ -180,7 +182,7 @@ void LyXView::AutoSave()
 void LyXView::resetAutosaveTimer()
 {
        if (lyxrc.autosave)
-               autosave_timeout.restart();
+               autosave_timeout->restart();
 }
 
 
@@ -203,12 +205,13 @@ void LyXView::updateLayoutChoice()
        if (last_textclass != int(buffer()->params.textclass)) {
                toolbar->updateLayoutList(true);
                last_textclass = int(buffer()->params.textclass);
-               current_layout = 0;
+               current_layout = textclasslist[last_textclass].defaultLayoutName();
        } else {
                toolbar->updateLayoutList(false);
        }
-       
-       layout_type layout = bufferview->getLyXText()->cursor.par()->getLayout();
+
+       string const & layout =
+               bufferview->getLyXText()->cursor.par()->layout();
 
        if (layout != current_layout) {
                toolbar->setLayout(layout);
@@ -226,7 +229,7 @@ void LyXView::updateWindowTitle()
 
        if (view()->available()) {
                string const cur_title = buffer()->fileName();
-               if (!cur_title.empty()){
+               if (!cur_title.empty()) {
                        title += ": " + MakeDisplayPath(cur_title, 30);
                        if (!buffer()->isLyxClean())
                                title += _(" (Changed)");