1 /* === S Y N F I G ========================================================= */
2 /*! \file layergrouptreestore.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
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.
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.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "layergrouptreestore.h"
33 #include "iconcontroler.h"
34 #include <gtkmm/button.h>
35 #include <synfig/paramdesc.h>
36 #include <synfigapp/action.h>
37 #include <synfigapp/instance.h>
40 #include <synfigapp/action_system.h>
41 #include "dockmanager.h"
43 #include "iconcontroler.h"
45 #include <gtk/gtkversion.h>
49 /* === U S I N G =========================================================== */
53 using namespace synfig;
54 using namespace studio;
56 /* === M A C R O S ========================================================= */
58 #define GROUP_NEST_CHAR '.'
60 /* === G L O B A L S ======================================================= */
62 /* === P R O C E D U R E S ================================================= */
64 /* === M E T H O D S ======================================================= */
66 static LayerGroupTreeStore::Model& ModelHack()
68 static LayerGroupTreeStore::Model* model(0);
69 if(!model)model=new LayerGroupTreeStore::Model;
73 LayerGroupTreeStore::LayerGroupTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_):
74 Gtk::TreeStore (ModelHack()),
75 canvas_interface_ (canvas_interface_)
77 layer_icon=Gtk::Button().render_icon(Gtk::StockID("synfig-layer"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
78 group_icon=Gtk::Button().render_icon(Gtk::StockID("synfig-group"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
80 // Connect Signals to Terminals
81 canvas_interface()->signal_layer_status_changed().connect(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_layer_status_changed));
82 canvas_interface()->signal_layer_new_description().connect(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_layer_new_description));
84 canvas_interface()->get_canvas()->signal_group_added().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_added)));
85 canvas_interface()->get_canvas()->signal_group_removed().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_removed)));
86 canvas_interface()->get_canvas()->signal_group_changed().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_changed)));
88 canvas_interface()->get_canvas()->signal_group_pair_added().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_pair_added)));
89 canvas_interface()->get_canvas()->signal_group_pair_removed().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_pair_removed)));
94 LayerGroupTreeStore::~LayerGroupTreeStore()
97 synfig::info("LayerGroupTreeStore::~LayerGroupTreeStore(): Deleted");
101 LayerGroupTreeStore::search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring& x,const TreeModel::iterator& iter)
105 Glib::ustring substr(x.uppercase());
106 Glib::ustring label((*iter)[model.label]);
107 label=label.uppercase();
109 return label.find(substr)==Glib::ustring::npos;
113 Glib::RefPtr<LayerGroupTreeStore>
114 LayerGroupTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_)
116 return Glib::RefPtr<LayerGroupTreeStore>(new LayerGroupTreeStore(canvas_interface_));
120 LayerGroupTreeStore::get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const
122 if(column==model.child_layers.index())
124 Glib::Value<LayerList> x;
125 g_value_init(x.gobj(),x.value_type());
127 if((bool)(*iter)[model.is_group])
129 set<Layer::Handle> layer_set(canvas_interface()->get_canvas()->get_layers_in_group((Glib::ustring)(*iter)[model.group_name]));
131 x.set(LayerList(layer_set.begin(),layer_set.end()));
133 else if((bool)(*iter)[model.is_layer])
135 LayerList layer_list;
136 layer_list.push_back((Layer::Handle)(*iter)[model.layer]);
140 g_value_init(value.gobj(),x.value_type());
143 else if(column==model.all_layers.index())
145 Glib::Value<LayerList> x;
146 g_value_init(x.gobj(),x.value_type());
148 if((bool)(*iter)[model.is_group])
150 LayerList layer_list;
151 Gtk::TreeModel::iterator child_iter(iter->children().begin());
152 for(;child_iter;++child_iter)
154 LayerList layer_list2((LayerList)(*child_iter)[model.all_layers]);
155 for(;layer_list2.size();layer_list2.pop_front())
156 layer_list.push_back(layer_list2.front());
160 else if((bool)(*iter)[model.is_layer])
162 LayerList layer_list;
163 layer_list.push_back((Layer::Handle)(*iter)[model.layer]);
167 g_value_init(value.gobj(),x.value_type());
170 else if(column==model.group_name.index())
172 if((bool)(*iter)[model.is_group])
173 return Gtk::TreeStore::get_value_vfunc(iter,column,value);
174 return get_value_vfunc(iter->parent(),column,value);
176 else if(column==model.parent_group_name.index())
179 return get_value_vfunc(iter->parent(),model.group_name.index(),value);
180 Glib::Value<Glib::ustring> x;
181 g_value_init(x.gobj(),x.value_type());
182 x.set(Glib::ustring());
183 g_value_init(value.gobj(),x.value_type());
186 else if(column==model.label.index())
188 if((bool)(*iter)[model.is_group])
190 Glib::Value<Glib::ustring> x;
191 g_value_init(x.gobj(),x.value_type());
193 Glib::ustring group_name((*iter)[model.group_name]);
195 // Get rid of any parent group crap
196 while(group_name.find(GROUP_NEST_CHAR)!=Glib::ustring::npos)
197 group_name=Glib::ustring(group_name,group_name.find(GROUP_NEST_CHAR)+1,Glib::ustring::npos);
201 g_value_init(value.gobj(),x.value_type());
205 else if((bool)(*iter)[model.is_layer])
207 synfig::Layer::Handle layer((*iter)[model.layer]);
211 Glib::Value<Glib::ustring> x;
212 g_value_init(x.gobj(),x.value_type());
215 if(!layer->get_description().empty())
216 x.set(layer->get_description());
218 x.set(layer->get_local_name());
220 g_value_init(value.gobj(),x.value_type());
221 //g_value_copy(x.gobj(),value.gobj());
226 if(column==model.tooltip.index())
228 synfig::Layer::Handle layer((*iter)[model.layer]);
232 Glib::Value<Glib::ustring> x;
233 g_value_init(x.gobj(),x.value_type());
236 x.set(layer->get_local_name());
238 g_value_init(value.gobj(),x.value_type());
239 //g_value_copy(x.gobj(),value.gobj());
243 if(column==model.canvas.index())
245 synfig::Layer::Handle layer((*iter)[model.layer]);
249 Glib::Value<Canvas::Handle> x;
250 g_value_init(x.gobj(),x.value_type());
253 x.set(layer->get_canvas());
255 g_value_init(value.gobj(),x.value_type());
256 //g_value_copy(x.gobj(),value.gobj());
260 if(column==model.active.index())
263 g_value_init(x.gobj(),x.value_type());
265 if((bool)(*iter)[model.is_layer])
267 synfig::Layer::Handle layer((*iter)[model.layer]);
268 x.set(layer->active());
270 else if((bool)(*iter)[model.is_group])
272 int activecount(0),total(0);
273 Gtk::TreeModel::iterator child_iter(iter->children().begin());
274 for(;child_iter;++child_iter)
277 if((*child_iter)[model.active])
280 x.set(activecount>total/2);
285 g_value_init(value.gobj(),x.value_type());
286 g_value_copy(x.gobj(),value.gobj());
289 if(column==model.icon.index())
291 Glib::Value<Glib::RefPtr<Gdk::Pixbuf> > x;
292 g_value_init(x.gobj(),x.value_type());
294 if((bool)(*iter)[model.is_layer])
296 synfig::Layer::Handle layer((*iter)[model.layer]);
299 x.set(get_tree_pixbuf_layer(layer->get_name()));
301 if((bool)(*iter)[model.is_group])
304 g_value_init(value.gobj(),x.value_type());
305 g_value_copy(x.gobj(),value.gobj());
308 Gtk::TreeStore::get_value_vfunc(iter,column,value);
312 LayerGroupTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
314 //if(!iterator_sane(row))
317 if(column>=get_n_columns_vfunc())
319 g_warning("LayerGroupTreeStore::set_value_impl: Bad column (%d)",column);
323 if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
325 g_warning("LayerGroupTreeStore::set_value_impl: Bad value type");
331 if(column==model.label.index())
333 Glib::Value<Glib::ustring> x;
334 g_value_init(x.gobj(),model.label.type());
335 g_value_copy(value.gobj(),x.gobj());
337 if((bool)(*iter)[model.is_layer])
339 synfig::Layer::Handle layer((*iter)[model.layer]);
342 synfig::String new_desc(x.get());
344 if(new_desc==layer->get_local_name())
345 new_desc=synfig::String();
347 if(new_desc==layer->get_description())
350 synfigapp::Action::Handle action(synfigapp::Action::create("layer_set_desc"));
355 action->set_param("canvas",canvas_interface()->get_canvas());
356 action->set_param("canvas_interface",canvas_interface());
357 action->set_param("layer",layer);
358 action->set_param("new_description",synfig::String(x.get()));
360 canvas_interface()->get_instance()->perform_action(action);
363 else if((bool)(*iter)[model.is_group])
365 synfig::String group((Glib::ustring)(*iter)[model.label]);
366 synfig::String new_group(x.get());
371 Glib::ustring group_name((*iter)[model.group_name]);
375 // Get rid of any parent group crap
376 while(group_name.find(GROUP_NEST_CHAR)!=Glib::ustring::npos)
378 new_group+=Glib::ustring(group_name,0,group_name.find(GROUP_NEST_CHAR)+1);
379 group_name=Glib::ustring(group_name,group_name.find(GROUP_NEST_CHAR)+1,Glib::ustring::npos);
383 synfig::info("Renaming group \"%s\" to \"%s\"...",group.c_str(),new_group.c_str());
385 // Check to see if this group is real or not.
386 // If it isn't real, then renaming it is a cinch.
387 // We know it isn't real if it doesn't have any
389 if(iter->children().empty())
391 (*iter)[model.group_name]=new_group;
395 synfigapp::Action::Handle action(synfigapp::Action::create("group_rename"));
400 action->set_param("canvas",canvas_interface()->get_canvas());
401 action->set_param("canvas_interface",canvas_interface());
402 action->set_param("group",group);
403 action->set_param("new_group",new_group);
405 canvas_interface()->get_instance()->perform_action(action);
412 if(column==model.active.index())
415 g_value_init(x.gobj(),model.active.type());
416 g_value_copy(value.gobj(),x.gobj());
418 if((bool)(*iter)[model.is_layer])
420 synfig::Layer::Handle layer((*iter)[model.layer]);
423 synfigapp::Action::Handle action(synfigapp::Action::create("layer_activate"));
428 action->set_param("canvas",canvas_interface()->get_canvas());
429 action->set_param("canvas_interface",canvas_interface());
430 action->set_param("layer",layer);
431 action->set_param("new_status",bool(x.get()));
434 canvas_interface()->get_instance()->perform_action(action);
437 else if(!iter->children().empty())
439 synfigapp::Action::PassiveGrouper group(
440 get_canvas_interface()->get_instance().get(),
442 x.get()?_("Activate "):_("Deactivate ")
443 )+(Glib::ustring)(*iter)[model.label]
446 Gtk::TreeModel::iterator child_iter(iter->children().begin());
448 for(;child_iter;++child_iter)
449 (*child_iter)[model.active]=x.get();
451 Gtk::TreeStore::set_value_impl(iter,column, value);
455 Gtk::TreeStore::set_value_impl(iter,column, value);
458 catch(std::exception x)
468 LayerGroupTreeStore::row_draggable_vfunc (const TreeModel::Path& path)const
470 //if(!get_iter(path)) return false;
471 // Gtk::TreeModel::Row row(*get_iter(path));
474 // return (bool)true;
478 LayerGroupTreeStore::drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const
480 if(!const_cast<LayerGroupTreeStore*>(this)->get_iter(path)) return false;
481 //synfig::info("Dragged data of type \"%s\"",selection_data.get_data_type());
482 //synfig::info("Dragged data of target \"%s\"",gdk_atom_name(selection_data->target));
483 //synfig::info("Dragged selection=\"%s\"",gdk_atom_name(selection_data->selection));
485 Gtk::TreeModel::Row row(*const_cast<LayerGroupTreeStore*>(this)->get_iter(path));
487 if((bool)row[model.is_layer])
489 Layer* layer(((Layer::Handle)row[model.layer]).get());
492 std::vector<Layer*> layers;
494 layers.push_back(layer);
496 selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layers.front()), sizeof(void*)*layers.size());
500 else if((bool)row[model.is_group])
502 synfig::String group((Glib::ustring)row[model.group_name]);
506 selection_data.set("GROUP", 8, reinterpret_cast<const guchar*>(&*group.begin()), sizeof(void*)*group.size());
515 LayerGroupTreeStore::drag_data_delete_vfunc (const TreeModel::Path& path)
521 LayerGroupTreeStore::row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const
523 Gtk::TreeIter iter(const_cast<LayerGroupTreeStore*>(this)->get_iter(dest));
524 if(!iter) return false;
526 if(synfig::String(selection_data.get_data_type())=="LAYER")
529 if(synfig::String(selection_data.get_data_type())=="GROUP")
531 synfig::String dest_group((Glib::ustring)(*iter)[model.group_name]);
532 synfig::String src_group(reinterpret_cast<const gchar*>(selection_data.get_data()));
533 //synfig::String src_group(const_cast<gchar*>(selection_data.get_data()));
535 // Avoid putting a group inside of itself
536 if(dest_group.size()>src_group.size() && src_group==String(dest_group,0,src_group.size()))
542 //synfig::info("possible_drop -- data of type \"%s\"",selection_data.get_data_type());
543 //synfig::info("possible_drop -- data of target \"%s\"",gdk_atom_name(selection_data->target));
544 //synfig::info("possible_drop -- selection=\"%s\"",gdk_atom_name(selection_data->selection));
546 //Gtk::TreeModel::Row row(*get_iter(dest));
548 /* if(synfig::String(selection_data.get_data_type())=="LAYER" && (bool)true)
555 LayerGroupTreeStore::drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)
557 if(!get_iter(dest)) return false;
561 Gtk::TreeModel::Row row(*get_iter(dest));
563 //synfig::info("Dropped data of type \"%s\"",selection_data.get_data_type());
564 //synfig::info("Dropped data of target \"%s\"",gdk_atom_name(selection_data->target));
565 //synfig::info("Dropped selection=\"%s\"",gdk_atom_name(selection_data->selection));
566 synfigapp::Action::PassiveGrouper passive_grouper(canvas_interface()->get_instance().get(),_("Regroup"));
568 if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
570 synfig::String dest_group;
572 dest_group=(Glib::ustring)row[model.group_name];
574 if(dest_group.empty())
577 if(synfig::String(selection_data.get_data_type())=="LAYER")
579 synfigapp::Action::Handle action(synfigapp::Action::create("group_add_layers"));
584 action->set_param("canvas",canvas_interface()->get_canvas());
585 action->set_param("canvas_interface",canvas_interface());
586 action->set_param("group",dest_group);
588 for(unsigned int i=0;i<selection_data.get_length()/sizeof(void*);i++)
590 Layer::Handle layer(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
593 action->set_param("layer",layer);
595 if(!canvas_interface()->get_instance()->perform_action(action))
597 passive_grouper.cancel();
602 if(synfig::String(selection_data.get_data_type())=="GROUP")
604 synfig::String src_group(reinterpret_cast<const gchar*>(selection_data.get_data()));
605 synfig::String group(src_group);
607 // Get rid of any parent group crap
608 while(group.find(GROUP_NEST_CHAR)!=Glib::ustring::npos)
609 group=Glib::ustring(group,group.find(GROUP_NEST_CHAR)+1,Glib::ustring::npos);
611 group=dest_group+GROUP_NEST_CHAR+group;
613 synfigapp::Action::Handle action(synfigapp::Action::create("group_rename"));
618 action->set_param("canvas",canvas_interface()->get_canvas());
619 action->set_param("canvas_interface",canvas_interface());
620 action->set_param("group",src_group);
621 action->set_param("new_group",group);
623 if(!canvas_interface()->get_instance()->perform_action(action))
625 passive_grouper.cancel();
631 /* // Save the selection data
632 synfigapp::SelectionManager::LayerList selected_layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
634 if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
636 Canvas::Handle dest_canvas;
637 Layer::Handle dest_layer;
639 dest_canvas=(Canvas::Handle)(row[model.canvas]);
640 dest_layer=(Layer::Handle)(row[model.layer]);
646 int dest_layer_depth=dest_layer->get_depth();
648 if(synfig::String(selection_data.get_data_type())=="LAYER")for(i=0;i<selection_data.get_length()/sizeof(void*);i++)
650 //synfig::info("dest_layer_depth=%d",dest_layer_depth);
652 Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
657 // In this case, we are just moving.
658 // if(dest_canvas==src->get_canvas())
660 if(dest_canvas==src->get_canvas() && dest_layer_depth && dest_layer_depth>src->get_depth())
662 if(dest_canvas==src->get_canvas() && dest_layer_depth==src->get_depth())
665 synfigapp::Action::Handle action(synfigapp::Action::create("layer_move"));
666 action->set_param("canvas",dest_canvas);
667 action->set_param("canvas_interface",canvas_interface());
668 action->set_param("layer",src);
669 action->set_param("new_index",dest_layer_depth);
670 action->set_param("dest_canvas",dest_canvas);
671 if(canvas_interface()->get_instance()->perform_action(action))
679 passive_grouper.cancel();
686 synfig::info("I suposidly moved %d layers",i);
688 // Reselect the previously selected layers
689 canvas_interface()->get_selection_manager()->set_selected_layers(selected_layer_list);
703 LayerGroupTreeStore::rebuild()
706 etl::clock timer;timer.reset();
709 // Clear out the current list
711 Canvas::Handle canvas(canvas_interface()->get_canvas());
712 std::set<String> groups(canvas->get_groups());
713 for(;groups.size();groups.erase(groups.begin()))
715 String group(*groups.begin());
716 Gtk::TreeRow row(on_group_added(group));
717 std::set<Layer::Handle> layers(canvas->get_layers_in_group(group));
719 for(;layers.size();layers.erase(layers.begin()))
721 Gtk::TreeRow layer_row(*(prepend(row.children())));
722 Layer::Handle layer(*layers.begin());
723 set_row_layer(layer_row,layer);
727 // Go ahead and and add all the layers
729 canvas_interface()->get_canvas()->rbegin(), canvas_interface()->get_canvas()->rend(),
730 sigc::mem_fun(*this, &studio::LayerGroupTreeStore::on_layer_added)
739 synfig::info("LayerGroupTreeStore::rebuild() took %f seconds",float(timer()));
743 LayerGroupTreeStore::refresh()
749 LayerGroupTreeStore::refresh_row(Gtk::TreeModel::Row &row)
751 if((bool)row[model.is_layer])
753 Layer::Handle layer=row[model.layer];
756 //if(layer->dynamic_param_list().count("z_depth"))
757 // row[model.z_depth]=Time::begin();
760 Gtk::TreeModel::Children children = row.children();
761 Gtk::TreeModel::Children::iterator iter;
763 if(!children.empty())
764 for(iter = children.begin(); iter && iter != children.end(); ++iter)
766 Gtk::TreeRow row=*iter;
773 LayerGroupTreeStore::set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle)
775 row[model.is_layer] = true;
776 row[model.is_group] = false;
777 row[model.layer] = handle;
781 LayerGroupTreeStore::on_group_added(synfig::String group)
783 // Check to see if this group perhaps already
786 Gtk::TreeModel::Children::iterator iter;
787 if(find_group_row(group, iter))
791 if(group.find(GROUP_NEST_CHAR)!=String::npos)
793 Gtk::TreeModel::Children::iterator iter;
797 if(parent_name.size())
798 parent_name+=GROUP_NEST_CHAR;
799 parent_name+=string(group,0,group.find(GROUP_NEST_CHAR));
801 if(!find_group_row(parent_name, iter))
802 iter=on_group_added(parent_name);
804 group=String(group,group.find(GROUP_NEST_CHAR)+1,String::npos);
805 }while(group.find(GROUP_NEST_CHAR)!=String::npos);
807 if(parent_name.size())
808 parent_name+=GROUP_NEST_CHAR;
813 Gtk::TreeRow row(*(prepend(iter->children())));
814 row[model.group_name]=parent_name;
815 row[model.is_layer]=false;
816 row[model.is_group]=true;
822 Gtk::TreeRow row(*(append()));
823 row[model.group_name]=group;
824 row[model.is_layer]=false;
825 row[model.is_group]=true;
831 LayerGroupTreeStore::on_group_removed(synfig::String group)
835 Gtk::TreeModel::Children::iterator iter;
836 if(find_group_row(group,iter) && iter->children().size()==0)
845 LayerGroupTreeStore::on_group_changed(synfig::String group)
852 LayerGroupTreeStore::on_group_pair_added(String group, etl::handle<Layer> layer)
854 if(!layer->get_canvas())
857 Gtk::TreeModel::Children::iterator iter;
858 if(!find_group_row(group, iter))
859 iter=on_group_added(group);
861 Gtk::TreeRow layer_row(*(append(iter->children())));
862 set_row_layer(layer_row,layer);
867 LayerGroupTreeStore::on_group_pair_removed(String group, etl::handle<Layer> layer)
869 if(!layer->get_canvas())
872 Gtk::TreeModel::Children::iterator iter;
873 if(!find_group_row(group, iter))
876 Gtk::TreeModel::Children::iterator prev,layer_iter;
878 if(!find_layer_row_(layer, layer->get_canvas(), iter->children(), layer_iter, prev))
887 LayerGroupTreeStore::on_activity()
889 // If we aren't rebuilding and the last action
890 // had something to do with groups, then go
891 // a head and present the groups dialog.
892 if(!rebuilding && canvas_interface()->get_instance()->get_most_recent_action() && canvas_interface()->get_instance()->get_most_recent_action()->get_name().find("group")!=String::npos)
895 App::dock_manager->find_dockable("groups").present();
901 LayerGroupTreeStore::on_layer_status_changed(synfig::Layer::Handle handle,bool x)
903 Gtk::TreeModel::Children::iterator iter;
904 if(find_layer_row(handle,iter))
905 (*iter)[model.layer]=handle;
908 synfig::warning("Couldn't find layer to be activated in layer list. Rebuilding index...");
915 LayerGroupTreeStore::on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc)
917 Gtk::TreeModel::Children::iterator iter;
918 if(find_layer_row(handle,iter))
920 Gtk::TreeRow row(*iter);
922 Layer::Handle layer(row[model.layer]);
926 //row[model.label]=layer->get_local_name();
927 row[model.tooltip]=Glib::ustring(_("Layer"));
930 //row[model.label]=layer->get_description();
931 row[model.tooltip]=layer->get_local_name();
940 LayerGroupTreeStore::find_layer_row_(const synfig::Layer::Handle &layer, synfig::Canvas::Handle canvas, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev)
944 //if(layer->get_canvas()==canvas)
946 for(iter=prev=layers.begin(); iter && iter != layers.end(); prev=iter++)
948 Gtk::TreeModel::Row row = *iter;
949 if((bool)row[model.is_layer] && layer==(synfig::Layer::Handle)row[model.layer])
953 iter=children().end();
958 Gtk::TreeModel::Children::iterator iter2;
960 for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
962 Gtk::TreeModel::Row row = *iter2;
965 if(row.children().empty())
968 /*Canvas::Handle canvas((*row.children().begin())[model.canvas]);
973 if(find_layer_row_(layer,canvas,iter2->children(),iter,prev))
977 iter=children().end();
982 LayerGroupTreeStore::find_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &iter)
984 Gtk::TreeModel::Children::iterator prev;
985 return find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev);
989 LayerGroupTreeStore::find_group_row(const String &group, Gtk::TreeModel::Children::iterator &iter)
991 Gtk::TreeModel::Children::iterator prev;
992 return find_group_row_(group,children(),iter,prev);
996 LayerGroupTreeStore::find_group_row_(const synfig::String &group, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev)
998 //if(layer->get_canvas()==canvas)
1000 for(iter=prev=layers.begin(); iter && iter != layers.end(); prev=iter++)
1002 Gtk::TreeModel::Row row = *iter;
1003 if((bool)row[model.is_group] && group==(Glib::ustring)row[model.group_name])
1007 iter=children().end();
1012 Gtk::TreeModel::Children::iterator iter2;
1014 for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
1016 Gtk::TreeModel::Row row = *iter2;
1019 if(row.children().empty())
1022 if(find_group_row_(group,iter2->children(),iter,prev))
1026 iter=children().end();
1031 LayerGroupTreeStore::find_prev_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &prev)
1033 Gtk::TreeModel::Children::iterator iter;
1034 if(!find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev))
1036 if(iter==children().begin())