#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;
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...
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();
//
// should be moved to lyxfunc.C
-void MenuWrite(Buffer * buffer)
+bool MenuWrite(Buffer * buffer)
{
XFlush(fl_display);
if (!buffer->save()) {
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;
}
// 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)
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;
}
-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)