X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Flayertreestore.cpp;h=3a446c9c040c5a89d75caa779d61751cba1b5f7f;hb=ac0dc220b589ebb2249074e4ed1d616b9879d7cf;hp=cb8440dd0ea901c02c60b63c230d49181618ed95;hpb=63e709f66d50c124cc0ece2325f4773ac4ae7b20;p=synfig.git diff --git a/synfig-studio/trunk/src/gtkmm/layertreestore.cpp b/synfig-studio/trunk/src/gtkmm/layertreestore.cpp index cb8440d..3a446c9 100644 --- a/synfig-studio/trunk/src/gtkmm/layertreestore.cpp +++ b/synfig-studio/trunk/src/gtkmm/layertreestore.cpp @@ -6,6 +6,7 @@ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley +** Copyright (c) 2008 Chris Moore ** ** This package is free software; you can redistribute it and/or ** modify it under the terms of the GNU General Public License as @@ -37,6 +38,7 @@ #include #include "app.h" #include "instance.h" +#include #include #include @@ -69,6 +71,7 @@ static LayerTreeStore::Model& ModelHack() LayerTreeStore::LayerTreeStore(etl::loose_handle canvas_interface_): Gtk::TreeStore (ModelHack()), + queued (false), canvas_interface_ (canvas_interface_) { layer_icon=Gtk::Button().render_icon(Gtk::StockID("synfig-layer"),Gtk::ICON_SIZE_SMALL_TOOLBAR); @@ -97,7 +100,8 @@ LayerTreeStore::LayerTreeStore(etl::loose_handle can LayerTreeStore::~LayerTreeStore() { - synfig::info("LayerTreeStore::~LayerTreeStore(): Deleted"); + if (getenv("SYNFIG_DEBUG_DESTRUCTORS")) + synfig::info("LayerTreeStore::~LayerTreeStore(): Deleted"); } int @@ -347,7 +351,7 @@ LayerTreeStore::set_value_impl(const Gtk::TreeModel::iterator& iter, int column, } catch(std::exception x) { - g_warning(x.what()); + g_warning("%s", x.what()); } } @@ -584,8 +588,30 @@ LayerTreeStore::drag_data_received_vfunc (const TreeModel::Path& dest, const Gtk } void +LayerTreeStore::queue_rebuild() +{ + if (queued) return; + queued = false; + queue_connection.disconnect(); + queue_connection=Glib::signal_timeout().connect( + sigc::bind_return( + sigc::mem_fun(*this,&LayerTreeStore::rebuild), + false + ) + ,150); +} + +void LayerTreeStore::rebuild() { + if (queued) queued = false; + + // disconnect any subcanvas_changed connections + std::map::iterator iter; + for (iter = subcanvas_changed_connections.begin(); iter != subcanvas_changed_connections.end(); iter++) + iter->second.disconnect(); + subcanvas_changed_connections.clear(); + //etl::clock timer;timer.reset(); //synfig::warning("---------rebuilding layer table---------"); @@ -595,7 +621,7 @@ LayerTreeStore::rebuild() // Clear out the current list clear(); - // Go ahead and and add all the layers + // Go ahead and add all the layers std::for_each( canvas_interface()->get_canvas()->rbegin(), canvas_interface()->get_canvas()->rend(), sigc::mem_fun(*this, &studio::LayerTreeStore::on_layer_added) @@ -734,6 +760,12 @@ LayerTreeStore::set_row_layer(Gtk::TreeRow &row,synfig::Layer::Handle &handle) void LayerTreeStore::on_layer_added(synfig::Layer::Handle layer) { + if (etl::handle::cast_dynamic(layer)) + subcanvas_changed_connections[layer] = + (etl::handle::cast_dynamic(layer))->signal_subcanvas_changed().connect( + sigc::mem_fun(*this,&studio::LayerTreeStore::queue_rebuild) + ); + assert(layer); Gtk::TreeRow row; if(canvas_interface()->get_canvas()==layer->get_canvas()) @@ -756,6 +788,11 @@ LayerTreeStore::on_layer_added(synfig::Layer::Handle layer) void LayerTreeStore::on_layer_removed(synfig::Layer::Handle handle) { + if (etl::handle::cast_dynamic(handle)) + { + subcanvas_changed_connections[handle].disconnect(); + subcanvas_changed_connections.erase(handle); + } Gtk::TreeModel::Children::iterator iter; if(find_layer_row(handle,iter)) erase(iter);