my log
[synfig.git] / synfig-studio / trunk / src / synfigapp / actions / layersetdesc.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file layersetdesc.cpp
3 **      \brief Template File
4 **
5 **      $Id: layersetdesc.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $
6 **
7 **      \legal
8 **      Copyright (c) 2002 Robert B. Quattlebaum Jr.
9 **
10 **      This software and associated documentation
11 **      are CONFIDENTIAL and PROPRIETARY property of
12 **      the above-mentioned copyright holder.
13 **
14 **      You may not copy, print, publish, or in any
15 **      other way distribute this software without
16 **      a prior written agreement with
17 **      the copyright holder.
18 **      \endlegal
19 */
20 /* ========================================================================= */
21
22 /* === H E A D E R S ======================================================= */
23
24 #ifdef USING_PCH
25 #       include "pch.h"
26 #else
27 #ifdef HAVE_CONFIG_H
28 #       include <config.h>
29 #endif
30
31 #include "layersetdesc.h"
32 #include <synfigapp/canvasinterface.h>
33
34 #endif
35
36 using namespace std;
37 using namespace etl;
38 using namespace synfig;
39 using namespace synfigapp;
40 using namespace Action;
41
42 /* === M A C R O S ========================================================= */
43
44 ACTION_INIT(Action::LayerSetDesc);
45 ACTION_SET_NAME(Action::LayerSetDesc,"layer_set_desc");
46 ACTION_SET_LOCAL_NAME(Action::LayerSetDesc,_("Set Layer Description"));
47 ACTION_SET_TASK(Action::LayerSetDesc,"set_desc");
48 ACTION_SET_CATEGORY(Action::LayerSetDesc,Action::CATEGORY_LAYER);
49 ACTION_SET_PRIORITY(Action::LayerSetDesc,0);
50 ACTION_SET_VERSION(Action::LayerSetDesc,"0.0");
51 ACTION_SET_CVS_ID(Action::LayerSetDesc,"$Id: layersetdesc.cpp,v 1.1.1.1 2005/01/07 03:34:37 darco Exp $");
52
53 /* === G L O B A L S ======================================================= */
54
55 static const int nindex=-1;
56
57 /* === P R O C E D U R E S ================================================= */
58
59 /* === M E T H O D S ======================================================= */
60
61 Action::LayerSetDesc::LayerSetDesc()
62 {
63 }
64
65 Action::ParamVocab
66 Action::LayerSetDesc::get_param_vocab()
67 {
68         ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
69         
70         ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
71                 .set_local_name(_("Layer"))
72                 .set_desc(_("Layer to be moved"))
73         );
74
75         ret.push_back(ParamDesc("new_description",Param::TYPE_STRING)
76                 .set_local_name(_("New Description"))
77                 .set_local_name(_("Enter a new description for this layer"))
78                 .set_user_supplied()
79         );
80         
81         return ret;
82 }
83
84 bool
85 Action::LayerSetDesc::is_canidate(const ParamList &x)
86 {
87         return canidate_check(get_param_vocab(),x);
88 }
89
90 bool
91 Action::LayerSetDesc::set_param(const synfig::String& name, const Action::Param &param)
92 {
93         if(name=="layer" && param.get_type()==Param::TYPE_LAYER)
94         {
95                 layer=param.get_layer();
96                 
97                 return true;
98         }
99
100         if(name=="new_description" && param.get_type()==Param::TYPE_STRING)
101         {
102                 new_description=param.get_string();
103                 
104                 return true;
105         }
106
107         return Action::CanvasSpecific::set_param(name,param);
108 }
109
110 bool
111 Action::LayerSetDesc::is_ready()const
112 {
113         if(!layer)
114                 return false;
115         return Action::CanvasSpecific::is_ready();
116 }
117
118 void
119 Action::LayerSetDesc::perform()
120 {
121         old_description=layer->get_description();
122         layer->set_description(new_description);
123         set_dirty(false);
124         if(get_canvas_interface())
125         {
126                 get_canvas_interface()->signal_layer_new_description()(layer,new_description);
127         }
128         else synfig::warning("CanvasInterface not set on action");
129 }
130
131 void
132 Action::LayerSetDesc::undo()
133 {
134         layer->set_description(old_description);
135         set_dirty(false);
136         if(get_canvas_interface())
137         {
138                 get_canvas_interface()->signal_layer_new_description()(layer,old_description);
139         }
140         else synfig::warning("CanvasInterface not set on action");
141 }