X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Fsrc%2Fsynfigapp%2Factions%2Fcanvasdescriptionset.cpp;fp=synfig-studio%2Fsrc%2Fsynfigapp%2Factions%2Fcanvasdescriptionset.cpp;h=845b7a1fa8244f76a1f7c14766aae36f2fbfe8dc;hb=a095981e18cc37a8ecc7cd237cc22b9c10329264;hp=0000000000000000000000000000000000000000;hpb=9459638ad6797b8139f1e9f0715c96076dbf0890;p=synfig.git diff --git a/synfig-studio/src/synfigapp/actions/canvasdescriptionset.cpp b/synfig-studio/src/synfigapp/actions/canvasdescriptionset.cpp new file mode 100644 index 0000000..845b7a1 --- /dev/null +++ b/synfig-studio/src/synfigapp/actions/canvasdescriptionset.cpp @@ -0,0 +1,141 @@ +/* === S Y N F I G ========================================================= */ +/*! \file canvasdescriptionset.cpp +** \brief Template File +** +** $Id$ +** +** \legal +** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 Chris Moore +** +** This package is free software; you can redistribute it and/or +** modify it under the terms of the GNU General Public License as +** published by the Free Software Foundation; either version 2 of +** the License, or (at your option) any later version. +** +** This package is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +** General Public License for more details. +** \endlegal +*/ +/* ========================================================================= */ + +/* === H E A D E R S ======================================================= */ + +#ifdef USING_PCH +# include "pch.h" +#else +#ifdef HAVE_CONFIG_H +# include +#endif + +#include "canvasdescriptionset.h" +#include + +#include + +#endif + +using namespace std; +using namespace etl; +using namespace synfig; +using namespace synfigapp; +using namespace Action; + +/* === M A C R O S ========================================================= */ + +ACTION_INIT_NO_GET_LOCAL_NAME(Action::CanvasDescriptionSet); +ACTION_SET_NAME(Action::CanvasDescriptionSet,"CanvasDescriptionSet"); +ACTION_SET_LOCAL_NAME(Action::CanvasDescriptionSet,N_("Set Canvas Description")); +ACTION_SET_TASK(Action::CanvasDescriptionSet,"set"); +ACTION_SET_CATEGORY(Action::CanvasDescriptionSet,Action::CATEGORY_CANVAS); +ACTION_SET_PRIORITY(Action::CanvasDescriptionSet,0); +ACTION_SET_VERSION(Action::CanvasDescriptionSet,"0.0"); +ACTION_SET_CVS_ID(Action::CanvasDescriptionSet,"$Id$"); + +/* === G L O B A L S ======================================================= */ + +/* === P R O C E D U R E S ================================================= */ + +/* === M E T H O D S ======================================================= */ + +Action::CanvasDescriptionSet::CanvasDescriptionSet() +{ +} + +synfig::String +Action::CanvasDescriptionSet::get_local_name()const +{ + // TRANSLATORS: This is used in the 'history' dialog when a Canvas has its description changed. + return strprintf(_("Change canvas description from '%s' to '%s'"), + old_description.c_str(), + new_description.c_str()); +} + +Action::ParamVocab +Action::CanvasDescriptionSet::get_param_vocab() +{ + ParamVocab ret(Action::CanvasSpecific::get_param_vocab()); + + ret.push_back(ParamDesc("description",Param::TYPE_STRING) + .set_local_name(_("Description")) + ); + + return ret; +} + +bool +Action::CanvasDescriptionSet::is_candidate(const ParamList &x) +{ + return candidate_check(get_param_vocab(),x); +} + +bool +Action::CanvasDescriptionSet::set_param(const synfig::String& description, const Action::Param ¶m) +{ + if(description=="description" && param.get_type()==Param::TYPE_STRING) + { + new_description=param.get_string(); + + return true; + } + + return Action::CanvasSpecific::set_param(description,param); +} + +bool +Action::CanvasDescriptionSet::is_ready()const +{ + if(new_description.empty()) + { + synfig::error("Action::CanvasDescriptionSet::is_ready(): Description not set!"); + return false; + } + + return Action::CanvasSpecific::is_ready(); +} + +void +Action::CanvasDescriptionSet::perform() +{ + old_description=get_canvas()->get_description(); + + get_canvas()->set_description(new_description); + + if(get_canvas_interface()) + get_canvas_interface()->signal_id_changed()(); + else + synfig::warning("CanvasInterface not set on action"); +} + +void +Action::CanvasDescriptionSet::undo() +{ + get_canvas()->set_description(old_description); + + if(get_canvas_interface()) + get_canvas_interface()->signal_id_changed()(); + else + synfig::warning("CanvasInterface not set on action"); +}