]> git.lyx.org Git - lyx.git/blobdiff - src/lyx_cb.C
small changes to ButtonController usage
[lyx.git] / src / lyx_cb.C
index dc55aed188a65d794e5c4e21e7b7ad895046f9d8..a6f8f60d18a07e90f0d132621b2723a24f6540e2 100644 (file)
 #include "support/filetools.h"
 #include "support/path.h"
 #include "lyxserver.h"
-#include "FontLoader.h"
 #include "lyxrc.h"
 #include "lyxtext.h"
 #include "CutAndPaste.h"
-#include "TextCache.h"
 
 using std::ifstream;
 using std::copy;
@@ -70,7 +68,6 @@ extern FD_form_quotes * fd_form_quotes;
 extern FD_form_preamble * fd_form_preamble;
 extern FD_form_table * fd_form_table;
 extern FD_form_figure * fd_form_figure;
-extern FD_form_screen * fd_form_screen;
 extern FD_form_bullet * fd_form_bullet;
 
 extern BufferView * current_view; // called too many times in this file...
@@ -157,7 +154,7 @@ void ToggleLockedInsetCursor(long x, long y, int asc, int desc);
 
 int RunLinuxDoc(BufferView *, int, string const &);
 int RunDocBook(int, string const &);
-void MenuWrite(Buffer * buf);
+bool MenuWrite(Buffer * buf);
 bool MenuWriteAs(Buffer * buffer);
 void MenuReload(Buffer * buf);
 void MenuLayoutSave();
@@ -187,7 +184,7 @@ void ShowMessage(Buffer * buf,
 //
 
 // should be moved to lyxfunc.C
-void MenuWrite(Buffer * buffer)
+bool MenuWrite(Buffer * buffer)
 {
        XFlush(fl_display);
        if (!buffer->save()) {
@@ -196,11 +193,13 @@ void MenuWrite(Buffer * buffer)
                if (AskQuestion(_("Save failed. Rename and try again?"),
                                MakeDisplayPath(s, 50),
                                _("(If not, document is not saved.)"))) {
-                       MenuWriteAs(buffer);
+                       return MenuWriteAs(buffer);
                }
+               return false;
        } else {
                lastfiles->newFile(buffer->fileName());
        }
+       return true;
 }
 
 
@@ -280,13 +279,23 @@ bool MenuWriteAs(Buffer * buffer)
        // Ok, change the name of the buffer
        buffer->fileName(s);
        buffer->markDirty();
+       bool unnamed = buffer->isUnnamed();
        buffer->setUnnamed(false);
        // And save
        // Small bug: If the save fails, we have irreversible changed the name
        // of the document.
-       MenuWrite(buffer);
+       // Hope this is fixed this way! (Jug)
+       if (!MenuWrite(buffer)) {
+           buffer->fileName(oldname);
+           buffer->setUnnamed(unnamed);
+           ShowMessage(buffer, _("Document could not be saved!"),
+                       _("Holding the old name."), MakeDisplayPath(oldname));
+           return false;
+       }
+       // now remove the oldname autosave file if existant!
+       removeAutosaveFile(oldname);
        return true;
-}    
+}
 
 
 int MenuRunLaTeX(Buffer * buffer)
@@ -978,8 +987,7 @@ void AutoSave(BufferView * bv)
        if (!bv->available())
                return;
 
-       if (bv->buffer()->isBakClean() ||
-           bv->buffer()->isReadonly() || bv->buffer()->isUnnamed()) {
+       if (bv->buffer()->isBakClean() || bv->buffer()->isReadonly()) {
                // We don't save now, but we'll try again later
                bv->owner()->resetAutosaveTimer();
                return;
@@ -2821,43 +2829,6 @@ extern "C" void FigureOKCB(FL_OBJECT * ob, long data)
 }
 
 
-extern "C" void ScreenApplyCB(FL_OBJECT *, long)
-{
-       lyxrc.roman_font_name = fl_get_input(fd_form_screen->input_roman);
-       lyxrc.sans_font_name = fl_get_input(fd_form_screen->input_sans);
-       lyxrc.typewriter_font_name = fl_get_input(fd_form_screen->input_typewriter);
-       lyxrc.font_norm = fl_get_input(fd_form_screen->input_font_norm);
-       lyxrc.set_font_norm_type();
-       lyxrc.zoom = atoi(fl_get_input(fd_form_screen->intinput_size));
-       fontloader.update();
-
-       // Of course we should only to the resize and the textcahce.clear
-       // if values really changed...but not very important right now. (Lgb)
-       
-       // All buffers will need resize
-       bufferlist.resize();
-       // We also need to empty the textcache so that
-       // the buffer will be formatted correctly after
-       // a zoom change.
-       textcache.clear();
-       
-       current_view->owner()->getMiniBuffer()->Set(_("Screen options set"));
-}
-
-
-extern "C" void ScreenCancelCB(FL_OBJECT *, long)
-{
-       fl_hide_form(fd_form_screen->form_screen);
-}
-
-
-extern "C" void ScreenOKCB(FL_OBJECT * ob, long data)
-{
-       ScreenCancelCB(ob, data);
-       ScreenApplyCB(ob, data);
-}
-
-
 // This function runs "configure" and then rereads lyx.defaults to
 // reconfigure the automatic settings.
 void Reconfigure(BufferView * bv)