Code

recent files: show tooltips with uri, hide local files which are missing or unaccessible
[inkscape.git] / src / profile-manager.cpp
index c2d3446296ed450f20e41e2526a15fa262922766..1cd965e390b526d89318918dd7569dfdaec4a049 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "profile-manager.h"
 #include "document.h"
+#include "color-profile.h"
 
 namespace Inkscape {
 
@@ -27,10 +28,12 @@ ProfileManager::~ProfileManager()
 void ProfileManager::_resourcesChanged()
 {
     std::vector<SPObject*> 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 = sp_document_get_resource_list( _doc, "iccprofile" );
+        while ( current ) {
+            newList.push_back(SP_OBJECT(current->data));
+            current = g_slist_next(current);
+        }
     }
     sort( newList.begin(), newList.end() );
 
@@ -62,6 +65,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<ColorProfile*>(obj);
+            if ( prof && prof->name && !strcmp(name, prof->name) ) {
+                match = prof;
+                break;
+            }
+        }
+    }
+    return match;
+}
 
 }