Move treeviews/treestores into subfolder
[synfig.git] / synfig-studio / src / gui / docks / dock_canvasspecific.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file dock_canvasspecific.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 "app.h"
33 #include "docks/dock_canvasspecific.h"
34
35 #include <gtkmm/scrolledwindow.h>
36 #include <cassert>
37 #include "instance.h"
38 #include <sigc++/signal.h>
39 #include <sigc++/adaptors/hide.h>
40 //#include <sigc++/hide.h>
41 #include <sigc++/slot.h>
42 #include "canvasview.h"
43 #include <ETL/clock>
44
45 #include "general.h"
46
47 #endif
48
49 /* === U S I N G =========================================================== */
50
51 using namespace std;
52 using namespace etl;
53 using namespace synfig;
54 using namespace studio;
55
56 /* === M A C R O S ========================================================= */
57
58 /* === G L O B A L S ======================================================= */
59
60 /* === P R O C E D U R E S ================================================= */
61
62 /* === M E T H O D S ======================================================= */
63
64 Dock_CanvasSpecific::Dock_CanvasSpecific(const synfig::String& name,const synfig::String& local_name,Gtk::StockID stock_id_):
65         Dockable(name,local_name,stock_id_)
66 {
67         App::signal_instance_created().connect(sigc::mem_fun(*this,&Dock_CanvasSpecific::init_instance));
68 }
69
70 Dock_CanvasSpecific::~Dock_CanvasSpecific()
71 {
72 }
73
74 etl::loose_handle<studio::CanvasView>
75 Dock_CanvasSpecific::get_canvas_view()
76 {
77         return App::get_selected_canvas_view();
78 }
79
80 etl::loose_handle<synfigapp::CanvasInterface>
81 Dock_CanvasSpecific::get_canvas_interface()
82 {
83         if(get_canvas_view())
84                 return get_canvas_view()->canvas_interface();
85         return 0;
86 }
87
88 void
89 Dock_CanvasSpecific::init_canvas_view_vfunc(etl::loose_handle<CanvasView> /*canvas_view*/)
90 {
91 }
92
93 void
94 Dock_CanvasSpecific::init_instance_vfunc(etl::loose_handle<Instance> /*instance*/)
95 {
96 }
97
98 void
99 Dock_CanvasSpecific::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> /*canvas_view*/)
100 {
101 }
102
103 void
104 Dock_CanvasSpecific::init_instance(etl::handle<Instance> instance)
105 {
106         etl::clock timer;timer.reset();
107         instance->signal_canvas_view_created().connect(sigc::mem_fun(*this,&Dock_CanvasSpecific::init_canvas_view));
108         init_instance_vfunc(instance);
109         // synfig::info("%s init_instance() took %f seconds",get_local_name().c_str(),float(timer()));
110 }
111
112 void
113 Dock_CanvasSpecific::delete_instance(etl::handle<Instance> /*instance*/)
114 {
115         changed_canvas_view_vfunc(0);
116 }
117
118 void
119 Dock_CanvasSpecific::init_canvas_view(CanvasView* canvas_view)
120 {
121         /*
122         canvas_view->signal_focus_in_event().connect(
123                 sigc::hide(
124                         sigc::bind_return(
125                                 sigc::mem_fun(
126                                         *this,
127                                         &Dock_CanvasSpecific::canvas_view_changed
128                                 ),
129                                 false
130                         )
131                 )
132         );
133         */
134         // synfig::info("%s init_canvas_view() Starting init...",get_local_name().c_str());
135         etl::clock timer;timer.reset();
136         App::signal_canvas_view_focus().connect(
137                 sigc::hide(
138                         sigc::mem_fun(
139                                 *this,
140                                 &Dock_CanvasSpecific::canvas_view_changed
141                         )
142                 )
143         );
144         init_canvas_view_vfunc(canvas_view);
145         // synfig::info("%s init_canvas_view() took %f seconds",get_local_name().c_str(),float(timer()));
146 }
147
148 void
149 Dock_CanvasSpecific::canvas_view_changed()
150 {
151         etl::loose_handle<CanvasView> canvas_view(App::get_selected_canvas_view());
152 /*      if(canvas_view)
153         {
154                 canvas_delete_connection.disconnect();
155                 canvas_delete_connection=canvas_view->signal_deleted().connect(
156                         sigc::bind(
157                                 sigc::mem_fun(
158                                         *this,
159                                         &Dock_CanvasSpecific::changed_canvas_view
160                                 ),
161                                 etl::loose_handle<CanvasView>(0)
162                         )
163                 );
164         }
165 */
166
167 // #ifdef _DEBUG
168 //      synfig::info("%s canvas_view_changed: start",get_local_name().c_str());
169 // #endif
170         changed_canvas_view_vfunc(canvas_view);
171 // #ifdef _DEBUG
172 //      synfig::info("%s canvas_view_changed: end",get_local_name().c_str());
173 // #endif
174 }