1 /* === S Y N F I G ========================================================= */
2 /*! \file dock_layergroups.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "docks/dock_layergroups.h"
35 #include <gtkmm/scrolledwindow.h>
38 #include <sigc++/signal.h>
39 #include <sigc++/hide.h>
40 #include <sigc++/retype_return.h>
41 #include <sigc++/slot.h>
42 #include "canvasview.h"
44 #include "trees/layergrouptreestore.h"
45 #include "trees/layergrouptree.h"
46 #include "actionmanagers/groupactionmanager.h"
52 /* === U S I N G =========================================================== */
56 using namespace synfig;
57 using namespace studio;
59 /* === M A C R O S ========================================================= */
61 /* === G L O B A L S ======================================================= */
63 /* === P R O C E D U R E S ================================================= */
65 /* === M E T H O D S ======================================================= */
67 Dock_LayerGroups::Dock_LayerGroups():
68 Dock_CanvasSpecific("groups",_("Groups"),Gtk::StockID("synfig-group")),
69 action_group_group_ops(Gtk::ActionGroup::create("action_group_dock_layergroups")),
70 group_action_manager(new GroupActionManager)
72 group_action_manager->set_ui_manager(App::ui_manager());
74 action_group_group_ops->add( Gtk::Action::create("toolbar-groups", _("Group Ops")) );
76 action_group_add=Gtk::Action::create("action-group_add", Gtk::Stock::ADD,_("Add a New Group"),_("Add a New Group"));
77 action_group_group_ops->add(action_group_add);
78 action_group_add->set_sensitive(false);
80 App::ui_manager()->insert_action_group(action_group_group_ops);
82 Glib::ustring ui_info =
84 " <toolbar action='toolbar-groups'>"
85 " <toolitem action='action-GroupRemove' />"
86 " <toolitem action='action-group_add' />"
91 App::ui_manager()->add_ui_from_string(ui_info);
93 set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-groups")));
96 Dock_LayerGroups::~Dock_LayerGroups()
98 delete group_action_manager;
102 Dock_LayerGroups::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
104 Glib::RefPtr<LayerGroupTreeStore> layer_group_tree_store;
105 layer_group_tree_store=LayerGroupTreeStore::create(canvas_view->canvas_interface());
107 LayerGroupTree* layer_group_tree(new LayerGroupTree());
108 layer_group_tree->set_model(layer_group_tree_store);
109 layer_group_tree->signal_popup_layer_menu().connect(sigc::mem_fun(*canvas_view,&CanvasView::popup_layer_menu));
111 canvas_view->set_tree_model(get_name(),layer_group_tree_store);
112 canvas_view->set_ext_widget(get_name(),layer_group_tree);
116 Dock_LayerGroups::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
120 Gtk::Widget* tree_view(canvas_view->get_ext_widget(get_name()));
125 group_action_manager->set_group_tree(dynamic_cast<LayerGroupTree*>(tree_view));
126 group_action_manager->set_canvas_interface(canvas_view->canvas_interface());
127 group_action_manager->refresh();
132 group_action_manager->clear();
133 group_action_manager->set_canvas_interface(0);
134 group_action_manager->set_group_tree(0);