Don't show the option of connecting to an existing Index parameter of the Duplicate...
[synfig.git] / synfig-studio / trunk / src / synfigapp / actions / valuedescconnect.cpp
index 420e17e..062edee 100644 (file)
@@ -36,6 +36,8 @@
 #include "valuedescconnect.h"
 #include <synfigapp/canvasinterface.h>
 
+#include <synfigapp/general.h>
+
 #endif
 
 using namespace std;
@@ -48,7 +50,7 @@ using namespace Action;
 
 ACTION_INIT(Action::ValueDescConnect);
 ACTION_SET_NAME(Action::ValueDescConnect,"value_desc_connect");
-ACTION_SET_LOCAL_NAME(Action::ValueDescConnect,"Connect");
+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);
@@ -93,15 +95,31 @@ 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();
                        ValueNode::Handle value_node=x.find("src")->second.get_value_node();
                        if(value_desc.get_value_type()==value_node->get_type())
+                       {
+                               printf("%s:%d\n", __FILE__, __LINE__);
                                return true;
+                       }
                }
+               printf("%s:%d\n", __FILE__, __LINE__);
                return true;
        }
+       printf("%s:%d\n", __FILE__, __LINE__);
        return false;
 }
 
@@ -213,5 +231,5 @@ Action::ValueDescConnect::prepare()
                return;
        }
 
-       throw Error(_("ValueDesc is not recognised or supported."));
+       throw Error(_("ValueDesc is not recognized or supported."));
 }