Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-studio / tags / synfigstudio_0_61_05 / synfig-studio / src / gtkmm / dock_params.cpp
1 /* === S Y N F I G ========================================================= */
2 /*!     \file dock_params.cpp
3 **      \brief Template File
4 **
5 **      $Id: dock_params.cpp,v 1.1.1.1 2005/01/07 03:34:36 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 "dock_params.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++/slot.h>
41 #include "canvasview.h"
42 #include "layerparamtreestore.h"
43 #include "workarea.h"
44
45 #endif
46
47 /* === U S I N G =========================================================== */
48
49 using namespace std;
50 using namespace etl;
51 using namespace synfig;
52 using namespace studio;
53
54 /* === M A C R O S ========================================================= */
55
56 /* === G L O B A L S ======================================================= */
57
58 /* === P R O C E D U R E S ================================================= */
59
60 /* === M E T H O D S ======================================================= */
61
62 Dock_Params::Dock_Params():
63         Dock_CanvasSpecific("params",_("Params"),Gtk::Stock::INDEX/*Gtk::StockID("synfig-params")*/),
64         action_group(Gtk::ActionGroup::create())
65 {
66 /*
67         App::ui_manager()->insert_action_group(action_group_layer_ops);
68
69     Glib::ustring ui_info =
70         "<ui>"
71         "       <toolbar action='toolbar-palette'>"
72         "       <toolitem action='amount-increase' />"
73         "       <toolitem action='amount-decrease' />"
74         "       </toolbar>"
75         "</ui>"
76         ;
77
78         App::ui_manager()->add_ui_from_string(ui_info);
79         */
80 }
81
82 Dock_Params::~Dock_Params()
83 {
84 }
85
86
87 void
88 Dock_Params::init_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
89 {
90         DEBUGPOINT();
91         Gtk::TreeView* tree_view(
92                 static_cast<Gtk::TreeView*>(canvas_view->get_ext_widget(get_name()))
93         );
94         
95         if(tree_view)
96         {
97                 tree_view->get_selection()->signal_changed().connect(
98                         sigc::mem_fun(
99                                 *this,
100                                 &Dock_Params::refresh_selected_param
101                         )
102                 );
103         }
104 }
105
106 void
107 Dock_Params::refresh_selected_param()
108 {
109         Gtk::TreeView* tree_view(
110                 static_cast<Gtk::TreeView*>(get_canvas_view()->get_ext_widget(get_name()))
111         );
112         Gtk::TreeModel::iterator iter(tree_view->get_selection()->get_selected());
113         
114         if(iter)
115         {
116                 LayerParamTreeStore::Model model;
117                 get_canvas_view()->work_area->set_selected_value_node(
118                         (synfig::ValueNode::Handle)(*iter)[model.value_node]
119                 );
120         }
121         else
122         {
123                 get_canvas_view()->work_area->set_selected_value_node(0);
124         }
125 }
126
127 void
128 Dock_Params::changed_canvas_view_vfunc(etl::loose_handle<CanvasView> canvas_view)
129 {
130         if(canvas_view)
131         {
132                 Gtk::Widget* tree_view(canvas_view->get_ext_widget(get_name()));
133                 
134                 add(*tree_view);
135                 tree_view->show();
136                 show_all();
137         }
138         else clear_previous();
139 }