source: synfigstudio/trunk/fuentes/src/synfigapp/actions/layersetdesc.cpp @ 481

Last change on this file since 481 was 481, checked in by jrpelegrina, 4 years ago

First release to xenial

File size: 4.3 KB
Line 
1/* === S Y N F I G ========================================================= */
2/*!     \file layersetdesc.cpp
3**      \brief Template File
4**
5**      $Id$
6**
7**      \legal
8**      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9**      Copyright (c) 2008 Chris Moore
10**
11**      This package is free software; you can redistribute it and/or
12**      modify it under the terms of the GNU General Public License as
13**      published by the Free Software Foundation; either version 2 of
14**      the License, or (at your option) any later version.
15**
16**      This package is distributed in the hope that it will be useful,
17**      but WITHOUT ANY WARRANTY; without even the implied warranty of
18**      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19**      General Public License for more details.
20**      \endlegal
21*/
22/* ========================================================================= */
23
24/* === H E A D E R S ======================================================= */
25
26#ifdef USING_PCH
27#       include "pch.h"
28#else
29#ifdef HAVE_CONFIG_H
30#       include <config.h>
31#endif
32
33#include "layersetdesc.h"
34#include <synfigapp/canvasinterface.h>
35
36#include <synfigapp/general.h>
37
38#endif
39
40using namespace std;
41using namespace etl;
42using namespace synfig;
43using namespace synfigapp;
44using namespace Action;
45
46/* === M A C R O S ========================================================= */
47
48ACTION_INIT_NO_GET_LOCAL_NAME(Action::LayerSetDesc);
49ACTION_SET_NAME(Action::LayerSetDesc,"LayerSetDesc");
50ACTION_SET_LOCAL_NAME(Action::LayerSetDesc,N_("Set Layer Description"));
51ACTION_SET_TASK(Action::LayerSetDesc,"set_desc");
52ACTION_SET_CATEGORY(Action::LayerSetDesc,Action::CATEGORY_LAYER);
53ACTION_SET_PRIORITY(Action::LayerSetDesc,0);
54ACTION_SET_VERSION(Action::LayerSetDesc,"0.0");
55ACTION_SET_CVS_ID(Action::LayerSetDesc,"$Id$");
56
57/* === G L O B A L S ======================================================= */
58
59// static const int nindex=-1;
60
61/* === P R O C E D U R E S ================================================= */
62
63/* === M E T H O D S ======================================================= */
64
65Action::LayerSetDesc::LayerSetDesc()
66{
67}
68
69synfig::String
70Action::LayerSetDesc::get_local_name()const
71{
72        return strprintf("%s: '%s' -> '%s'",
73                                         _("Set Layer Description"),
74                                         /* TRANSLATORS: this is the string used in the history dialog when renaming a layer to/from its default name */
75                                         old_description.empty() ? _("[default]") : old_description.c_str(),
76                                         new_description.empty() ? _("[default]") : new_description.c_str());
77}
78
79Action::ParamVocab
80Action::LayerSetDesc::get_param_vocab()
81{
82        ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
83
84        ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
85                .set_local_name(_("Layer"))
86                .set_desc(_("Layer to be described"))
87        );
88
89        ret.push_back(ParamDesc("new_description",Param::TYPE_STRING)
90                .set_local_name(_("New Description"))
91                .set_local_name(_("Enter a new description for this layer"))
92                .set_user_supplied()
93                .set_value_provided()
94        );
95
96        return ret;
97}
98
99bool
100Action::LayerSetDesc::is_candidate(const ParamList &x)
101{
102        return candidate_check(get_param_vocab(),x);
103}
104
105bool
106Action::LayerSetDesc::set_param(const synfig::String& name, const Action::Param &param)
107{
108        if(name=="layer" && param.get_type()==Param::TYPE_LAYER)
109        {
110                layer=param.get_layer();
111
112                return true;
113        }
114
115        if(name=="new_description" && param.get_type()==Param::TYPE_STRING)
116        {
117                new_description=param.get_string();
118
119                return true;
120        }
121
122        return Action::CanvasSpecific::set_param(name,param);
123}
124
125bool
126Action::LayerSetDesc::get_param(const synfig::String& name, Action::Param &param)
127{
128        if(name=="new_description")
129        {
130                param=layer->get_description();
131
132                return true;
133        }
134        return Action::CanvasSpecific::get_param(name,param);
135}
136
137bool
138Action::LayerSetDesc::is_ready()const
139{
140        if(!layer)
141                return false;
142        return Action::CanvasSpecific::is_ready();
143}
144
145void
146Action::LayerSetDesc::perform()
147{
148        old_description=layer->get_description();
149        layer->set_description(new_description);
150        set_dirty(false);
151        if(get_canvas_interface())
152        {
153                get_canvas_interface()->signal_layer_new_description()(layer,new_description);
154        }
155        else synfig::warning("CanvasInterface not set on action");
156}
157
158void
159Action::LayerSetDesc::undo()
160{
161        layer->set_description(old_description);
162        set_dirty(false);
163        if(get_canvas_interface())
164        {
165                get_canvas_interface()->signal_layer_new_description()(layer,old_description);
166        }
167        else synfig::warning("CanvasInterface not set on action");
168}
Note: See TracBrowser for help on using the repository browser.