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