Changed the "tagrelease" and "tagstable" make targets to use subversion. Also increme...
[synfig.git] / synfig-studio / tags / stable / src / sinfgapp / actions / grouprename.cpp
1 /* === S I N F G =========================================================== */
2 /*!     \file action_layerremove.cpp
3 **      \brief Template File
4 **
5 **      $Id: grouprename.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 "grouprename.h"
32 #include <sinfgapp/canvasinterface.h>
33
34 #endif
35
36 using namespace std;
37 using namespace etl;
38 using namespace sinfg;
39 using namespace sinfgapp;
40 using namespace Action;
41
42 /* === M A C R O S ========================================================= */
43
44 ACTION_INIT(Action::GroupRename);
45 ACTION_SET_NAME(Action::GroupRename,"group_rename");
46 ACTION_SET_LOCAL_NAME(Action::GroupRename,"Rename Group");
47 ACTION_SET_TASK(Action::GroupRename,"rename");
48 ACTION_SET_CATEGORY(Action::GroupRename,Action::CATEGORY_GROUP);
49 ACTION_SET_PRIORITY(Action::GroupRename,0);
50 ACTION_SET_VERSION(Action::GroupRename,"0.0");
51 ACTION_SET_CVS_ID(Action::GroupRename,"$Id: grouprename.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 /* === P R O C E D U R E S ================================================= */
56
57 /* === M E T H O D S ======================================================= */
58
59 Action::GroupRename::GroupRename()
60 {
61 }
62
63 Action::ParamVocab
64 Action::GroupRename::get_param_vocab()
65 {
66         ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
67         
68         ret.push_back(ParamDesc("group",Param::TYPE_STRING)
69                 .set_local_name(_("Old Group"))
70                 .set_desc(_("Name of the Group to rename"))
71         );
72
73         ret.push_back(ParamDesc("new_group",Param::TYPE_STRING)
74                 .set_local_name(_("New Group"))
75                 .set_desc(_("New name for group"))
76         );
77         
78         return ret;
79 }
80
81 bool
82 Action::GroupRename::is_canidate(const ParamList &x)
83 {
84         return canidate_check(get_param_vocab(),x);
85 }
86
87 bool
88 Action::GroupRename::set_param(const sinfg::String& name, const Action::Param &param)
89 {
90         if(name=="group" && param.get_type()==Param::TYPE_STRING)
91         {
92                 old_group_name=param.get_string();
93                 
94                 return true;
95         }
96
97         if(name=="new_group" && param.get_type()==Param::TYPE_STRING)
98         {
99                 new_group_name=param.get_string();
100                 
101                 return true;
102         }
103
104         return Action::CanvasSpecific::set_param(name,param);
105 }
106
107 bool
108 Action::GroupRename::is_ready()const
109 {
110         if(old_group_name.empty()||new_group_name.empty())
111                 return false;
112         return Action::CanvasSpecific::is_ready();
113 }
114
115 void
116 Action::GroupRename::perform()
117 {
118         if(get_canvas()->get_groups().count(new_group_name)!=0)
119         {
120                 throw Error(_("A group with the name \"%s\" already exists!"),new_group_name.c_str());
121         }
122         get_canvas()->rename_group(old_group_name,new_group_name);
123 }
124
125 void
126 Action::GroupRename::undo()
127 {
128         get_canvas()->rename_group(new_group_name,old_group_name);
129 }