On Tue, Apr 20, 2010 at 09:20:32AM -0400, rgheck wrote:

> On 04/20/2010 09:16 AM, Jean-Marc Lasgouttes wrote:
> >>In this case, I don't see how we could take advantage of that.
> >>If the alert is never displayed again, the choice cannot be reverted.
> >>Then, the alert doesn't distinguish between ancillary files and
> >>main file.
> >
> >Ah, we have no way to revert these dialog choices? This is very bad.
> >
> I think the "don't show it again" thing is a per-session option. You
> see it again the next session.

Using a RC setting you don't have to restart lyx as you can change it
in the preferences. The attached patch implements (minus the GUI part)
a "\export_overwrite what" setting, where "what" is "ask", "main", or
"all". This is independent from the choice made in batch exports.

-- 
Enrico
Index: src/LyXRC.h
===================================================================
--- src/LyXRC.h	(revisione 34227)
+++ src/LyXRC.h	(copia locale)
@@ -76,6 +76,7 @@ public:
 		RC_EDITOR_ALTERNATIVES,
 		RC_ESC_CHARS,
 		RC_EXAMPLEPATH,
+		RC_EXPORT_OVERWRITE,
 		RC_FONT_ENCODING,
 		RC_FORMAT,
 		RC_FORWARD_SEARCH_DVI,
@@ -496,6 +497,8 @@ public:
 	std::string forward_search_dvi;
 	///
 	std::string forward_search_pdf;
+	///
+	int export_overwrite;
 };
 
 
Index: src/LyXRC.cpp
===================================================================
--- src/LyXRC.cpp	(revisione 34227)
+++ src/LyXRC.cpp	(copia locale)
@@ -23,6 +23,7 @@
 #include "FontEnums.h"
 #include "Format.h"
 #include "Lexer.h"
+#include "LyX.h"
 #include "Mover.h"
 #include "Session.h"
 #include "version.h"
@@ -92,6 +93,7 @@ LexerKeyword lyxrcTags[] = {
 	{ "\\editor_alternatives", LyXRC::RC_EDITOR_ALTERNATIVES },
 	{ "\\escape_chars", LyXRC::RC_ESC_CHARS },
 	{ "\\example_path", LyXRC::RC_EXAMPLEPATH },
+	{ "\\export_overwrite", LyXRC::RC_EXPORT_OVERWRITE },
 	{ "\\font_encoding", LyXRC::RC_FONT_ENCODING },
 	{ "\\format", LyXRC::RC_FORMAT },
 	{ "\\forward_search_dvi", LyXRC::RC_FORWARD_SEARCH_DVI },
@@ -330,6 +332,7 @@ void LyXRC::setDefaults()
 	single_close_tab_button = false;
 	forward_search_dvi = string();
 	forward_search_pdf = string();
+	export_overwrite = NO_FILES;
 
 	// Fullscreen settings
 	full_screen_limit = false;
@@ -1168,6 +1171,21 @@ int LyXRC::read(Lexer & lexrc)
 			if (lexrc.next(true)) 
 				forward_search_pdf = lexrc.getString();
 			break;
+		case RC_EXPORT_OVERWRITE:
+			if (lexrc.next()) {
+				string const tmp = lexrc.getString();
+				if (tmp == "all" || tmp == "true")
+					export_overwrite = ALL_FILES;
+				else if (tmp == "main")
+					export_overwrite = MAIN_FILE;
+				else {
+					export_overwrite = NO_FILES;
+					if (tmp != "ask" && tmp != "false")
+						LYXERR0("Unrecognized export_overwrite status \""
+						       << tmp << '"');
+				}
+			}
+			break;
 
 		// Obsoteted in 1.4.0
 		case RC_USETEMPDIR:
@@ -2494,6 +2512,25 @@ void LyXRC::write(ostream & os, bool ign
 		}
 		if (tag != RC_LAST)
 			break;
+	case RC_EXPORT_OVERWRITE:
+		if (ignore_system_lyxrc ||
+		    export_overwrite != system_lyxrc.export_overwrite) {
+			string status;
+			switch (export_overwrite) {
+			case NO_FILES:
+				status = "ask";
+				break;
+			case MAIN_FILE:
+				status = "main";
+				break;
+			case ALL_FILES:
+				status = "all";
+				break;
+			}
+			os << "\\export_overwrite " << status << '\n';
+		}
+		if (tag != RC_LAST)
+			break;
 
 		os << "\n#\n"
 		   << "# FORMATS SECTION ##########################\n"
@@ -2831,6 +2868,7 @@ void actOnUpdatedPrefs(LyXRC const & lyx
 	case LyXRC::RC_VIEWER_ALTERNATIVES:
 	case LyXRC::RC_FORWARD_SEARCH_DVI:
 	case LyXRC::RC_FORWARD_SEARCH_PDF:
+	case LyXRC::RC_EXPORT_OVERWRITE:
 	case LyXRC::RC_LAST:
 		break;
 	}
Index: src/Buffer.cpp
===================================================================
--- src/Buffer.cpp	(revisione 34227)
+++ src/Buffer.cpp	(copia locale)
@@ -3377,8 +3377,9 @@ bool Buffer::doExport(string const & for
 	vector<ExportedFile> const files =
 		runparams.exportdata->externalFiles(format);
 	string const dest = onlyPath(result_file);
-	CopyStatus status = !use_gui && force_overwrite == ALL_FILES ? FORCE
-								     : SUCCESS;
+	bool use_force = use_gui ? lyxrc.export_overwrite == ALL_FILES
+				 : force_overwrite == ALL_FILES;
+	CopyStatus status = use_force ? FORCE : SUCCESS;
 	
 	vector<ExportedFile>::const_iterator it = files.begin();
 	vector<ExportedFile>::const_iterator const en = files.end();
@@ -3393,7 +3394,9 @@ bool Buffer::doExport(string const & for
 		message(_("Document export cancelled."));
 	} else if (tmp_result_file.exists()) {
 		// Finally copy the main file
-		if (!use_gui && force_overwrite != NO_FILES)
+		use_force = use_gui ? lyxrc.export_overwrite != NO_FILES
+				    : force_overwrite != NO_FILES;
+		if (status == SUCCESS && use_force)
 			status = FORCE;
 		status = copyFile(format, tmp_result_file,
 			FileName(result_file), result_file,

Reply via email to