Added copyright lines for files I've edited this year.
[synfig.git] / synfig-studio / trunk / src / synfigapp / action.cpp
index c3e2aac..05c5be8 100644 (file)
@@ -6,6 +6,7 @@
 **
 **     \legal
 **     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2008 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
 
 #include "canvasinterface.h"
 
+#include "general.h"
+
 #endif
 
 using namespace std;
@@ -128,7 +131,7 @@ 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__; \
@@ -230,7 +233,7 @@ 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?
@@ -264,7 +267,7 @@ Action::compile_candidate_list(const ParamList& param_list, Category category)
 }
 
 Action::CandidateList::iterator
-Action::CandidateList::find(const String& x)
+Action::CandidateList::find(const synfig::String& x)
 {
        iterator iter;
        for(iter=begin();iter!=end();++iter)
@@ -282,6 +285,72 @@ Action::Base::set_param_list(const ParamList &param_list)
                set_param(iter->first,iter->second);
 }
 
+synfig::String
+Action::Base::get_layer_descriptions(const std::list<synfig::Layer::Handle> 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<synfig::Layer::Handle>::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<std::pair<synfig::Layer::Handle,int> > 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<std::pair<synfig::Layer::Handle,int> >::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()
 {
@@ -365,7 +434,7 @@ Super::add_action_front(etl::handle<Undoable> action)
 }
 
 
-Group::Group(const std::string &str):
+Group::Group(const synfig::String &str):
        name_(str),
        ready_(true)
 {