1 /* === S Y N F I G ========================================================= */
2 /*! \file dock_layergroups.cpp
3 ** \brief Template File
5 ** $Id: dock_layergroups.cpp,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $
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 "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 "layergrouptreestore.h"
45 #include "layergrouptree.h"
46 #include "groupactionmanager.h"
50 /* === U S I N G =========================================================== */
54 using namespace synfig;
55 using namespace studio;
57 /* === M A C R O S ========================================================= */
59 /* === G L O B A L S ======================================================= */
61 /* === P R O C E D U R E S ================================================= */
63 /* === M E T H O D S ======================================================= */
65 Dock_LayerGroups::Dock_LayerGroups():
66 Dock_CanvasSpecific("groups",_("Groups"),Gtk::StockID("synfig-group")),
67 action_group_group_ops(Gtk::ActionGroup::create()),
68 group_action_manager(new GroupActionManager)
70 group_action_manager->set_ui_manager(App::ui_manager());
72 action_group_group_ops->add( Gtk::Action::create("toolbar-groups", "Group Ops") );
74 action_group_add=Gtk::Action::create("action-group_add", Gtk::Stock::ADD,_("Add a New Group"),_("Add a New Group"));
75 action_group_group_ops->add(action_group_add);
76 action_group_add->set_sensitive(false);
78 App::ui_manager()->insert_action_group(action_group_group_ops);
80 Glib::ustring ui_info =
82 " <toolbar action='toolbar-groups'>"
83 " <toolitem action='action-group_remove' />"
84 " <toolitem action='action-group_add' />"
89 App::ui_manager()->add_ui_from_string(ui_info);
91 set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-groups")));
94 Dock_LayerGroups::~Dock_LayerGroups()
96 delete group_action_manager;
100 Dock_LayerGroups::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
102 Glib::RefPtr<LayerGroupTreeStore> layer_group_tree_store;
103 layer_group_tree_store=LayerGroupTreeStore::create(canvas_view->canvas_interface());
105 LayerGroupTree* layer_group_tree(new LayerGroupTree());
106 layer_group_tree->set_model(layer_group_tree_store);
107 layer_group_tree->signal_popup_layer_menu().connect(sigc::mem_fun(*canvas_view,&CanvasView::popup_layer_menu));
109 canvas_view->set_tree_model(get_name(),layer_group_tree_store);
110 canvas_view->set_ext_widget(get_name(),layer_group_tree);
114 Dock_LayerGroups::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
118 Gtk::Widget* tree_view(canvas_view->get_ext_widget(get_name()));
123 group_action_manager->set_group_tree(dynamic_cast<LayerGroupTree*>(tree_view));
124 group_action_manager->set_canvas_interface(canvas_view->canvas_interface());
125 group_action_manager->refresh();
130 group_action_manager->clear();
131 group_action_manager->set_canvas_interface(0);
132 group_action_manager->set_group_tree(0);