X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fbufferlist.C;h=3f4477636478f3fe8f20590692be00d5112c1ee7;hb=e72ef278b8c4b4bc1b0009cb00a1a56c7b02d2e8;hp=08173d2c81ecc548923c4d69b6d3b38c8e184c7e;hpb=e7401bd8f2310213b4b765c01676459f37adb530;p=lyx.git diff --git a/src/bufferlist.C b/src/bufferlist.C index 08173d2c81..3f44776364 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -43,6 +43,11 @@ using std::vector; using std::find; using std::endl; +using std::find_if; +using std::for_each; +using std::mem_fun; + +extern BufferView * current_view; // // Class BufferStorage @@ -67,8 +72,8 @@ Buffer * BufferStorage::newBuffer(string const & s, bool ronly) { Buffer * tmpbuf = new Buffer(s, ronly); tmpbuf->params.useClassDefaults(); - lyxerr.debug() << "Assigning to buffer " - << container.size() << endl; + lyxerr[Debug::INFO] << "Assigning to buffer " + << container.size() << endl; container.push_back(tmpbuf); return tmpbuf; } @@ -89,9 +94,6 @@ bool BufferList::empty() const } -extern bool MenuWrite(Buffer *); -extern bool MenuWriteAs(Buffer *); - bool BufferList::QwriteAll() { bool askMoreConfirmation = false; @@ -105,15 +107,15 @@ bool BufferList::QwriteAll() else fname = MakeDisplayPath((*it)->fileName(), 50); bool reask = true; - while(reask) { - switch(AskConfirmation(_("Changes in document:"), + while (reask) { + switch (AskConfirmation(_("Changes in document:"), fname, _("Save document?"))) { case 1: // Yes if ((*it)->isUnnamed()) - reask = !MenuWriteAs((*it)); + reask = !MenuWriteAs(current_view, (*it)); else { - reask = !MenuWrite((*it)); + reask = !MenuWrite(current_view, (*it)); } break; case 2: // No @@ -182,12 +184,12 @@ bool BufferList::close(Buffer * buf) fname = MakeDisplayPath(buf->fileName(), 50); bool reask = true; while (reask) { - switch(AskConfirmation(_("Changes in document:"), + switch (AskConfirmation(_("Changes in document:"), fname, _("Save document?"))){ case 1: // Yes if (buf->isUnnamed()) - reask = !MenuWriteAs(buf); + reask = !MenuWriteAs(current_view, buf); else if (buf->save()) { lastfiles->newFile(buf->fileName()); reask = false; @@ -288,50 +290,6 @@ void BufferList::emergencyWrite(Buffer * buf) buf->isUnnamed() ? OnlyFilename(buf->fileName()).c_str() : buf->fileName().c_str()) << endl; - //if (buf->isUnnamed()) - // lyxerr << OnlyFilename(buf->fileName()); - //else - // lyxerr << buf->fileName(); - //lyxerr << _(" as...") << endl; - - // Let's unroll this loop (Lgb) -#if 0 - bool madeit = false; - - for (int i = 0; i < 3 && !madeit; ++i) { - string s; - - // We try to save three places: - // 1) Same place as document. - // 2) In HOME directory. - // 3) In "/tmp" directory. - if (i == 0) { - if (buf->isUnnamed()) - continue; - s = buf->fileName(); - } else if (i == 1) { - s = AddName(GetEnvPath("HOME"), buf->fileName()); - } else { - // MakeAbsPath to prepend the current - // drive letter on OS/2 - s = AddName(MakeAbsPath("/tmp/"), buf->fileName()); - } - s += ".emergency"; - - lyxerr << " " << i + 1 << ") " << s << endl; - - if (buf->writeFile(s, true)) { - buf->markLyxClean(); - lyxerr << _(" Save seems successful. Phew.") << endl; - madeit = true; - } else if (i != 2) { - lyxerr << _(" Save failed! Trying...") << endl; - } else { - lyxerr << _(" Save failed! Bummer. Document is lost.") - << endl; - } - } -#else // We try to save three places: // 1) Same place as document. Unless it is an unnamed doc. @@ -372,7 +330,6 @@ void BufferList::emergencyWrite(Buffer * buf) return; } lyxerr << _(" Save failed! Bummer. Document is lost.") << endl; -#endif } @@ -498,10 +455,11 @@ Buffer * BufferList::newFile(string const & name, string tname, bool isNamed) b->paragraph = new LyXParagraph; } - if (!lyxrc.new_ask_filename) { - if (!isNamed) - b->setUnnamed(); + if (!lyxrc.new_ask_filename && !isNamed) { + b->setUnnamed(); + b->setFileName(name); } + b->setReadonly(false); return b;