Fix bugs in previous commit that caused FTBFS in synfig and ETL FTBFS with older...
[synfig.git] / synfig-studio / tags / synfigstudio_0_61_07_rc2 / src / gtkmm / childrentreestore.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file childrentreestore.h
3 **      \brief Template Header
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 /* === S T A R T =========================================================== */
24
25 #ifndef __SYNFIG_STUDIO_CHILDRENTREESTORE_H
26 #define __SYNFIG_STUDIO_CHILDRENTREESTORE_H
27
28 /* === H E A D E R S ======================================================= */
29
30 #include <gtkmm/treestore.h>
31 #include <synfigapp/canvasinterface.h>
32 #include "canvastreestore.h"
33 #include <synfig/value.h>
34 #include <synfig/valuenode.h>
35 #include <set>
36
37 /* === M A C R O S ========================================================= */
38
39 /* === T Y P E D E F S ===================================================== */
40
41 /* === C L A S S E S & S T R U C T S ======================================= */
42
43 namespace studio {
44
45 class ChildrenTreeStore : public CanvasTreeStore
46 {
47         /*
48  -- ** -- P U B L I C   T Y P E S ---------------------------------------------
49         */
50
51 public:
52
53         /*
54  -- ** -- P U B L I C  D A T A ------------------------------------------------
55         */
56
57 public:
58
59         //! TreeModel for the layers
60         const Model model;
61
62         /*
63  -- ** -- P R I V A T E   D A T A ---------------------------------------------
64         */
65
66 private:
67
68         Gtk::TreeModel::Row value_node_row;
69         Gtk::TreeModel::Row canvas_row;
70
71         std::set<synfig::ValueNode::Handle> changed_set_;
72
73         std::set<synfig::ValueNode::Handle> replaced_set_;
74
75         /*
76  -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
77         */
78
79 private:
80
81         sigc::connection changed_connection;
82         bool execute_changed_queued()const { return !changed_set_.empty() || !replaced_set_.empty(); }
83         bool execute_changed_value_nodes();
84         void clear_changed_queue() { changed_set_.clear(); replaced_set_.clear(); }
85
86         /*
87  -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
88         */
89
90 private:
91
92         void on_value_node_added(synfig::ValueNode::Handle value_node);
93         void on_value_node_deleted(synfig::ValueNode::Handle value_node);
94         void on_value_node_changed(synfig::ValueNode::Handle value_node);
95         void on_value_node_replaced(synfig::ValueNode::Handle replaced_value_node,synfig::ValueNode::Handle new_value_node);
96         void on_canvas_added(synfig::Canvas::Handle canvas);
97         void on_canvas_removed(synfig::Canvas::Handle canvas);
98
99         void set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value);
100
101         /*
102  -- ** -- P U B L I C   M E T H O D S -----------------------------------------
103         */
104
105 public:
106
107         ChildrenTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
108         ~ChildrenTreeStore();
109
110         void rebuild();
111
112         void refresh();
113
114         void rebuild_value_nodes();
115
116         void refresh_value_nodes();
117
118         void rebuild_canvases();
119
120         void refresh_canvases();
121
122         void refresh_row(Gtk::TreeModel::Row &row, bool do_children=false);
123
124         Gtk::TreeModel::Row get_canvas_row()const { return canvas_row; }
125
126         Gtk::TreeModel::Row get_value_node_row()const { return value_node_row; }
127
128         /*
129  -- ** -- S T A T I C   P U B L I C   M E T H O D S ---------------------------
130         */
131
132 public:
133
134         static Glib::RefPtr<ChildrenTreeStore> create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_);
135 }; // END of class ChildrenTreeStore
136
137 }; // END of namespace studio
138
139 /* === E N D =============================================================== */
140
141 #endif