diff --git a/src/layer-manager.cpp b/src/layer-manager.cpp
index 3e49edac5723299ab5699850b14ab31fe6c478c1..95cefc229f44351203035c37a2136e61a7bf4d39 100644 (file)
--- a/src/layer-manager.cpp
+++ b/src/layer-manager.cpp
* to a particular desktop
*
* Copyright 2006 MenTaLguY <mental@rydia.net>
+ * Abhishek Sharma
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
_layer_connection.disconnect();
_document_connection.disconnect();
_resource_connection.disconnect();
+ _document = 0;
}
void LayerManager::setCurrentLayer( SPObject* obj )
}
}
-void LayerManager::renameLayer( SPObject* obj, gchar const *label )
+void LayerManager::renameLayer( SPObject* obj, gchar const *label, bool uniquify )
{
Glib::ustring incoming( label ? label : "" );
Glib::ustring result(incoming);
Glib::ustring base(incoming);
guint startNum = 1;
- Glib::ustring::size_type pos = base.rfind('#');
- if ( pos != Glib::ustring::npos ) {
- gchar* numpart = g_strdup(base.substr(pos+1).c_str());
- if ( numpart ) {
- gchar* endPtr = 0;
- guint64 val = g_ascii_strtoull( numpart, &endPtr, 10);
- if ( ((val > 0) || (endPtr != numpart)) && (val < 65536) ) {
- base.erase( pos );
- result = base;
- startNum = static_cast<int>(val);
+ if (uniquify) {
+
+ Glib::ustring::size_type pos = base.rfind('#');
+ if ( pos != Glib::ustring::npos ) {
+ gchar* numpart = g_strdup(base.substr(pos+1).c_str());
+ if ( numpart ) {
+ gchar* endPtr = 0;
+ guint64 val = g_ascii_strtoull( numpart, &endPtr, 10);
+ if ( ((val > 0) || (endPtr != numpart)) && (val < 65536) ) {
+ base.erase( pos );
+ result = base;
+ startNum = static_cast<int>(val);
+ }
+ g_free(numpart);
}
- g_free(numpart);
}
- }
- std::set<Glib::ustring> currentNames;
- GSList const *layers=sp_document_get_resource_list(_document, "layer");
- SPObject *root=_desktop->currentRoot();
- if ( root ) {
- for ( GSList const *iter=layers ; iter ; iter = iter->next ) {
- SPObject *layer=static_cast<SPObject *>(iter->data);
- if ( layer != obj ) {
- currentNames.insert( layer->label() ? Glib::ustring(layer->label()) : Glib::ustring() );
+ std::set<Glib::ustring> currentNames;
+ GSList const *layers=_document->getResourceList("layer");
+ SPObject *root=_desktop->currentRoot();
+ if ( root ) {
+ for ( GSList const *iter=layers ; iter ; iter = iter->next ) {
+ SPObject *layer=static_cast<SPObject *>(iter->data);
+ if ( layer != obj ) {
+ currentNames.insert( layer->label() ? Glib::ustring(layer->label()) : Glib::ustring() );
+ }
}
}
- }
- // Not sure if we need to cap it, but we'll just be paranoid for the moment
- // Intentionally unsigned
- guint endNum = startNum + 3000;
- for ( guint i = startNum; (i < endNum) && (currentNames.find(result) != currentNames.end()); i++ ) {
- gchar* suffix = g_strdup_printf("#%d", i);
- result = base;
- result += suffix;
+ // Not sure if we need to cap it, but we'll just be paranoid for the moment
+ // Intentionally unsigned
+ guint endNum = startNum + 3000;
+ for ( guint i = startNum; (i < endNum) && (currentNames.find(result) != currentNames.end()); i++ ) {
+ gchar* suffix = g_strdup_printf("#%d", i);
+ result = base;
+ result += suffix;
+
+ g_free(suffix);
+ }
- g_free(suffix);
}
obj->setLabel( result.c_str() );
}
_document = document;
if (document) {
- _resource_connection = sp_document_resources_changed_connect(document, "layer", sigc::mem_fun(*this, &LayerManager::_rebuild));
+ _resource_connection = document->connectResourcesChanged("layer", sigc::mem_fun(*this, &LayerManager::_rebuild));
}
_rebuild();
}
if (!_document) // http://sourceforge.net/mailarchive/forum.php?thread_name=5747bce9a7ed077c1b4fc9f0f4f8a5e0%40localhost&forum_name=inkscape-devel
return;
- GSList const *layers = sp_document_get_resource_list(_document, "layer");
+ GSList const *layers = _document->getResourceList("layer");
SPObject *root=_desktop->currentRoot();
if ( root ) {
_addOne(root);
if ( group->layerMode() == SPGroup::LAYER ) {
// If we have a layer-group as the one or a parent, ensure it is listed as a valid layer.
needsAdd &= ( g_slist_find(const_cast<GSList *>(layers), curr) != NULL );
- if ( (!(group->repr)) || (!(group->repr->parent())) ) {
+ // XML Tree being used here directly while it shouldn't be...
+ if ( (!(group->getRepr())) || (!(group->getRepr()->parent())) ) {
needsAdd = false;
}
} else {
// If a non-layer group is a parent of layer groups, then show it also as a layer.
// TODO add the magic Inkscape group mode?
- if ( group->repr && group->repr->parent() ) {
+ // XML Tree being used directly while it shouldn't be...
+ if ( group->getRepr() && group->getRepr()->parent() ) {
additional.insert(group);
} else {
needsAdd = false;
LayerWatcher *eye = new LayerWatcher(this, layer, connection);
_watchers.push_back( eye );
SP_OBJECT_REPR(layer)->addObserver(*eye);
-
+
_addOne(layer);
}
}
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :