X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fsynfigapp%2Faction.cpp;h=05c5be8801b36f127ce7f769a31a144e57894192;hb=d15c4522466bedfbe61620c401becae0931854f5;hp=26fbd57c772e49f8ccc4e0561a50e3fdb010aaca;hpb=02252941b29de64037116f4d37991a38d9ff0d94;p=synfig.git diff --git a/synfig-studio/trunk/src/synfigapp/action.cpp b/synfig-studio/trunk/src/synfigapp/action.cpp index 26fbd57..05c5be8 100644 --- a/synfig-studio/trunk/src/synfigapp/action.cpp +++ b/synfig-studio/trunk/src/synfigapp/action.cpp @@ -2,19 +2,21 @@ /*! \file action.cpp ** \brief Template File ** -** $Id: action.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $ +** $Id$ ** ** \legal -** Copyright (c) 2002 Robert B. Quattlebaum Jr. +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 Chris Moore ** -** This software and associated documentation -** are CONFIDENTIAL and PROPRIETARY property of -** the above-mentioned copyright holder. +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. ** -** You may not copy, print, publish, or in any -** other way distribute this software without -** a prior written agreement with -** the copyright holder. +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. ** \endlegal */ /* ========================================================================= */ @@ -109,6 +111,8 @@ #include "canvasinterface.h" +#include "general.h" + #endif using namespace std; @@ -127,21 +131,21 @@ synfigapp::Action::Book *book_; #define ADD_ACTION(x) { BookEntry &be(book()[x::name__]); \ be.name=x::name__; \ - be.local_name=x::local_name__; \ + be.local_name=dgettext("synfigstudio",x::local_name__); \ be.version=x::version__; \ be.task=x::task__; \ be.priority=x::priority__; \ be.category=x::category__; \ be.factory=x::create; \ be.get_param_vocab=x::get_param_vocab; \ - be.is_canidate=x::is_canidate; \ + be.is_candidate=x::is_candidate; \ } - + Action::Main::Main() { book_=new synfigapp::Action::Book(); - + ADD_ACTION(Action::LayerRemove); ADD_ACTION(Action::LayerMove); ADD_ACTION(Action::LayerRaise); @@ -154,10 +158,10 @@ Action::Main::Main() ADD_ACTION(Action::LayerEncapsulate); ADD_ACTION(Action::LayerDuplicate); ADD_ACTION(Action::LayerSetDesc); - - ADD_ACTION(Action::ValueNodeConstSet); - ADD_ACTION(Action::ValueNodeAdd); - ADD_ACTION(Action::ValueNodeReplace); + + ADD_ACTION(Action::ValueNodeConstSet); + ADD_ACTION(Action::ValueNodeAdd); + ADD_ACTION(Action::ValueNodeReplace); ADD_ACTION(Action::ValueNodeLinkConnect); ADD_ACTION(Action::ValueNodeLinkDisconnect); ADD_ACTION(Action::ValueNodeDynamicListInsert); @@ -169,7 +173,7 @@ Action::Main::Main() ADD_ACTION(Action::ValueNodeDynamicListRotateOrder); ADD_ACTION(Action::ValueNodeRename); ADD_ACTION(Action::ValueNodeRemove); - + ADD_ACTION(Action::ValueDescSet); ADD_ACTION(Action::ValueDescExport); ADD_ACTION(Action::ValueDescConvert); @@ -207,7 +211,7 @@ Action::Main::Main() ADD_ACTION(Action::GradientSet); ADD_ACTION(Action::ColorSet); - + ADD_ACTION(Action::TimepointsMove); ADD_ACTION(Action::TimepointsCopy); ADD_ACTION(Action::TimepointsDelete); @@ -221,7 +225,7 @@ Action::Main::Main() Action::Main::~Main() { delete book_; - + } @@ -229,19 +233,19 @@ Action::Book& Action::book() { return *book_; } Action::Handle -Action::create(const String &name) +Action::create(const synfig::String &name) { if(!book().count(name)) return 0; //! \todo perhaps we should throw something instead? - return book()[name].factory(); + return book()[name].factory(); } -Action::CanidateList -Action::compile_canidate_list(const ParamList& param_list, Category category) +Action::CandidateList +Action::compile_candidate_list(const ParamList& param_list, Category category) { - Action::CanidateList ret; - + Action::CandidateList ret; + Book::const_iterator iter; //synfig::info("param_list.size()=%d",param_list.size()); @@ -250,20 +254,20 @@ Action::compile_canidate_list(const ParamList& param_list, Category category) { if((iter->second.category&category)) { - if(iter->second.is_canidate(param_list)) + if(iter->second.is_candidate(param_list)) ret.push_back(iter->second); else { - //synfig::info("Action \"%s\" is not a canidate",iter->second.name.c_str()); + //synfig::info("Action \"%s\" is not a candidate",iter->second.name.c_str()); } } } - + return ret; } -Action::CanidateList::iterator -Action::CanidateList::find(const String& x) +Action::CandidateList::iterator +Action::CandidateList::find(const synfig::String& x) { iterator iter; for(iter=begin();iter!=end();++iter) @@ -276,16 +280,82 @@ void Action::Base::set_param_list(const ParamList ¶m_list) { ParamList::const_iterator iter; - + for(iter=param_list.begin();iter!=param_list.end();++iter) set_param(iter->first,iter->second); } +synfig::String +Action::Base::get_layer_descriptions(const std::list layers, synfig::String singular_prefix, synfig::String plural_prefix) +{ + String ret; + bool first = true; + + if (plural_prefix.empty()) + plural_prefix = singular_prefix; + + if (layers.empty()) + return plural_prefix; + + if (layers.size() == 1) + ret = singular_prefix; + else + ret = plural_prefix; + + if (!ret.empty()) + ret.push_back(' '); + + for(std::list::const_iterator iter=layers.begin(); iter!=layers.end(); ++iter) + { + if (first) + first = false; + else + ret += ", "; + + ret += strprintf("'%s'", (*iter)->get_non_empty_description().c_str()); + } + + return ret; +} + +synfig::String +Action::Base::get_layer_descriptions(const std::list > layers, synfig::String singular_prefix, synfig::String plural_prefix) +{ + String ret; + bool first = true; + + if (plural_prefix.empty()) + plural_prefix = singular_prefix; + + if (layers.empty()) + return plural_prefix; + + if (layers.size() == 1) + ret = singular_prefix; + else + ret = plural_prefix; + + if (!ret.empty()) + ret.push_back(' '); + + for(std::list >::const_iterator iter=layers.begin(); iter!=layers.end(); ++iter) + { + if (first) + first = false; + else + ret += ", "; + + ret += strprintf("'%s'", iter->first->get_non_empty_description().c_str()); + } + + return ret; +} + void Super::perform() { set_dirty(false); - + prepare(); ActionList::const_iterator iter; @@ -364,7 +434,7 @@ Super::add_action_front(etl::handle action) } -Group::Group(const std::string &str): +Group::Group(const synfig::String &str): name_(str), ready_(true) { @@ -381,7 +451,7 @@ Action::ParamVocab Action::CanvasSpecific::get_param_vocab() { ParamVocab ret; - + ret.push_back(ParamDesc("canvas",Param::TYPE_CANVAS) .set_local_name(_("Canvas")) .set_desc(_("Selected Canvas")) @@ -392,7 +462,7 @@ Action::CanvasSpecific::get_param_vocab() .set_desc(_("Canvas Interface")) .set_optional(true) ); - + return ret; } @@ -405,7 +475,7 @@ CanvasSpecific::set_param(const synfig::String& name, const Param ¶m) if(!param.get_canvas()) return false; set_canvas(param.get_canvas()); - + return true; } if(name=="canvas_interface" && param.get_type()==Param::TYPE_CANVASINTERFACE) @@ -415,13 +485,13 @@ CanvasSpecific::set_param(const synfig::String& name, const Param ¶m) set_canvas_interface(param.get_canvas_interface()); if(!get_canvas()) set_canvas(get_canvas_interface()->get_canvas()); - + return true; } if(name=="edit_mode" && param.get_type()==Param::TYPE_EDITMODE) { set_edit_mode(param.get_edit_mode()); - + return true; } @@ -441,9 +511,9 @@ CanvasSpecific::get_edit_mode()const { if(mode_!=MODE_UNDEFINED) return mode_; - + if(get_canvas_interface()) return get_canvas_interface()->get_mode(); - + return MODE_NORMAL; }