Angus Leeming wrote: > On Tuesday 02 July 2002 2:03 pm, Herbert Voss wrote: > >>I suppose that this belongs to Angus, >> >>who killed without any discussion some >>graphics stuff ... (default converter) >> >>http://www.lyx.org/cgi-bin/viewcvs.cgi/lyx-devel/src/graphics/GraphicsConve >>rter.C?r1=1.7&r2=1.8 >> > > Ahhhh. Thank you Herbert. I guess I forgot about this when trying to turn the > GraphicsConverter into coherent code. Certainly, I didn't /plan/ to remove > this code, but since I did remove it, I'm happy to own up. > > Personally, I think that we should not hard code such stuff into the > executable. Such stuff belongs in the configure script. You're "default" is > most certainly not mine.
It absoultely nonsense to define tons of converter commands with the same program. here is another try, where the user can define a default converter or not. Herbert -- http://www.lyx.org/help/
Index: lib/scripts/convertDefault.sh =================================================================== RCS file: lib/scripts/convertDefault.sh diff -N lib/scripts/convertDefault.sh --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lib/scripts/convertDefault.sh 2 Jul 2002 14:05:49 -0000 @@ -0,0 +1,4 @@ +#!/bin/bash +# converts an image from $1 to $2 format +convert -depth 8 $1 $2 +exit 0 \ No newline at end of file Index: src/graphics/GraphicsConverter.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/graphics/GraphicsConverter.C,v retrieving revision 1.9 diff -u -r1.9 GraphicsConverter.C --- src/graphics/GraphicsConverter.C 1 Jul 2002 14:31:57 -0000 1.9 +++ src/graphics/GraphicsConverter.C 2 Jul 2002 14:06:09 -0000 @@ -129,38 +129,45 @@ bool const success = build_script(from_file, to_file_base, from_format, to_format, script); - if (!success) - return; + // The converted image is to be stored in this file + to_file_ = ChangeExtension(to_file_base, formats.extension(to_format)); + + if (!success) { + script_file_ = string(); + script_command_ = + LibFileSearch("scripts", "convertDefault.sh") + + from_format + ':' + from_file + ' ' + + to_format + ':' + to_file_; + lyxerr[Debug::GRAPHICS] + << "\tNo converter defined! I use +convertDefault.sh\n\t" + << script_command_ << endl; + } else { - lyxerr[Debug::GRAPHICS] << "\tConversion script:" + lyxerr[Debug::GRAPHICS] << "\tConversion script:" << "\n--------------------------------------\n" << script.str().c_str() << "\n--------------------------------------\n"; - // Output the script to file. - static int counter = 0; - script_file_ = OnlyPath(to_file_base) + "lyxconvert" + - tostr(counter++) + ".sh"; - - std::ofstream fs(script_file_.c_str()); - if (!fs.good()) - return; - - fs << script.str().c_str(); - fs.close(); - - // The converted image is to be stored in this file - // We do not use ChangeExtension here because this is a - // basename, which may nevertheless contain a dot - to_file_ = to_file_base + '.' + formats.extension(to_format); - - // The command needed to run the conversion process - // We create a dummy command for ease of understanding of the - // list of forked processes. - // Note that 'sh ' is absolutely essential, or execvp will fail. - script_command_ = "sh " + script_file_ + " " + - OnlyFilename(from_file) + " " + to_format; - + // Output the script to file. + static int counter = 0; + script_file_ = OnlyPath(to_file_base) + "lyxconvert" + + tostr(counter++) + ".sh"; + + std::ofstream fs(script_file_.c_str()); + if (!fs.good()) + return; + + fs << script.str().c_str(); + fs.close(); + + // The command needed to run the conversion process + // We create a dummy command for ease of understanding of the + // list of forked processes. + // Note that 'sh ' is absolutely essential, or execvp will fail. + script_command_ = "sh " + script_file_ + " " + + // Output the script to file. + OnlyFilename(from_file) + " " + to_format; + } // All is ready to go valid_process_ = true; } Index: src/insets/insetgraphics.C =================================================================== RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/insets/insetgraphics.C,v retrieving revision 1.123 diff -u -r1.123 insetgraphics.C --- src/insets/insetgraphics.C 28 Jun 2002 11:22:56 -0000 1.123 +++ src/insets/insetgraphics.C 2 Jul 2002 14:06:12 -0000 @@ -748,11 +764,11 @@ // from ImageMagic: convert from:inname.from to:outname.to if (!converters.convert(buf, temp_file, outfile_base, from, to)) { string const command = - "convert " + - from + ':' + temp_file + ' ' + - to + ':' + outfile_base + '.' + to; + LibFileSearch("scripts", "convertDefault.sh") + + from + ':' + temp_file + ' ' + + to + ':' + outfile_base + '.' + to; lyxerr[Debug::GRAPHICS] - << "No converter defined! I use convert from ImageMagic:\n\t" + << "No converter defined! I use convertDefault.sh:\n\t" << command << endl; Systemcall one; one.startscript(Systemcall::Wait, command);