Remove .gitignore do nothing is ignored.
[synfig.git] / synfig-studio / trunk / src / synfigapp / actions / valuedescconnect.cpp
index 45783fb..cf018f3 100644 (file)
@@ -2,10 +2,11 @@
 /*!    \file valuedescconnect.cpp
 **     \brief Template File
 **
-**     $Id: valuedescconnect.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
+**     $Id$
 **
 **     \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
 #endif
 
 #include "layerparamconnect.h"
+#include "waypointconnect.h"
 #include "valuenodelinkconnect.h"
 #include "valuenodereplace.h"
 
 #include "valuedescconnect.h"
 #include <synfigapp/canvasinterface.h>
 
+#include <synfigapp/general.h>
+
 #endif
 
 using namespace std;
@@ -46,14 +50,14 @@ using namespace Action;
 
 /* === M A C R O S ========================================================= */
 
-ACTION_INIT(Action::ValueDescConnect);
-ACTION_SET_NAME(Action::ValueDescConnect,"value_desc_connect");
-ACTION_SET_LOCAL_NAME(Action::ValueDescConnect,"Connect");
+ACTION_INIT_NO_GET_LOCAL_NAME(Action::ValueDescConnect);
+ACTION_SET_NAME(Action::ValueDescConnect,"ValueDescConnect");
+ACTION_SET_LOCAL_NAME(Action::ValueDescConnect,N_("Connect"));
 ACTION_SET_TASK(Action::ValueDescConnect,"connect");
 ACTION_SET_CATEGORY(Action::ValueDescConnect,Action::CATEGORY_VALUEDESC|Action::CATEGORY_VALUENODE);
 ACTION_SET_PRIORITY(Action::ValueDescConnect,0);
 ACTION_SET_VERSION(Action::ValueDescConnect,"0.0");
-ACTION_SET_CVS_ID(Action::ValueDescConnect,"$Id: valuedescconnect.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
+ACTION_SET_CVS_ID(Action::ValueDescConnect,"$Id$");
 
 /* === G L O B A L S ======================================================= */
 
@@ -65,6 +69,15 @@ Action::ValueDescConnect::ValueDescConnect()
 {
 }
 
+synfig::String
+Action::ValueDescConnect::get_local_name()const
+{
+       // TRANSLATORS: This is used in the 'history' dialog when a connection is made.
+       return strprintf(_("Connect '%s' to '%s'"),
+                                        value_desc.get_description(false).c_str(),
+                                        value_node->get_id().c_str());
+}
+
 Action::ParamVocab
 Action::ValueDescConnect::get_param_vocab()
 {
@@ -93,6 +106,17 @@ Action::ValueDescConnect::is_candidate(const ParamList &x)
 {
        if(candidate_check(get_param_vocab(),x))
        {
+               // don't show the option of connecting to an existing Index parameter of the Duplicate layer
+               if(x.count("dest"))
+               {
+                       ValueDesc value_desc=x.find("dest")->second.get_value_desc();
+
+                       if (value_desc.parent_is_layer_param() &&
+                               value_desc.get_layer()->get_name() == "duplicate" &&
+                               value_desc.get_param_name() == "index")
+                               return false;
+               }
+
                if(x.count("src"))
                {
                        ValueDesc value_desc=x.find("dest")->second.get_value_desc();
@@ -177,6 +201,23 @@ Action::ValueDescConnect::prepare()
                return;
        }
        else
+       if(value_desc.parent_is_waypoint())
+       {
+               Action::Handle action(WaypointConnect::create());
+
+               action->set_param("canvas",get_canvas());
+               action->set_param("canvas_interface",get_canvas_interface());
+               action->set_param("parent_value_node",value_desc.get_parent_value_node());
+               action->set_param("value_node", value_node);
+               action->set_param("waypoint_time",value_desc.get_waypoint_time());
+
+               assert(action->is_ready());
+               if(!action->is_ready())
+                       throw Error(Error::TYPE_NOTREADY);
+
+               add_action_front(action);
+               return;
+       }
        if(value_desc.parent_is_linkable_value_node())
        {
                Action::Handle action(ValueNodeLinkConnect::create());
@@ -213,5 +254,5 @@ Action::ValueDescConnect::prepare()
                return;
        }
 
-       throw Error(_("ValueDesc is not recognised or supported."));
+       throw Error(_("ValueDesc is not recognized or supported."));
 }