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 "iconcontroller.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"
44 #include <gtk/gtkversion.h>
50 /* === U S I N G =========================================================== */
54 using namespace synfig;
55 using namespace studio;
57 /* === M A C R O S ========================================================= */
59 #define GROUP_NEST_CHAR '.'
61 /* === G L O B A L S ======================================================= */
63 /* === P R O C E D U R E S ================================================= */
65 /* === M E T H O D S ======================================================= */
67 static LayerGroupTreeStore::Model& ModelHack()
69 static LayerGroupTreeStore::Model* model(0);
70 if(!model)model=new LayerGroupTreeStore::Model;
74 LayerGroupTreeStore::LayerGroupTreeStore(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_):
75 Gtk::TreeStore (ModelHack()),
76 canvas_interface_ (canvas_interface_)
78 layer_icon=Gtk::Button().render_icon(Gtk::StockID("synfig-layer"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
79 group_icon=Gtk::Button().render_icon(Gtk::StockID("synfig-group"),Gtk::ICON_SIZE_SMALL_TOOLBAR);
81 // Connect Signals to Terminals
82 canvas_interface()->signal_layer_status_changed().connect(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_layer_status_changed));
83 canvas_interface()->signal_layer_new_description().connect(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_layer_new_description));
85 canvas_interface()->get_canvas()->signal_group_added().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_added)));
86 canvas_interface()->get_canvas()->signal_group_removed().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_removed)));
87 canvas_interface()->get_canvas()->signal_group_changed().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_changed)));
89 canvas_interface()->get_canvas()->signal_group_pair_added().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_pair_added)));
90 canvas_interface()->get_canvas()->signal_group_pair_removed().connect(sigc::hide_return(sigc::mem_fun(*this,&studio::LayerGroupTreeStore::on_group_pair_removed)));
95 LayerGroupTreeStore::~LayerGroupTreeStore()
98 synfig::info("LayerGroupTreeStore::~LayerGroupTreeStore(): Deleted");
102 LayerGroupTreeStore::search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring& x,const TreeModel::iterator& iter)
106 Glib::ustring substr(x.uppercase());
107 Glib::ustring label((*iter)[model.label]);
108 label=label.uppercase();
110 return label.find(substr)==Glib::ustring::npos;
114 Glib::RefPtr<LayerGroupTreeStore>
115 LayerGroupTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_)
117 return Glib::RefPtr<LayerGroupTreeStore>(new LayerGroupTreeStore(canvas_interface_));
121 LayerGroupTreeStore::get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const
123 if(column==model.child_layers.index())
125 Glib::Value<LayerList> x;
126 g_value_init(x.gobj(),x.value_type());
128 if((bool)(*iter)[model.is_group])
130 set<Layer::Handle> layer_set(canvas_interface()->get_canvas()->get_layers_in_group((Glib::ustring)(*iter)[model.group_name]));
132 x.set(LayerList(layer_set.begin(),layer_set.end()));
134 else if((bool)(*iter)[model.is_layer])
136 LayerList layer_list;
137 layer_list.push_back((Layer::Handle)(*iter)[model.layer]);
141 g_value_init(value.gobj(),x.value_type());
144 else if(column==model.all_layers.index())
146 Glib::Value<LayerList> x;
147 g_value_init(x.gobj(),x.value_type());
149 if((bool)(*iter)[model.is_group])
151 LayerList layer_list;
152 Gtk::TreeModel::iterator child_iter(iter->children().begin());
153 for(;child_iter;++child_iter)
155 LayerList layer_list2((LayerList)(*child_iter)[model.all_layers]);
156 for(;layer_list2.size();layer_list2.pop_front())
157 layer_list.push_back(layer_list2.front());
161 else if((bool)(*iter)[model.is_layer])
163 LayerList layer_list;
164 layer_list.push_back((Layer::Handle)(*iter)[model.layer]);
168 g_value_init(value.gobj(),x.value_type());
171 else if(column==model.group_name.index())
173 if((bool)(*iter)[model.is_group])
174 return Gtk::TreeStore::get_value_vfunc(iter,column,value);
175 return get_value_vfunc(iter->parent(),column,value);
177 else if(column==model.parent_group_name.index())
180 return get_value_vfunc(iter->parent(),model.group_name.index(),value);
181 Glib::Value<Glib::ustring> x;
182 g_value_init(x.gobj(),x.value_type());
183 x.set(Glib::ustring());
184 g_value_init(value.gobj(),x.value_type());
187 else if(column==model.label.index())
189 if((bool)(*iter)[model.is_group])
191 Glib::Value<Glib::ustring> x;
192 g_value_init(x.gobj(),x.value_type());
194 Glib::ustring group_name((*iter)[model.group_name]);
196 // Get rid of any parent group crap
197 while(group_name.find(GROUP_NEST_CHAR)!=Glib::ustring::npos)
198 group_name=Glib::ustring(group_name,group_name.find(GROUP_NEST_CHAR)+1,Glib::ustring::npos);
202 g_value_init(value.gobj(),x.value_type());
206 else if((bool)(*iter)[model.is_layer])
208 synfig::Layer::Handle layer((*iter)[model.layer]);
212 Glib::Value<Glib::ustring> x;
213 g_value_init(x.gobj(),x.value_type());
215 x.set(layer->get_non_empty_description());
217 g_value_init(value.gobj(),x.value_type());
218 //g_value_copy(x.gobj(),value.gobj());
223 if(column==model.tooltip.index())
225 synfig::Layer::Handle layer((*iter)[model.layer]);
229 Glib::Value<Glib::ustring> x;
230 g_value_init(x.gobj(),x.value_type());
233 x.set(layer->get_local_name());
235 g_value_init(value.gobj(),x.value_type());
236 //g_value_copy(x.gobj(),value.gobj());
240 if(column==model.canvas.index())
242 synfig::Layer::Handle layer((*iter)[model.layer]);
246 Glib::Value<Canvas::Handle> x;
247 g_value_init(x.gobj(),x.value_type());
250 x.set(layer->get_canvas());
252 g_value_init(value.gobj(),x.value_type());
253 //g_value_copy(x.gobj(),value.gobj());
257 if(column==model.active.index())
260 g_value_init(x.gobj(),x.value_type());
262 if((bool)(*iter)[model.is_layer])
264 synfig::Layer::Handle layer((*iter)[model.layer]);
265 x.set(layer->active());
267 else if((bool)(*iter)[model.is_group])
269 int activecount(0),total(0);
270 Gtk::TreeModel::iterator child_iter(iter->children().begin());
271 for(;child_iter;++child_iter)
274 if((*child_iter)[model.active])
277 x.set(activecount>total/2);
282 g_value_init(value.gobj(),x.value_type());
283 g_value_copy(x.gobj(),value.gobj());
286 if(column==model.icon.index())
288 Glib::Value<Glib::RefPtr<Gdk::Pixbuf> > x;
289 g_value_init(x.gobj(),x.value_type());
291 if((bool)(*iter)[model.is_layer])
293 synfig::Layer::Handle layer((*iter)[model.layer]);
296 x.set(get_tree_pixbuf_layer(layer->get_name()));
298 if((bool)(*iter)[model.is_group])
301 g_value_init(value.gobj(),x.value_type());
302 g_value_copy(x.gobj(),value.gobj());
305 Gtk::TreeStore::get_value_vfunc(iter,column,value);
309 LayerGroupTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
311 //if(!iterator_sane(row))
314 if(column>=get_n_columns_vfunc())
316 g_warning("LayerGroupTreeStore::set_value_impl: Bad column (%d)",column);
320 if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
322 g_warning("LayerGroupTreeStore::set_value_impl: Bad value type");
328 if(column==model.label.index())
330 Glib::Value<Glib::ustring> x;
331 g_value_init(x.gobj(),model.label.type());
332 g_value_copy(value.gobj(),x.gobj());
334 if((bool)(*iter)[model.is_layer])
336 synfig::Layer::Handle layer((*iter)[model.layer]);
339 synfig::String new_desc(x.get());
341 if(new_desc==layer->get_local_name())
342 new_desc=synfig::String();
344 if(new_desc==layer->get_description())
347 synfigapp::Action::Handle action(synfigapp::Action::create("layer_set_desc"));
352 action->set_param("canvas",canvas_interface()->get_canvas());
353 action->set_param("canvas_interface",canvas_interface());
354 action->set_param("layer",layer);
355 action->set_param("new_description",synfig::String(x.get()));
357 canvas_interface()->get_instance()->perform_action(action);
360 else if((bool)(*iter)[model.is_group])
362 synfig::String group((Glib::ustring)(*iter)[model.label]);
363 synfig::String new_group(x.get());
368 Glib::ustring group_name((*iter)[model.group_name]);
372 // Get rid of any parent group crap
373 while(group_name.find(GROUP_NEST_CHAR)!=Glib::ustring::npos)
375 new_group+=Glib::ustring(group_name,0,group_name.find(GROUP_NEST_CHAR)+1);
376 group_name=Glib::ustring(group_name,group_name.find(GROUP_NEST_CHAR)+1,Glib::ustring::npos);
380 synfig::info("Renaming group \"%s\" to \"%s\"...",group.c_str(),new_group.c_str());
382 // Check to see if this group is real or not.
383 // If it isn't real, then renaming it is a cinch.
384 // We know it isn't real if it doesn't have any
386 if(iter->children().empty())
388 (*iter)[model.group_name]=new_group;
392 synfigapp::Action::Handle action(synfigapp::Action::create("group_rename"));
397 action->set_param("canvas",canvas_interface()->get_canvas());
398 action->set_param("canvas_interface",canvas_interface());
399 action->set_param("group",group);
400 action->set_param("new_group",new_group);
402 canvas_interface()->get_instance()->perform_action(action);
409 if(column==model.active.index())
412 g_value_init(x.gobj(),model.active.type());
413 g_value_copy(value.gobj(),x.gobj());
415 if((bool)(*iter)[model.is_layer])
417 synfig::Layer::Handle layer((*iter)[model.layer]);
420 synfigapp::Action::Handle action(synfigapp::Action::create("layer_activate"));
425 action->set_param("canvas",canvas_interface()->get_canvas());
426 action->set_param("canvas_interface",canvas_interface());
427 action->set_param("layer",layer);
428 action->set_param("new_status",bool(x.get()));
431 canvas_interface()->get_instance()->perform_action(action);
434 else if(!iter->children().empty())
436 synfigapp::Action::PassiveGrouper group(
437 get_canvas_interface()->get_instance().get(),
439 x.get()?_("Activate "):_("Deactivate ")
440 )+(Glib::ustring)(*iter)[model.label]
443 Gtk::TreeModel::iterator child_iter(iter->children().begin());
445 for(;child_iter;++child_iter)
446 (*child_iter)[model.active]=x.get();
448 Gtk::TreeStore::set_value_impl(iter,column, value);
452 Gtk::TreeStore::set_value_impl(iter,column, value);
455 catch(std::exception x)
465 LayerGroupTreeStore::row_draggable_vfunc (const TreeModel::Path& /*path*/)const
467 //if(!get_iter(path)) return false;
468 // Gtk::TreeModel::Row row(*get_iter(path));
471 // return (bool)true;
475 LayerGroupTreeStore::drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const
477 if(!const_cast<LayerGroupTreeStore*>(this)->get_iter(path)) return false;
478 //synfig::info("Dragged data of type \"%s\"",selection_data.get_data_type());
479 //synfig::info("Dragged data of target \"%s\"",gdk_atom_name(selection_data->target));
480 //synfig::info("Dragged selection=\"%s\"",gdk_atom_name(selection_data->selection));
482 Gtk::TreeModel::Row row(*const_cast<LayerGroupTreeStore*>(this)->get_iter(path));
484 if((bool)row[model.is_layer])
486 Layer* layer(((Layer::Handle)row[model.layer]).get());
489 std::vector<Layer*> layers;
491 layers.push_back(layer);
493 selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layers.front()), sizeof(void*)*layers.size());
497 else if((bool)row[model.is_group])
499 synfig::String group((Glib::ustring)row[model.group_name]);
503 selection_data.set("GROUP", 8, reinterpret_cast<const guchar*>(&*group.begin()), sizeof(void*)*group.size());
512 LayerGroupTreeStore::drag_data_delete_vfunc (const TreeModel::Path& /*path*/)
518 LayerGroupTreeStore::row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const
520 Gtk::TreeIter iter(const_cast<LayerGroupTreeStore*>(this)->get_iter(dest));
521 if(!iter) return false;
523 if(synfig::String(selection_data.get_data_type())=="LAYER")
526 if(synfig::String(selection_data.get_data_type())=="GROUP")
528 synfig::String dest_group((Glib::ustring)(*iter)[model.group_name]);
529 synfig::String src_group(reinterpret_cast<const gchar*>(selection_data.get_data()));
530 //synfig::String src_group(const_cast<gchar*>(selection_data.get_data()));
532 // Avoid putting a group inside of itself
533 if(dest_group.size()>src_group.size() && src_group==String(dest_group,0,src_group.size()))
539 //synfig::info("possible_drop -- data of type \"%s\"",selection_data.get_data_type());
540 //synfig::info("possible_drop -- data of target \"%s\"",gdk_atom_name(selection_data->target));
541 //synfig::info("possible_drop -- selection=\"%s\"",gdk_atom_name(selection_data->selection));
543 //Gtk::TreeModel::Row row(*get_iter(dest));
545 /* if(synfig::String(selection_data.get_data_type())=="LAYER" && (bool)true)
552 LayerGroupTreeStore::drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)
554 if(!get_iter(dest)) return false;
558 Gtk::TreeModel::Row row(*get_iter(dest));
560 //synfig::info("Dropped data of type \"%s\"",selection_data.get_data_type());
561 //synfig::info("Dropped data of target \"%s\"",gdk_atom_name(selection_data->target));
562 //synfig::info("Dropped selection=\"%s\"",gdk_atom_name(selection_data->selection));
563 synfigapp::Action::PassiveGrouper passive_grouper(canvas_interface()->get_instance().get(),_("Regroup"));
565 if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
567 synfig::String dest_group;
569 dest_group=(Glib::ustring)row[model.group_name];
571 if(dest_group.empty())
574 if(synfig::String(selection_data.get_data_type())=="LAYER")
576 synfigapp::Action::Handle action(synfigapp::Action::create("group_add_layers"));
581 action->set_param("canvas",canvas_interface()->get_canvas());
582 action->set_param("canvas_interface",canvas_interface());
583 action->set_param("group",dest_group);
585 for(unsigned int i=0;i<selection_data.get_length()/sizeof(void*);i++)
587 Layer::Handle layer(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
590 action->set_param("layer",layer);
592 if(!canvas_interface()->get_instance()->perform_action(action))
594 passive_grouper.cancel();
599 if(synfig::String(selection_data.get_data_type())=="GROUP")
601 synfig::String src_group(reinterpret_cast<const gchar*>(selection_data.get_data()));
602 synfig::String group(src_group);
604 // Get rid of any parent group crap
605 while(group.find(GROUP_NEST_CHAR)!=Glib::ustring::npos)
606 group=Glib::ustring(group,group.find(GROUP_NEST_CHAR)+1,Glib::ustring::npos);
608 group=dest_group+GROUP_NEST_CHAR+group;
610 synfigapp::Action::Handle action(synfigapp::Action::create("group_rename"));
615 action->set_param("canvas",canvas_interface()->get_canvas());
616 action->set_param("canvas_interface",canvas_interface());
617 action->set_param("group",src_group);
618 action->set_param("new_group",group);
620 if(!canvas_interface()->get_instance()->perform_action(action))
622 passive_grouper.cancel();
628 /* // Save the selection data
629 synfigapp::SelectionManager::LayerList selected_layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
631 if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
633 Canvas::Handle dest_canvas;
634 Layer::Handle dest_layer;
636 dest_canvas=(Canvas::Handle)(row[model.canvas]);
637 dest_layer=(Layer::Handle)(row[model.layer]);
643 int dest_layer_depth=dest_layer->get_depth();
645 if(synfig::String(selection_data.get_data_type())=="LAYER")for(i=0;i<selection_data.get_length()/sizeof(void*);i++)
647 //synfig::info("dest_layer_depth=%d",dest_layer_depth);
649 Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
654 // In this case, we are just moving.
655 // if(dest_canvas==src->get_canvas())
657 if(dest_canvas==src->get_canvas() && dest_layer_depth && dest_layer_depth>src->get_depth())
659 if(dest_canvas==src->get_canvas() && dest_layer_depth==src->get_depth())
662 synfigapp::Action::Handle action(synfigapp::Action::create("layer_move"));
663 action->set_param("canvas",dest_canvas);
664 action->set_param("canvas_interface",canvas_interface());
665 action->set_param("layer",src);
666 action->set_param("new_index",dest_layer_depth);
667 action->set_param("dest_canvas",dest_canvas);
668 if(canvas_interface()->get_instance()->perform_action(action))
674 passive_grouper.cancel();
681 synfig::info("I supposedly moved %d layers",i);
683 // Reselect the previously selected layers
684 canvas_interface()->get_selection_manager()->set_selected_layers(selected_layer_list);
698 LayerGroupTreeStore::rebuild()
701 // etl::clock timer;timer.reset();
704 // Clear out the current list
706 Canvas::Handle canvas(canvas_interface()->get_canvas());
707 std::set<String> groups(canvas->get_groups());
708 for(;groups.size();groups.erase(groups.begin()))
710 String group(*groups.begin());
711 Gtk::TreeRow row(on_group_added(group));
712 std::set<Layer::Handle> layers(canvas->get_layers_in_group(group));
714 for(;layers.size();layers.erase(layers.begin()))
716 Gtk::TreeRow layer_row(*(prepend(row.children())));
717 Layer::Handle layer(*layers.begin());
718 set_row_layer(layer_row,layer);
722 // Go ahead and and add all the layers
724 canvas_interface()->get_canvas()->rbegin(), canvas_interface()->get_canvas()->rend(),
725 sigc::mem_fun(*this, &studio::LayerGroupTreeStore::on_layer_added)
734 // synfig::info("LayerGroupTreeStore::rebuild() took %f seconds",float(timer()));
738 LayerGroupTreeStore::refresh()
744 LayerGroupTreeStore::refresh_row(Gtk::TreeModel::Row &row)
746 if((bool)row[model.is_layer])
748 Layer::Handle layer=row[model.layer];
751 //if(layer->dynamic_param_list().count("z_depth"))
752 // row[model.z_depth]=Time::begin();
755 Gtk::TreeModel::Children children = row.children();
756 Gtk::TreeModel::Children::iterator iter;
758 if(!children.empty())
759 for(iter = children.begin(); iter && iter != children.end(); ++iter)
761 Gtk::TreeRow row=*iter;
768 LayerGroupTreeStore::set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle)
770 row[model.is_layer] = true;
771 row[model.is_group] = false;
772 row[model.layer] = handle;
776 LayerGroupTreeStore::on_group_added(synfig::String group)
778 // Check to see if this group perhaps already
781 Gtk::TreeModel::Children::iterator iter;
782 if(find_group_row(group, iter))
786 if(group.find(GROUP_NEST_CHAR)!=String::npos)
788 Gtk::TreeModel::Children::iterator iter;
792 if(parent_name.size())
793 parent_name+=GROUP_NEST_CHAR;
794 parent_name+=string(group,0,group.find(GROUP_NEST_CHAR));
796 if(!find_group_row(parent_name, iter))
797 iter=on_group_added(parent_name);
799 group=String(group,group.find(GROUP_NEST_CHAR)+1,String::npos);
800 }while(group.find(GROUP_NEST_CHAR)!=String::npos);
802 if(parent_name.size())
803 parent_name+=GROUP_NEST_CHAR;
808 Gtk::TreeRow row(*(prepend(iter->children())));
809 row[model.group_name]=parent_name;
810 row[model.is_layer]=false;
811 row[model.is_group]=true;
817 Gtk::TreeRow row(*(append()));
818 row[model.group_name]=group;
819 row[model.is_layer]=false;
820 row[model.is_group]=true;
826 LayerGroupTreeStore::on_group_removed(synfig::String group)
828 Gtk::TreeModel::Children::iterator iter;
829 if(find_group_row(group,iter) && iter->children().size()==0)
838 LayerGroupTreeStore::on_group_changed(synfig::String /*group*/)
844 LayerGroupTreeStore::on_group_pair_added(synfig::String group, etl::handle<synfig::Layer> layer)
846 if(!layer->get_canvas())
848 Gtk::TreeModel::Children::iterator iter;
849 if(!find_group_row(group, iter))
850 iter=on_group_added(group);
852 Gtk::TreeRow layer_row(*(append(iter->children())));
853 set_row_layer(layer_row,layer);
858 LayerGroupTreeStore::on_group_pair_removed(synfig::String group, etl::handle<synfig::Layer> layer)
860 if(!layer->get_canvas())
862 Gtk::TreeModel::Children::iterator iter;
863 if(!find_group_row(group, iter))
866 Gtk::TreeModel::Children::iterator prev,layer_iter;
868 if(!find_layer_row_(layer, layer->get_canvas(), iter->children(), layer_iter, prev))
877 LayerGroupTreeStore::on_activity()
879 // If we aren't rebuilding and the last action
880 // had something to do with groups, then go
881 // a head and present the groups dialog.
882 if(!rebuilding && canvas_interface()->get_instance()->get_most_recent_action() && canvas_interface()->get_instance()->get_most_recent_action()->get_name().find("group")!=String::npos)
885 App::dock_manager->find_dockable("groups").present();
891 LayerGroupTreeStore::on_layer_status_changed(synfig::Layer::Handle handle,bool /*x*/)
893 Gtk::TreeModel::Children::iterator iter;
894 if(find_layer_row(handle,iter))
895 (*iter)[model.layer]=handle;
898 synfig::warning("Couldn't find layer to be activated in layer list. Rebuilding index...");
905 LayerGroupTreeStore::on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc)
907 Gtk::TreeModel::Children::iterator iter;
908 if(find_layer_row(handle,iter))
910 Gtk::TreeRow row(*iter);
912 Layer::Handle layer(row[model.layer]);
916 //row[model.label]=layer->get_local_name();
917 row[model.tooltip]=Glib::ustring(_("Layer"));
920 //row[model.label]=layer->get_description();
921 row[model.tooltip]=layer->get_local_name();
930 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)
934 //if(layer->get_canvas()==canvas)
936 for(iter=prev=layers.begin(); iter && iter != layers.end(); prev=iter++)
938 Gtk::TreeModel::Row row = *iter;
939 if((bool)row[model.is_layer] && layer==(synfig::Layer::Handle)row[model.layer])
943 iter=children().end();
947 Gtk::TreeModel::Children::iterator iter2;
949 for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
951 Gtk::TreeModel::Row row = *iter2;
954 if(row.children().empty())
957 /*Canvas::Handle canvas((*row.children().begin())[model.canvas]);
962 if(find_layer_row_(layer,canvas,iter2->children(),iter,prev))
966 iter=children().end();
971 LayerGroupTreeStore::find_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &iter)
973 Gtk::TreeModel::Children::iterator prev;
974 return find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev);
978 LayerGroupTreeStore::find_group_row(const synfig::String &group, Gtk::TreeModel::Children::iterator &iter)
980 Gtk::TreeModel::Children::iterator prev;
981 return find_group_row_(group,children(),iter,prev);
985 LayerGroupTreeStore::find_group_row_(const synfig::String &group, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev)
987 //if(layer->get_canvas()==canvas)
989 for(iter=prev=layers.begin(); iter && iter != layers.end(); prev=iter++)
991 Gtk::TreeModel::Row row = *iter;
992 if((bool)row[model.is_group] && group==(Glib::ustring)row[model.group_name])
996 iter=children().end();
1000 Gtk::TreeModel::Children::iterator iter2;
1002 for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
1004 Gtk::TreeModel::Row row = *iter2;
1007 if(row.children().empty())
1010 if(find_group_row_(group,iter2->children(),iter,prev))
1014 iter=children().end();
1019 LayerGroupTreeStore::find_prev_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &prev)
1021 Gtk::TreeModel::Children::iterator iter;
1022 if(!find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev))
1024 if(iter==children().begin())