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

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

First release to xenial

File size: 3.4 KB
Line 
1/* === S Y N F I G ========================================================= */
2/*!     \file canvasmetadataerase.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**      Copyright (c) 2011 Nikita Kitaev
11**
12**      This package is free software; you can redistribute it and/or
13**      modify it under the terms of the GNU General Public License as
14**      published by the Free Software Foundation; either version 2 of
15**      the License, or (at your option) any later version.
16**
17**      This package is distributed in the hope that it will be useful,
18**      but WITHOUT ANY WARRANTY; without even the implied warranty of
19**      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20**      General Public License for more details.
21**      \endlegal
22*/
23/* ========================================================================= */
24
25/* === H E A D E R S ======================================================= */
26
27#ifdef USING_PCH
28#       include "pch.h"
29#else
30#ifdef HAVE_CONFIG_H
31#       include <config.h>
32#endif
33
34#include "canvasmetadataerase.h"
35#include <synfigapp/canvasinterface.h>
36
37#include <synfigapp/general.h>
38
39#endif
40
41using namespace std;
42using namespace etl;
43using namespace synfig;
44using namespace synfigapp;
45using namespace Action;
46
47/* === M A C R O S ========================================================= */
48
49ACTION_INIT_NO_GET_LOCAL_NAME(Action::CanvasMetadataErase);
50ACTION_SET_NAME(Action::CanvasMetadataErase,"CanvasMetadataErase");
51ACTION_SET_LOCAL_NAME(Action::CanvasMetadataErase,N_("Erase Canvas Metadata"));
52ACTION_SET_TASK(Action::CanvasMetadataErase,"set");
53ACTION_SET_CATEGORY(Action::CanvasMetadataErase,Action::CATEGORY_CANVAS);
54ACTION_SET_PRIORITY(Action::CanvasMetadataErase,0);
55ACTION_SET_VERSION(Action::CanvasMetadataErase,"0.0");
56ACTION_SET_CVS_ID(Action::CanvasMetadataErase,"$Id$");
57
58/* === G L O B A L S ======================================================= */
59
60/* === P R O C E D U R E S ================================================= */
61
62/* === M E T H O D S ======================================================= */
63
64Action::CanvasMetadataErase::CanvasMetadataErase()
65{
66}
67
68synfig::String
69Action::CanvasMetadataErase::get_local_name()const
70{
71        // TRANSLATORS: This is used in the 'history' dialog when a Canvas has its name changed.
72        return _("Erase canvas metadata");
73}
74
75Action::ParamVocab
76Action::CanvasMetadataErase::get_param_vocab()
77{
78        ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
79
80        ret.push_back(ParamDesc("key",Param::TYPE_STRING)
81                .set_local_name(_("Key"))
82        );
83
84        return ret;
85}
86
87bool
88Action::CanvasMetadataErase::is_candidate(const ParamList &x)
89{
90        return candidate_check(get_param_vocab(),x);
91}
92
93bool
94Action::CanvasMetadataErase::set_param(const synfig::String& name, const Action::Param &param)
95{
96        if(name=="key" && param.get_type()==Param::TYPE_STRING)
97        {
98                key=param.get_string();
99
100                return true;
101        }
102
103        return Action::CanvasSpecific::set_param(name,param);
104}
105
106bool
107Action::CanvasMetadataErase::is_ready()const
108{
109        if(key.empty())
110        {
111                synfig::error("Action::CanvasMetadataErase::is_ready(): Metadata Key not specified!");
112                return false;
113        }
114
115        return Action::CanvasSpecific::is_ready();
116}
117
118void
119Action::CanvasMetadataErase::perform()
120{
121        old_value=get_canvas()->get_meta_data(key);
122
123        get_canvas()->erase_meta_data(key);
124}
125
126void
127Action::CanvasMetadataErase::undo()
128{
129        get_canvas()->set_meta_data(key,old_value);
130}
Note: See TracBrowser for help on using the repository browser.