]> git.lyx.org Git - lyx.git/blobdiff - src/lyx_cb.C
* lyx_gui: create_view(), start() and exit() functions deleted.
[lyx.git] / src / lyx_cb.C
index 2a4d9b69bddf38400baa5655dcfa8503c0fd7321..455136b3dfeda597a1ccb7049eb50d26f98a946d 100644 (file)
 #include "paragraph.h"
 
 #include "frontends/Alert.h"
+#include "frontends/Application.h"
 #include "frontends/FileDialog.h"
 #include "frontends/lyx_gui.h"
-#include "frontends/LyXView.h"
 
 #include "support/filefilterlist.h"
 #include "support/filetools.h"
+#include "support/fontutils.h"
 #include "support/forkedcall.h"
 #include "support/fs_extras.h"
 #include "support/lyxlib.h"
@@ -89,7 +90,6 @@ using std::ios;
 using std::istream_iterator;
 
 
-extern BufferList bufferlist;
 // this should be static, but I need it in buffer.C
 bool quitting; // flag, that we are quitting the program
 
@@ -193,7 +193,7 @@ void quitLyX(bool noask)
        lyxerr[Debug::INFO] << "Running QuitLyX." << endl;
 
        if (lyx_gui::use_gui) {
-               if (!noask && !bufferlist.quitWriteAll())
+               if (!noask && !theApp->bufferList().quitWriteAll())
                        return;
 
                LyX::cref().session().writeFile();
@@ -204,7 +204,7 @@ void quitLyX(bool noask)
        quitting = true;
 
        // close buffers first
-       bufferlist.closeAll();
+       theApp->bufferList().closeAll();
 
        // do any other cleanup procedures now
        lyxerr[Debug::INFO] << "Deleting tmp dir " << package().temp_dir() << endl;
@@ -216,7 +216,9 @@ void quitLyX(bool noask)
                Alert::warning(_("Unable to remove temporary directory"), msg);
        }
 
-       lyx_gui::exit(0);
+       theApp->exit(0);
+       // Restore original font resources after Application is destroyed.
+       lyx::support::restoreFontResources();
 }
 
 
@@ -302,12 +304,12 @@ void autoSave(BufferView * bv)
        // should probably be moved into BufferList (Lgb)
        // Perfect target for a thread...
 {
-       if (!bv->available())
+       if (!bv->buffer())
                return;
 
        if (bv->buffer()->isBakClean() || bv->buffer()->isReadonly()) {
                // We don't save now, but we'll try again later
-               bv->owner()->resetAutosaveTimer();
+               bv->buffer()->resetAutosaveTimers();
                return;
        }
 
@@ -324,7 +326,7 @@ void autoSave(BufferView * bv)
        autosave.start();
 
        bv->buffer()->markBakClean();
-       bv->owner()->resetAutosaveTimer();
+       bv->buffer()->resetAutosaveTimers();
 }
 
 
@@ -353,7 +355,7 @@ void newFile(BufferView * bv, string const & filename)
 // Insert ascii file (if filename is empty, prompt for one)
 void insertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
 {
-       if (!bv->available())
+       if (!bv->buffer())
                return;
 
        // FIXME: We don't know the encoding of the file
@@ -362,7 +364,8 @@ void insertAsciiFile(BufferView * bv, string const & f, bool asParagraph)
                return;
 
        // clear the selection
-       if (bv->text() == bv->getLyXText())
+       LyXText const & text = bv->buffer()->text();
+       if (&text == bv->getLyXText())
                bv->cursor().clearSelection();
        if (asParagraph)
                bv->getLyXText()->insertStringAsParagraphs(bv->cursor(), tmpstr);
@@ -382,7 +385,7 @@ string getContentsOfAsciiFile(BufferView * bv, string const & f, bool asParagrap
                        (asParagraph) ? LFUN_FILE_INSERT_ASCII_PARA : LFUN_FILE_INSERT_ASCII);
 
                FileDialog::Result result =
-                       fileDlg.open(bv->owner()->buffer()->filePath(),
+                       fileDlg.open(bv->buffer()->filePath(),
                                     FileFilterList(), string());
 
                if (result.first == FileDialog::Later)