Move action managers into subfolder
authorNikita Kitaev <nikitakit@gmail.com>
Sat, 17 Apr 2010 06:53:06 +0000 (23:53 -0700)
committerNikita Kitaev <nikitakit@gmail.com>
Sat, 17 Apr 2010 06:53:06 +0000 (23:53 -0700)
16 files changed:
synfig-studio/src/gui/Makefile.am
synfig-studio/src/gui/actionmanagers/groupactionmanager.cpp [new file with mode: 0644]
synfig-studio/src/gui/actionmanagers/groupactionmanager.h [new file with mode: 0644]
synfig-studio/src/gui/actionmanagers/keyframeactionmanager.cpp [new file with mode: 0644]
synfig-studio/src/gui/actionmanagers/keyframeactionmanager.h [new file with mode: 0644]
synfig-studio/src/gui/actionmanagers/layeractionmanager.cpp [new file with mode: 0644]
synfig-studio/src/gui/actionmanagers/layeractionmanager.h [new file with mode: 0644]
synfig-studio/src/gui/docks/dock_keyframes.cpp
synfig-studio/src/gui/docks/dock_layergroups.cpp
synfig-studio/src/gui/docks/dock_layers.cpp
synfig-studio/src/gui/groupactionmanager.cpp [deleted file]
synfig-studio/src/gui/groupactionmanager.h [deleted file]
synfig-studio/src/gui/keyframeactionmanager.cpp [deleted file]
synfig-studio/src/gui/keyframeactionmanager.h [deleted file]
synfig-studio/src/gui/layeractionmanager.cpp [deleted file]
synfig-studio/src/gui/layeractionmanager.h [deleted file]

index ac42f1b..6a44796 100644 (file)
@@ -248,14 +248,14 @@ EVENTS_HH = \
 
 
 ACTION_MANAGERS_HH = \
-       groupactionmanager.h \
-       keyframeactionmanager.h \
-       layeractionmanager.h
+       actionmanagers/groupactionmanager.h \
+       actionmanagers/keyframeactionmanager.h \
+       actionmanagers/layeractionmanager.h
 
 ACTION_MANAGERS_CC = \
-       groupactionmanager.cpp \
-       keyframeactionmanager.cpp \
-       layeractionmanager.cpp
+       actionmanagers/groupactionmanager.cpp \
+       actionmanagers/keyframeactionmanager.cpp \
+       actionmanagers/layeractionmanager.cpp
 
 
 OTHER_HH = \
diff --git a/synfig-studio/src/gui/actionmanagers/groupactionmanager.cpp b/synfig-studio/src/gui/actionmanagers/groupactionmanager.cpp
new file mode 100644 (file)
index 0000000..2d77407
--- /dev/null
@@ -0,0 +1,275 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file groupactionmanager.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007 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 "groupactionmanager.h"
+#include "trees/layergrouptree.h"
+#include <synfigapp/action_param.h>
+#include "instance.h"
+#include <gtkmm/stock.h>
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace studio;
+
+static const guint no_prev_popup((guint)-1);
+
+/* === M A C R O S ========================================================= */
+
+//#define ONE_ACTION_GROUP 1
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+GroupActionManager::GroupActionManager():
+       action_group_(Gtk::ActionGroup::create("action_group_group_action_manager")),
+       popup_id_(no_prev_popup),
+       queued(false)
+{
+}
+
+GroupActionManager::~GroupActionManager()
+{
+}
+
+void
+GroupActionManager::set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x)
+{
+       clear();
+
+#ifdef ONE_ACTION_GROUP
+       if(ui_manager_) get_ui_manager()->remove_action_group(action_group_);
+       ui_manager_=x;
+       if(ui_manager_) get_ui_manager()->insert_action_group(action_group_);
+#else
+       ui_manager_=x;
+#endif
+}
+
+void
+GroupActionManager::set_group_tree(LayerGroupTree* x)
+{
+       selection_changed_connection.disconnect();
+       group_tree_=x;
+       if(group_tree_)
+       {
+               selection_changed_connection=group_tree_->get_selection()->signal_changed().connect(
+                       sigc::mem_fun(*this,&GroupActionManager::queue_refresh)
+               );
+       }
+}
+
+void
+GroupActionManager::set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x)
+{
+       canvas_interface_=x;
+}
+
+void
+GroupActionManager::clear()
+{
+       if(ui_manager_)
+       {
+               // Clear out old stuff
+               if(popup_id_!=no_prev_popup)
+               {
+                       get_ui_manager()->remove_ui(popup_id_);
+                       popup_id_=no_prev_popup;
+                       action_group_->set_sensitive(false);
+#ifdef ONE_ACTION_GROUP
+                       while(!action_group_->get_actions().empty())action_group_->remove(*action_group_->get_actions().begin());
+                       action_group_->set_sensitive(true);
+#else
+                       get_ui_manager()->remove_action_group(action_group_);
+                       action_group_=Gtk::ActionGroup::create("action_group_group_action_manager");
+#endif
+               }
+       }
+}
+
+void
+GroupActionManager::queue_refresh()
+{
+       if(queued)
+               return;
+
+       //queue_refresh_connection.disconnect();
+       queue_refresh_connection=Glib::signal_idle().connect(
+               sigc::bind_return(
+                       sigc::mem_fun(*this,&GroupActionManager::refresh),
+                       false
+               )
+       );
+
+       queued=true;
+}
+
+void
+GroupActionManager::refresh()
+{
+       if(queued)
+       {
+               queued=false;
+               //queue_refresh_connection.disconnect();
+       }
+
+
+       clear();
+
+       // Make sure we are ready
+       if(!ui_manager_ || !group_tree_ || !canvas_interface_)
+       {
+               synfig::error("GroupActionManager::refresh(): Not ready!");
+               return;
+       }
+
+       if(group_tree_->get_selection()->count_selected_rows()==0)
+               return;
+
+       String ui_info;
+
+       {
+               {
+                       action_group_->add(
+                               Gtk::Action::create(
+                                       "action-group_add",
+                                       Gtk::Stock::ADD,
+                                       _("Add a New Group"),
+                                       _("Add a New Group")
+                               ),
+                               sigc::mem_fun(
+                                       *this,
+                                       &GroupActionManager::on_action_add
+                               )
+                       );
+               }
+
+
+//             bool multiple_selected(group_tree_->get_selection()->count_selected_rows()>1);
+               LayerGroupTree::LayerList selected_layers(group_tree_->get_selected_layers());
+               std::list<synfig::String> selected_groups(group_tree_->get_selected_groups());
+
+               synfig::info("selected_layers.size()=%d",selected_layers.size());
+               synfig::info("selected_groups.size()=%d",selected_groups.size());
+
+               {
+                       bool canvas_set(false);
+                       synfigapp::Action::ParamList param_list;
+                       param_list.add("time",get_canvas_interface()->get_time());
+                       param_list.add("canvas_interface",get_canvas_interface());
+
+                       {
+                               LayerGroupTree::LayerList::iterator iter;
+
+                               for(iter=selected_layers.begin();iter!=selected_layers.end();++iter)
+                               {
+                                       if(!canvas_set)
+                                       {
+                                               param_list.add("canvas",Canvas::Handle(Layer::Handle(*iter)->get_canvas()));
+                                               canvas_set=true;
+                                       }
+                                       param_list.add("layer",Layer::Handle(*iter));
+                               }
+                       }
+
+                       {
+                               std::list<synfig::String>::iterator iter;
+
+                               for(iter=selected_groups.begin();iter!=selected_groups.end();++iter)
+                               {
+                                       param_list.add("group",(synfig::String)*iter);
+                               }
+                       }
+
+                       if(!canvas_set)
+                       {
+                               param_list.add("canvas",Canvas::Handle(get_canvas_interface()->get_canvas()));
+                               canvas_set=true;
+                       }
+
+                       handle<studio::Instance>::cast_static(get_canvas_interface()->get_instance())->
+                               add_actions_to_group(action_group_, ui_info,   param_list, synfigapp::Action::CATEGORY_GROUP);
+                       }
+       }
+
+       if(true)
+       {
+               ui_info="<ui><popup action='menu-main'><menu action='menu-group'>"+ui_info+"</menu></popup></ui>";
+               popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
+       }
+       else
+       {
+               get_ui_manager()->ensure_update();
+       }
+
+#ifdef ONE_ACTION_GROUP
+#else
+       get_ui_manager()->insert_action_group(action_group_);
+#endif
+}
+
+void
+GroupActionManager::on_action_add()
+{
+       LayerGroupTreeStore::Model model;
+
+       String group_name;
+
+       Gtk::TreeIter selected_iter;
+
+       if(group_tree_->get_selection()->count_selected_rows())
+       {
+               selected_iter=(
+                       group_tree_->get_model()->get_iter(
+                               (*group_tree_->get_selection()->get_selected_rows().begin())
+                       )
+               );
+               if(selected_iter && selected_iter->parent())
+                       group_name=(Glib::ustring)(*selected_iter->parent())[model.group_name]+'.';
+       }
+
+       group_name+=_("UnnamedGroup");
+
+       Gtk::TreePath path(group_tree_->get_model()->on_group_added(group_name));
+
+       group_tree_->expand_to_path(path);
+       group_tree_->set_cursor(path,true);
+}
diff --git a/synfig-studio/src/gui/actionmanagers/groupactionmanager.h b/synfig-studio/src/gui/actionmanagers/groupactionmanager.h
new file mode 100644 (file)
index 0000000..0e232f9
--- /dev/null
@@ -0,0 +1,85 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file groupactionmanager.h
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**
+**     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_GROUP_ACTION_MANAGER_H
+#define __SYNFIG_GROUP_ACTION_MANAGER_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/uimanager.h>
+#include <gtkmm/treeview.h>
+#include <synfigapp/canvasinterface.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 studio {
+
+class LayerGroupTree;
+
+class GroupActionManager
+{
+       Glib::RefPtr<Gtk::UIManager> ui_manager_;
+       LayerGroupTree* group_tree_;
+       etl::handle<synfigapp::CanvasInterface> canvas_interface_;
+
+       Glib::RefPtr<Gtk::ActionGroup>  action_group_;
+       Gtk::UIManager::ui_merge_id     popup_id_;
+
+       sigc::connection selection_changed_connection;
+
+       bool queued;
+       sigc::connection queue_refresh_connection;
+
+private:
+
+       void on_action_add();
+
+public:
+       void queue_refresh();
+
+       GroupActionManager();
+       ~GroupActionManager();
+
+       void set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x);
+       Glib::RefPtr<Gtk::UIManager> get_ui_manager()const { return ui_manager_; }
+
+       void set_group_tree(LayerGroupTree* x);
+       LayerGroupTree* get_group_tree()const { return group_tree_; }
+
+       void set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x);
+       etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
+
+       void refresh();
+       void clear();
+}; // END of GroupActionManager
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/actionmanagers/keyframeactionmanager.cpp b/synfig-studio/src/gui/actionmanagers/keyframeactionmanager.cpp
new file mode 100644 (file)
index 0000000..906591b
--- /dev/null
@@ -0,0 +1,251 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file keyframeactionmanager.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007 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 "keyframeactionmanager.h"
+#include "trees/keyframetree.h"
+#include <synfigapp/action_param.h>
+#include "instance.h"
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace studio;
+
+static const guint no_prev_popup((guint)-1);
+
+/* === M A C R O S ========================================================= */
+
+//#define ONE_ACTION_GROUP 1
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+KeyframeActionManager::KeyframeActionManager():
+       action_group_(Gtk::ActionGroup::create("action_group_keyframe_action_manager")),
+       popup_id_(no_prev_popup),
+       queued(false)
+{
+}
+
+KeyframeActionManager::~KeyframeActionManager()
+{
+}
+
+void
+KeyframeActionManager::set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x)
+{
+       clear();
+
+#ifdef ONE_ACTION_GROUP
+       if(ui_manager_) get_ui_manager()->remove_action_group(action_group_);
+       ui_manager_=x;
+       if(ui_manager_) get_ui_manager()->insert_action_group(action_group_);
+#else
+       ui_manager_=x;
+#endif
+}
+
+void
+KeyframeActionManager::set_keyframe_tree(KeyframeTree* x)
+{
+       selection_changed_connection.disconnect();
+       keyframe_tree_=x;
+       if(keyframe_tree_)
+       {
+               selection_changed_connection=keyframe_tree_->get_selection()->signal_changed().connect(
+                       sigc::mem_fun(*this,&KeyframeActionManager::queue_refresh)
+               );
+       }
+}
+
+void
+KeyframeActionManager::set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x)
+{
+       time_changed_connection.disconnect();
+       canvas_interface_=x;
+       if(canvas_interface_)
+       {
+               canvas_interface_->signal_time_changed().connect(
+                       sigc::mem_fun(*this,&KeyframeActionManager::queue_refresh)
+               );
+       }
+}
+
+void
+KeyframeActionManager::clear()
+{
+       if(ui_manager_)
+       {
+               // Clear out old stuff
+               if(popup_id_!=no_prev_popup)
+               {
+                       get_ui_manager()->remove_ui(popup_id_);
+                       popup_id_=no_prev_popup;
+#ifdef ONE_ACTION_GROUP
+                       while(!action_group_->get_actions().empty())action_group_->remove(*action_group_->get_actions().begin());
+#else
+                       get_ui_manager()->remove_action_group(action_group_);
+                       action_group_=Gtk::ActionGroup::create("action_group_keyframe_action_manager");
+#endif
+               }
+       }
+}
+
+void
+KeyframeActionManager::queue_refresh()
+{
+       if(queued)
+               return;
+
+       //queue_refresh_connection.disconnect();
+       queue_refresh_connection=Glib::signal_idle().connect(
+               sigc::bind_return(
+                       sigc::mem_fun(*this,&KeyframeActionManager::refresh),
+                       false
+               )
+       );
+
+       queued=true;
+}
+
+void
+KeyframeActionManager::on_keyframe_properties()
+{
+       signal_show_keyframe_properties_();
+}
+
+void
+KeyframeActionManager::on_add_keyframe()
+{
+       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeAdd"));
+
+       if(!action)
+               return;
+
+       action->set_param("canvas",canvas_interface_->get_canvas());
+       action->set_param("canvas_interface",canvas_interface_);
+       action->set_param("keyframe",Keyframe(canvas_interface_->get_time()));
+
+       canvas_interface_->get_instance()->perform_action(action);
+}
+
+void
+KeyframeActionManager::refresh()
+{
+       KeyframeTreeStore::Model model;
+
+       if(queued)
+       {
+               queued=false;
+               //queue_refresh_connection.disconnect();
+       }
+
+
+       clear();
+
+       // Make sure we are ready
+       if(!ui_manager_ || !keyframe_tree_ || !canvas_interface_)
+       {
+               synfig::error("KeyframeActionManager::refresh(): Not ready!");
+               return;
+       }
+
+       String ui_info;
+
+       {
+               synfigapp::Action::ParamList param_list;
+               param_list.add("time",get_canvas_interface()->get_time());
+               param_list.add("canvas",get_canvas_interface()->get_canvas());
+               param_list.add("canvas_interface",get_canvas_interface());
+               if(keyframe_tree_->get_selection()->count_selected_rows()==1)
+               {
+                       Keyframe keyframe((*keyframe_tree_->get_selection()->get_selected())[model.keyframe]);
+                       param_list.add("keyframe",keyframe);
+               }
+
+               handle<studio::Instance>::cast_static(
+                       get_canvas_interface()->get_instance()
+               )->add_actions_to_group(
+                       action_group_,
+                       ui_info,
+                       param_list,
+                       synfigapp::Action::CATEGORY_KEYFRAME
+               );
+       }
+       if(action_group_->get_action("action-KeyframeAdd"))
+       {
+               action_group_->remove(action_group_->get_action("action-KeyframeAdd"));
+       }
+
+               action_group_->add(Gtk::Action::create(
+                       "action-KeyframeAdd",
+                       Gtk::StockID("gtk-add"),
+                       _("Add New Keyframe"),_("Add New Keyframe")
+               ),
+                       sigc::mem_fun(*this,&KeyframeActionManager::on_add_keyframe)
+               );
+
+       try
+       {
+               canvas_interface_->get_canvas()->keyframe_list().find(canvas_interface_->get_time());
+               action_group_->get_action("action-KeyframeAdd")->set_sensitive(false);
+               if(action_group_->get_action("action-KeyframeDuplicate"))
+                       action_group_->get_action("action-KeyframeDuplicate")->set_sensitive(false);
+       }
+       catch(...)
+       {
+       }
+
+       {
+               Glib::RefPtr<Gtk::Action> action(Gtk::Action::create("keyframe-properties", Gtk::StockID("gtk-properties"),
+                                                                                                                        _("Keyframe Properties"), _("Keyframe Properties")));
+               action_group_->add(action,sigc::mem_fun(*this,&KeyframeActionManager::on_keyframe_properties));
+               if(keyframe_tree_->get_selection()->count_selected_rows()==0)
+                       action->set_sensitive(false);
+       }
+
+       ui_info="<ui><popup action='menu-main'><menu action='menu-keyframe'>"+ui_info+"</menu></popup></ui>";
+       popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
+#ifdef ONE_ACTION_GROUP
+#else
+       get_ui_manager()->insert_action_group(action_group_);
+#endif
+}
diff --git a/synfig-studio/src/gui/actionmanagers/keyframeactionmanager.h b/synfig-studio/src/gui/actionmanagers/keyframeactionmanager.h
new file mode 100644 (file)
index 0000000..9048a42
--- /dev/null
@@ -0,0 +1,91 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file keyframeactionmanager.h
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**
+**     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_KEYFRAME_ACTION_MANAGER_H
+#define __SYNFIG_KEYFRAME_ACTION_MANAGER_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/uimanager.h>
+#include <gtkmm/treeview.h>
+#include <synfigapp/canvasinterface.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 studio {
+
+class KeyframeTree;
+
+class KeyframeActionManager
+{
+       sigc::signal<void> signal_show_keyframe_properties_;
+
+       Glib::RefPtr<Gtk::UIManager> ui_manager_;
+       //Glib::RefPtr<Gtk::TreeSelection> tree_selection_;
+       KeyframeTree* keyframe_tree_;
+       etl::handle<synfigapp::CanvasInterface> canvas_interface_;
+
+       Glib::RefPtr<Gtk::ActionGroup>  action_group_;
+       Gtk::UIManager::ui_merge_id     popup_id_;
+
+
+       sigc::connection selection_changed_connection;
+
+       bool queued;
+       sigc::connection queue_refresh_connection;
+       sigc::connection time_changed_connection;
+
+       void on_add_keyframe();
+       void on_keyframe_properties();
+
+public:
+       sigc::signal<void>& signal_show_keyframe_properties() { return signal_show_keyframe_properties_; }
+
+       void queue_refresh();
+
+       KeyframeActionManager();
+       ~KeyframeActionManager();
+
+       void set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x);
+       Glib::RefPtr<Gtk::UIManager> get_ui_manager()const { return ui_manager_; }
+
+       void set_keyframe_tree(KeyframeTree* x);
+       KeyframeTree* get_keyframe_tree()const { return keyframe_tree_; }
+
+       void set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x);
+       etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
+
+       void refresh();
+       void clear();
+}; // END of KeyframeActionManager
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
diff --git a/synfig-studio/src/gui/actionmanagers/layeractionmanager.cpp b/synfig-studio/src/gui/actionmanagers/layeractionmanager.cpp
new file mode 100644 (file)
index 0000000..5f0538f
--- /dev/null
@@ -0,0 +1,524 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file layeractionmanager.cpp
+**     \brief Template File
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**     Copyright (c) 2007, 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 "layeractionmanager.h"
+#include "trees/layertree.h"
+#include <synfig/context.h>
+#include <synfig/layer_pastecanvas.h>
+#include <synfigapp/action_param.h>
+#include "instance.h"
+#include <synfigapp/selectionmanager.h>
+
+#include "general.h"
+
+#endif
+
+/* === U S I N G =========================================================== */
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace studio;
+
+static const guint no_prev_popup((guint)-1);
+
+/* === M A C R O S ========================================================= */
+
+//#define ONE_ACTION_GROUP 1
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+LayerActionManager::LayerActionManager():
+       action_group_(Gtk::ActionGroup::create("action_group_layer_action_manager")),
+       popup_id_(no_prev_popup),
+       action_group_copy_paste(Gtk::ActionGroup::create("action_group_copy_paste")),
+       queued(false)
+{
+       action_cut_=Gtk::Action::create(
+               "cut",
+               Gtk::StockID("gtk-cut")
+       );
+       action_cut_->signal_activate().connect(
+               sigc::mem_fun(
+                       *this,
+                       &LayerActionManager::cut
+               )
+       );
+       action_copy_=Gtk::Action::create(
+               "copy",
+               Gtk::StockID("gtk-copy")
+       );
+       action_copy_->signal_activate().connect(
+               sigc::mem_fun(
+                       *this,
+                       &LayerActionManager::copy
+               )
+       );
+       action_paste_=Gtk::Action::create(
+               "paste",
+               Gtk::StockID("gtk-paste")
+       );
+       action_paste_->signal_activate().connect(
+               sigc::mem_fun(
+                       *this,
+                       &LayerActionManager::paste
+               )
+       );
+
+
+       action_amount_inc_=Gtk::Action::create(
+               "amount-inc",
+               Gtk::StockID("gtk-add"),
+               _("Increase Amount"),_("Increase Amount")
+       );
+       action_amount_inc_->signal_activate().connect(
+               sigc::mem_fun(
+                       *this,
+                       &LayerActionManager::amount_inc
+               )
+       );
+
+       action_amount_dec_=Gtk::Action::create(
+               "amount-dec",
+               Gtk::StockID("gtk-remove"),
+               _("Decrease Amount"),_("Decrease Amount")
+       );
+       action_amount_dec_->signal_activate().connect(
+               sigc::mem_fun(
+                       *this,
+                       &LayerActionManager::amount_dec
+               )
+       );
+
+       action_amount_=Gtk::Action::create(
+               "amount",
+               Gtk::StockID("gtk-index"),
+               _("Amount"),_("Amount")
+       );
+
+       action_select_all_child_layers_=Gtk::Action::create(
+               "select-all-child-layers",
+               Gtk::StockID("synfig-select_all_child_layers"),
+               _("Select All Child Layers"),_("Select All Child Layers")
+       );
+       action_select_all_child_layers_->set_sensitive(false);
+}
+
+LayerActionManager::~LayerActionManager()
+{
+}
+
+void
+LayerActionManager::set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x)
+{
+       clear();
+
+#ifdef ONE_ACTION_GROUP
+       if(ui_manager_) get_ui_manager()->remove_action_group(action_group_);
+       ui_manager_=x;
+       if(ui_manager_) get_ui_manager()->insert_action_group(action_group_);
+#else
+       ui_manager_=x;
+#endif
+}
+
+void
+LayerActionManager::set_layer_tree(LayerTree* x)
+{
+       selection_changed_connection.disconnect();
+       layer_tree_=x;
+       if(layer_tree_)
+       {
+               selection_changed_connection=layer_tree_->get_selection()->signal_changed().connect(
+                       sigc::mem_fun(*this,&LayerActionManager::queue_refresh)
+               );
+       }
+}
+
+void
+LayerActionManager::set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x)
+{
+       canvas_interface_=x;
+}
+
+void
+LayerActionManager::clear()
+{
+       if(ui_manager_)
+       {
+               // Clear out old stuff
+               if(popup_id_!=no_prev_popup)
+               {
+                       get_ui_manager()->remove_ui(popup_id_);
+                       if(action_group_)get_ui_manager()->ensure_update();
+                       popup_id_=no_prev_popup;
+                       if(action_group_)while(!action_group_->get_actions().empty())action_group_->remove(*action_group_->get_actions().begin());
+#ifdef ONE_ACTION_GROUP
+#else
+                       if(action_group_)get_ui_manager()->remove_action_group(action_group_);
+                       action_group_=Gtk::ActionGroup::create("action_group_layer_action_manager");
+#endif
+               }
+       }
+
+       while(!update_connection_list.empty())
+       {
+               update_connection_list.front().disconnect();
+               update_connection_list.pop_front();
+       }
+}
+
+void
+LayerActionManager::queue_refresh()
+{
+       if(queued)
+               return;
+
+       //queue_refresh_connection.disconnect();
+       queue_refresh_connection=Glib::signal_idle().connect(
+               sigc::bind_return(
+                       sigc::mem_fun(*this,&LayerActionManager::refresh),
+                       false
+               )
+       );
+
+       queued=true;
+}
+
+void
+LayerActionManager::refresh()
+{
+       if(queued)
+       {
+               queued=false;
+               //queue_refresh_connection.disconnect();
+       }
+
+
+       clear();
+
+       // Make sure we are ready
+       if(!ui_manager_ || !layer_tree_ || !canvas_interface_)
+       {
+               synfig::error("LayerActionManager::refresh(): Not ready!");
+               return;
+       }
+
+       String ui_info;
+
+       action_paste_->set_sensitive(!clipboard_.empty());
+       action_group_->add(action_paste_);
+
+       if(layer_tree_->get_selection()->count_selected_rows()!=0)
+       {
+               bool multiple_selected(layer_tree_->get_selection()->count_selected_rows()>1);
+               Layer::Handle layer(layer_tree_->get_selected_layer());
+
+               {
+                       bool canvas_set(false);
+                       synfigapp::Action::ParamList param_list;
+                       param_list.add("time",get_canvas_interface()->get_time());
+                       param_list.add("canvas_interface",get_canvas_interface());
+                       {
+                               synfigapp::SelectionManager::LayerList layer_list(layer_tree_->get_selected_layers());
+                               synfigapp::SelectionManager::LayerList::iterator iter;
+                               action_copy_->set_sensitive(!layer_list.empty());
+                               action_cut_->set_sensitive(!layer_list.empty());
+                               action_group_->add(action_copy_);
+                               action_group_->add(action_cut_);
+
+                               action_amount_inc_->set_sensitive(!layer_list.empty());
+                               action_amount_dec_->set_sensitive(!layer_list.empty());
+                               action_amount_->set_sensitive(!layer_list.empty());
+                               action_group_->add(action_amount_inc_);
+                               action_group_->add(action_amount_dec_);
+                               action_group_->add(action_amount_);
+
+                               for(iter=layer_list.begin();iter!=layer_list.end();++iter)
+                               {
+                                       update_connection_list.push_back(
+                                               (*iter)->signal_changed().connect(
+                                                       sigc::mem_fun(*this, &LayerActionManager::queue_refresh)
+                                               )
+                                       );
+
+                                       if(!canvas_set)
+                                       {
+                                               param_list.add("canvas",Canvas::Handle((*iter)->get_canvas()));
+                                               canvas_set=true;
+                                               update_connection_list.push_back(
+                                                       (*iter)->get_canvas()->signal_changed().connect(
+                                                               sigc::mem_fun(*this, &LayerActionManager::queue_refresh)
+                                                       )
+                                               );
+                                       }
+                                       param_list.add("layer",Layer::Handle(*iter));
+                               }
+                       }
+
+                       if(!multiple_selected && layer->get_name()=="PasteCanvas")
+                       {
+                               if (select_all_child_layers_connection)
+                                       select_all_child_layers_connection.disconnect();
+
+                               select_all_child_layers_connection = action_select_all_child_layers_->signal_activate().connect(
+                                       sigc::bind(sigc::mem_fun(*layer_tree_,
+                                                                                        &studio::LayerTree::select_all_children_layers),
+                                                          Layer::LooseHandle(layer)));
+
+                               action_select_all_child_layers_->set_sensitive(true);
+
+                               ui_info+="<menuitem action='select-all-child-layers'/>";
+                       }
+                       else
+                               action_select_all_child_layers_->set_sensitive(false);
+
+                       handle<studio::Instance>::cast_static(get_canvas_interface()->get_instance())->
+                               add_actions_to_group(action_group_, ui_info,   param_list, synfigapp::Action::CATEGORY_LAYER);
+               }
+       }
+
+       ui_info=("<ui>"
+                          "<popup action='menu-main'>"
+                            "<menu action='menu-layer'>" +
+                                  ui_info +
+                                  "<separator/>"
+                              "<menuitem action='cut' />"
+                                  "<menuitem action='copy' />"
+                                  "<menuitem action='paste' />"
+                                  "<separator/>"
+                            "</menu>"
+                          "</popup>" +
+                        "</ui>");
+       popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
+#ifdef ONE_ACTION_GROUP
+#else
+       get_ui_manager()->insert_action_group(action_group_);
+#endif
+}
+
+void
+LayerActionManager::cut()
+{
+       copy();
+       if(action_group_->get_action("action-LayerRemove"))
+               action_group_->get_action("action-LayerRemove")->activate();
+}
+
+void
+LayerActionManager::copy()
+{
+       synfigapp::SelectionManager::LayerList layer_list(layer_tree_->get_selected_layers());
+       clipboard_.clear();
+       synfig::GUID guid;
+
+       while(!layer_list.empty())
+       {
+               clipboard_.push_back(layer_list.front()->clone(guid));
+               layer_list.pop_front();
+       }
+
+       action_paste_->set_sensitive(!clipboard_.empty());
+
+       //queue_refresh();
+}
+
+void
+LayerActionManager::paste()
+{
+       synfig::GUID guid;
+
+       // Create the action group
+       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Paste"));
+
+       Canvas::Handle canvas(get_canvas_interface()->get_canvas());
+       int depth(0);
+
+       // we are temporarily using the layer to hold something
+       Layer::Handle layer(layer_tree_->get_selected_layer());
+       if(layer)
+       {
+               depth=layer->get_depth();
+               canvas=layer->get_canvas();
+       }
+
+       synfigapp::SelectionManager::LayerList layer_selection;
+
+       for(std::list<synfig::Layer::Handle>::iterator iter=clipboard_.begin();iter!=clipboard_.end();++iter)
+       {
+               layer=(*iter)->clone(guid);
+               layer_selection.push_back(layer);
+               synfigapp::Action::Handle       action(synfigapp::Action::create("LayerAdd"));
+
+               assert(action);
+               if(!action)
+                       return;
+
+               action->set_param("canvas",canvas);
+               action->set_param("canvas_interface",etl::loose_handle<synfigapp::CanvasInterface>(get_canvas_interface()));
+               action->set_param("new",layer);
+
+               if(!action->is_ready())
+               {
+                       return;
+               }
+
+               if(!get_instance()->perform_action(action))
+               {
+                       return;
+               }
+
+               etl::handle<Layer_PasteCanvas> paste = etl::handle<Layer_PasteCanvas>::cast_dynamic(layer);
+               if (paste) paste->update_renddesc();
+
+               // synfig::info("DEPTH=%d",depth);
+
+               // Action to move the layer (if necessary)
+               if(depth>0)
+               {
+                       synfigapp::Action::Handle       action(synfigapp::Action::create("LayerMove"));
+
+                       assert(action);
+                       if(!action)
+                               return;
+
+                       action->set_param("canvas",canvas);
+                       action->set_param("canvas_interface",etl::loose_handle<synfigapp::CanvasInterface>(get_canvas_interface()));
+                       action->set_param("layer",layer);
+                       action->set_param("new_index",depth);
+
+                       if(!action->is_ready())
+                       {
+                               //get_ui_interface()->error(_("Move Action Not Ready"));
+                               //return 0;
+                               return;
+                       }
+
+                       if(!get_instance()->perform_action(action))
+                       {
+                               //get_ui_interface()->error(_("Move Action Not Ready"));
+                               //return 0;
+                               return;
+                       }
+               }
+               depth++;
+
+               // automatically export the Index parameter of Duplicate layers when pasting
+               int index = 1;
+               export_dup_nodes(layer, canvas, index);
+       }
+       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
+       get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
+}
+
+void
+LayerActionManager::export_dup_nodes(synfig::Layer::Handle layer, Canvas::Handle canvas, int &index)
+{
+       // automatically export the Index parameter of Duplicate layers when pasting
+       if (layer->get_name() == "duplicate")
+               while (true)
+               {
+                       String name = strprintf(_("Index %d"), index++);
+                       try
+                       {
+                               canvas->find_value_node(name);
+                       }
+                       catch (Exception::IDNotFound x)
+                       {
+                               get_canvas_interface()->add_value_node(layer->dynamic_param_list().find("index")->second, name);
+                               break;
+                       }
+               }
+       else
+       {
+               Layer::ParamList param_list(layer->get_param_list());
+               for (Layer::ParamList::const_iterator iter(param_list.begin())
+                                ; iter != param_list.end()
+                                ; iter++)
+                       if (layer->dynamic_param_list().count(iter->first)==0 && iter->second.get_type()==ValueBase::TYPE_CANVAS)
+                       {
+                               Canvas::Handle subcanvas(iter->second.get(Canvas::Handle()));
+                               if (subcanvas && subcanvas->is_inline())
+                                       for (Context iter = subcanvas->get_context(); iter != subcanvas->end(); iter++)
+                                               export_dup_nodes(*iter, canvas, index);
+                       }
+
+               for (Layer::DynamicParamList::const_iterator iter(layer->dynamic_param_list().begin())
+                                ; iter != layer->dynamic_param_list().end()
+                                ; iter++)
+                       if (iter->second->get_type()==ValueBase::TYPE_CANVAS)
+                       {
+                               Canvas::Handle canvas((*iter->second)(0).get(Canvas::Handle()));
+                               if (canvas->is_inline())
+                                       //! \todo do we need to implement this?  and if so, shouldn't we check all canvases, not just the one at t=0s?
+                                       warning("%s:%d not yet implemented - do we need to export duplicate valuenodes in dynamic canvas parameters?", __FILE__, __LINE__);
+                       }
+       }
+}
+
+void
+LayerActionManager::amount_inc()
+{
+       float adjust(0.1);
+
+       // Create the action group
+       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Increase Amount"));
+       synfigapp::SelectionManager::LayerList layer_list(layer_tree_->get_selected_layers());
+
+       for (; !layer_list.empty(); layer_list.pop_front())
+       {
+               ValueBase value(layer_list.front()->get_param("amount"));
+               if(value.same_type_as(Real()))
+                       get_canvas_interface()->change_value(synfigapp::ValueDesc(layer_list.front(),"amount"),value.get(Real())+adjust);
+       }
+}
+
+void
+LayerActionManager::amount_dec()
+{
+       float adjust(-0.1);
+
+       // Create the action group
+       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Decrease Amount"));
+       synfigapp::SelectionManager::LayerList layer_list(layer_tree_->get_selected_layers());
+
+       for (; !layer_list.empty(); layer_list.pop_front())
+       {
+               ValueBase value(layer_list.front()->get_param("amount"));
+               if(value.same_type_as(Real()))
+                       get_canvas_interface()->change_value(synfigapp::ValueDesc(layer_list.front(),"amount"),value.get(Real())+adjust);
+       }
+}
diff --git a/synfig-studio/src/gui/actionmanagers/layeractionmanager.h b/synfig-studio/src/gui/actionmanagers/layeractionmanager.h
new file mode 100644 (file)
index 0000000..91c400f
--- /dev/null
@@ -0,0 +1,112 @@
+/* === S Y N F I G ========================================================= */
+/*!    \file layeractionmanager.h
+**     \brief Template Header
+**
+**     $Id$
+**
+**     \legal
+**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+**
+**     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_LAYER_ACTION_MANAGER_H
+#define __SYNFIG_LAYER_ACTION_MANAGER_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <gtkmm/uimanager.h>
+#include <gtkmm/treeview.h>
+#include <synfigapp/canvasinterface.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 studio {
+
+class LayerTree;
+
+class LayerActionManager
+{
+       Glib::RefPtr<Gtk::UIManager> ui_manager_;
+       //Glib::RefPtr<Gtk::TreeSelection> tree_selection_;
+       LayerTree* layer_tree_;
+       etl::handle<synfigapp::CanvasInterface> canvas_interface_;
+
+       Glib::RefPtr<Gtk::ActionGroup>  action_group_;
+       Gtk::UIManager::ui_merge_id     popup_id_;
+
+
+       Glib::RefPtr<Gtk::ActionGroup> action_group_copy_paste;
+
+       Glib::RefPtr<Gtk::Action>       action_cut_;
+       Glib::RefPtr<Gtk::Action>       action_copy_;
+       Glib::RefPtr<Gtk::Action>       action_paste_;
+
+       Glib::RefPtr<Gtk::Action>       action_amount_inc_;
+       Glib::RefPtr<Gtk::Action>       action_amount_dec_;
+       Glib::RefPtr<Gtk::Action>       action_amount_;
+
+       Glib::RefPtr<Gtk::Action>       action_select_all_child_layers_;
+       sigc::connection                        select_all_child_layers_connection;
+
+       std::list<synfig::Layer::Handle> clipboard_;
+
+       sigc::connection selection_changed_connection;
+
+       bool queued;
+       sigc::connection queue_refresh_connection;
+
+       std::list<sigc::connection> update_connection_list;
+
+       void cut();
+       void copy();
+       void paste();
+       void export_dup_nodes(synfig::Layer::Handle, synfig::Canvas::Handle, int &);
+
+       void amount_inc();
+       void amount_dec();
+
+public:
+       void queue_refresh();
+
+       LayerActionManager();
+       ~LayerActionManager();
+
+       void set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x);
+       Glib::RefPtr<Gtk::UIManager> get_ui_manager()const { return ui_manager_; }
+
+       void set_layer_tree(LayerTree* x);
+       LayerTree* get_layer_tree()const { return layer_tree_; }
+
+       void set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x);
+       etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
+
+       etl::loose_handle<synfigapp::Instance> get_instance()const { return canvas_interface_->get_instance(); }
+
+       void refresh();
+       void clear();
+
+       Glib::RefPtr<Gtk::Action> get_action_select_all_child_layers() { return action_select_all_child_layers_; }
+}; // END of LayerActionManager
+
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
index c05b92c..50a3a9d 100644 (file)
@@ -41,7 +41,7 @@
 #include "trees/keyframetreestore.h"
 #include "trees/keyframetree.h"
 #include "canvasview.h"
-#include "keyframeactionmanager.h"
+#include "actionmanagers/keyframeactionmanager.h"
 
 #include "general.h"
 
index 03daeaf..e712af0 100644 (file)
@@ -43,7 +43,7 @@
 
 #include "trees/layergrouptreestore.h"
 #include "trees/layergrouptree.h"
-#include "groupactionmanager.h"
+#include "actionmanagers/groupactionmanager.h"
 
 #include "general.h"
 
index df0e4af..a626680 100644 (file)
@@ -43,7 +43,7 @@
 #include "trees/layertreestore.h"
 #include "trees/layertree.h"
 #include "canvasview.h"
-#include "layeractionmanager.h"
+#include "actionmanagers/layeractionmanager.h"
 //#include <ETL/ref_count>
 
 #include "general.h"
diff --git a/synfig-studio/src/gui/groupactionmanager.cpp b/synfig-studio/src/gui/groupactionmanager.cpp
deleted file mode 100644 (file)
index 2d77407..0000000
+++ /dev/null
@@ -1,275 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file groupactionmanager.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007 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 "groupactionmanager.h"
-#include "trees/layergrouptree.h"
-#include <synfigapp/action_param.h>
-#include "instance.h"
-#include <gtkmm/stock.h>
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace studio;
-
-static const guint no_prev_popup((guint)-1);
-
-/* === M A C R O S ========================================================= */
-
-//#define ONE_ACTION_GROUP 1
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-GroupActionManager::GroupActionManager():
-       action_group_(Gtk::ActionGroup::create("action_group_group_action_manager")),
-       popup_id_(no_prev_popup),
-       queued(false)
-{
-}
-
-GroupActionManager::~GroupActionManager()
-{
-}
-
-void
-GroupActionManager::set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x)
-{
-       clear();
-
-#ifdef ONE_ACTION_GROUP
-       if(ui_manager_) get_ui_manager()->remove_action_group(action_group_);
-       ui_manager_=x;
-       if(ui_manager_) get_ui_manager()->insert_action_group(action_group_);
-#else
-       ui_manager_=x;
-#endif
-}
-
-void
-GroupActionManager::set_group_tree(LayerGroupTree* x)
-{
-       selection_changed_connection.disconnect();
-       group_tree_=x;
-       if(group_tree_)
-       {
-               selection_changed_connection=group_tree_->get_selection()->signal_changed().connect(
-                       sigc::mem_fun(*this,&GroupActionManager::queue_refresh)
-               );
-       }
-}
-
-void
-GroupActionManager::set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x)
-{
-       canvas_interface_=x;
-}
-
-void
-GroupActionManager::clear()
-{
-       if(ui_manager_)
-       {
-               // Clear out old stuff
-               if(popup_id_!=no_prev_popup)
-               {
-                       get_ui_manager()->remove_ui(popup_id_);
-                       popup_id_=no_prev_popup;
-                       action_group_->set_sensitive(false);
-#ifdef ONE_ACTION_GROUP
-                       while(!action_group_->get_actions().empty())action_group_->remove(*action_group_->get_actions().begin());
-                       action_group_->set_sensitive(true);
-#else
-                       get_ui_manager()->remove_action_group(action_group_);
-                       action_group_=Gtk::ActionGroup::create("action_group_group_action_manager");
-#endif
-               }
-       }
-}
-
-void
-GroupActionManager::queue_refresh()
-{
-       if(queued)
-               return;
-
-       //queue_refresh_connection.disconnect();
-       queue_refresh_connection=Glib::signal_idle().connect(
-               sigc::bind_return(
-                       sigc::mem_fun(*this,&GroupActionManager::refresh),
-                       false
-               )
-       );
-
-       queued=true;
-}
-
-void
-GroupActionManager::refresh()
-{
-       if(queued)
-       {
-               queued=false;
-               //queue_refresh_connection.disconnect();
-       }
-
-
-       clear();
-
-       // Make sure we are ready
-       if(!ui_manager_ || !group_tree_ || !canvas_interface_)
-       {
-               synfig::error("GroupActionManager::refresh(): Not ready!");
-               return;
-       }
-
-       if(group_tree_->get_selection()->count_selected_rows()==0)
-               return;
-
-       String ui_info;
-
-       {
-               {
-                       action_group_->add(
-                               Gtk::Action::create(
-                                       "action-group_add",
-                                       Gtk::Stock::ADD,
-                                       _("Add a New Group"),
-                                       _("Add a New Group")
-                               ),
-                               sigc::mem_fun(
-                                       *this,
-                                       &GroupActionManager::on_action_add
-                               )
-                       );
-               }
-
-
-//             bool multiple_selected(group_tree_->get_selection()->count_selected_rows()>1);
-               LayerGroupTree::LayerList selected_layers(group_tree_->get_selected_layers());
-               std::list<synfig::String> selected_groups(group_tree_->get_selected_groups());
-
-               synfig::info("selected_layers.size()=%d",selected_layers.size());
-               synfig::info("selected_groups.size()=%d",selected_groups.size());
-
-               {
-                       bool canvas_set(false);
-                       synfigapp::Action::ParamList param_list;
-                       param_list.add("time",get_canvas_interface()->get_time());
-                       param_list.add("canvas_interface",get_canvas_interface());
-
-                       {
-                               LayerGroupTree::LayerList::iterator iter;
-
-                               for(iter=selected_layers.begin();iter!=selected_layers.end();++iter)
-                               {
-                                       if(!canvas_set)
-                                       {
-                                               param_list.add("canvas",Canvas::Handle(Layer::Handle(*iter)->get_canvas()));
-                                               canvas_set=true;
-                                       }
-                                       param_list.add("layer",Layer::Handle(*iter));
-                               }
-                       }
-
-                       {
-                               std::list<synfig::String>::iterator iter;
-
-                               for(iter=selected_groups.begin();iter!=selected_groups.end();++iter)
-                               {
-                                       param_list.add("group",(synfig::String)*iter);
-                               }
-                       }
-
-                       if(!canvas_set)
-                       {
-                               param_list.add("canvas",Canvas::Handle(get_canvas_interface()->get_canvas()));
-                               canvas_set=true;
-                       }
-
-                       handle<studio::Instance>::cast_static(get_canvas_interface()->get_instance())->
-                               add_actions_to_group(action_group_, ui_info,   param_list, synfigapp::Action::CATEGORY_GROUP);
-                       }
-       }
-
-       if(true)
-       {
-               ui_info="<ui><popup action='menu-main'><menu action='menu-group'>"+ui_info+"</menu></popup></ui>";
-               popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
-       }
-       else
-       {
-               get_ui_manager()->ensure_update();
-       }
-
-#ifdef ONE_ACTION_GROUP
-#else
-       get_ui_manager()->insert_action_group(action_group_);
-#endif
-}
-
-void
-GroupActionManager::on_action_add()
-{
-       LayerGroupTreeStore::Model model;
-
-       String group_name;
-
-       Gtk::TreeIter selected_iter;
-
-       if(group_tree_->get_selection()->count_selected_rows())
-       {
-               selected_iter=(
-                       group_tree_->get_model()->get_iter(
-                               (*group_tree_->get_selection()->get_selected_rows().begin())
-                       )
-               );
-               if(selected_iter && selected_iter->parent())
-                       group_name=(Glib::ustring)(*selected_iter->parent())[model.group_name]+'.';
-       }
-
-       group_name+=_("UnnamedGroup");
-
-       Gtk::TreePath path(group_tree_->get_model()->on_group_added(group_name));
-
-       group_tree_->expand_to_path(path);
-       group_tree_->set_cursor(path,true);
-}
diff --git a/synfig-studio/src/gui/groupactionmanager.h b/synfig-studio/src/gui/groupactionmanager.h
deleted file mode 100644 (file)
index 0e232f9..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file groupactionmanager.h
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**
-**     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_GROUP_ACTION_MANAGER_H
-#define __SYNFIG_GROUP_ACTION_MANAGER_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/uimanager.h>
-#include <gtkmm/treeview.h>
-#include <synfigapp/canvasinterface.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 studio {
-
-class LayerGroupTree;
-
-class GroupActionManager
-{
-       Glib::RefPtr<Gtk::UIManager> ui_manager_;
-       LayerGroupTree* group_tree_;
-       etl::handle<synfigapp::CanvasInterface> canvas_interface_;
-
-       Glib::RefPtr<Gtk::ActionGroup>  action_group_;
-       Gtk::UIManager::ui_merge_id     popup_id_;
-
-       sigc::connection selection_changed_connection;
-
-       bool queued;
-       sigc::connection queue_refresh_connection;
-
-private:
-
-       void on_action_add();
-
-public:
-       void queue_refresh();
-
-       GroupActionManager();
-       ~GroupActionManager();
-
-       void set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x);
-       Glib::RefPtr<Gtk::UIManager> get_ui_manager()const { return ui_manager_; }
-
-       void set_group_tree(LayerGroupTree* x);
-       LayerGroupTree* get_group_tree()const { return group_tree_; }
-
-       void set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x);
-       etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
-
-       void refresh();
-       void clear();
-}; // END of GroupActionManager
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gui/keyframeactionmanager.cpp b/synfig-studio/src/gui/keyframeactionmanager.cpp
deleted file mode 100644 (file)
index 906591b..0000000
+++ /dev/null
@@ -1,251 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file keyframeactionmanager.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007 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 "keyframeactionmanager.h"
-#include "trees/keyframetree.h"
-#include <synfigapp/action_param.h>
-#include "instance.h"
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace studio;
-
-static const guint no_prev_popup((guint)-1);
-
-/* === M A C R O S ========================================================= */
-
-//#define ONE_ACTION_GROUP 1
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-KeyframeActionManager::KeyframeActionManager():
-       action_group_(Gtk::ActionGroup::create("action_group_keyframe_action_manager")),
-       popup_id_(no_prev_popup),
-       queued(false)
-{
-}
-
-KeyframeActionManager::~KeyframeActionManager()
-{
-}
-
-void
-KeyframeActionManager::set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x)
-{
-       clear();
-
-#ifdef ONE_ACTION_GROUP
-       if(ui_manager_) get_ui_manager()->remove_action_group(action_group_);
-       ui_manager_=x;
-       if(ui_manager_) get_ui_manager()->insert_action_group(action_group_);
-#else
-       ui_manager_=x;
-#endif
-}
-
-void
-KeyframeActionManager::set_keyframe_tree(KeyframeTree* x)
-{
-       selection_changed_connection.disconnect();
-       keyframe_tree_=x;
-       if(keyframe_tree_)
-       {
-               selection_changed_connection=keyframe_tree_->get_selection()->signal_changed().connect(
-                       sigc::mem_fun(*this,&KeyframeActionManager::queue_refresh)
-               );
-       }
-}
-
-void
-KeyframeActionManager::set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x)
-{
-       time_changed_connection.disconnect();
-       canvas_interface_=x;
-       if(canvas_interface_)
-       {
-               canvas_interface_->signal_time_changed().connect(
-                       sigc::mem_fun(*this,&KeyframeActionManager::queue_refresh)
-               );
-       }
-}
-
-void
-KeyframeActionManager::clear()
-{
-       if(ui_manager_)
-       {
-               // Clear out old stuff
-               if(popup_id_!=no_prev_popup)
-               {
-                       get_ui_manager()->remove_ui(popup_id_);
-                       popup_id_=no_prev_popup;
-#ifdef ONE_ACTION_GROUP
-                       while(!action_group_->get_actions().empty())action_group_->remove(*action_group_->get_actions().begin());
-#else
-                       get_ui_manager()->remove_action_group(action_group_);
-                       action_group_=Gtk::ActionGroup::create("action_group_keyframe_action_manager");
-#endif
-               }
-       }
-}
-
-void
-KeyframeActionManager::queue_refresh()
-{
-       if(queued)
-               return;
-
-       //queue_refresh_connection.disconnect();
-       queue_refresh_connection=Glib::signal_idle().connect(
-               sigc::bind_return(
-                       sigc::mem_fun(*this,&KeyframeActionManager::refresh),
-                       false
-               )
-       );
-
-       queued=true;
-}
-
-void
-KeyframeActionManager::on_keyframe_properties()
-{
-       signal_show_keyframe_properties_();
-}
-
-void
-KeyframeActionManager::on_add_keyframe()
-{
-       synfigapp::Action::Handle action(synfigapp::Action::create("KeyframeAdd"));
-
-       if(!action)
-               return;
-
-       action->set_param("canvas",canvas_interface_->get_canvas());
-       action->set_param("canvas_interface",canvas_interface_);
-       action->set_param("keyframe",Keyframe(canvas_interface_->get_time()));
-
-       canvas_interface_->get_instance()->perform_action(action);
-}
-
-void
-KeyframeActionManager::refresh()
-{
-       KeyframeTreeStore::Model model;
-
-       if(queued)
-       {
-               queued=false;
-               //queue_refresh_connection.disconnect();
-       }
-
-
-       clear();
-
-       // Make sure we are ready
-       if(!ui_manager_ || !keyframe_tree_ || !canvas_interface_)
-       {
-               synfig::error("KeyframeActionManager::refresh(): Not ready!");
-               return;
-       }
-
-       String ui_info;
-
-       {
-               synfigapp::Action::ParamList param_list;
-               param_list.add("time",get_canvas_interface()->get_time());
-               param_list.add("canvas",get_canvas_interface()->get_canvas());
-               param_list.add("canvas_interface",get_canvas_interface());
-               if(keyframe_tree_->get_selection()->count_selected_rows()==1)
-               {
-                       Keyframe keyframe((*keyframe_tree_->get_selection()->get_selected())[model.keyframe]);
-                       param_list.add("keyframe",keyframe);
-               }
-
-               handle<studio::Instance>::cast_static(
-                       get_canvas_interface()->get_instance()
-               )->add_actions_to_group(
-                       action_group_,
-                       ui_info,
-                       param_list,
-                       synfigapp::Action::CATEGORY_KEYFRAME
-               );
-       }
-       if(action_group_->get_action("action-KeyframeAdd"))
-       {
-               action_group_->remove(action_group_->get_action("action-KeyframeAdd"));
-       }
-
-               action_group_->add(Gtk::Action::create(
-                       "action-KeyframeAdd",
-                       Gtk::StockID("gtk-add"),
-                       _("Add New Keyframe"),_("Add New Keyframe")
-               ),
-                       sigc::mem_fun(*this,&KeyframeActionManager::on_add_keyframe)
-               );
-
-       try
-       {
-               canvas_interface_->get_canvas()->keyframe_list().find(canvas_interface_->get_time());
-               action_group_->get_action("action-KeyframeAdd")->set_sensitive(false);
-               if(action_group_->get_action("action-KeyframeDuplicate"))
-                       action_group_->get_action("action-KeyframeDuplicate")->set_sensitive(false);
-       }
-       catch(...)
-       {
-       }
-
-       {
-               Glib::RefPtr<Gtk::Action> action(Gtk::Action::create("keyframe-properties", Gtk::StockID("gtk-properties"),
-                                                                                                                        _("Keyframe Properties"), _("Keyframe Properties")));
-               action_group_->add(action,sigc::mem_fun(*this,&KeyframeActionManager::on_keyframe_properties));
-               if(keyframe_tree_->get_selection()->count_selected_rows()==0)
-                       action->set_sensitive(false);
-       }
-
-       ui_info="<ui><popup action='menu-main'><menu action='menu-keyframe'>"+ui_info+"</menu></popup></ui>";
-       popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
-#ifdef ONE_ACTION_GROUP
-#else
-       get_ui_manager()->insert_action_group(action_group_);
-#endif
-}
diff --git a/synfig-studio/src/gui/keyframeactionmanager.h b/synfig-studio/src/gui/keyframeactionmanager.h
deleted file mode 100644 (file)
index 9048a42..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file keyframeactionmanager.h
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**
-**     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_KEYFRAME_ACTION_MANAGER_H
-#define __SYNFIG_KEYFRAME_ACTION_MANAGER_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/uimanager.h>
-#include <gtkmm/treeview.h>
-#include <synfigapp/canvasinterface.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 studio {
-
-class KeyframeTree;
-
-class KeyframeActionManager
-{
-       sigc::signal<void> signal_show_keyframe_properties_;
-
-       Glib::RefPtr<Gtk::UIManager> ui_manager_;
-       //Glib::RefPtr<Gtk::TreeSelection> tree_selection_;
-       KeyframeTree* keyframe_tree_;
-       etl::handle<synfigapp::CanvasInterface> canvas_interface_;
-
-       Glib::RefPtr<Gtk::ActionGroup>  action_group_;
-       Gtk::UIManager::ui_merge_id     popup_id_;
-
-
-       sigc::connection selection_changed_connection;
-
-       bool queued;
-       sigc::connection queue_refresh_connection;
-       sigc::connection time_changed_connection;
-
-       void on_add_keyframe();
-       void on_keyframe_properties();
-
-public:
-       sigc::signal<void>& signal_show_keyframe_properties() { return signal_show_keyframe_properties_; }
-
-       void queue_refresh();
-
-       KeyframeActionManager();
-       ~KeyframeActionManager();
-
-       void set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x);
-       Glib::RefPtr<Gtk::UIManager> get_ui_manager()const { return ui_manager_; }
-
-       void set_keyframe_tree(KeyframeTree* x);
-       KeyframeTree* get_keyframe_tree()const { return keyframe_tree_; }
-
-       void set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x);
-       etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
-
-       void refresh();
-       void clear();
-}; // END of KeyframeActionManager
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif
diff --git a/synfig-studio/src/gui/layeractionmanager.cpp b/synfig-studio/src/gui/layeractionmanager.cpp
deleted file mode 100644 (file)
index 5f0538f..0000000
+++ /dev/null
@@ -1,524 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file layeractionmanager.cpp
-**     \brief Template File
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**     Copyright (c) 2007, 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 "layeractionmanager.h"
-#include "trees/layertree.h"
-#include <synfig/context.h>
-#include <synfig/layer_pastecanvas.h>
-#include <synfigapp/action_param.h>
-#include "instance.h"
-#include <synfigapp/selectionmanager.h>
-
-#include "general.h"
-
-#endif
-
-/* === U S I N G =========================================================== */
-
-using namespace std;
-using namespace etl;
-using namespace synfig;
-using namespace studio;
-
-static const guint no_prev_popup((guint)-1);
-
-/* === M A C R O S ========================================================= */
-
-//#define ONE_ACTION_GROUP 1
-
-/* === G L O B A L S ======================================================= */
-
-/* === P R O C E D U R E S ================================================= */
-
-/* === M E T H O D S ======================================================= */
-
-LayerActionManager::LayerActionManager():
-       action_group_(Gtk::ActionGroup::create("action_group_layer_action_manager")),
-       popup_id_(no_prev_popup),
-       action_group_copy_paste(Gtk::ActionGroup::create("action_group_copy_paste")),
-       queued(false)
-{
-       action_cut_=Gtk::Action::create(
-               "cut",
-               Gtk::StockID("gtk-cut")
-       );
-       action_cut_->signal_activate().connect(
-               sigc::mem_fun(
-                       *this,
-                       &LayerActionManager::cut
-               )
-       );
-       action_copy_=Gtk::Action::create(
-               "copy",
-               Gtk::StockID("gtk-copy")
-       );
-       action_copy_->signal_activate().connect(
-               sigc::mem_fun(
-                       *this,
-                       &LayerActionManager::copy
-               )
-       );
-       action_paste_=Gtk::Action::create(
-               "paste",
-               Gtk::StockID("gtk-paste")
-       );
-       action_paste_->signal_activate().connect(
-               sigc::mem_fun(
-                       *this,
-                       &LayerActionManager::paste
-               )
-       );
-
-
-       action_amount_inc_=Gtk::Action::create(
-               "amount-inc",
-               Gtk::StockID("gtk-add"),
-               _("Increase Amount"),_("Increase Amount")
-       );
-       action_amount_inc_->signal_activate().connect(
-               sigc::mem_fun(
-                       *this,
-                       &LayerActionManager::amount_inc
-               )
-       );
-
-       action_amount_dec_=Gtk::Action::create(
-               "amount-dec",
-               Gtk::StockID("gtk-remove"),
-               _("Decrease Amount"),_("Decrease Amount")
-       );
-       action_amount_dec_->signal_activate().connect(
-               sigc::mem_fun(
-                       *this,
-                       &LayerActionManager::amount_dec
-               )
-       );
-
-       action_amount_=Gtk::Action::create(
-               "amount",
-               Gtk::StockID("gtk-index"),
-               _("Amount"),_("Amount")
-       );
-
-       action_select_all_child_layers_=Gtk::Action::create(
-               "select-all-child-layers",
-               Gtk::StockID("synfig-select_all_child_layers"),
-               _("Select All Child Layers"),_("Select All Child Layers")
-       );
-       action_select_all_child_layers_->set_sensitive(false);
-}
-
-LayerActionManager::~LayerActionManager()
-{
-}
-
-void
-LayerActionManager::set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x)
-{
-       clear();
-
-#ifdef ONE_ACTION_GROUP
-       if(ui_manager_) get_ui_manager()->remove_action_group(action_group_);
-       ui_manager_=x;
-       if(ui_manager_) get_ui_manager()->insert_action_group(action_group_);
-#else
-       ui_manager_=x;
-#endif
-}
-
-void
-LayerActionManager::set_layer_tree(LayerTree* x)
-{
-       selection_changed_connection.disconnect();
-       layer_tree_=x;
-       if(layer_tree_)
-       {
-               selection_changed_connection=layer_tree_->get_selection()->signal_changed().connect(
-                       sigc::mem_fun(*this,&LayerActionManager::queue_refresh)
-               );
-       }
-}
-
-void
-LayerActionManager::set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x)
-{
-       canvas_interface_=x;
-}
-
-void
-LayerActionManager::clear()
-{
-       if(ui_manager_)
-       {
-               // Clear out old stuff
-               if(popup_id_!=no_prev_popup)
-               {
-                       get_ui_manager()->remove_ui(popup_id_);
-                       if(action_group_)get_ui_manager()->ensure_update();
-                       popup_id_=no_prev_popup;
-                       if(action_group_)while(!action_group_->get_actions().empty())action_group_->remove(*action_group_->get_actions().begin());
-#ifdef ONE_ACTION_GROUP
-#else
-                       if(action_group_)get_ui_manager()->remove_action_group(action_group_);
-                       action_group_=Gtk::ActionGroup::create("action_group_layer_action_manager");
-#endif
-               }
-       }
-
-       while(!update_connection_list.empty())
-       {
-               update_connection_list.front().disconnect();
-               update_connection_list.pop_front();
-       }
-}
-
-void
-LayerActionManager::queue_refresh()
-{
-       if(queued)
-               return;
-
-       //queue_refresh_connection.disconnect();
-       queue_refresh_connection=Glib::signal_idle().connect(
-               sigc::bind_return(
-                       sigc::mem_fun(*this,&LayerActionManager::refresh),
-                       false
-               )
-       );
-
-       queued=true;
-}
-
-void
-LayerActionManager::refresh()
-{
-       if(queued)
-       {
-               queued=false;
-               //queue_refresh_connection.disconnect();
-       }
-
-
-       clear();
-
-       // Make sure we are ready
-       if(!ui_manager_ || !layer_tree_ || !canvas_interface_)
-       {
-               synfig::error("LayerActionManager::refresh(): Not ready!");
-               return;
-       }
-
-       String ui_info;
-
-       action_paste_->set_sensitive(!clipboard_.empty());
-       action_group_->add(action_paste_);
-
-       if(layer_tree_->get_selection()->count_selected_rows()!=0)
-       {
-               bool multiple_selected(layer_tree_->get_selection()->count_selected_rows()>1);
-               Layer::Handle layer(layer_tree_->get_selected_layer());
-
-               {
-                       bool canvas_set(false);
-                       synfigapp::Action::ParamList param_list;
-                       param_list.add("time",get_canvas_interface()->get_time());
-                       param_list.add("canvas_interface",get_canvas_interface());
-                       {
-                               synfigapp::SelectionManager::LayerList layer_list(layer_tree_->get_selected_layers());
-                               synfigapp::SelectionManager::LayerList::iterator iter;
-                               action_copy_->set_sensitive(!layer_list.empty());
-                               action_cut_->set_sensitive(!layer_list.empty());
-                               action_group_->add(action_copy_);
-                               action_group_->add(action_cut_);
-
-                               action_amount_inc_->set_sensitive(!layer_list.empty());
-                               action_amount_dec_->set_sensitive(!layer_list.empty());
-                               action_amount_->set_sensitive(!layer_list.empty());
-                               action_group_->add(action_amount_inc_);
-                               action_group_->add(action_amount_dec_);
-                               action_group_->add(action_amount_);
-
-                               for(iter=layer_list.begin();iter!=layer_list.end();++iter)
-                               {
-                                       update_connection_list.push_back(
-                                               (*iter)->signal_changed().connect(
-                                                       sigc::mem_fun(*this, &LayerActionManager::queue_refresh)
-                                               )
-                                       );
-
-                                       if(!canvas_set)
-                                       {
-                                               param_list.add("canvas",Canvas::Handle((*iter)->get_canvas()));
-                                               canvas_set=true;
-                                               update_connection_list.push_back(
-                                                       (*iter)->get_canvas()->signal_changed().connect(
-                                                               sigc::mem_fun(*this, &LayerActionManager::queue_refresh)
-                                                       )
-                                               );
-                                       }
-                                       param_list.add("layer",Layer::Handle(*iter));
-                               }
-                       }
-
-                       if(!multiple_selected && layer->get_name()=="PasteCanvas")
-                       {
-                               if (select_all_child_layers_connection)
-                                       select_all_child_layers_connection.disconnect();
-
-                               select_all_child_layers_connection = action_select_all_child_layers_->signal_activate().connect(
-                                       sigc::bind(sigc::mem_fun(*layer_tree_,
-                                                                                        &studio::LayerTree::select_all_children_layers),
-                                                          Layer::LooseHandle(layer)));
-
-                               action_select_all_child_layers_->set_sensitive(true);
-
-                               ui_info+="<menuitem action='select-all-child-layers'/>";
-                       }
-                       else
-                               action_select_all_child_layers_->set_sensitive(false);
-
-                       handle<studio::Instance>::cast_static(get_canvas_interface()->get_instance())->
-                               add_actions_to_group(action_group_, ui_info,   param_list, synfigapp::Action::CATEGORY_LAYER);
-               }
-       }
-
-       ui_info=("<ui>"
-                          "<popup action='menu-main'>"
-                            "<menu action='menu-layer'>" +
-                                  ui_info +
-                                  "<separator/>"
-                              "<menuitem action='cut' />"
-                                  "<menuitem action='copy' />"
-                                  "<menuitem action='paste' />"
-                                  "<separator/>"
-                            "</menu>"
-                          "</popup>" +
-                        "</ui>");
-       popup_id_=get_ui_manager()->add_ui_from_string(ui_info);
-#ifdef ONE_ACTION_GROUP
-#else
-       get_ui_manager()->insert_action_group(action_group_);
-#endif
-}
-
-void
-LayerActionManager::cut()
-{
-       copy();
-       if(action_group_->get_action("action-LayerRemove"))
-               action_group_->get_action("action-LayerRemove")->activate();
-}
-
-void
-LayerActionManager::copy()
-{
-       synfigapp::SelectionManager::LayerList layer_list(layer_tree_->get_selected_layers());
-       clipboard_.clear();
-       synfig::GUID guid;
-
-       while(!layer_list.empty())
-       {
-               clipboard_.push_back(layer_list.front()->clone(guid));
-               layer_list.pop_front();
-       }
-
-       action_paste_->set_sensitive(!clipboard_.empty());
-
-       //queue_refresh();
-}
-
-void
-LayerActionManager::paste()
-{
-       synfig::GUID guid;
-
-       // Create the action group
-       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Paste"));
-
-       Canvas::Handle canvas(get_canvas_interface()->get_canvas());
-       int depth(0);
-
-       // we are temporarily using the layer to hold something
-       Layer::Handle layer(layer_tree_->get_selected_layer());
-       if(layer)
-       {
-               depth=layer->get_depth();
-               canvas=layer->get_canvas();
-       }
-
-       synfigapp::SelectionManager::LayerList layer_selection;
-
-       for(std::list<synfig::Layer::Handle>::iterator iter=clipboard_.begin();iter!=clipboard_.end();++iter)
-       {
-               layer=(*iter)->clone(guid);
-               layer_selection.push_back(layer);
-               synfigapp::Action::Handle       action(synfigapp::Action::create("LayerAdd"));
-
-               assert(action);
-               if(!action)
-                       return;
-
-               action->set_param("canvas",canvas);
-               action->set_param("canvas_interface",etl::loose_handle<synfigapp::CanvasInterface>(get_canvas_interface()));
-               action->set_param("new",layer);
-
-               if(!action->is_ready())
-               {
-                       return;
-               }
-
-               if(!get_instance()->perform_action(action))
-               {
-                       return;
-               }
-
-               etl::handle<Layer_PasteCanvas> paste = etl::handle<Layer_PasteCanvas>::cast_dynamic(layer);
-               if (paste) paste->update_renddesc();
-
-               // synfig::info("DEPTH=%d",depth);
-
-               // Action to move the layer (if necessary)
-               if(depth>0)
-               {
-                       synfigapp::Action::Handle       action(synfigapp::Action::create("LayerMove"));
-
-                       assert(action);
-                       if(!action)
-                               return;
-
-                       action->set_param("canvas",canvas);
-                       action->set_param("canvas_interface",etl::loose_handle<synfigapp::CanvasInterface>(get_canvas_interface()));
-                       action->set_param("layer",layer);
-                       action->set_param("new_index",depth);
-
-                       if(!action->is_ready())
-                       {
-                               //get_ui_interface()->error(_("Move Action Not Ready"));
-                               //return 0;
-                               return;
-                       }
-
-                       if(!get_instance()->perform_action(action))
-                       {
-                               //get_ui_interface()->error(_("Move Action Not Ready"));
-                               //return 0;
-                               return;
-                       }
-               }
-               depth++;
-
-               // automatically export the Index parameter of Duplicate layers when pasting
-               int index = 1;
-               export_dup_nodes(layer, canvas, index);
-       }
-       get_canvas_interface()->get_selection_manager()->clear_selected_layers();
-       get_canvas_interface()->get_selection_manager()->set_selected_layers(layer_selection);
-}
-
-void
-LayerActionManager::export_dup_nodes(synfig::Layer::Handle layer, Canvas::Handle canvas, int &index)
-{
-       // automatically export the Index parameter of Duplicate layers when pasting
-       if (layer->get_name() == "duplicate")
-               while (true)
-               {
-                       String name = strprintf(_("Index %d"), index++);
-                       try
-                       {
-                               canvas->find_value_node(name);
-                       }
-                       catch (Exception::IDNotFound x)
-                       {
-                               get_canvas_interface()->add_value_node(layer->dynamic_param_list().find("index")->second, name);
-                               break;
-                       }
-               }
-       else
-       {
-               Layer::ParamList param_list(layer->get_param_list());
-               for (Layer::ParamList::const_iterator iter(param_list.begin())
-                                ; iter != param_list.end()
-                                ; iter++)
-                       if (layer->dynamic_param_list().count(iter->first)==0 && iter->second.get_type()==ValueBase::TYPE_CANVAS)
-                       {
-                               Canvas::Handle subcanvas(iter->second.get(Canvas::Handle()));
-                               if (subcanvas && subcanvas->is_inline())
-                                       for (Context iter = subcanvas->get_context(); iter != subcanvas->end(); iter++)
-                                               export_dup_nodes(*iter, canvas, index);
-                       }
-
-               for (Layer::DynamicParamList::const_iterator iter(layer->dynamic_param_list().begin())
-                                ; iter != layer->dynamic_param_list().end()
-                                ; iter++)
-                       if (iter->second->get_type()==ValueBase::TYPE_CANVAS)
-                       {
-                               Canvas::Handle canvas((*iter->second)(0).get(Canvas::Handle()));
-                               if (canvas->is_inline())
-                                       //! \todo do we need to implement this?  and if so, shouldn't we check all canvases, not just the one at t=0s?
-                                       warning("%s:%d not yet implemented - do we need to export duplicate valuenodes in dynamic canvas parameters?", __FILE__, __LINE__);
-                       }
-       }
-}
-
-void
-LayerActionManager::amount_inc()
-{
-       float adjust(0.1);
-
-       // Create the action group
-       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Increase Amount"));
-       synfigapp::SelectionManager::LayerList layer_list(layer_tree_->get_selected_layers());
-
-       for (; !layer_list.empty(); layer_list.pop_front())
-       {
-               ValueBase value(layer_list.front()->get_param("amount"));
-               if(value.same_type_as(Real()))
-                       get_canvas_interface()->change_value(synfigapp::ValueDesc(layer_list.front(),"amount"),value.get(Real())+adjust);
-       }
-}
-
-void
-LayerActionManager::amount_dec()
-{
-       float adjust(-0.1);
-
-       // Create the action group
-       synfigapp::Action::PassiveGrouper group(get_canvas_interface()->get_instance().get(),_("Decrease Amount"));
-       synfigapp::SelectionManager::LayerList layer_list(layer_tree_->get_selected_layers());
-
-       for (; !layer_list.empty(); layer_list.pop_front())
-       {
-               ValueBase value(layer_list.front()->get_param("amount"));
-               if(value.same_type_as(Real()))
-                       get_canvas_interface()->change_value(synfigapp::ValueDesc(layer_list.front(),"amount"),value.get(Real())+adjust);
-       }
-}
diff --git a/synfig-studio/src/gui/layeractionmanager.h b/synfig-studio/src/gui/layeractionmanager.h
deleted file mode 100644 (file)
index 91c400f..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-/* === S Y N F I G ========================================================= */
-/*!    \file layeractionmanager.h
-**     \brief Template Header
-**
-**     $Id$
-**
-**     \legal
-**     Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-**
-**     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_LAYER_ACTION_MANAGER_H
-#define __SYNFIG_LAYER_ACTION_MANAGER_H
-
-/* === H E A D E R S ======================================================= */
-
-#include <gtkmm/uimanager.h>
-#include <gtkmm/treeview.h>
-#include <synfigapp/canvasinterface.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 studio {
-
-class LayerTree;
-
-class LayerActionManager
-{
-       Glib::RefPtr<Gtk::UIManager> ui_manager_;
-       //Glib::RefPtr<Gtk::TreeSelection> tree_selection_;
-       LayerTree* layer_tree_;
-       etl::handle<synfigapp::CanvasInterface> canvas_interface_;
-
-       Glib::RefPtr<Gtk::ActionGroup>  action_group_;
-       Gtk::UIManager::ui_merge_id     popup_id_;
-
-
-       Glib::RefPtr<Gtk::ActionGroup> action_group_copy_paste;
-
-       Glib::RefPtr<Gtk::Action>       action_cut_;
-       Glib::RefPtr<Gtk::Action>       action_copy_;
-       Glib::RefPtr<Gtk::Action>       action_paste_;
-
-       Glib::RefPtr<Gtk::Action>       action_amount_inc_;
-       Glib::RefPtr<Gtk::Action>       action_amount_dec_;
-       Glib::RefPtr<Gtk::Action>       action_amount_;
-
-       Glib::RefPtr<Gtk::Action>       action_select_all_child_layers_;
-       sigc::connection                        select_all_child_layers_connection;
-
-       std::list<synfig::Layer::Handle> clipboard_;
-
-       sigc::connection selection_changed_connection;
-
-       bool queued;
-       sigc::connection queue_refresh_connection;
-
-       std::list<sigc::connection> update_connection_list;
-
-       void cut();
-       void copy();
-       void paste();
-       void export_dup_nodes(synfig::Layer::Handle, synfig::Canvas::Handle, int &);
-
-       void amount_inc();
-       void amount_dec();
-
-public:
-       void queue_refresh();
-
-       LayerActionManager();
-       ~LayerActionManager();
-
-       void set_ui_manager(const Glib::RefPtr<Gtk::UIManager> &x);
-       Glib::RefPtr<Gtk::UIManager> get_ui_manager()const { return ui_manager_; }
-
-       void set_layer_tree(LayerTree* x);
-       LayerTree* get_layer_tree()const { return layer_tree_; }
-
-       void set_canvas_interface(const etl::handle<synfigapp::CanvasInterface> &x);
-       etl::handle<synfigapp::CanvasInterface> get_canvas_interface()const { return canvas_interface_; }
-
-       etl::loose_handle<synfigapp::Instance> get_instance()const { return canvas_interface_->get_instance(); }
-
-       void refresh();
-       void clear();
-
-       Glib::RefPtr<Gtk::Action> get_action_select_all_child_layers() { return action_select_all_child_layers_; }
-}; // END of LayerActionManager
-
-}; // END of namespace studio
-
-/* === E N D =============================================================== */
-
-#endif