1 /* === S I N F G =========================================================== */
2 /*! \file historytreestore.cpp
3 ** \brief Template File
5 ** $Id: historytreestore.cpp,v 1.1.1.1 2005/01/07 03:34:36 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === H E A D E R S ======================================================= */
31 #include "historytreestore.h"
32 #include <sinfg/valuenode.h>
33 #include "iconcontroler.h"
34 #include <sinfg/valuenode_timedswap.h>
35 #include <gtkmm/button.h>
36 #include <sinfgapp/action.h>
41 /* === U S I N G =========================================================== */
45 using namespace sinfg;
46 using namespace studio;
48 /* === M A C R O S ========================================================= */
50 /* === G L O B A L S ======================================================= */
52 /* === P R O C E D U R E S ================================================= */
54 /* === M E T H O D S ======================================================= */
56 static HistoryTreeStore::Model& ModelHack()
58 static HistoryTreeStore::Model* model(0);
59 if(!model)model=new HistoryTreeStore::Model;
63 HistoryTreeStore::HistoryTreeStore(etl::loose_handle<studio::Instance> instance_):
64 Gtk::TreeStore (ModelHack()),
67 instance_->signal_undo().connect(sigc::mem_fun(*this,&studio::HistoryTreeStore::on_undo));
68 instance_->signal_redo().connect(sigc::mem_fun(*this,&studio::HistoryTreeStore::on_redo));
69 instance_->signal_undo_stack_cleared().connect(sigc::mem_fun(*this,&studio::HistoryTreeStore::on_undo_stack_cleared));
70 instance_->signal_redo_stack_cleared().connect(sigc::mem_fun(*this,&studio::HistoryTreeStore::on_redo_stack_cleared));
71 instance_->signal_new_action().connect(sigc::mem_fun(*this,&studio::HistoryTreeStore::on_new_action));
72 instance_->signal_action_status_changed().connect(sigc::mem_fun(*this,&studio::HistoryTreeStore::on_action_status_changed));
75 HistoryTreeStore::~HistoryTreeStore()
77 sinfg::info("HistoryTreeStore::~HistoryTreeStore(): Deleted");
80 Glib::RefPtr<HistoryTreeStore>
81 HistoryTreeStore::create(etl::loose_handle<studio::Instance> instance_)
83 return Glib::RefPtr<HistoryTreeStore>(new HistoryTreeStore(instance_));
87 HistoryTreeStore::rebuild()
89 sinfgapp::Action::Stack::const_iterator iter;
93 for(iter=instance()->undo_action_stack().begin();iter!=instance()->undo_action_stack().end();++iter)
95 insert_action(*(prepend()),*iter,true,true,false);
97 curr_row=*children().end();
98 for(iter=instance()->redo_action_stack().begin();iter!=instance()->redo_action_stack().end();++iter)
100 insert_action(*(append()),*iter,true,false,true);
105 HistoryTreeStore::insert_action(Gtk::TreeRow row,etl::handle<sinfgapp::Action::Undoable> action, bool is_active, bool is_undo, bool is_redo)
109 row[model.action] = action;
110 row[model.name] = static_cast<Glib::ustring>(action->get_local_name());
111 row[model.is_active] = action->is_active();
112 row[model.is_undo] = is_undo;
113 row[model.is_redo] = is_redo;
115 sinfgapp::Action::CanvasSpecific *specific_action;
116 specific_action=dynamic_cast<sinfgapp::Action::CanvasSpecific*>(action.get());
119 row[model.canvas] = specific_action->get_canvas();
120 row[model.canvas_id] = specific_action->get_canvas()->get_id();
123 etl::handle<sinfgapp::Action::Group> group;
124 group=etl::handle<sinfgapp::Action::Group>::cast_dynamic(action);
127 sinfgapp::Action::ActionList::const_iterator iter;
128 for(iter=group->action_list().begin();iter!=group->action_list().end();++iter)
130 Gtk::TreeRow child_row = *(append(row.children()));
131 insert_action(child_row,*iter,true,is_undo,is_redo);
135 //row[model.icon] = Gtk::Button().render_icon(Gtk::StockID("sinfg-canvas"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
140 HistoryTreeStore::on_undo()
146 HistoryTreeStore::on_redo()
152 HistoryTreeStore::on_undo_stack_cleared()
154 Gtk::TreeModel::Children::iterator iter,next;
155 Gtk::TreeModel::Children children_(children());
157 for(next=children_.begin(),iter=next++; iter != children_.end(); iter=(next!=children_.end())?next++:next)
159 Gtk::TreeModel::Row row = *iter;
160 if(row[model.is_undo])
166 HistoryTreeStore::on_redo_stack_cleared()
168 Gtk::TreeModel::Children::iterator iter,next;
169 Gtk::TreeModel::Children children_(children());
171 for(next=children_.begin(),iter=next++; iter != children_.end(); iter=(next!=children_.end())?next++:next)
173 Gtk::TreeModel::Row row = *iter;
174 if(row[model.is_redo])
180 HistoryTreeStore::on_new_action(etl::handle<sinfgapp::Action::Undoable> action)
182 // Gtk::TreeRow row = *(append());
184 Gtk::TreeModel::Children::iterator iter;
185 for(iter=children().begin(); iter != children().end(); ++iter)
187 Gtk::TreeModel::Row row = *iter;
188 if(row[model.is_redo])
196 insert_action(row,action);
200 HistoryTreeStore::on_action_status_changed(etl::handle<sinfgapp::Action::Undoable> action)
202 Gtk::TreeModel::Children::iterator iter;
203 Gtk::TreeModel::Children children_(children());
205 for(iter=children_.begin(); iter != children_.end(); ++iter)
207 Gtk::TreeModel::Row row = *iter;
208 if(action == (etl::handle<sinfgapp::Action::Undoable>)row[model.action])
210 row[model.is_active]=action->is_active();