+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()
b->paragraph->layout(textclasslist[b->params.textclass].defaultLayout());
}
- if (!lyxrc.new_ask_filename && !isNamed) {
+ if (!isNamed) {
b->setUnnamed();
b->setFileName(name);
}
+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:
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 =
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);
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)
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,
--------------------
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
Name: form_preferences_lnf_misc
Width: 450
Height: 350
-Number of Objects: 18
+Number of Objects: 17
--------------------
class: FL_BOX
--------------------
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
--------------------
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
--------------------
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
--------------------
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
--------------------
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
--------------------
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
// --- Menus -----------------------------------------------
case LFUN_MENUNEW:
- menuNew(false);
+ menuNew(argument, false);
break;
case LFUN_MENUNEWTMPLT:
- menuNew(true);
+ menuNew(argument, true);
break;
case LFUN_CLOSEBUFFER:
}
-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();
}
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);
}
}
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()));
}
// 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 &);
{ "\\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 },
language_command_begin = "\\selectlanguage{$$lang}";
language_command_local = "\\foreignlanguage{$$lang}{";
default_language = "english";
- //
- new_ask_filename = false;
//
date_insert_format = "%A, %e %B %Y";
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())
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";
/// Do we have to use a GUI?
bool use_gui;
///
- bool new_ask_filename;
- ///
string default_language;
///
bool cursor_follows_scrollbar;