Added copyright lines for files I've edited this year.
[synfig.git] / synfig-studio / trunk / src / synfigapp / actions / layerduplicate.cpp
index 6036b92..530dc84 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
@@ -45,7 +46,7 @@ using namespace Action;
 
 /* === M A C R O S ========================================================= */
 
-ACTION_INIT(Action::LayerDuplicate);
+ACTION_INIT_NO_GET_LOCAL_NAME(Action::LayerDuplicate);
 ACTION_SET_NAME(Action::LayerDuplicate,"layer_duplicate");
 ACTION_SET_LOCAL_NAME(Action::LayerDuplicate,N_("Duplicate Layer"));
 ACTION_SET_TASK(Action::LayerDuplicate,"duplicate");
@@ -64,6 +65,12 @@ Action::LayerDuplicate::LayerDuplicate()
 {
 }
 
+synfig::String
+Action::LayerDuplicate::get_local_name()const
+{
+       return get_layer_descriptions(layers, _("Duplicate Layer"), _("Duplicate Layers"));
+}
+
 Action::ParamVocab
 Action::LayerDuplicate::get_param_vocab()
 {
@@ -153,5 +160,29 @@ Action::LayerDuplicate::prepare()
 
                        add_action_front(action);
                }
+
+               // automatically export the Index parameter of Duplicate layers when duplicating
+               if (new_layer->get_name() == "duplicate")
+                       for (int i = 1; ; i++)
+                       {
+                               String name = strprintf(_("Index %d"), i);
+                               try
+                               {
+                                       subcanvas->find_value_node(name);
+                               }
+                               catch (Exception::IDNotFound x)
+                               {
+                                       Action::Handle action(Action::create("value_node_add"));
+
+                                       action->set_param("canvas",subcanvas);
+                                       action->set_param("canvas_interface",get_canvas_interface());
+                                       action->set_param("new",new_layer->dynamic_param_list().find("index")->second);
+                                       action->set_param("name",name);
+
+                                       add_action_front(action);
+
+                                       break;
+                               }
+                       }
        }
 }