From: John Levon Date: Thu, 11 Jul 2002 15:13:21 +0000 (+0000) Subject: remove file->new asks for name X-Git-Tag: 1.6.10~18901 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=fa02980a7ea3578ed74bf4a9faf1242e06340a62;p=lyx.git remove file->new asks for name git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4606 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/ChangeLog b/src/ChangeLog index 134668eb67..5dcd1d7699 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,12 @@ +2002-07-11 John Levon + + * 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 * BufferView_pimpl.C: remove unneeded extra repaint() diff --git a/src/bufferlist.C b/src/bufferlist.C index 1617e1ace3..f185e71346 100644 --- a/src/bufferlist.C +++ b/src/bufferlist.C @@ -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); } diff --git a/src/frontends/xforms/ChangeLog b/src/frontends/xforms/ChangeLog index c5656a15b8..15f7b08be9 100644 --- a/src/frontends/xforms/ChangeLog +++ b/src/frontends/xforms/ChangeLog @@ -1,3 +1,8 @@ +2002-07-11 John Levon + + * FormPreferences.C: + * forms/form_preferences.fd: remove file->new asks for name + 2002-07-11 John Levon * XWorkArea.h: diff --git a/src/frontends/xforms/FormPreferences.C b/src/frontends/xforms/FormPreferences.C index a64cc2fa8d..e0d6bb1838 100644 --- a/src/frontends/xforms/FormPreferences.C +++ b/src/frontends/xforms/FormPreferences.C @@ -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, diff --git a/src/frontends/xforms/forms/form_preferences.fd b/src/frontends/xforms/forms/form_preferences.fd index 770bc70d5d..0bfbe193ba 100644 --- a/src/frontends/xforms/forms/form_preferences.fd +++ b/src/frontends/xforms/forms/form_preferences.fd @@ -973,7 +973,7 @@ argument: 0 -------------------- class: FL_BEGIN_GROUP type: 0 -box: 0 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 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 diff --git a/src/lyxfunc.C b/src/lyxfunc.C index d1d920895f..d88688876c 100644 --- a/src/lyxfunc.C +++ b/src/lyxfunc.C @@ -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())); } diff --git a/src/lyxfunc.h b/src/lyxfunc.h index 9f72d2c406..70153ce121 100644 --- a/src/lyxfunc.h +++ b/src/lyxfunc.h @@ -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 &); diff --git a/src/lyxrc.C b/src/lyxrc.C index e75b78aab8..7ad40b5f08 100644 --- a/src/lyxrc.C +++ b/src/lyxrc.C @@ -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"; diff --git a/src/lyxrc.h b/src/lyxrc.h index ba1a8beb61..96d243e53d 100644 --- a/src/lyxrc.h +++ b/src/lyxrc.h @@ -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;