]> git.lyx.org Git - lyx.git/commitdiff
Added new lyxrc tag new_ask_filename for New... behaviour and fixed errors
authorJürgen Vigna <jug@sad.it>
Tue, 8 Aug 2000 11:08:07 +0000 (11:08 +0000)
committerJürgen Vigna <jug@sad.it>
Tue, 8 Aug 2000 11:08:07 +0000 (11:08 +0000)
with automatically assigned filename.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@959 a592a061-630c-0410-9148-cb99ea01b6c8

ChangeLog
lib/lyxrc.example
src/bufferlist.C
src/lyxfunc.C
src/lyxrc.C
src/lyxrc.h

index 8b9d4a4f105b987b35553f9ad36cf69be1881491..c28baaf11ef88bcb49a948ecf1a4aec63de28b55 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2000-08-08  Juergen Vigna  <jug@sad.it>
+
+       * src/bufferlist.C (newFile):
+       * src/lyxfunc.C (MenuNew): use the new_ask_filename tag from lyxrc.
+
+       * src/lyxrc.C: added new_ask_filename tag
+
 2000-08-07  Baruch Even  <baruch.even@writeme.com>
 
        * src/graphics/Renderer.h:
index 82e96da2df35dff3054350585d410d4464b889b5..411d8fd94079a5827d16364d302d0743bfad5909 100644 (file)
 # We recommend to keep the confirmation, though.
 #\exit_confirmation false
 
+# This sets the behaviour if you want to be asked for a filename when
+# creating a new document or wait until you save it and be asked then.
+# The default for now is ask on save.
+# \new_ask_filename false
+
 # LyX continously displays names of last command executed, along with a list 
 # of defined short-cuts for it in the minibuffer.
 # It requires some horsepower to function, so you can turn it off, if LyX
index e180a015d6a46dd7bb5bc2fcba149c4e1c6dfb7e..d88a2a7e03fb736c5fd6c71833cc65c296184098 100644 (file)
@@ -453,12 +453,11 @@ Buffer * BufferList::newFile(string const & name, string tname)
                b->paragraph = new LyXParagraph;
        }
 
-#ifdef NEW_WITH_FILENAME
-       b->markDirty();
-#else
-#warning Why mark a new document dirty? I deactivate this for unnamed docs! (Jug)
-       b->setUnnamed();
-#endif
+#warning Why mark a new document dirty? I deactivate this (Jug)
+       if (!lyxrc.new_ask_filename) {
+//             b->markDirty();
+               b->setUnnamed();
+       }
        b->setReadonly(false);
        
        return b;
index 56bc0d84ba9b354a6ca5989a15baefe616cee062..fe0b186c8cd605041eb6e3b4d2eaece1a92d88ad 100644 (file)
@@ -2962,32 +2962,35 @@ void LyXFunc::MenuNew(bool fromTemplate)
                        initpath = trypath;
        }
 
-#ifdef NEW_WITH_FILENAME
-       ProhibitInput(owner->view());
-       fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
-       fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
-       fname = fileDlg.Select(_("Enter Filename for new document"), 
-                              initpath, "*.lyx", _("newfile"));
-       AllowInput(owner->view());
+       static int newfile_number = 0;
+       string s = "newfile"+tostr(++newfile_number);
+
+       if (lyxrc.new_ask_filename) {
+               ProhibitInput(owner->view());
+               fileDlg.SetButton(0, _("Documents"), lyxrc.document_path);
+               fileDlg.SetButton(1, _("Templates"), lyxrc.template_path);
+               fname = fileDlg.Select(_("Enter Filename for new document"), 
+                                      initpath, "*.lyx", _("newfile"));
+               AllowInput(owner->view());
        
-       if (fname.empty()) {
-               owner->getMiniBuffer()->Set(_("Canceled."));
-               lyxerr.debug() << "New Document Cancelled." << endl;
-               return;
-       }
+               if (fname.empty()) {
+                       owner->getMiniBuffer()->Set(_("Canceled."));
+                       lyxerr.debug() << "New Document Cancelled." << endl;
+                       return;
+               }
        
-       // get absolute path of file and make sure the filename ends
-       // with .lyx
-       string s = MakeAbsPath(fname);
-       if (!IsLyXFilename(s))
-               s += ".lyx";
-
-       // Check if the document already is open
-       if (bufferlist.exists(s)) {
-               switch(AskConfirmation(_("Document is already open:"), 
-                                      MakeDisplayPath(s, 50),
-                                      _("Do you want to close that document now?\n"
-                                        "('No' will just switch to the open version)")))
+               // get absolute path of file and make sure the filename ends
+               // with .lyx
+               string s = MakeAbsPath(fname);
+               if (!IsLyXFilename(s))
+                       s += ".lyx";
+
+               // Check if the document already is open
+               if (bufferlist.exists(s)) {
+                       switch(AskConfirmation(_("Document is already open:"), 
+                                              MakeDisplayPath(s, 50),
+                                              _("Do you want to close that document now?\n"
+                                                "('No' will just switch to the open version)")))
                        {
                        case 1: // Yes: close the document
                                if (!bufferlist.close(bufferlist.getBuffer(s)))
@@ -3001,37 +3004,34 @@ void LyXFunc::MenuNew(bool fromTemplate)
                                owner->getMiniBuffer()->Set(_("Canceled."));
                                return;
                        }
-       }
-
-       // Check whether the file already exists
-       if (IsLyXFilename(s)) {
+               }
+               // Check whether the file already exists
+               if (IsLyXFilename(s)) {
+                       FileInfo fi(s);
+                       if (fi.readable() &&
+                           AskQuestion(_("File already exists:"), 
+                                       MakeDisplayPath(s, 50),
+                                       _("Do you want to open the document?"))) {
+                               // loads document
+                               owner->getMiniBuffer()->Set(_("Opening document"), 
+                                                           MakeDisplayPath(s), "...");
+                               XFlush(fl_display);
+                               owner->view()->buffer(
+                                       bufferlist.loadLyXFile(s));
+                               owner->getMiniBuffer()->Set(_("Document"),
+                                                           MakeDisplayPath(s),
+                                                           _("opened."));
+                               return;
+                       }
+               }
+       } else {
                FileInfo fi(s);
-               if (fi.readable() &&
-                   AskQuestion(_("File already exists:"), 
-                               MakeDisplayPath(s, 50),
-                               _("Do you want to open the document?"))) {
-                       // loads document
-                       owner->getMiniBuffer()->Set(_("Opening document"), 
-                                                   MakeDisplayPath(s), "...");
-                       XFlush(fl_display);
-                       owner->view()->buffer(
-                               bufferlist.loadLyXFile(s));
-                       owner->getMiniBuffer()->Set(_("Document"),
-                                                   MakeDisplayPath(s),
-                                                   _("opened."));
-                       return;
+               while (bufferlist.exists(s) || fi.readable()) {
+                       ++newfile_number;
+                       s = "newfile"+tostr(newfile_number);
+                       fi.newFile(s);
                }
        }
-#else
-       static int newfile_number = 0;
-       string s = "/lyx/dummy/dirname/newfile ["+tostr(++newfile_number)+"]";
-       FileInfo fi(s);
-       while (bufferlist.exists(s) || fi.readable()) {
-               ++newfile_number;
-               s = "/lyx/dummy/dirname/newfile ["+tostr(newfile_number)+"]";
-               fi.newFile(s);
-       }
-#endif
 
        // The template stuff
        string templname;
index 145899be6549f62f6e85d4cb9af911dd44f5d1d2..1cdf1a51f2e94bb03a32799511ad9b7597f51ead 100644 (file)
@@ -155,6 +155,7 @@ enum LyXRCTags {
        RC_DOCBOOK_TO_HTML_COMMAND,
        RC_DOCBOOK_TO_PDF_COMMAND,
        RC_WHEEL_JUMP,
+       RC_NEW_ASK_FILENAME,
        RC_LAST
 };
 
@@ -211,6 +212,7 @@ keyword_item lyxrcTags[] = {
         { "\\literate_extension", RC_LITERATE_EXTENSION },
        { "\\make_backup", RC_MAKE_BACKUP },
        { "\\mark_foreign_language", RC_MARK_FOREIGN_LANGUAGE },
+       { "\\new_ask_filename", RC_NEW_ASK_FILENAME },
        { "\\num_lastfiles", RC_NUMLASTFILES },
        { "\\override_x_deadkeys", RC_OVERRIDE_X_DEADKEYS },
        { "\\pdf_mode", RC_PDF_MODE },
@@ -376,6 +378,8 @@ void LyXRC::setDefaults() {
        language_auto_end = true;
        language_command_begin = "\\selectlanguage{$$lang}";
        language_command_end = "\\selectlanguage{$$lang}";
+       ///
+       new_ask_filename = false;
 
        ///
        date_insert_format = "%A, %e %B %Y";
@@ -1097,6 +1101,11 @@ int LyXRC::read(string const & filename)
                        if ( lexrc.next())
                                docbook_to_pdf_command = lexrc.GetString();
                        break;
+                       
+               case RC_NEW_ASK_FILENAME:
+                       if ( lexrc.next())
+                               new_ask_filename = lexrc.GetBool();
+                       break;
 
                case RC_LAST: break; // this is just a dummy
                }
index 79a08efd84bfc155a5a71183418a6cbddd4ae058..b6694c5aaff612a0be5bb8b521f3d0b4a8148182 100644 (file)
@@ -259,6 +259,8 @@ public:
        string docbook_to_html_command;
        ///
        string docbook_to_pdf_command;
+       ///
+       bool new_ask_filename;
 };
 
 ///