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()
99 if (getenv("SYNFIG_DEBUG_DESTRUCTORS"))
100 synfig::info("LayerGroupTreeStore::~LayerGroupTreeStore(): Deleted");
104 LayerGroupTreeStore::search_func(const Glib::RefPtr<TreeModel>&,int,const Glib::ustring& x,const TreeModel::iterator& iter)
108 Glib::ustring substr(x.uppercase());
109 Glib::ustring label((*iter)[model.label]);
110 label=label.uppercase();
112 return label.find(substr)==Glib::ustring::npos;
116 Glib::RefPtr<LayerGroupTreeStore>
117 LayerGroupTreeStore::create(etl::loose_handle<synfigapp::CanvasInterface> canvas_interface_)
119 return Glib::RefPtr<LayerGroupTreeStore>(new LayerGroupTreeStore(canvas_interface_));
123 LayerGroupTreeStore::get_value_vfunc (const Gtk::TreeModel::iterator& iter, int column, Glib::ValueBase& value)const
125 if(column==model.child_layers.index())
127 Glib::Value<LayerList> x;
128 g_value_init(x.gobj(),x.value_type());
130 if((bool)(*iter)[model.is_group])
132 set<Layer::Handle> layer_set(canvas_interface()->get_canvas()->get_layers_in_group((Glib::ustring)(*iter)[model.group_name]));
134 x.set(LayerList(layer_set.begin(),layer_set.end()));
136 else if((bool)(*iter)[model.is_layer])
138 LayerList layer_list;
139 layer_list.push_back((Layer::Handle)(*iter)[model.layer]);
143 g_value_init(value.gobj(),x.value_type());
146 else if(column==model.all_layers.index())
148 Glib::Value<LayerList> x;
149 g_value_init(x.gobj(),x.value_type());
151 if((bool)(*iter)[model.is_group])
153 LayerList layer_list;
154 Gtk::TreeModel::iterator child_iter(iter->children().begin());
155 for(;child_iter;++child_iter)
157 LayerList layer_list2((LayerList)(*child_iter)[model.all_layers]);
158 for(;layer_list2.size();layer_list2.pop_front())
159 layer_list.push_back(layer_list2.front());
163 else if((bool)(*iter)[model.is_layer])
165 LayerList layer_list;
166 layer_list.push_back((Layer::Handle)(*iter)[model.layer]);
170 g_value_init(value.gobj(),x.value_type());
173 else if(column==model.group_name.index())
175 if((bool)(*iter)[model.is_group])
176 return Gtk::TreeStore::get_value_vfunc(iter,column,value);
177 return get_value_vfunc(iter->parent(),column,value);
179 else if(column==model.parent_group_name.index())
182 return get_value_vfunc(iter->parent(),model.group_name.index(),value);
183 Glib::Value<Glib::ustring> x;
184 g_value_init(x.gobj(),x.value_type());
185 x.set(Glib::ustring());
186 g_value_init(value.gobj(),x.value_type());
189 else if(column==model.label.index())
191 if((bool)(*iter)[model.is_group])
193 Glib::Value<Glib::ustring> x;
194 g_value_init(x.gobj(),x.value_type());
196 Glib::ustring group_name((*iter)[model.group_name]);
198 // Get rid of any parent group crap
199 while(group_name.find(GROUP_NEST_CHAR)!=Glib::ustring::npos)
200 group_name=Glib::ustring(group_name,group_name.find(GROUP_NEST_CHAR)+1,Glib::ustring::npos);
204 g_value_init(value.gobj(),x.value_type());
208 else if((bool)(*iter)[model.is_layer])
210 synfig::Layer::Handle layer((*iter)[model.layer]);
214 Glib::Value<Glib::ustring> x;
215 g_value_init(x.gobj(),x.value_type());
217 x.set(layer->get_non_empty_description());
219 g_value_init(value.gobj(),x.value_type());
220 //g_value_copy(x.gobj(),value.gobj());
225 if(column==model.tooltip.index())
227 synfig::Layer::Handle layer((*iter)[model.layer]);
231 Glib::Value<Glib::ustring> x;
232 g_value_init(x.gobj(),x.value_type());
235 x.set(layer->get_local_name());
237 g_value_init(value.gobj(),x.value_type());
238 //g_value_copy(x.gobj(),value.gobj());
242 if(column==model.canvas.index())
244 synfig::Layer::Handle layer((*iter)[model.layer]);
248 Glib::Value<Canvas::Handle> x;
249 g_value_init(x.gobj(),x.value_type());
252 x.set(layer->get_canvas());
254 g_value_init(value.gobj(),x.value_type());
255 //g_value_copy(x.gobj(),value.gobj());
259 if(column==model.active.index())
262 g_value_init(x.gobj(),x.value_type());
264 if((bool)(*iter)[model.is_layer])
266 synfig::Layer::Handle layer((*iter)[model.layer]);
267 x.set(layer->active());
269 else if((bool)(*iter)[model.is_group])
271 int activecount(0),total(0);
272 Gtk::TreeModel::iterator child_iter(iter->children().begin());
273 for(;child_iter;++child_iter)
276 if((*child_iter)[model.active])
279 x.set(activecount>total/2);
284 g_value_init(value.gobj(),x.value_type());
285 g_value_copy(x.gobj(),value.gobj());
288 if(column==model.icon.index())
290 Glib::Value<Glib::RefPtr<Gdk::Pixbuf> > x;
291 g_value_init(x.gobj(),x.value_type());
293 if((bool)(*iter)[model.is_layer])
295 synfig::Layer::Handle layer((*iter)[model.layer]);
298 x.set(get_tree_pixbuf_layer(layer->get_name()));
300 if((bool)(*iter)[model.is_group])
303 g_value_init(value.gobj(),x.value_type());
304 g_value_copy(x.gobj(),value.gobj());
307 Gtk::TreeStore::get_value_vfunc(iter,column,value);
311 LayerGroupTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, const Glib::ValueBase& value)
313 //if(!iterator_sane(row))
316 if(column>=get_n_columns_vfunc())
318 g_warning("LayerGroupTreeStore::set_value_impl: Bad column (%d)",column);
322 if(!g_value_type_compatible(G_VALUE_TYPE(value.gobj()),get_column_type_vfunc(column)))
324 g_warning("LayerGroupTreeStore::set_value_impl: Bad value type");
330 if(column==model.label.index())
332 Glib::Value<Glib::ustring> x;
333 g_value_init(x.gobj(),model.label.type());
334 g_value_copy(value.gobj(),x.gobj());
336 if((bool)(*iter)[model.is_layer])
338 synfig::Layer::Handle layer((*iter)[model.layer]);
341 synfig::String new_desc(x.get());
343 if(new_desc==layer->get_local_name())
344 new_desc=synfig::String();
346 if(new_desc==layer->get_description())
349 synfigapp::Action::Handle action(synfigapp::Action::create("layer_set_desc"));
354 action->set_param("canvas",canvas_interface()->get_canvas());
355 action->set_param("canvas_interface",canvas_interface());
356 action->set_param("layer",layer);
357 action->set_param("new_description",synfig::String(x.get()));
359 canvas_interface()->get_instance()->perform_action(action);
362 else if((bool)(*iter)[model.is_group])
364 synfig::String group((Glib::ustring)(*iter)[model.label]);
365 synfig::String new_group(x.get());
370 Glib::ustring group_name((*iter)[model.group_name]);
374 // Get rid of any parent group crap
375 while(group_name.find(GROUP_NEST_CHAR)!=Glib::ustring::npos)
377 new_group+=Glib::ustring(group_name,0,group_name.find(GROUP_NEST_CHAR)+1);
378 group_name=Glib::ustring(group_name,group_name.find(GROUP_NEST_CHAR)+1,Glib::ustring::npos);
382 synfig::info("Renaming group \"%s\" to \"%s\"...",group.c_str(),new_group.c_str());
384 // Check to see if this group is real or not.
385 // If it isn't real, then renaming it is a cinch.
386 // We know it isn't real if it doesn't have any
388 if(iter->children().empty())
390 (*iter)[model.group_name]=new_group;
394 synfigapp::Action::Handle action(synfigapp::Action::create("group_rename"));
399 action->set_param("canvas",canvas_interface()->get_canvas());
400 action->set_param("canvas_interface",canvas_interface());
401 action->set_param("group",group);
402 action->set_param("new_group",new_group);
404 canvas_interface()->get_instance()->perform_action(action);
411 if(column==model.active.index())
414 g_value_init(x.gobj(),model.active.type());
415 g_value_copy(value.gobj(),x.gobj());
417 if((bool)(*iter)[model.is_layer])
419 synfig::Layer::Handle layer((*iter)[model.layer]);
422 synfigapp::Action::Handle action(synfigapp::Action::create("layer_activate"));
427 action->set_param("canvas",canvas_interface()->get_canvas());
428 action->set_param("canvas_interface",canvas_interface());
429 action->set_param("layer",layer);
430 action->set_param("new_status",bool(x.get()));
433 canvas_interface()->get_instance()->perform_action(action);
436 else if(!iter->children().empty())
438 synfigapp::Action::PassiveGrouper group(
439 get_canvas_interface()->get_instance().get(),
441 x.get()?_("Activate "):_("Deactivate ")
442 )+(Glib::ustring)(*iter)[model.label]
445 Gtk::TreeModel::iterator child_iter(iter->children().begin());
447 for(;child_iter;++child_iter)
448 (*child_iter)[model.active]=x.get();
450 Gtk::TreeStore::set_value_impl(iter,column, value);
454 Gtk::TreeStore::set_value_impl(iter,column, value);
457 catch(std::exception x)
467 LayerGroupTreeStore::row_draggable_vfunc (const TreeModel::Path& /*path*/)const
469 //if(!get_iter(path)) return false;
470 // Gtk::TreeModel::Row row(*get_iter(path));
473 // return (bool)true;
477 LayerGroupTreeStore::drag_data_get_vfunc (const TreeModel::Path& path, Gtk::SelectionData& selection_data)const
479 if(!const_cast<LayerGroupTreeStore*>(this)->get_iter(path)) return false;
480 //synfig::info("Dragged data of type \"%s\"",selection_data.get_data_type());
481 //synfig::info("Dragged data of target \"%s\"",gdk_atom_name(selection_data->target));
482 //synfig::info("Dragged selection=\"%s\"",gdk_atom_name(selection_data->selection));
484 Gtk::TreeModel::Row row(*const_cast<LayerGroupTreeStore*>(this)->get_iter(path));
486 if((bool)row[model.is_layer])
488 Layer* layer(((Layer::Handle)row[model.layer]).get());
491 std::vector<Layer*> layers;
493 layers.push_back(layer);
495 selection_data.set("LAYER", 8, reinterpret_cast<const guchar*>(&layers.front()), sizeof(void*)*layers.size());
499 else if((bool)row[model.is_group])
501 synfig::String group((Glib::ustring)row[model.group_name]);
505 selection_data.set("GROUP", 8, reinterpret_cast<const guchar*>(&*group.begin()), sizeof(void*)*group.size());
514 LayerGroupTreeStore::drag_data_delete_vfunc (const TreeModel::Path& /*path*/)
520 LayerGroupTreeStore::row_drop_possible_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)const
522 Gtk::TreeIter iter(const_cast<LayerGroupTreeStore*>(this)->get_iter(dest));
523 if(!iter) return false;
525 if(synfig::String(selection_data.get_data_type())=="LAYER")
528 if(synfig::String(selection_data.get_data_type())=="GROUP")
530 synfig::String dest_group((Glib::ustring)(*iter)[model.group_name]);
531 synfig::String src_group(reinterpret_cast<const gchar*>(selection_data.get_data()));
532 //synfig::String src_group(const_cast<gchar*>(selection_data.get_data()));
534 // Avoid putting a group inside of itself
535 if(dest_group.size()>src_group.size() && src_group==String(dest_group,0,src_group.size()))
541 //synfig::info("possible_drop -- data of type \"%s\"",selection_data.get_data_type());
542 //synfig::info("possible_drop -- data of target \"%s\"",gdk_atom_name(selection_data->target));
543 //synfig::info("possible_drop -- selection=\"%s\"",gdk_atom_name(selection_data->selection));
545 //Gtk::TreeModel::Row row(*get_iter(dest));
547 /* if(synfig::String(selection_data.get_data_type())=="LAYER" && (bool)true)
554 LayerGroupTreeStore::drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk::SelectionData& selection_data)
556 if(!get_iter(dest)) return false;
560 Gtk::TreeModel::Row row(*get_iter(dest));
562 //synfig::info("Dropped data of type \"%s\"",selection_data.get_data_type());
563 //synfig::info("Dropped data of target \"%s\"",gdk_atom_name(selection_data->target));
564 //synfig::info("Dropped selection=\"%s\"",gdk_atom_name(selection_data->selection));
565 synfigapp::Action::PassiveGrouper passive_grouper(canvas_interface()->get_instance().get(),_("Regroup"));
567 if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
569 synfig::String dest_group;
571 dest_group=(Glib::ustring)row[model.group_name];
573 if(dest_group.empty())
576 if(synfig::String(selection_data.get_data_type())=="LAYER")
578 synfigapp::Action::Handle action(synfigapp::Action::create("group_add_layers"));
583 action->set_param("canvas",canvas_interface()->get_canvas());
584 action->set_param("canvas_interface",canvas_interface());
585 action->set_param("group",dest_group);
587 for(unsigned int i=0;i<selection_data.get_length()/sizeof(void*);i++)
589 Layer::Handle layer(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
592 action->set_param("layer",layer);
594 if(!canvas_interface()->get_instance()->perform_action(action))
596 passive_grouper.cancel();
601 if(synfig::String(selection_data.get_data_type())=="GROUP")
603 synfig::String src_group(reinterpret_cast<const gchar*>(selection_data.get_data()));
604 synfig::String group(src_group);
606 // Get rid of any parent group crap
607 while(group.find(GROUP_NEST_CHAR)!=Glib::ustring::npos)
608 group=Glib::ustring(group,group.find(GROUP_NEST_CHAR)+1,Glib::ustring::npos);
610 group=dest_group+GROUP_NEST_CHAR+group;
612 synfigapp::Action::Handle action(synfigapp::Action::create("group_rename"));
617 action->set_param("canvas",canvas_interface()->get_canvas());
618 action->set_param("canvas_interface",canvas_interface());
619 action->set_param("group",src_group);
620 action->set_param("new_group",group);
622 if(!canvas_interface()->get_instance()->perform_action(action))
624 passive_grouper.cancel();
630 /* // Save the selection data
631 synfigapp::SelectionManager::LayerList selected_layer_list=canvas_interface()->get_selection_manager()->get_selected_layers();
633 if ((selection_data.get_length() >= 0) && (selection_data.get_format() == 8))
635 Canvas::Handle dest_canvas;
636 Layer::Handle dest_layer;
638 dest_canvas=(Canvas::Handle)(row[model.canvas]);
639 dest_layer=(Layer::Handle)(row[model.layer]);
645 int dest_layer_depth=dest_layer->get_depth();
647 if(synfig::String(selection_data.get_data_type())=="LAYER")for(i=0;i<selection_data.get_length()/sizeof(void*);i++)
649 //synfig::info("dest_layer_depth=%d",dest_layer_depth);
651 Layer::Handle src(reinterpret_cast<Layer**>(const_cast<guint8*>(selection_data.get_data()))[i]);
656 // In this case, we are just moving.
657 // if(dest_canvas==src->get_canvas())
659 if(dest_canvas==src->get_canvas() && dest_layer_depth && dest_layer_depth>src->get_depth())
661 if(dest_canvas==src->get_canvas() && dest_layer_depth==src->get_depth())
664 synfigapp::Action::Handle action(synfigapp::Action::create("layer_move"));
665 action->set_param("canvas",dest_canvas);
666 action->set_param("canvas_interface",canvas_interface());
667 action->set_param("layer",src);
668 action->set_param("new_index",dest_layer_depth);
669 action->set_param("dest_canvas",dest_canvas);
670 if(canvas_interface()->get_instance()->perform_action(action))
676 passive_grouper.cancel();
683 synfig::info("I supposedly moved %d layers",i);
685 // Reselect the previously selected layers
686 canvas_interface()->get_selection_manager()->set_selected_layers(selected_layer_list);
700 LayerGroupTreeStore::rebuild()
703 // etl::clock timer;timer.reset();
706 // Clear out the current list
708 Canvas::Handle canvas(canvas_interface()->get_canvas());
709 std::set<String> groups(canvas->get_groups());
710 for(;groups.size();groups.erase(groups.begin()))
712 String group(*groups.begin());
713 Gtk::TreeRow row(on_group_added(group));
714 std::set<Layer::Handle> layers(canvas->get_layers_in_group(group));
716 for(;layers.size();layers.erase(layers.begin()))
718 Gtk::TreeRow layer_row(*(prepend(row.children())));
719 Layer::Handle layer(*layers.begin());
720 set_row_layer(layer_row,layer);
724 // Go ahead and and add all the layers
726 canvas_interface()->get_canvas()->rbegin(), canvas_interface()->get_canvas()->rend(),
727 sigc::mem_fun(*this, &studio::LayerGroupTreeStore::on_layer_added)
736 // synfig::info("LayerGroupTreeStore::rebuild() took %f seconds",float(timer()));
740 LayerGroupTreeStore::refresh()
746 LayerGroupTreeStore::refresh_row(Gtk::TreeModel::Row &row)
748 if((bool)row[model.is_layer])
750 Layer::Handle layer=row[model.layer];
753 //if(layer->dynamic_param_list().count("z_depth"))
754 // row[model.z_depth]=Time::begin();
757 Gtk::TreeModel::Children children = row.children();
758 Gtk::TreeModel::Children::iterator iter;
760 if(!children.empty())
761 for(iter = children.begin(); iter && iter != children.end(); ++iter)
763 Gtk::TreeRow row=*iter;
770 LayerGroupTreeStore::set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle)
772 row[model.is_layer] = true;
773 row[model.is_group] = false;
774 row[model.layer] = handle;
778 LayerGroupTreeStore::on_group_added(synfig::String group)
780 // Check to see if this group perhaps already
783 Gtk::TreeModel::Children::iterator iter;
784 if(find_group_row(group, iter))
788 if(group.find(GROUP_NEST_CHAR)!=String::npos)
790 Gtk::TreeModel::Children::iterator iter;
794 if(parent_name.size())
795 parent_name+=GROUP_NEST_CHAR;
796 parent_name+=string(group,0,group.find(GROUP_NEST_CHAR));
798 if(!find_group_row(parent_name, iter))
799 iter=on_group_added(parent_name);
801 group=String(group,group.find(GROUP_NEST_CHAR)+1,String::npos);
802 }while(group.find(GROUP_NEST_CHAR)!=String::npos);
804 if(parent_name.size())
805 parent_name+=GROUP_NEST_CHAR;
810 Gtk::TreeRow row(*(prepend(iter->children())));
811 row[model.group_name]=parent_name;
812 row[model.is_layer]=false;
813 row[model.is_group]=true;
819 Gtk::TreeRow row(*(append()));
820 row[model.group_name]=group;
821 row[model.is_layer]=false;
822 row[model.is_group]=true;
828 LayerGroupTreeStore::on_group_removed(synfig::String group)
830 Gtk::TreeModel::Children::iterator iter;
831 if(find_group_row(group,iter) && iter->children().size()==0)
840 LayerGroupTreeStore::on_group_changed(synfig::String /*group*/)
846 LayerGroupTreeStore::on_group_pair_added(synfig::String group, etl::handle<synfig::Layer> layer)
848 if(!layer->get_canvas())
850 Gtk::TreeModel::Children::iterator iter;
851 if(!find_group_row(group, iter))
852 iter=on_group_added(group);
854 Gtk::TreeRow layer_row(*(append(iter->children())));
855 set_row_layer(layer_row,layer);
860 LayerGroupTreeStore::on_group_pair_removed(synfig::String group, etl::handle<synfig::Layer> layer)
862 if(!layer->get_canvas())
864 Gtk::TreeModel::Children::iterator iter;
865 if(!find_group_row(group, iter))
868 Gtk::TreeModel::Children::iterator prev,layer_iter;
870 if(!find_layer_row_(layer, layer->get_canvas(), iter->children(), layer_iter, prev))
879 LayerGroupTreeStore::on_activity()
881 // If we aren't rebuilding and the last action
882 // had something to do with groups, then go
883 // a head and present the groups dialog.
884 if(!rebuilding && canvas_interface()->get_instance()->get_most_recent_action() && canvas_interface()->get_instance()->get_most_recent_action()->get_name().find("group")!=String::npos)
887 App::dock_manager->find_dockable("groups").present();
893 LayerGroupTreeStore::on_layer_status_changed(synfig::Layer::Handle handle,bool /*x*/)
895 Gtk::TreeModel::Children::iterator iter;
896 if(find_layer_row(handle,iter))
897 (*iter)[model.layer]=handle;
900 synfig::warning("Couldn't find layer to be activated in layer list. Rebuilding index...");
907 LayerGroupTreeStore::on_layer_new_description(synfig::Layer::Handle handle,synfig::String desc)
909 Gtk::TreeModel::Children::iterator iter;
910 if(find_layer_row(handle,iter))
912 Gtk::TreeRow row(*iter);
914 Layer::Handle layer(row[model.layer]);
918 //row[model.label]=layer->get_local_name();
919 row[model.tooltip]=Glib::ustring(_("Layer"));
922 //row[model.label]=layer->get_description();
923 row[model.tooltip]=layer->get_local_name();
932 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)
936 //if(layer->get_canvas()==canvas)
938 for(iter=prev=layers.begin(); iter && iter != layers.end(); prev=iter++)
940 Gtk::TreeModel::Row row = *iter;
941 if((bool)row[model.is_layer] && layer==(synfig::Layer::Handle)row[model.layer])
945 iter=children().end();
949 Gtk::TreeModel::Children::iterator iter2;
951 for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
953 Gtk::TreeModel::Row row = *iter2;
956 if(row.children().empty())
959 /*Canvas::Handle canvas((*row.children().begin())[model.canvas]);
964 if(find_layer_row_(layer,canvas,iter2->children(),iter,prev))
968 iter=children().end();
973 LayerGroupTreeStore::find_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &iter)
975 Gtk::TreeModel::Children::iterator prev;
976 return find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev);
980 LayerGroupTreeStore::find_group_row(const synfig::String &group, Gtk::TreeModel::Children::iterator &iter)
982 Gtk::TreeModel::Children::iterator prev;
983 return find_group_row_(group,children(),iter,prev);
987 LayerGroupTreeStore::find_group_row_(const synfig::String &group, Gtk::TreeModel::Children layers, Gtk::TreeModel::Children::iterator &iter, Gtk::TreeModel::Children::iterator &prev)
989 //if(layer->get_canvas()==canvas)
991 for(iter=prev=layers.begin(); iter && iter != layers.end(); prev=iter++)
993 Gtk::TreeModel::Row row = *iter;
994 if((bool)row[model.is_group] && group==(Glib::ustring)row[model.group_name])
998 iter=children().end();
1002 Gtk::TreeModel::Children::iterator iter2;
1004 for(iter2 = layers.begin(); iter2 && iter2 != layers.end(); ++iter2)
1006 Gtk::TreeModel::Row row = *iter2;
1009 if(row.children().empty())
1012 if(find_group_row_(group,iter2->children(),iter,prev))
1016 iter=children().end();
1021 LayerGroupTreeStore::find_prev_layer_row(const synfig::Layer::Handle &layer, Gtk::TreeModel::Children::iterator &prev)
1023 Gtk::TreeModel::Children::iterator iter;
1024 if(!find_layer_row_(layer,canvas_interface()->get_canvas(),children(),iter,prev))
1026 if(iter==children().begin())