]> git.lyx.org Git - lyx.git/commitdiff
remove file->new asks for name
authorJohn Levon <levon@movementarian.org>
Thu, 11 Jul 2002 15:13:21 +0000 (15:13 +0000)
committerJohn Levon <levon@movementarian.org>
Thu, 11 Jul 2002 15:13:21 +0000 (15:13 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4606 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/bufferlist.C
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormPreferences.C
src/frontends/xforms/forms/form_preferences.fd
src/lyxfunc.C
src/lyxfunc.h
src/lyxrc.C
src/lyxrc.h

index 134668eb67699c32b5c6e587dce1c507f8ea4809..5dcd1d769941212f2756e0034f00dcce22677a15 100644 (file)
@@ -1,3 +1,12 @@
+2002-07-11  John Levon  <moz@compsoc.man.ac.uk>
+
+       * bufferlist.C:
+       * lyxfunc.h: 
+       * lyxfunc.C:
+       * lyxrc.h:
+       * lyxrc.C: remove file->new asks for name option, and let
+         buffer-new take an argument
 2002-07-11  John Levon  <moz@compsoc.man.ac.uk>
 
        * BufferView_pimpl.C: remove unneeded extra repaint()
index 1617e1ace31a704c6114ebd9d76387a8c8b88850..f185e713465307758ce320010ae103ea9a7283d3 100644 (file)
@@ -489,7 +489,7 @@ Buffer * BufferList::newFile(string const & name, string tname, bool isNamed)
                        b->paragraph->layout(textclasslist[b->params.textclass].defaultLayout());
        }
 
-       if (!lyxrc.new_ask_filename && !isNamed) {
+       if (!isNamed) {
                b->setUnnamed();
                b->setFileName(name);
        }
index c5656a15b8619d6d920d9692b0d7b6a42dd23f76..15f7b08be9546eac05f7309d5b93249f29cf1df1 100644 (file)
@@ -1,3 +1,8 @@
+2002-07-11  John Levon  <moz@compsoc.man.ac.uk>
+
+       * FormPreferences.C:
+       * forms/form_preferences.fd: remove file->new asks for name
 2002-07-11  John Levon  <moz@compsoc.man.ac.uk>
 
        * XWorkArea.h:
index a64cc2fa8d1fdea87d8689437be34d0887a68dfe..e0d6bb1838b4fb7d65998322b32f362fa5904ae1 100644 (file)
@@ -1822,7 +1822,6 @@ void FormPreferences::LnFmisc::apply() const
        lyxrc.auto_region_delete =
                fl_get_button(dialog_->check_auto_region_delete);
        lyxrc.exit_confirmation = fl_get_button(dialog_->check_exit_confirm);
-       lyxrc.new_ask_filename = fl_get_button(dialog_->check_ask_new_file);
        lyxrc.cursor_follows_scrollbar =
                fl_get_button(dialog_->check_cursor_follows_scrollbar);
        lyxrc.dialogs_iconify_with_main =
@@ -1870,7 +1869,6 @@ void FormPreferences::LnFmisc::build()
        setPrehandler(dialog_->check_auto_region_delete);
        setPrehandler(dialog_->check_exit_confirm);
        setPrehandler(dialog_->counter_autosave);
-       setPrehandler(dialog_->check_ask_new_file);
        setPrehandler(dialog_->check_cursor_follows_scrollbar);
        setPrehandler(dialog_->check_dialogs_iconify_with_main);
        setPrehandler(dialog_->check_preview_latex);
@@ -1891,8 +1889,6 @@ FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
                str = lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
        else if (ob == dialog_->check_exit_confirm)
                str = lyxrc.getDescription(LyXRC::RC_EXIT_CONFIRMATION);
-       else if (ob == dialog_->check_ask_new_file)
-               str = lyxrc.getDescription(LyXRC::RC_NEW_ASK_FILENAME);
        else if (ob == dialog_->check_cursor_follows_scrollbar)
                str = lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
        else if (ob == dialog_->check_dialogs_iconify_with_main)
@@ -1918,7 +1914,6 @@ void FormPreferences::LnFmisc::update()
        fl_set_button(dialog_->check_auto_region_delete,
                      lyxrc.auto_region_delete);
        fl_set_button(dialog_->check_exit_confirm, lyxrc.exit_confirmation);
-       fl_set_button(dialog_->check_ask_new_file, lyxrc.new_ask_filename);
        fl_set_button(dialog_->check_cursor_follows_scrollbar,
                      lyxrc.cursor_follows_scrollbar);
        fl_set_button(dialog_->check_dialogs_iconify_with_main,
index 770bc70d5d38f5eb8a31c6be59e528a566b5d728..0bfbe193bad5b50f911ea029ec200e2a77445b93 100644 (file)
@@ -973,7 +973,7 @@ argument: 0
 --------------------
 class: FL_BEGIN_GROUP
 type: 0
-box: 0 0 0
+box: 0 10 10 0
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_CENTER
@@ -1101,7 +1101,7 @@ argument: 0
 Name: form_preferences_lnf_misc
 Width: 450
 Height: 350
-Number of Objects: 18
+Number of Objects: 17
 
 --------------------
 class: FL_BOX
@@ -1142,7 +1142,7 @@ argument:
 --------------------
 class: FL_CHECKBUTTON
 type: PUSH_BUTTON
-box: 15 20 30 30
+box: 15 25 30 30
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_YELLOW
 alignment: FL_ALIGN_CENTER
@@ -1161,7 +1161,7 @@ argument: 0
 --------------------
 class: FL_CHECKBUTTON
 type: PUSH_BUTTON
-box: 15 50 30 30
+box: 15 65 30 30
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_YELLOW
 alignment: FL_ALIGN_CENTER
@@ -1180,26 +1180,7 @@ argument: 0
 --------------------
 class: FL_CHECKBUTTON
 type: PUSH_BUTTON
-box: 15 80 30 30
-boxtype: FL_NO_BOX
-colors: FL_COL1 FL_YELLOW
-alignment: FL_ALIGN_CENTER
-style: FL_NORMAL_STYLE
-size: FL_NORMAL_SIZE
-lcol: FL_BLACK
-label: File->New asks for name|#N
-shortcut: 
-resize: FL_RESIZE_ALL
-gravity: FL_NoGravity FL_NoGravity
-name: check_ask_new_file
-callback: C_FormBaseDeprecatedInputCB
-argument: 0
-       value: 1
-
---------------------
-class: FL_CHECKBUTTON
-type: PUSH_BUTTON
-box: 15 110 30 30
+box: 15 105 30 30
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_YELLOW
 alignment: FL_ALIGN_CENTER
@@ -1218,7 +1199,7 @@ argument: 0
 --------------------
 class: FL_CHECKBUTTON
 type: PUSH_BUTTON
-box: 15 140 30 30
+box: 15 145 30 30
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_YELLOW
 alignment: FL_ALIGN_CENTER
@@ -1281,7 +1262,7 @@ argument: 0
 --------------------
 class: FL_BEGIN_GROUP
 type: 0
-box: 0 0 0
+box: 0 10 10 0
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_MCOL
 alignment: FL_ALIGN_CENTER
@@ -1426,7 +1407,7 @@ argument:
 --------------------
 class: FL_CHECKBUTTON
 type: PUSH_BUTTON
-box: 15 170 30 30
+box: 15 185 30 30
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_YELLOW
 alignment: FL_ALIGN_CENTER
index d1d920895f6c30ff25165657037550bbfdb3a041..d88688876ca8006d4a68178a13ac8cdf04f18af6 100644 (file)
@@ -1069,11 +1069,11 @@ string const LyXFunc::dispatch(kb_action action, string argument)
 
                // --- Menus -----------------------------------------------
        case LFUN_MENUNEW:
-               menuNew(false);
+               menuNew(argument, false);
                break;
 
        case LFUN_MENUNEWTMPLT:
-               menuNew(true);
+               menuNew(argument, true);
                break;
 
        case LFUN_CLOSEBUFFER:
@@ -1690,9 +1690,10 @@ void LyXFunc::setupLocalKeymap()
 }
 
 
-void LyXFunc::menuNew(bool fromTemplate)
+void LyXFunc::menuNew(string const & name, bool fromTemplate)
 {
        string initpath = lyxrc.document_path;
+       string filename(name);
 
        if (owner->view()->available()) {
                string const trypath = owner->buffer()->filePath();
@@ -1702,86 +1703,17 @@ void LyXFunc::menuNew(bool fromTemplate)
        }
 
        static int newfile_number;
-       string s;
 
-       if (lyxrc.new_ask_filename) {
-               FileDialog fileDlg(owner, _("Enter filename for new document"),
-                                  LFUN_SELECT_FILE_SYNC,
-                       make_pair(string(_("Documents|#o#O")),
-                                 string(lyxrc.document_path)),
-                       make_pair(string(_("Templates|#T#t")),
-                                 string(lyxrc.template_path)));
-
-               FileDialog::Result result =
-                       fileDlg.Select(initpath,
-                                      _("*.lyx|LyX Documents (*.lyx)"),
-                                      _("newfile"));
-
-               if (result.second.empty()) {
-                       owner->message(_("Canceled."));
-                       lyxerr[Debug::INFO] << "New Document Cancelled." << endl;
-                       return;
-               }
-
-               // get absolute path of file and make sure the filename ends
-               // with .lyx
-               s = MakeAbsPath(result.second);
-               if (!IsLyXFilename(s))
-                       s += ".lyx";
-
-               // Check if the document already is open
-               if (bufferlist.exists(s)) {
-                       switch (Alert::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)))
-                               // If close is canceled, we cancel here too.
-                                       return;
-                               break;
-                       case 2: // No: switch to the open document
-                               owner->view()->buffer(bufferlist.getBuffer(s));
-                               return;
-                       case 3: // Cancel: Do nothing
-                               owner->message(_("Canceled."));
-                               return;
-                       }
-               }
-               // Check whether the file already exists
-               FileInfo fi(s);
-               if (fi.readable() &&
-                   Alert::askQuestion(_("File already exists:"),
-                               MakeDisplayPath(s, 50),
-                               _("Do you want to open the document?"))) {
-                               // loads document
-                       string const disp_fn(MakeDisplayPath(s));
-
-                       ostringstream str;
-                       str << _("Opening  document") << ' '
-                           << disp_fn << "...";
-
-                       owner->message(str.str().c_str());
-                       owner->view()->buffer(bufferlist.loadLyXFile(s));
-                       ostringstream str2;
-                       str2 << _("Document") << ' '
-                            << disp_fn << ' ' << _("opened.");
-
-                       owner->message(str2.str().c_str());
-
-                       return;
-               }
-       } else {
-               s = AddName(lyxrc.document_path,
+       if (filename.empty()) {
+               filename = AddName(lyxrc.document_path,
                            "newfile" + tostr(++newfile_number) + ".lyx");
-               FileInfo fi(s);
-               while (bufferlist.exists(s) || fi.readable()) {
+               FileInfo fi(filename);
+               while (bufferlist.exists(filename) || fi.readable()) {
                        ++newfile_number;
-                       s = AddName(lyxrc.document_path,
+                       filename = AddName(lyxrc.document_path,
                                    "newfile" + tostr(newfile_number) +
                                    ".lyx");
-                       fi.newFile(s);
+                       fi.newFile(filename);
                }
        }
 
@@ -1809,9 +1741,7 @@ void LyXFunc::menuNew(bool fromTemplate)
                templname = fname;
        }
 
-       // find a free buffer
-       lyxerr[Debug::INFO] << "Find a free buffer." << endl;
-       owner->view()->buffer(bufferlist.newFile(s, templname));
+       owner->view()->buffer(bufferlist.newFile(filename, templname, !name.empty()));
 }
 
 
index 9f72d2c406e12ce607312015f81a2e9b5f581c58..70153ce12135e1b0ac11241990898f32d6a8b2ec 100644 (file)
@@ -118,7 +118,7 @@ private:
        // I think the following should be moved to BufferView. (Asger)
 
        ///
-       void menuNew(bool fromTemplate);
+       void menuNew(string const & argument, bool fromTemplate);
 
        ///
        void open(string const &);
index e75b78aab89550241dbe5fe7e83362c03574a547..7ad40b5f08d40bba5050fd4e70844d5fc0ac2439 100644 (file)
@@ -88,7 +88,6 @@ keyword_item lyxrcTags[] = {
        { "\\lastfiles", LyXRC::RC_LASTFILES },
        { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
        { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
-       { "\\new_ask_filename", LyXRC::RC_NEW_ASK_FILENAME },
        { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
        { "\\override_x_deadkeys", LyXRC::RC_OVERRIDE_X_DEADKEYS },
        { "\\personal_dictionary", LyXRC::RC_PERS_DICT },
@@ -250,8 +249,6 @@ void LyXRC::setDefaults() {
        language_command_begin = "\\selectlanguage{$$lang}";
        language_command_local = "\\foreignlanguage{$$lang}{";
        default_language = "english";
-       //
-       new_ask_filename = false;
 
        //
        date_insert_format = "%A, %e %B %Y";
@@ -882,10 +879,6 @@ int LyXRC::read(string const & filename)
                                mark_foreign_language = lexrc.getBool();
                        break;
 
-               case RC_NEW_ASK_FILENAME:
-                       if (lexrc.next())
-                               new_ask_filename = lexrc.getBool();
-                       break;
                case RC_CONVERTER: {
                        string from, to, command, flags;
                        if (lexrc.next())
@@ -1595,11 +1588,6 @@ void LyXRC::output(ostream & os) const
                if (auto_number != system_lyxrc.auto_number) {
                        os << "\\auto_number " << tostr(auto_number) << "\n";
                }
-       case RC_NEW_ASK_FILENAME:
-               if (new_ask_filename != system_lyxrc.new_ask_filename) {
-                       os << "\\new_ask_filename " << tostr(new_ask_filename)
-                          << "\n";
-               }
        case RC_DEFAULT_LANGUAGE:
                if (default_language != system_lyxrc.default_language) {
                        os << "\\default_language " << default_language << "\n";
index ba1a8beb61e459b791f9bbc77e96e2622e0784a3..96d243e53d5681cd5a338ae22ef699728679a255 100644 (file)
@@ -337,8 +337,6 @@ enum LyXRCTags {
        /// Do we have to use a GUI?
        bool use_gui;
        ///
-       bool new_ask_filename;
-       ///
        string default_language;
        ///
        bool cursor_follows_scrollbar;