Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-studio / tags / synfigstudio_0_61_04 / synfig-studio / src / synfigapp / actions / valuenodedynamiclistunloop.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file valuenodedynamiclistunloop.cpp
3 **      \brief Template File
4 **
5 **      $Id: valuenodedynamiclistunloop.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
10 **      This package is free software; you can redistribute it and/or
11 **      modify it under the terms of the GNU General Public License as
12 **      published by the Free Software Foundation; either version 2 of
13 **      the License, or (at your option) any later version.
14 **
15 **      This package is distributed in the hope that it will be useful,
16 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
17 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 **      General Public License for more details.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === H E A D E R S ======================================================= */
24
25 #ifdef USING_PCH
26 #       include "pch.h"
27 #else
28 #ifdef HAVE_CONFIG_H
29 #       include <config.h>
30 #endif
31
32 #include "valuenodedynamiclistunloop.h"
33 #include <synfigapp/canvasinterface.h>
34
35 #endif
36
37 using namespace std;
38 using namespace etl;
39 using namespace synfig;
40 using namespace synfigapp;
41 using namespace Action;
42
43 /* === M A C R O S ========================================================= */
44
45 ACTION_INIT(Action::ValueNodeDynamicListUnLoop);
46 ACTION_SET_NAME(Action::ValueNodeDynamicListUnLoop,"value_node_dynamic_list_unloop");
47 ACTION_SET_LOCAL_NAME(Action::ValueNodeDynamicListUnLoop,"Unloop");
48 ACTION_SET_TASK(Action::ValueNodeDynamicListUnLoop,"unloop");
49 ACTION_SET_CATEGORY(Action::ValueNodeDynamicListUnLoop,Action::CATEGORY_VALUEDESC|Action::CATEGORY_VALUENODE);
50 ACTION_SET_PRIORITY(Action::ValueNodeDynamicListUnLoop,0);
51 ACTION_SET_VERSION(Action::ValueNodeDynamicListUnLoop,"0.0");
52 ACTION_SET_CVS_ID(Action::ValueNodeDynamicListUnLoop,"$Id: valuenodedynamiclistunloop.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
53
54 /* === G L O B A L S ======================================================= */
55
56 /* === P R O C E D U R E S ================================================= */
57
58 /* === M E T H O D S ======================================================= */
59
60 Action::ValueNodeDynamicListUnLoop::ValueNodeDynamicListUnLoop()
61 {
62 }
63
64 Action::ParamVocab
65 Action::ValueNodeDynamicListUnLoop::get_param_vocab()
66 {
67         ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
68         
69         ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
70                 .set_local_name(_("ValueNode"))
71         );
72
73         return ret;
74 }
75
76 bool
77 Action::ValueNodeDynamicListUnLoop::is_canidate(const ParamList &x)
78 {
79         if(canidate_check(get_param_vocab(),x))
80         {
81                 ValueNode::Handle value_node(x.find("value_node")->second.get_value_node());
82                 if(!ValueNode_DynamicList::Handle::cast_dynamic(value_node))
83                         return false;
84                 if(ValueNode_DynamicList::Handle::cast_dynamic(value_node)->get_loop()==false)
85                         return false;
86                 return true;
87         }
88         return false;
89 }
90
91 bool
92 Action::ValueNodeDynamicListUnLoop::set_param(const synfig::String& name, const Action::Param &param)
93 {
94         if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
95         {               
96                 value_node=ValueNode_DynamicList::Handle::cast_dynamic(param.get_value_node());
97                 
98                 if(!value_node)
99                         return false;
100
101                 return true;
102         }
103
104         return Action::CanvasSpecific::set_param(name,param);
105 }
106
107 bool
108 Action::ValueNodeDynamicListUnLoop::is_ready()const
109 {
110         if(!value_node)
111                 return false;
112         return Action::CanvasSpecific::is_ready();
113 }
114
115 void
116 Action::ValueNodeDynamicListUnLoop::perform()
117 {       
118         old_loop_value=value_node->get_loop();
119         
120         if(old_loop_value==false)
121         {
122                 set_dirty(false);
123                 return;
124         }
125
126         set_dirty(true);
127         value_node->set_loop(false);
128                 
129         value_node->changed();
130 /*_if(get_canvas_interface())
131         {
132                 get_canvas_interface()->signal_value_node_changed()(value_node);
133         }
134         else synfig::warning("CanvasInterface not set on action");*/
135 }
136
137 void
138 Action::ValueNodeDynamicListUnLoop::undo()
139 {
140         if(old_loop_value==value_node->get_loop())
141         {
142                 set_dirty(false);
143                 return;
144         }
145
146         set_dirty(true);
147         value_node->set_loop(old_loop_value);
148                 
149         value_node->changed();
150 /*_if(get_canvas_interface())
151         {
152                 get_canvas_interface()->signal_value_node_changed()(value_node);
153         }
154         else synfig::warning("CanvasInterface not set on action");*/
155 }