remove file->new asks for name

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@4606 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
John Levon 2002-07-11 15:13:21 +00:00
parent 61fc371093
commit fa02980a7e
9 changed files with 35 additions and 129 deletions

View 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> 2002-07-11 John Levon <moz@compsoc.man.ac.uk>
* BufferView_pimpl.C: remove unneeded extra repaint() * BufferView_pimpl.C: remove unneeded extra repaint()

View File

@ -489,7 +489,7 @@ Buffer * BufferList::newFile(string const & name, string tname, bool isNamed)
b->paragraph->layout(textclasslist[b->params.textclass].defaultLayout()); b->paragraph->layout(textclasslist[b->params.textclass].defaultLayout());
} }
if (!lyxrc.new_ask_filename && !isNamed) { if (!isNamed) {
b->setUnnamed(); b->setUnnamed();
b->setFileName(name); b->setFileName(name);
} }

View 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> 2002-07-11 John Levon <moz@compsoc.man.ac.uk>
* XWorkArea.h: * XWorkArea.h:

View File

@ -1822,7 +1822,6 @@ void FormPreferences::LnFmisc::apply() const
lyxrc.auto_region_delete = lyxrc.auto_region_delete =
fl_get_button(dialog_->check_auto_region_delete); fl_get_button(dialog_->check_auto_region_delete);
lyxrc.exit_confirmation = fl_get_button(dialog_->check_exit_confirm); 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 = lyxrc.cursor_follows_scrollbar =
fl_get_button(dialog_->check_cursor_follows_scrollbar); fl_get_button(dialog_->check_cursor_follows_scrollbar);
lyxrc.dialogs_iconify_with_main = lyxrc.dialogs_iconify_with_main =
@ -1870,7 +1869,6 @@ void FormPreferences::LnFmisc::build()
setPrehandler(dialog_->check_auto_region_delete); setPrehandler(dialog_->check_auto_region_delete);
setPrehandler(dialog_->check_exit_confirm); setPrehandler(dialog_->check_exit_confirm);
setPrehandler(dialog_->counter_autosave); setPrehandler(dialog_->counter_autosave);
setPrehandler(dialog_->check_ask_new_file);
setPrehandler(dialog_->check_cursor_follows_scrollbar); setPrehandler(dialog_->check_cursor_follows_scrollbar);
setPrehandler(dialog_->check_dialogs_iconify_with_main); setPrehandler(dialog_->check_dialogs_iconify_with_main);
setPrehandler(dialog_->check_preview_latex); setPrehandler(dialog_->check_preview_latex);
@ -1891,8 +1889,6 @@ FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
str = lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE); str = lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
else if (ob == dialog_->check_exit_confirm) else if (ob == dialog_->check_exit_confirm)
str = lyxrc.getDescription(LyXRC::RC_EXIT_CONFIRMATION); 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) else if (ob == dialog_->check_cursor_follows_scrollbar)
str = lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR); str = lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
else if (ob == dialog_->check_dialogs_iconify_with_main) 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, fl_set_button(dialog_->check_auto_region_delete,
lyxrc.auto_region_delete); lyxrc.auto_region_delete);
fl_set_button(dialog_->check_exit_confirm, lyxrc.exit_confirmation); 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, fl_set_button(dialog_->check_cursor_follows_scrollbar,
lyxrc.cursor_follows_scrollbar); lyxrc.cursor_follows_scrollbar);
fl_set_button(dialog_->check_dialogs_iconify_with_main, fl_set_button(dialog_->check_dialogs_iconify_with_main,

View File

@ -973,7 +973,7 @@ argument: 0
-------------------- --------------------
class: FL_BEGIN_GROUP class: FL_BEGIN_GROUP
type: 0 type: 0
box: 0 0 0 0 box: 0 10 10 0
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_COL1 FL_MCOL colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_CENTER alignment: FL_ALIGN_CENTER
@ -1101,7 +1101,7 @@ argument: 0
Name: form_preferences_lnf_misc Name: form_preferences_lnf_misc
Width: 450 Width: 450
Height: 350 Height: 350
Number of Objects: 18 Number of Objects: 17
-------------------- --------------------
class: FL_BOX class: FL_BOX
@ -1142,7 +1142,7 @@ argument:
-------------------- --------------------
class: FL_CHECKBUTTON class: FL_CHECKBUTTON
type: PUSH_BUTTON type: PUSH_BUTTON
box: 15 20 30 30 box: 15 25 30 30
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER alignment: FL_ALIGN_CENTER
@ -1161,7 +1161,7 @@ argument: 0
-------------------- --------------------
class: FL_CHECKBUTTON class: FL_CHECKBUTTON
type: PUSH_BUTTON type: PUSH_BUTTON
box: 15 50 30 30 box: 15 65 30 30
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER alignment: FL_ALIGN_CENTER
@ -1180,26 +1180,7 @@ argument: 0
-------------------- --------------------
class: FL_CHECKBUTTON class: FL_CHECKBUTTON
type: PUSH_BUTTON type: PUSH_BUTTON
box: 15 80 30 30 box: 15 105 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
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER alignment: FL_ALIGN_CENTER
@ -1218,7 +1199,7 @@ argument: 0
-------------------- --------------------
class: FL_CHECKBUTTON class: FL_CHECKBUTTON
type: PUSH_BUTTON type: PUSH_BUTTON
box: 15 140 30 30 box: 15 145 30 30
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER alignment: FL_ALIGN_CENTER
@ -1281,7 +1262,7 @@ argument: 0
-------------------- --------------------
class: FL_BEGIN_GROUP class: FL_BEGIN_GROUP
type: 0 type: 0
box: 0 0 0 0 box: 0 10 10 0
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_COL1 FL_MCOL colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_CENTER alignment: FL_ALIGN_CENTER
@ -1426,7 +1407,7 @@ argument:
-------------------- --------------------
class: FL_CHECKBUTTON class: FL_CHECKBUTTON
type: PUSH_BUTTON type: PUSH_BUTTON
box: 15 170 30 30 box: 15 185 30 30
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER alignment: FL_ALIGN_CENTER

View File

@ -1069,11 +1069,11 @@ string const LyXFunc::dispatch(kb_action action, string argument)
// --- Menus ----------------------------------------------- // --- Menus -----------------------------------------------
case LFUN_MENUNEW: case LFUN_MENUNEW:
menuNew(false); menuNew(argument, false);
break; break;
case LFUN_MENUNEWTMPLT: case LFUN_MENUNEWTMPLT:
menuNew(true); menuNew(argument, true);
break; break;
case LFUN_CLOSEBUFFER: 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 initpath = lyxrc.document_path;
string filename(name);
if (owner->view()->available()) { if (owner->view()->available()) {
string const trypath = owner->buffer()->filePath(); string const trypath = owner->buffer()->filePath();
@ -1702,86 +1703,17 @@ void LyXFunc::menuNew(bool fromTemplate)
} }
static int newfile_number; static int newfile_number;
string s;
if (lyxrc.new_ask_filename) { if (filename.empty()) {
FileDialog fileDlg(owner, _("Enter filename for new document"), filename = AddName(lyxrc.document_path,
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,
"newfile" + tostr(++newfile_number) + ".lyx"); "newfile" + tostr(++newfile_number) + ".lyx");
FileInfo fi(s); FileInfo fi(filename);
while (bufferlist.exists(s) || fi.readable()) { while (bufferlist.exists(filename) || fi.readable()) {
++newfile_number; ++newfile_number;
s = AddName(lyxrc.document_path, filename = AddName(lyxrc.document_path,
"newfile" + tostr(newfile_number) + "newfile" + tostr(newfile_number) +
".lyx"); ".lyx");
fi.newFile(s); fi.newFile(filename);
} }
} }
@ -1809,9 +1741,7 @@ void LyXFunc::menuNew(bool fromTemplate)
templname = fname; templname = fname;
} }
// find a free buffer owner->view()->buffer(bufferlist.newFile(filename, templname, !name.empty()));
lyxerr[Debug::INFO] << "Find a free buffer." << endl;
owner->view()->buffer(bufferlist.newFile(s, templname));
} }

View File

@ -118,7 +118,7 @@ private:
// I think the following should be moved to BufferView. (Asger) // 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 &); void open(string const &);

View File

@ -88,7 +88,6 @@ keyword_item lyxrcTags[] = {
{ "\\lastfiles", LyXRC::RC_LASTFILES }, { "\\lastfiles", LyXRC::RC_LASTFILES },
{ "\\make_backup", LyXRC::RC_MAKE_BACKUP }, { "\\make_backup", LyXRC::RC_MAKE_BACKUP },
{ "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE }, { "\\mark_foreign_language", LyXRC::RC_MARK_FOREIGN_LANGUAGE },
{ "\\new_ask_filename", LyXRC::RC_NEW_ASK_FILENAME },
{ "\\num_lastfiles", LyXRC::RC_NUMLASTFILES }, { "\\num_lastfiles", LyXRC::RC_NUMLASTFILES },
{ "\\override_x_deadkeys", LyXRC::RC_OVERRIDE_X_DEADKEYS }, { "\\override_x_deadkeys", LyXRC::RC_OVERRIDE_X_DEADKEYS },
{ "\\personal_dictionary", LyXRC::RC_PERS_DICT }, { "\\personal_dictionary", LyXRC::RC_PERS_DICT },
@ -250,8 +249,6 @@ void LyXRC::setDefaults() {
language_command_begin = "\\selectlanguage{$$lang}"; language_command_begin = "\\selectlanguage{$$lang}";
language_command_local = "\\foreignlanguage{$$lang}{"; language_command_local = "\\foreignlanguage{$$lang}{";
default_language = "english"; default_language = "english";
//
new_ask_filename = false;
// //
date_insert_format = "%A, %e %B %Y"; date_insert_format = "%A, %e %B %Y";
@ -882,10 +879,6 @@ int LyXRC::read(string const & filename)
mark_foreign_language = lexrc.getBool(); mark_foreign_language = lexrc.getBool();
break; break;
case RC_NEW_ASK_FILENAME:
if (lexrc.next())
new_ask_filename = lexrc.getBool();
break;
case RC_CONVERTER: { case RC_CONVERTER: {
string from, to, command, flags; string from, to, command, flags;
if (lexrc.next()) if (lexrc.next())
@ -1595,11 +1588,6 @@ void LyXRC::output(ostream & os) const
if (auto_number != system_lyxrc.auto_number) { if (auto_number != system_lyxrc.auto_number) {
os << "\\auto_number " << tostr(auto_number) << "\n"; 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: case RC_DEFAULT_LANGUAGE:
if (default_language != system_lyxrc.default_language) { if (default_language != system_lyxrc.default_language) {
os << "\\default_language " << default_language << "\n"; os << "\\default_language " << default_language << "\n";

View File

@ -337,8 +337,6 @@ enum LyXRCTags {
/// Do we have to use a GUI? /// Do we have to use a GUI?
bool use_gui; bool use_gui;
/// ///
bool new_ask_filename;
///
string default_language; string default_language;
/// ///
bool cursor_follows_scrollbar; bool cursor_follows_scrollbar;