dialogBox->pack_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();
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
#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"
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);
--- /dev/null
+/* === 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 <config.h>
+#endif
+
+#include "canvasdescriptionset.h"
+#include <synfigapp/canvasinterface.h>
+
+#include <synfigapp/general.h>
+
+#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");
+}
--- /dev/null
+/* === 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 <synfigapp/action.h>
+
+/* === 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
--- /dev/null
+/* === 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 <config.h>
+#endif
+
+#include "canvasidset.h"
+#include <synfigapp/canvasinterface.h>
+
+#include <synfigapp/general.h>
+
+#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");
+}
--- /dev/null
+/* === 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 <synfigapp/action.h>
+
+/* === 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
--- /dev/null
+/* === 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 <config.h>
+#endif
+
+#include "canvasnameset.h"
+#include <synfigapp/canvasinterface.h>
+
+#include <synfigapp/general.h>
+
+#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");
+}
--- /dev/null
+/* === 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 <synfigapp/action.h>
+
+/* === 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
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<CanvasInterface>(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<CanvasInterface>(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<CanvasInterface>(this));
+ action->set_param("id",x);
+
+ if(!get_instance()->perform_action(action))
+ get_ui_interface()->error(_("Action Failed."));
+
signal_id_changed_();
- return true;
}
etl::loose_handle<Instance> 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(); }