Added a couple of implementations of Action::Base::get_layer_descriptions() to format...
authordooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Tue, 15 Jan 2008 14:47:28 +0000 (14:47 +0000)
committerdooglus <dooglus@1f10aa63-cdf2-0310-b900-c93c546f37ac>
Tue, 15 Jan 2008 14:47:28 +0000 (14:47 +0000)
git-svn-id: http://svn.voria.com/code@1368 1f10aa63-cdf2-0310-b900-c93c546f37ac

synfig-studio/trunk/src/synfigapp/action.cpp
synfig-studio/trunk/src/synfigapp/action.h

index aa026f4..a8de89e 100644 (file)
@@ -284,6 +284,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()
 {
index 4458062..d23039c 100644 (file)
@@ -211,6 +211,8 @@ public:
 
        void set_param_list(const ParamList &);
 
+       static synfig::String get_layer_descriptions(const std::list<synfig::Layer::Handle> layers, synfig::String singular_prefix = "", synfig::String plural_prefix = "");
+       static synfig::String get_layer_descriptions(const std::list<std::pair<synfig::Layer::Handle,int> > layers, synfig::String singular_prefix = "", synfig::String plural_prefix = "");
 }; // END of class Action::Base
 
 typedef Action::Base* (*Factory)();