Agreed that making a finder DYNAMICALLY give a custom icon to a file or folder is no Rocket Science but i am unable to make out the mistake that is causing it not to work properly. I may be missing something really small. Can any one please help me?.
I have a contextual menu plugin (XYZ.plugin) located at "/Library/Contextual Menu Items/". This is invoked when the user right-clicks on a file/folder. There are custom items in the contextual menu. Depending on the selection i need to provide a custom icon to the file/folder.
In the Plugin Code i do something like this: I have a file abc.txt to which I need to give a custom icon. Now I get the IconRef of the file abc.txt and get the IconRef of the "bsd.icns" [Icon file] file and form a composite IconRef and apply this composite IconRef to abc.txt file.
In my plugin i am forcing the finder to call my overrided function -
SCFinderIconOverlayGetIconRefFromFileInfo when it makes a call to "GetIconRefFromFileInfo" by using
//even using the finderInfo.fdtype & finderInfo.fdCreator is not useful. newErr = RegisterIconRefFromFSRef(kUnknownType,kUnknownType,&fsRef,&foregroundIconRef);
//the composite of the foreground and the background icons. newErr = CompositeIconRef(backgroundIconRef, foregroundIconRef, &compositeIconRef);
*outIconRef = compositeIconRef; //send the composite as the icon to be displayed for the abc.txt file
//decrement the reference count of back & foreground Icons. //cleanup
return noErr; }
On testing, to my astonishment, all the files with file extension ".txt" on ANY VOLUME have a composite Icon while only abc.txt should have the composite and the rest of the .txt files should have their original icon. What's wrong? Pls note that in the SCFinderIconOverlayGetIconRefFromFileInfo function of the plugin, i return the original icon if the file is not abc.txt.
When i log the results, for all other files other than abc.txt the SCFinderIconOverlayGetIconRefFromFileInfo returns the default icon and composite icon for abc.txt correctly.But the finder display shows otherwise.
Also when i edit other files other than abc.txt they loose their composite Icon, when the original file abc.txt is edited, all of them get back the composite Icon.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden
This email sent to email@hidden