Build rectanglular blines in the same handedness as all the other shapes.
[synfig.git] / synfig-studio / trunk / src / gtkmm / dock_layergroups.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file dock_layergroups.cpp
3 **      \brief Template File
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **
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.
14 **
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.
19 **      \endlegal
20 */
21 /* ========================================================================= */
22
23 /* === H E A D E R S ======================================================= */
24
25 #ifdef USING_PCH
26 #       include "pch.h"
27 #else
28 #ifdef HAVE_CONFIG_H
29 #       include <config.h>
30 #endif
31
32 #include "dock_layergroups.h"
33 #include "app.h"
34
35 #include <gtkmm/scrolledwindow.h>
36 #include <cassert>
37 #include "instance.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"
43
44 #include "layergrouptreestore.h"
45 #include "layergrouptree.h"
46 #include "groupactionmanager.h"
47
48 #include "general.h"
49
50 #endif
51
52 /* === U S I N G =========================================================== */
53
54 using namespace std;
55 using namespace etl;
56 using namespace synfig;
57 using namespace studio;
58
59 /* === M A C R O S ========================================================= */
60
61 /* === G L O B A L S ======================================================= */
62
63 /* === P R O C E D U R E S ================================================= */
64
65 /* === M E T H O D S ======================================================= */
66
67 Dock_LayerGroups::Dock_LayerGroups():
68         Dock_CanvasSpecific("groups",_("Groups"),Gtk::StockID("synfig-group")),
69         action_group_group_ops(Gtk::ActionGroup::create()),
70         group_action_manager(new GroupActionManager)
71 {
72         group_action_manager->set_ui_manager(App::ui_manager());
73
74         action_group_group_ops->add( Gtk::Action::create("toolbar-groups", _("Group Ops")) );
75
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);
79
80         App::ui_manager()->insert_action_group(action_group_group_ops);
81
82     Glib::ustring ui_info =
83         "<ui>"
84         "       <toolbar action='toolbar-groups'>"
85         "       <toolitem action='action-group_remove' />"
86         "       <toolitem action='action-group_add' />"
87         "       </toolbar>"
88         "</ui>"
89         ;
90
91         App::ui_manager()->add_ui_from_string(ui_info);
92
93         set_toolbar(*dynamic_cast<Gtk::Toolbar*>(App::ui_manager()->get_widget("/toolbar-groups")));
94 }
95
96 Dock_LayerGroups::~Dock_LayerGroups()
97 {
98         delete group_action_manager;
99 }
100
101 void
102 Dock_LayerGroups::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
103 {
104         Glib::RefPtr<LayerGroupTreeStore> layer_group_tree_store;
105         layer_group_tree_store=LayerGroupTreeStore::create(canvas_view->canvas_interface());
106
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));
110
111         canvas_view->set_tree_model(get_name(),layer_group_tree_store);
112         canvas_view->set_ext_widget(get_name(),layer_group_tree);
113 }
114
115 void
116 Dock_LayerGroups::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
117 {
118         if(canvas_view)
119         {
120                 Gtk::Widget* tree_view(canvas_view->get_ext_widget(get_name()));
121
122                 add(*tree_view);
123                 tree_view->show();
124
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();
128         }
129         else
130         {
131                 clear_previous();
132                 group_action_manager->clear();
133                 group_action_manager->set_canvas_interface(0);
134                 group_action_manager->set_group_tree(0);
135         }
136 }