Added copyright lines for files I've edited this year.
[synfig.git] / synfig-studio / trunk / src / gtkmm / historytreestore.h
1 /* === S Y N F I G ========================================================= */
2 /*!     \file historytreestore.h
3 **      \brief Template Header
4 **
5 **      $Id$
6 **
7 **      \legal
8 **      Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 **      Copyright (c) 2008 Chris Moore
10 **
11 **      This package is free software; you can redistribute it and/or
12 **      modify it under the terms of the GNU General Public License as
13 **      published by the Free Software Foundation; either version 2 of
14 **      the License, or (at your option) any later version.
15 **
16 **      This package is distributed in the hope that it will be useful,
17 **      but WITHOUT ANY WARRANTY; without even the implied warranty of
18 **      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 **      General Public License for more details.
20 **      \endlegal
21 */
22 /* ========================================================================= */
23
24 /* === S T A R T =========================================================== */
25
26 #ifndef __SYNFIG_STUDIO_HISTORYTREESTORE_H
27 #define __SYNFIG_STUDIO_HISTORYTREESTORE_H
28
29 /* === H E A D E R S ======================================================= */
30
31 #include <gtkmm/treestore.h>
32 #include <synfigapp/canvasinterface.h>
33 #include <gdkmm/pixbuf.h>
34 #include <synfigapp/action.h>
35
36 /* === M A C R O S ========================================================= */
37
38 /* === T Y P E D E F S ===================================================== */
39
40 /* === C L A S S E S & S T R U C T S ======================================= */
41
42 namespace studio {
43
44 class Instance;
45
46 class HistoryTreeStore : virtual public Gtk::TreeStore
47 {
48         /*
49  -- ** -- P U B L I C   T Y P E S ---------------------------------------------
50         */
51
52 public:
53
54         class Model : public Gtk::TreeModel::ColumnRecord
55         {
56         public:
57         public:
58                 Gtk::TreeModelColumn<etl::handle<synfigapp::Action::Undoable> > action;
59                 Gtk::TreeModelColumn<Glib::ustring> name;
60                 Gtk::TreeModelColumn<Glib::RefPtr<Gdk::Pixbuf> > icon;
61                 Gtk::TreeModelColumn<bool> is_active;
62                 Gtk::TreeModelColumn<bool> is_undo;
63                 Gtk::TreeModelColumn<bool> is_redo;
64
65                 Gtk::TreeModelColumn<Glib::ustring> canvas_id;
66                 Gtk::TreeModelColumn<synfig::Canvas::Handle> canvas;
67
68                 Model()
69                 {
70                         add(action);
71                         add(name);
72                         add(icon);
73                         add(is_active);
74                         add(is_undo);
75                         add(is_redo);
76                         add(canvas_id);
77                         add(canvas);
78                 }
79         };
80
81         /*
82  -- ** -- P U B L I C  D A T A ------------------------------------------------
83         */
84
85 public:
86
87         const Model model;
88
89         /*
90  -- ** -- P R I V A T E   D A T A ---------------------------------------------
91         */
92
93 private:
94
95         etl::loose_handle<studio::Instance> instance_;
96         Gtk::TreeIter curr_row;
97
98         /*
99  -- ** -- P R I V A T E   M E T H O D S ---------------------------------------
100         */
101
102 private:
103
104         /*
105  -- ** -- S I G N A L   T E R M I N A L S -------------------------------------
106         */
107
108 private:
109
110         void on_undo();
111
112         void on_redo();
113
114         void on_undo_stack_cleared();
115
116         void on_redo_stack_cleared();
117
118         void on_new_action(etl::handle<synfigapp::Action::Undoable> action);
119
120         void on_action_status_changed(etl::handle<synfigapp::Action::Undoable> action);
121
122         /*
123  -- ** -- P U B L I C   M E T H O D S -----------------------------------------
124         */
125
126 public:
127
128         HistoryTreeStore(etl::loose_handle<studio::Instance> instance_);
129         ~HistoryTreeStore();
130
131         etl::loose_handle<studio::Instance> instance() { return instance_; }
132         etl::loose_handle<const studio::Instance> instance()const { return instance_; }
133
134         void rebuild();
135
136         void refresh() { rebuild(); }
137
138         void insert_action(Gtk::TreeRow row,etl::handle<synfigapp::Action::Undoable> action, bool is_active=true, bool is_undo=true, bool is_redo=false);
139
140         static bool search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring&,const TreeModel::iterator&);
141
142         /*
143  -- ** -- P R O T E C T E D   M E T H O D S -----------------------------------
144         */
145
146 public:
147
148         static Glib::RefPtr<HistoryTreeStore> create(etl::loose_handle<studio::Instance> instance);
149
150 }; // END of class HistoryTreeStore
151
152 }; // END of namespace studio
153
154 /* === E N D =============================================================== */
155
156 #endif