/* get IPIcon from file icon */ OSErr GetFileIPIcon(const FSSpec *theFile,IPIconRec *ipIcon,Boolean isFolder,Boolean *is32Exist,short *alertMode) { #if TARGET_API_MAC_CARBON #pragma unused(isFolder) #endif OSErr err=noErr; if (isFolder) err=FolderIconCheck(theFile,alertMode); else err=FileIconCheck(theFile,alertMode); #if !TARGET_API_MAC_CARBON if (isIconServicesAvailable) #endif { /* use IconServices when runinng on 8.5 or later */ IconRef iconRef; short label; IconFamilyHandle iconFamily; err=GetIconRefFromFile(theFile,&iconRef,&label); if (err!=noErr) return err; //err=IconRefToIconFamily(iconRef,GetMySelector(),&iconFamily); err=IconRefToIconFamily(iconRef,kSelectorAllAvailableData,&iconFamily); // 1.20b14 ReleaseIconRef(iconRef); if (err!=noErr) return err; err=IconFamilyToIPIcon(iconFamily,ipIcon); DisposeHandle((Handle)iconFamily); if (err==noErr) err=IPIconHas32Icons(ipIcon,is32Exist); return err; } #if !TARGET_API_MAC_CARBON else { /* use Find_icon when running on older than 8.5 */ err=Find_icon(theFile,NULL,kSelectorMyData,&ipIcon->iconSuite); ipIcon->it32Data=NULL; ipIcon->t8mkData=NULL; return err; } #endif }
static PyObject *Icn_GetIconRefFromFile(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; OSErr _err; FSSpec theFile; IconRef theIconRef; SInt16 theLabel; #ifndef GetIconRefFromFile PyMac_PRECHECK(GetIconRefFromFile); #endif if (!PyArg_ParseTuple(_args, "O&", PyMac_GetFSSpec, &theFile)) return NULL; _err = GetIconRefFromFile(&theFile, &theIconRef, &theLabel); if (_err != noErr) return PyMac_Error(_err); _res = Py_BuildValue("O&h", ResObj_New, theIconRef, theLabel); return _res; }
static void ccdrawfrontiericon (Rect rcicn, boolean flpressed) { // // 2006-07-12 creedon: FSRef-ized // // 7.0b53 PBS: draw an OS X style icon // #ifdef MACVERSION IconRef iconref; tyfilespec programfspec; short label; OSErr err; Rect r = rcicn; FSSpec fs; getapplicationfilespec (nil, &programfspec); err = macgetfsspec (&programfspec, &fs); if (GetIconRefFromFile (&fs, &iconref, &label) == noErr) { err = PlotIconRef (&r, kAlignAbsoluteCenter, flpressed? kTransformSelected : 0, kIconServicesNormalUsageFlag, iconref); ReleaseIconRef (iconref); if (err == noErr) return; } // if #endif // MACVERSION ploticonresource ( &rcicn, kAlignAbsoluteCenter, flpressed ? kTransformSelected : 0, idfrontiericon ); } // ccdrawfrontiericon