22d2e2727eb70cea926491390d3bcad3b8e0dfc8
[synfig.git] / synfig-studio / tags / stable / src / sinfgapp / actions / groupremove.cpp
1 /* === S I N F G =========================================================== */
2 /*!     \file action_layerremove.cpp
3 **      \brief Template File
4 **
5 **      $Id: groupremove.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 "groupremove.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::GroupRemove);
45 ACTION_SET_NAME(Action::GroupRemove,"group_remove");
46 ACTION_SET_LOCAL_NAME(Action::GroupRemove,"Remove Group");
47 ACTION_SET_TASK(Action::GroupRemove,"remove");
48 ACTION_SET_CATEGORY(Action::GroupRemove,Action::CATEGORY_GROUP);
49 ACTION_SET_PRIORITY(Action::GroupRemove,0);
50 ACTION_SET_VERSION(Action::GroupRemove,"0.0");
51 ACTION_SET_CVS_ID(Action::GroupRemove,"$Id: groupremove.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::GroupRemove::GroupRemove()
60 {
61 }
62
63 Action::ParamVocab
64 Action::GroupRemove::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(_("Group"))
70                 .set_desc(_("Name of the Group to remove"))
71         );
72         
73         return ret;
74 }
75
76 bool
77 Action::GroupRemove::is_canidate(const ParamList &x)
78 {
79         bool ret(canidate_check(get_param_vocab(),x));
80         if(!ret)
81         {
82                 sinfg::info("Action::GroupRemove::is_canidate(): failed canidate check");
83                 ParamList::const_iterator iter;
84                 for(iter=x.begin();iter!=x.end();++iter)
85                 {
86                         sinfg::info("PARAM: %s",iter->first.c_str());
87                 }
88         }
89         return ret;
90 }
91
92 bool
93 Action::GroupRemove::set_param(const sinfg::String& name, const Action::Param &param)
94 {
95         if(name=="group" && param.get_type()==Param::TYPE_STRING)
96         {
97                 group=param.get_string();
98                 
99                 return true;
100         }
101
102         return Action::CanvasSpecific::set_param(name,param);
103 }
104
105 bool
106 Action::GroupRemove::is_ready()const
107 {
108         if(group.empty())
109                 return false;
110         return Action::CanvasSpecific::is_ready();
111 }
112
113 void
114 Action::GroupRemove::perform()
115 {
116         layer_list=get_canvas()->get_layers_in_group(group);
117         
118         std::set<sinfg::Layer::Handle>::iterator iter;
119         for(iter=layer_list.begin();iter!=layer_list.end();++iter)
120         {
121                 (*iter)->remove_from_group(group);
122         }
123 }
124
125 void
126 Action::GroupRemove::undo()
127 {
128         std::set<sinfg::Layer::Handle>::iterator iter;
129         for(iter=layer_list.begin();iter!=layer_list.end();++iter)
130         {
131                 (*iter)->add_to_group(group);
132         }
133 }