From 21b7221174dff900ae2f2bc2dd5987c717bab9a3 Mon Sep 17 00:00:00 2001 From: dooglus Date: Wed, 26 Mar 2008 20:04:43 +0000 Subject: [PATCH] Fix 1924592: Editing the name, description, or id of a canvas should mark the canvas as needing to be saved, and should also be undoable. git-svn-id: http://svn.voria.com/code@1923 1f10aa63-cdf2-0310-b900-c93c546f37ac --- synfig-studio/trunk/src/gtkmm/canvasproperties.cpp | 1 + synfig-studio/trunk/src/synfigapp/Makefile.am | 6 +- synfig-studio/trunk/src/synfigapp/action.cpp | 6 + .../src/synfigapp/actions/canvasdescriptionset.cpp | 141 +++++++++++++++++++++ .../src/synfigapp/actions/canvasdescriptionset.h | 75 +++++++++++ .../trunk/src/synfigapp/actions/canvasidset.cpp | 141 +++++++++++++++++++++ .../trunk/src/synfigapp/actions/canvasidset.h | 75 +++++++++++ .../trunk/src/synfigapp/actions/canvasnameset.cpp | 141 +++++++++++++++++++++ .../trunk/src/synfigapp/actions/canvasnameset.h | 75 +++++++++++ .../trunk/src/synfigapp/canvasinterface.cpp | 53 ++++++-- .../trunk/src/synfigapp/canvasinterface.h | 6 +- 11 files changed, 703 insertions(+), 17 deletions(-) create mode 100644 synfig-studio/trunk/src/synfigapp/actions/canvasdescriptionset.cpp create mode 100644 synfig-studio/trunk/src/synfigapp/actions/canvasdescriptionset.h create mode 100644 synfig-studio/trunk/src/synfigapp/actions/canvasidset.cpp create mode 100644 synfig-studio/trunk/src/synfigapp/actions/canvasidset.h create mode 100644 synfig-studio/trunk/src/synfigapp/actions/canvasnameset.cpp create mode 100644 synfig-studio/trunk/src/synfigapp/actions/canvasnameset.h diff --git a/synfig-studio/trunk/src/gtkmm/canvasproperties.cpp b/synfig-studio/trunk/src/gtkmm/canvasproperties.cpp index ea1f83b..a6792ed 100644 --- a/synfig-studio/trunk/src/gtkmm/canvasproperties.cpp +++ b/synfig-studio/trunk/src/gtkmm/canvasproperties.cpp @@ -112,6 +112,7 @@ CanvasProperties::CanvasProperties(Gtk::Window& parent,etl::handlepack_start(widget_rend_desc, false, false, 0); canvas_interface_->signal_rend_desc_changed().connect(sigc::mem_fun(*this,&studio::CanvasProperties::refresh)); + canvas_interface_->signal_id_changed().connect(sigc::mem_fun(*this,&studio::CanvasProperties::refresh)); Gtk::Button *ok_button(manage(new class Gtk::Button(Gtk::StockID("gtk-ok")))); ok_button->show(); diff --git a/synfig-studio/trunk/src/synfigapp/Makefile.am b/synfig-studio/trunk/src/synfigapp/Makefile.am index c1dd93c..f6402e6 100644 --- a/synfig-studio/trunk/src/synfigapp/Makefile.am +++ b/synfig-studio/trunk/src/synfigapp/Makefile.am @@ -63,9 +63,11 @@ KEYFRAME_ACTION_CC = \ actions/keyframesetdelta.cpp actions/keyframewaypointset.cpp CANVAS_ACTION_HH = \ - actions/canvasadd.h actions/canvasremove.h actions/canvasrenddescset.h + actions/canvasadd.h actions/canvasdescriptionset.h actions/canvasidset.h actions/canvasnameset.h \ + actions/canvasremove.h actions/canvasrenddescset.h CANVAS_ACTION_CC = \ - actions/canvasadd.cpp actions/canvasremove.cpp actions/canvasrenddescset.cpp + actions/canvasadd.cpp actions/canvasdescriptionset.cpp actions/canvasidset.cpp actions/canvasnameset.cpp \ + actions/canvasremove.cpp actions/canvasrenddescset.cpp GROUP_ACTION_HH = \ actions/groupaddlayers.h actions/groupremove.h actions/groupremovelayers.h actions/grouprename.h diff --git a/synfig-studio/trunk/src/synfigapp/action.cpp b/synfig-studio/trunk/src/synfigapp/action.cpp index 5193f7b..5332434 100644 --- a/synfig-studio/trunk/src/synfigapp/action.cpp +++ b/synfig-studio/trunk/src/synfigapp/action.cpp @@ -95,6 +95,9 @@ #include "actions/timepointscopy.h" #include "actions/timepointsdelete.h" +#include "actions/canvasdescriptionset.h" +#include "actions/canvasidset.h" +#include "actions/canvasnameset.h" #include "actions/canvasrenddescset.h" #include "actions/canvasadd.h" #include "actions/canvasremove.h" @@ -206,6 +209,9 @@ Action::Main::Main() ADD_ACTION(Action::KeyframeWaypointSet); ADD_ACTION(Action::KeyframeSetDelta); + ADD_ACTION(Action::CanvasDescriptionSet); + ADD_ACTION(Action::CanvasIdSet); + ADD_ACTION(Action::CanvasNameSet); ADD_ACTION(Action::CanvasRendDescSet); ADD_ACTION(Action::CanvasAdd); ADD_ACTION(Action::CanvasRemove); diff --git a/synfig-studio/trunk/src/synfigapp/actions/canvasdescriptionset.cpp b/synfig-studio/trunk/src/synfigapp/actions/canvasdescriptionset.cpp new file mode 100644 index 0000000..91b2a8b --- /dev/null +++ b/synfig-studio/trunk/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,"canvas_description_set"); +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"); +} diff --git a/synfig-studio/trunk/src/synfigapp/actions/canvasdescriptionset.h b/synfig-studio/trunk/src/synfigapp/actions/canvasdescriptionset.h new file mode 100644 index 0000000..76496a4 --- /dev/null +++ b/synfig-studio/trunk/src/synfigapp/actions/canvasdescriptionset.h @@ -0,0 +1,75 @@ +/* === S Y N F I G ========================================================= */ +/*! \file canvasdescriptionset.h +** \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 +*/ +/* ========================================================================= */ + +/* === S T A R T =========================================================== */ + +#ifndef __SYNFIG_APP_ACTION_CANVASDESCRIPTIONSET_H +#define __SYNFIG_APP_ACTION_CANVASDESCRIPTIONSET_H + +/* === H E A D E R S ======================================================= */ + +#include + +/* === M A C R O S ========================================================= */ + +/* === T Y P E D E F S ===================================================== */ + +/* === C L A S S E S & S T R U C T S ======================================= */ + +namespace synfigapp { + +class Instance; + +namespace Action { + +class CanvasDescriptionSet : + public Undoable, + public CanvasSpecific +{ +private: + + synfig::String new_description; + synfig::String old_description; + +public: + + CanvasDescriptionSet(); + + static ParamVocab get_param_vocab(); + static bool is_candidate(const ParamList &x); + + virtual bool set_param(const synfig::String& description, const Param &); + virtual bool is_ready()const; + + virtual void perform(); + virtual void undo(); + + ACTION_MODULE_EXT +}; + +}; // END of namespace action +}; // END of namespace studio + +/* === E N D =============================================================== */ + +#endif diff --git a/synfig-studio/trunk/src/synfigapp/actions/canvasidset.cpp b/synfig-studio/trunk/src/synfigapp/actions/canvasidset.cpp new file mode 100644 index 0000000..a35cf97 --- /dev/null +++ b/synfig-studio/trunk/src/synfigapp/actions/canvasidset.cpp @@ -0,0 +1,141 @@ +/* === S Y N F I G ========================================================= */ +/*! \file canvasidset.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 "canvasidset.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::CanvasIdSet); +ACTION_SET_NAME(Action::CanvasIdSet,"canvas_id_set"); +ACTION_SET_LOCAL_NAME(Action::CanvasIdSet,N_("Set Canvas Id")); +ACTION_SET_TASK(Action::CanvasIdSet,"set"); +ACTION_SET_CATEGORY(Action::CanvasIdSet,Action::CATEGORY_CANVAS); +ACTION_SET_PRIORITY(Action::CanvasIdSet,0); +ACTION_SET_VERSION(Action::CanvasIdSet,"0.0"); +ACTION_SET_CVS_ID(Action::CanvasIdSet,"$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::CanvasIdSet::CanvasIdSet() +{ +} + +synfig::String +Action::CanvasIdSet::get_local_name()const +{ + // TRANSLATORS: This is used in the 'history' dialog when a Canvas has its id changed. + return strprintf(_("Change canvas id from '%s' to '%s'"), + old_id.c_str(), + new_id.c_str()); +} + +Action::ParamVocab +Action::CanvasIdSet::get_param_vocab() +{ + ParamVocab ret(Action::CanvasSpecific::get_param_vocab()); + + ret.push_back(ParamDesc("id",Param::TYPE_STRING) + .set_local_name(_("Id")) + ); + + return ret; +} + +bool +Action::CanvasIdSet::is_candidate(const ParamList &x) +{ + return candidate_check(get_param_vocab(),x); +} + +bool +Action::CanvasIdSet::set_param(const synfig::String& id, const Action::Param ¶m) +{ + if(id=="id" && param.get_type()==Param::TYPE_STRING) + { + new_id=param.get_string(); + + return true; + } + + return Action::CanvasSpecific::set_param(id,param); +} + +bool +Action::CanvasIdSet::is_ready()const +{ + if(new_id.empty()) + { + synfig::error("Action::CanvasIdSet::is_ready(): Id not set!"); + return false; + } + + return Action::CanvasSpecific::is_ready(); +} + +void +Action::CanvasIdSet::perform() +{ + old_id=get_canvas()->get_id(); + + get_canvas()->set_id(new_id); + + if(get_canvas_interface()) + get_canvas_interface()->signal_id_changed()(); + else + synfig::warning("CanvasInterface not set on action"); +} + +void +Action::CanvasIdSet::undo() +{ + get_canvas()->set_id(old_id); + + if(get_canvas_interface()) + get_canvas_interface()->signal_id_changed()(); + else + synfig::warning("CanvasInterface not set on action"); +} diff --git a/synfig-studio/trunk/src/synfigapp/actions/canvasidset.h b/synfig-studio/trunk/src/synfigapp/actions/canvasidset.h new file mode 100644 index 0000000..a28b611 --- /dev/null +++ b/synfig-studio/trunk/src/synfigapp/actions/canvasidset.h @@ -0,0 +1,75 @@ +/* === S Y N F I G ========================================================= */ +/*! \file canvasidset.h +** \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 +*/ +/* ========================================================================= */ + +/* === S T A R T =========================================================== */ + +#ifndef __SYNFIG_APP_ACTION_CANVASIDSET_H +#define __SYNFIG_APP_ACTION_CANVASIDSET_H + +/* === H E A D E R S ======================================================= */ + +#include + +/* === M A C R O S ========================================================= */ + +/* === T Y P E D E F S ===================================================== */ + +/* === C L A S S E S & S T R U C T S ======================================= */ + +namespace synfigapp { + +class Instance; + +namespace Action { + +class CanvasIdSet : + public Undoable, + public CanvasSpecific +{ +private: + + synfig::String new_id; + synfig::String old_id; + +public: + + CanvasIdSet(); + + static ParamVocab get_param_vocab(); + static bool is_candidate(const ParamList &x); + + virtual bool set_param(const synfig::String& id, const Param &); + virtual bool is_ready()const; + + virtual void perform(); + virtual void undo(); + + ACTION_MODULE_EXT +}; + +}; // END of namespace action +}; // END of namespace studio + +/* === E N D =============================================================== */ + +#endif diff --git a/synfig-studio/trunk/src/synfigapp/actions/canvasnameset.cpp b/synfig-studio/trunk/src/synfigapp/actions/canvasnameset.cpp new file mode 100644 index 0000000..8b0088c --- /dev/null +++ b/synfig-studio/trunk/src/synfigapp/actions/canvasnameset.cpp @@ -0,0 +1,141 @@ +/* === S Y N F I G ========================================================= */ +/*! \file canvasnameset.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 "canvasnameset.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::CanvasNameSet); +ACTION_SET_NAME(Action::CanvasNameSet,"canvas_name_set"); +ACTION_SET_LOCAL_NAME(Action::CanvasNameSet,N_("Set Canvas Name")); +ACTION_SET_TASK(Action::CanvasNameSet,"set"); +ACTION_SET_CATEGORY(Action::CanvasNameSet,Action::CATEGORY_CANVAS); +ACTION_SET_PRIORITY(Action::CanvasNameSet,0); +ACTION_SET_VERSION(Action::CanvasNameSet,"0.0"); +ACTION_SET_CVS_ID(Action::CanvasNameSet,"$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::CanvasNameSet::CanvasNameSet() +{ +} + +synfig::String +Action::CanvasNameSet::get_local_name()const +{ + // TRANSLATORS: This is used in the 'history' dialog when a Canvas has its name changed. + return strprintf(_("Change canvas name from '%s' to '%s'"), + old_name.c_str(), + new_name.c_str()); +} + +Action::ParamVocab +Action::CanvasNameSet::get_param_vocab() +{ + ParamVocab ret(Action::CanvasSpecific::get_param_vocab()); + + ret.push_back(ParamDesc("name",Param::TYPE_STRING) + .set_local_name(_("Name")) + ); + + return ret; +} + +bool +Action::CanvasNameSet::is_candidate(const ParamList &x) +{ + return candidate_check(get_param_vocab(),x); +} + +bool +Action::CanvasNameSet::set_param(const synfig::String& name, const Action::Param ¶m) +{ + if(name=="name" && param.get_type()==Param::TYPE_STRING) + { + new_name=param.get_string(); + + return true; + } + + return Action::CanvasSpecific::set_param(name,param); +} + +bool +Action::CanvasNameSet::is_ready()const +{ + if(new_name.empty()) + { + synfig::error("Action::CanvasNameSet::is_ready(): Name not set!"); + return false; + } + + return Action::CanvasSpecific::is_ready(); +} + +void +Action::CanvasNameSet::perform() +{ + old_name=get_canvas()->get_name(); + + get_canvas()->set_name(new_name); + + if(get_canvas_interface()) + get_canvas_interface()->signal_id_changed()(); + else + synfig::warning("CanvasInterface not set on action"); +} + +void +Action::CanvasNameSet::undo() +{ + get_canvas()->set_name(old_name); + + if(get_canvas_interface()) + get_canvas_interface()->signal_id_changed()(); + else + synfig::warning("CanvasInterface not set on action"); +} diff --git a/synfig-studio/trunk/src/synfigapp/actions/canvasnameset.h b/synfig-studio/trunk/src/synfigapp/actions/canvasnameset.h new file mode 100644 index 0000000..7d6395e --- /dev/null +++ b/synfig-studio/trunk/src/synfigapp/actions/canvasnameset.h @@ -0,0 +1,75 @@ +/* === S Y N F I G ========================================================= */ +/*! \file canvasnameset.h +** \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 +*/ +/* ========================================================================= */ + +/* === S T A R T =========================================================== */ + +#ifndef __SYNFIG_APP_ACTION_CANVASNAMESET_H +#define __SYNFIG_APP_ACTION_CANVASNAMESET_H + +/* === H E A D E R S ======================================================= */ + +#include + +/* === M A C R O S ========================================================= */ + +/* === T Y P E D E F S ===================================================== */ + +/* === C L A S S E S & S T R U C T S ======================================= */ + +namespace synfigapp { + +class Instance; + +namespace Action { + +class CanvasNameSet : + public Undoable, + public CanvasSpecific +{ +private: + + synfig::String new_name; + synfig::String old_name; + +public: + + CanvasNameSet(); + + static ParamVocab get_param_vocab(); + static bool is_candidate(const ParamList &x); + + virtual bool set_param(const synfig::String& name, const Param &); + virtual bool is_ready()const; + + virtual void perform(); + virtual void undo(); + + ACTION_MODULE_EXT +}; + +}; // END of namespace action +}; // END of namespace studio + +/* === E N D =============================================================== */ + +#endif diff --git a/synfig-studio/trunk/src/synfigapp/canvasinterface.cpp b/synfig-studio/trunk/src/synfigapp/canvasinterface.cpp index 6619719..40d14df 100644 --- a/synfig-studio/trunk/src/synfigapp/canvasinterface.cpp +++ b/synfig-studio/trunk/src/synfigapp/canvasinterface.cpp @@ -477,30 +477,59 @@ CanvasInterface::set_rend_desc(const synfig::RendDesc &rend_desc) get_ui_interface()->error(_("Action Failed.")); } -bool +void CanvasInterface::set_name(const synfig::String &x) { - //! \todo This needs to be converted into an action - get_canvas()->set_name(x); + Action::Handle action(Action::create("canvas_name_set")); + + assert(action); + if(!action) + return; + + action->set_param("canvas",get_canvas()); + action->set_param("canvas_interface",etl::loose_handle(this)); + action->set_param("name",x); + + if(!get_instance()->perform_action(action)) + get_ui_interface()->error(_("Action Failed.")); + signal_id_changed_(); - return true; } -bool +void CanvasInterface::set_description(const synfig::String &x) { - //! \todo This needs to be converted into an action - get_canvas()->set_description(x); - return true; + Action::Handle action(Action::create("canvas_description_set")); + + assert(action); + if(!action) + return; + + action->set_param("canvas",get_canvas()); + action->set_param("canvas_interface",etl::loose_handle(this)); + action->set_param("description",x); + + if(!get_instance()->perform_action(action)) + get_ui_interface()->error(_("Action Failed.")); } -bool +void CanvasInterface::set_id(const synfig::String &x) { - //! \todo This needs to be converted into an action - get_canvas()->set_id(x); + Action::Handle action(Action::create("canvas_id_set")); + + assert(action); + if(!action) + return; + + action->set_param("canvas",get_canvas()); + action->set_param("canvas_interface",etl::loose_handle(this)); + action->set_param("id",x); + + if(!get_instance()->perform_action(action)) + get_ui_interface()->error(_("Action Failed.")); + signal_id_changed_(); - return true; } diff --git a/synfig-studio/trunk/src/synfigapp/canvasinterface.h b/synfig-studio/trunk/src/synfigapp/canvasinterface.h index 878f562..1d82f05 100644 --- a/synfig-studio/trunk/src/synfigapp/canvasinterface.h +++ b/synfig-studio/trunk/src/synfigapp/canvasinterface.h @@ -211,13 +211,13 @@ public: etl::loose_handle get_instance()const { return instance_; } //! Changes the name of the canvas. Undoable. - bool set_name(const synfig::String &x); + void set_name(const synfig::String &x); //! Changes the description of the canvas. Undoable. - bool set_description(const synfig::String &x); + void set_description(const synfig::String &x); //! Changes the ID of the canvas. Undoable. - bool set_id(const synfig::String &x); + void set_id(const synfig::String &x); //! Convenience function to retrieve the name of the canvas synfig::String get_name()const { return get_canvas()->get_name(); } -- 2.7.4