Ejemplo n.º 1
0
extern pascal OSStatus GetDetachedIconSuite(IconSuiteRef *theIconSuite, SInt16 theResID, IconSelectorValue selector)
	// See comment in interface part.
{
	long oldA4;
	OSStatus err;
	THz oldZone;
	
	oldA4 = SetUpA4();
	
	assert(theIconSuite != NULL);
	
	oldZone = SetSystemZone();

	// The algorithm here is perfectly simple.  First get the icon suite,
	// then iterate over its contents detaching each handle.  I looked
	// at the Icon Services code and this seems like a perfectly reasonable
	// strategy.  It also disassembled SBGetDetachIconSuite and it works
	// in the same way.
	
	err = GetIconSuite(theIconSuite, theResID, selector);
	if (err == noErr) {
		(void) ForEachIconDo(*theIconSuite, kSelectorAllAvailableData, gDetachIconActionUPP, NULL);
	}
	
	SetZone(oldZone);
	
	(void) SetA4(oldA4);
	
	return err;
}
Ejemplo n.º 2
0
static PyObject *Icn_GetIconSuite(PyObject *_self, PyObject *_args)
{
	PyObject *_res = NULL;
	OSErr _err;
	IconSuiteRef theIconSuite;
	SInt16 theResID;
	IconSelectorValue selector;
#ifndef GetIconSuite
	PyMac_PRECHECK(GetIconSuite);
#endif
	if (!PyArg_ParseTuple(_args, "hl",
	                      &theResID,
	                      &selector))
		return NULL;
	_err = GetIconSuite(&theIconSuite,
	                    theResID,
	                    selector);
	if (_err != noErr) return PyMac_Error(_err);
	_res = Py_BuildValue("O&",
	                     ResObj_New, theIconSuite);
	return _res;
}