X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Ftool%2Fmain.cpp;h=66efb3cd8148fa8d46a535c22679fbf470a78c5d;hb=4b886acca3929def466b0fb6a948bb5c37029190;hp=eb609c553f773f018fa02a73af6023fa14041a17;hpb=e8a065f2385c219c511b57dac52786120bfa097d;p=synfig.git diff --git a/synfig-core/trunk/src/tool/main.cpp b/synfig-core/trunk/src/tool/main.cpp index eb609c5..66efb3c 100644 --- a/synfig-core/trunk/src/tool/main.cpp +++ b/synfig-core/trunk/src/tool/main.cpp @@ -1,11 +1,12 @@ /* === S Y N F I G ========================================================= */ -/*! \file main.cpp +/*! \file tool/main.cpp ** \brief SYNFIG Tool ** -** $Id: main.cpp,v 1.9 2005/01/23 04:41:10 darco Exp $ +** $Id$ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2007 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -34,6 +35,7 @@ #include #include #include +#include #include #include @@ -56,18 +58,22 @@ using namespace synfig; /* === M A C R O S ========================================================= */ +#undef _ +#define _(x) gettext(x) + enum exit_code { - SYNFIGTOOL_OK =0, - SYNFIGTOOL_FILENOTFOUND =1, - SYNFIGTOOL_BORRED =2, - SYNFIGTOOL_HELP =3, - SYNFIGTOOL_UNKNOWNARGUMENT =4, - SYNFIGTOOL_UNKNOWNERROR =5, - SYNFIGTOOL_INVALIDTARGET =6, - SYNFIGTOOL_RENDERFAILURE =7, - SYNFIGTOOL_BLANK =8, - SYNFIGTOOL_BADVERSION =9 + SYNFIGTOOL_OK = 0, + SYNFIGTOOL_FILENOTFOUND = 1, + SYNFIGTOOL_BORED = 2, + SYNFIGTOOL_HELP = 3, + SYNFIGTOOL_UNKNOWNARGUMENT = 4, + SYNFIGTOOL_UNKNOWNERROR = 5, + SYNFIGTOOL_INVALIDTARGET = 6, + SYNFIGTOOL_RENDERFAILURE = 7, + SYNFIGTOOL_BLANK = 8, + SYNFIGTOOL_BADVERSION = 9, + SYNFIGTOOL_MISSINGARGUMENT =10 }; #ifndef VERSION @@ -94,11 +100,11 @@ bool print_benchmarks=false; class Progress : public synfig::ProgressCallback { const char *program; - + public: - + Progress(const char *name):program(name) { } - + virtual bool task(const String &task) { @@ -121,7 +127,7 @@ public: } virtual bool - amount_complete(int current, int total) + amount_complete(int /*current*/, int /*total*/) { return true; } @@ -130,16 +136,16 @@ public: class RenderProgress : public synfig::ProgressCallback { string taskname; - + etl::clock clk; int clk_scanline; // The scanline at which the clock was reset etl::clock clk2; - float last_time; + float last_time; public: - - RenderProgress():clk_scanline(0) { } - + + RenderProgress():clk_scanline(0), last_time(0) { } + virtual bool task(const String &thetask) { @@ -177,7 +183,7 @@ public: if(clk2()<0.2) return true; clk2.reset(); - + if(scanline) seconds=(int)time+1; else @@ -186,7 +192,7 @@ public: clk.reset(); clk_scanline=scanline; } - + if(seconds<0) { clk.reset(); @@ -201,7 +207,7 @@ public: days++,hours-=24; while(days>=7) weeks++,days-=7; - + cerr<first<first<first<begin() != '-') @@ -565,12 +571,16 @@ int extract_arg_cluster(arg_list_t &arg_list,arg_list_t &cluster) cluster.push_back(*iter); arg_list.erase(iter); iter=next++; + if (iter==arg_list.end()) { + error("The `%s' flag requires a value. Use --help for a list of options.", cluster.back().c_str()); + return SYNFIGTOOL_MISSINGARGUMENT; + } } - + cluster.push_back(*iter); arg_list.erase(iter); } - + return SYNFIGTOOL_OK; } @@ -588,14 +598,14 @@ int extract_RendDesc(arg_list_t &arg_list,RendDesc &desc) w=atoi(iter->c_str()); arg_list.erase(iter); } - if(*iter=="-h") + else if(*iter=="-h") { arg_list.erase(iter); iter=next++; h=atoi(iter->c_str()); arg_list.erase(iter); } - if(*iter=="-a") + else if(*iter=="-a") { int a; arg_list.erase(iter); @@ -605,7 +615,7 @@ int extract_RendDesc(arg_list_t &arg_list,RendDesc &desc) VERBOSE_OUT(1)<c_str()))); - //arg_list.erase(iter); + arg_list.erase(iter); } } if(w&&h) @@ -720,7 +730,7 @@ int extract_quality(arg_list_t &arg_list,int &quality) arg_list.erase(iter); } } - + return SYNFIGTOOL_OK; } @@ -738,7 +748,7 @@ int extract_threads(arg_list_t &arg_list,int &threads) arg_list.erase(iter); } } - + return SYNFIGTOOL_OK; } @@ -746,7 +756,7 @@ int extract_target(arg_list_t &arg_list,string &type) { arg_list_t::iterator iter, next; type.clear(); - + for(next=arg_list.begin(),iter=next++;iter!=arg_list.end();iter=next++) { if(*iter=="-t") @@ -765,7 +775,7 @@ int extract_append(arg_list_t &arg_list,string &filename) { arg_list_t::iterator iter, next; filename.clear(); - + for(next=arg_list.begin(),iter=next++;iter!=arg_list.end();iter=next++) { if(*iter=="--append") @@ -785,7 +795,7 @@ int extract_outfile(arg_list_t &arg_list,string &outfile) arg_list_t::iterator iter, next; int ret=SYNFIGTOOL_FILENOTFOUND; outfile.clear(); - + for(next=arg_list.begin(),iter=next++;iter!=arg_list.end();iter=next++) { if(*iter=="-o") @@ -805,7 +815,7 @@ int extract_canvasid(arg_list_t &arg_list,string &canvasid) { arg_list_t::iterator iter, next; //canvasid.clear(); - + for(next=arg_list.begin(),iter=next++;iter!=arg_list.end();iter=next++) { if(*iter=="-c") @@ -829,10 +839,14 @@ int main(int argc, char *argv[]) int i; arg_list_t arg_list; job_list_t job_list; - + + setlocale(LC_ALL, ""); + bindtextdomain("synfig", LOCALEDIR); + textdomain("synfig"); + progname=argv[0]; Progress p(argv[0]); - + if(!SYNFIG_CHECK_VERSION()) { cerr<<_("FATAL: Synfig Version Mismatch")<set_time(0); - + string canvasid; extract_canvasid(imageargs,canvasid); if(!canvasid.empty()) @@ -899,7 +916,7 @@ int main(int argc, char *argv[]) cerr<<_("Throwing out job...")<rend_desc()); extract_target(imageargs,target_name); extract_threads(imageargs,threads); @@ -941,25 +958,21 @@ int main(int argc, char *argv[]) VERBOSE_OUT(2)<<_("Appended contents of ")<set_canvas(job_list.front().canvas); - VERBOSE_OUT(4)<<_("Setting the quality of the target...")<set_quality(job_list.front().quality); } - + // Set the threads for the target if(job_list.front().target && Target_Scanline::Handle::cast_dynamic(job_list.front().target)) { Target_Scanline::Handle::cast_dynamic(job_list.front().target)->set_threads(threads); } - + if(imageargs.size()) { cerr<<_("Unidentified arguments for ")< "+job_list.front().outfilename); if(!job_list.front().sifout) @@ -1094,10 +1105,10 @@ int main(int argc, char *argv[]) } } } - + job_list.clear(); - + VERBOSE_OUT(1)<<_("Done.")<