X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fprofile-manager.cpp;h=27ab7549715bad75a6ab20dc650503c2c375ce6b;hb=42382dfb4164b919ffcdf03766da9f8be4e43b42;hp=c2d3446296ed450f20e41e2526a15fa262922766;hpb=98bca1e5a1676e6bd459a85f0d54349d4a5df5ce;p=inkscape.git diff --git a/src/profile-manager.cpp b/src/profile-manager.cpp index c2d344629..27ab75497 100644 --- a/src/profile-manager.cpp +++ b/src/profile-manager.cpp @@ -2,6 +2,7 @@ * Inkscape::ProfileManager - a view of a document's color profiles. * * Copyright 2007 Jon A. Cruz + * Abhishek Sharma * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -10,6 +11,7 @@ #include "profile-manager.h" #include "document.h" +#include "color-profile.h" namespace Inkscape { @@ -17,20 +19,24 @@ ProfileManager::ProfileManager(SPDocument *document) : _doc(document), _knownProfiles() { - _resource_connection = sp_document_resources_changed_connect( _doc, "iccprofile", sigc::mem_fun(*this, &ProfileManager::_resourcesChanged) ); + _resource_connection = _doc->connectResourcesChanged( "iccprofile", sigc::mem_fun(*this, &ProfileManager::_resourcesChanged) ); } ProfileManager::~ProfileManager() { + _resource_connection.disconnect(); + _doc = 0; } void ProfileManager::_resourcesChanged() { std::vector newList; - const GSList *current = sp_document_get_resource_list( _doc, "iccprofile" ); - while ( current ) { - newList.push_back(SP_OBJECT(current->data)); - current = g_slist_next(current); + if (_doc) { + const GSList *current = _doc->getResourceList( "iccprofile" ); + while ( current ) { + newList.push_back(SP_OBJECT(current->data)); + current = g_slist_next(current); + } } sort( newList.begin(), newList.end() ); @@ -62,6 +68,22 @@ void ProfileManager::_resourcesChanged() } } +ColorProfile* ProfileManager::find(gchar const* name) +{ + ColorProfile* match = 0; + if ( name ) { + unsigned int howMany = childCount(NULL); + for ( unsigned int index = 0; index < howMany; index++ ) { + SPObject *obj = nthChildOf(NULL, index); + ColorProfile* prof = reinterpret_cast(obj); + if ( prof && prof->name && !strcmp(name, prof->name) ) { + match = prof; + break; + } + } + } + return match; +} } @@ -75,4 +97,4 @@ void ProfileManager::_resourcesChanged() 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 :