1
2 /* ========================== Module _Icn =========================== */
3
4 #include "Python.h"
5 #include "pymactoolbox.h"
6
7
8 #if APPLE_SUPPORTS_QUICKTIME
9
10
11 /* Macro to test whether a weak-loaded CFM function exists */
12 #define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
13 PyErr_SetString(PyExc_NotImplementedError, \
14 "Not available in this shared library/OS version"); \
15 return NULL; \
16 }} while(0)
17
18
19 #include <Carbon/Carbon.h>
20
21
22 static PyObject *Icn_Error;
23
Icn_GetCIcon(PyObject * _self,PyObject * _args)24 static PyObject *Icn_GetCIcon(PyObject *_self, PyObject *_args)
25 {
26 PyObject *_res = NULL;
27 CIconHandle _rv;
28 SInt16 iconID;
29 #ifndef GetCIcon
30 PyMac_PRECHECK(GetCIcon);
31 #endif
32 if (!PyArg_ParseTuple(_args, "h",
33 &iconID))
34 return NULL;
35 _rv = GetCIcon(iconID);
36 _res = Py_BuildValue("O&",
37 ResObj_New, _rv);
38 return _res;
39 }
40
Icn_PlotCIcon(PyObject * _self,PyObject * _args)41 static PyObject *Icn_PlotCIcon(PyObject *_self, PyObject *_args)
42 {
43 PyObject *_res = NULL;
44 Rect theRect;
45 CIconHandle theIcon;
46 #ifndef PlotCIcon
47 PyMac_PRECHECK(PlotCIcon);
48 #endif
49 if (!PyArg_ParseTuple(_args, "O&O&",
50 PyMac_GetRect, &theRect,
51 ResObj_Convert, &theIcon))
52 return NULL;
53 PlotCIcon(&theRect,
54 theIcon);
55 Py_INCREF(Py_None);
56 _res = Py_None;
57 return _res;
58 }
59
Icn_DisposeCIcon(PyObject * _self,PyObject * _args)60 static PyObject *Icn_DisposeCIcon(PyObject *_self, PyObject *_args)
61 {
62 PyObject *_res = NULL;
63 CIconHandle theIcon;
64 #ifndef DisposeCIcon
65 PyMac_PRECHECK(DisposeCIcon);
66 #endif
67 if (!PyArg_ParseTuple(_args, "O&",
68 ResObj_Convert, &theIcon))
69 return NULL;
70 DisposeCIcon(theIcon);
71 Py_INCREF(Py_None);
72 _res = Py_None;
73 return _res;
74 }
75
Icn_GetIcon(PyObject * _self,PyObject * _args)76 static PyObject *Icn_GetIcon(PyObject *_self, PyObject *_args)
77 {
78 PyObject *_res = NULL;
79 Handle _rv;
80 SInt16 iconID;
81 #ifndef GetIcon
82 PyMac_PRECHECK(GetIcon);
83 #endif
84 if (!PyArg_ParseTuple(_args, "h",
85 &iconID))
86 return NULL;
87 _rv = GetIcon(iconID);
88 _res = Py_BuildValue("O&",
89 ResObj_New, _rv);
90 return _res;
91 }
92
Icn_PlotIcon(PyObject * _self,PyObject * _args)93 static PyObject *Icn_PlotIcon(PyObject *_self, PyObject *_args)
94 {
95 PyObject *_res = NULL;
96 Rect theRect;
97 Handle theIcon;
98 #ifndef PlotIcon
99 PyMac_PRECHECK(PlotIcon);
100 #endif
101 if (!PyArg_ParseTuple(_args, "O&O&",
102 PyMac_GetRect, &theRect,
103 ResObj_Convert, &theIcon))
104 return NULL;
105 PlotIcon(&theRect,
106 theIcon);
107 Py_INCREF(Py_None);
108 _res = Py_None;
109 return _res;
110 }
111
Icn_PlotIconID(PyObject * _self,PyObject * _args)112 static PyObject *Icn_PlotIconID(PyObject *_self, PyObject *_args)
113 {
114 PyObject *_res = NULL;
115 OSErr _err;
116 Rect theRect;
117 IconAlignmentType align;
118 IconTransformType transform;
119 SInt16 theResID;
120 #ifndef PlotIconID
121 PyMac_PRECHECK(PlotIconID);
122 #endif
123 if (!PyArg_ParseTuple(_args, "O&hhh",
124 PyMac_GetRect, &theRect,
125 &align,
126 &transform,
127 &theResID))
128 return NULL;
129 _err = PlotIconID(&theRect,
130 align,
131 transform,
132 theResID);
133 if (_err != noErr) return PyMac_Error(_err);
134 Py_INCREF(Py_None);
135 _res = Py_None;
136 return _res;
137 }
138
Icn_NewIconSuite(PyObject * _self,PyObject * _args)139 static PyObject *Icn_NewIconSuite(PyObject *_self, PyObject *_args)
140 {
141 PyObject *_res = NULL;
142 OSErr _err;
143 IconSuiteRef theIconSuite;
144 #ifndef NewIconSuite
145 PyMac_PRECHECK(NewIconSuite);
146 #endif
147 if (!PyArg_ParseTuple(_args, ""))
148 return NULL;
149 _err = NewIconSuite(&theIconSuite);
150 if (_err != noErr) return PyMac_Error(_err);
151 _res = Py_BuildValue("O&",
152 ResObj_New, theIconSuite);
153 return _res;
154 }
155
Icn_AddIconToSuite(PyObject * _self,PyObject * _args)156 static PyObject *Icn_AddIconToSuite(PyObject *_self, PyObject *_args)
157 {
158 PyObject *_res = NULL;
159 OSErr _err;
160 Handle theIconData;
161 IconSuiteRef theSuite;
162 ResType theType;
163 #ifndef AddIconToSuite
164 PyMac_PRECHECK(AddIconToSuite);
165 #endif
166 if (!PyArg_ParseTuple(_args, "O&O&O&",
167 ResObj_Convert, &theIconData,
168 ResObj_Convert, &theSuite,
169 PyMac_GetOSType, &theType))
170 return NULL;
171 _err = AddIconToSuite(theIconData,
172 theSuite,
173 theType);
174 if (_err != noErr) return PyMac_Error(_err);
175 Py_INCREF(Py_None);
176 _res = Py_None;
177 return _res;
178 }
179
Icn_GetIconFromSuite(PyObject * _self,PyObject * _args)180 static PyObject *Icn_GetIconFromSuite(PyObject *_self, PyObject *_args)
181 {
182 PyObject *_res = NULL;
183 OSErr _err;
184 Handle theIconData;
185 IconSuiteRef theSuite;
186 ResType theType;
187 #ifndef GetIconFromSuite
188 PyMac_PRECHECK(GetIconFromSuite);
189 #endif
190 if (!PyArg_ParseTuple(_args, "O&O&",
191 ResObj_Convert, &theSuite,
192 PyMac_GetOSType, &theType))
193 return NULL;
194 _err = GetIconFromSuite(&theIconData,
195 theSuite,
196 theType);
197 if (_err != noErr) return PyMac_Error(_err);
198 _res = Py_BuildValue("O&",
199 ResObj_New, theIconData);
200 return _res;
201 }
202
Icn_GetIconSuite(PyObject * _self,PyObject * _args)203 static PyObject *Icn_GetIconSuite(PyObject *_self, PyObject *_args)
204 {
205 PyObject *_res = NULL;
206 OSErr _err;
207 IconSuiteRef theIconSuite;
208 SInt16 theResID;
209 IconSelectorValue selector;
210 #ifndef GetIconSuite
211 PyMac_PRECHECK(GetIconSuite);
212 #endif
213 if (!PyArg_ParseTuple(_args, "hl",
214 &theResID,
215 &selector))
216 return NULL;
217 _err = GetIconSuite(&theIconSuite,
218 theResID,
219 selector);
220 if (_err != noErr) return PyMac_Error(_err);
221 _res = Py_BuildValue("O&",
222 ResObj_New, theIconSuite);
223 return _res;
224 }
225
Icn_DisposeIconSuite(PyObject * _self,PyObject * _args)226 static PyObject *Icn_DisposeIconSuite(PyObject *_self, PyObject *_args)
227 {
228 PyObject *_res = NULL;
229 OSErr _err;
230 IconSuiteRef theIconSuite;
231 Boolean disposeData;
232 #ifndef DisposeIconSuite
233 PyMac_PRECHECK(DisposeIconSuite);
234 #endif
235 if (!PyArg_ParseTuple(_args, "O&b",
236 ResObj_Convert, &theIconSuite,
237 &disposeData))
238 return NULL;
239 _err = DisposeIconSuite(theIconSuite,
240 disposeData);
241 if (_err != noErr) return PyMac_Error(_err);
242 Py_INCREF(Py_None);
243 _res = Py_None;
244 return _res;
245 }
246
Icn_PlotIconSuite(PyObject * _self,PyObject * _args)247 static PyObject *Icn_PlotIconSuite(PyObject *_self, PyObject *_args)
248 {
249 PyObject *_res = NULL;
250 OSErr _err;
251 Rect theRect;
252 IconAlignmentType align;
253 IconTransformType transform;
254 IconSuiteRef theIconSuite;
255 #ifndef PlotIconSuite
256 PyMac_PRECHECK(PlotIconSuite);
257 #endif
258 if (!PyArg_ParseTuple(_args, "O&hhO&",
259 PyMac_GetRect, &theRect,
260 &align,
261 &transform,
262 ResObj_Convert, &theIconSuite))
263 return NULL;
264 _err = PlotIconSuite(&theRect,
265 align,
266 transform,
267 theIconSuite);
268 if (_err != noErr) return PyMac_Error(_err);
269 Py_INCREF(Py_None);
270 _res = Py_None;
271 return _res;
272 }
273
Icn_LoadIconCache(PyObject * _self,PyObject * _args)274 static PyObject *Icn_LoadIconCache(PyObject *_self, PyObject *_args)
275 {
276 PyObject *_res = NULL;
277 OSErr _err;
278 Rect theRect;
279 IconAlignmentType align;
280 IconTransformType transform;
281 IconCacheRef theIconCache;
282 #ifndef LoadIconCache
283 PyMac_PRECHECK(LoadIconCache);
284 #endif
285 if (!PyArg_ParseTuple(_args, "O&hhO&",
286 PyMac_GetRect, &theRect,
287 &align,
288 &transform,
289 ResObj_Convert, &theIconCache))
290 return NULL;
291 _err = LoadIconCache(&theRect,
292 align,
293 transform,
294 theIconCache);
295 if (_err != noErr) return PyMac_Error(_err);
296 Py_INCREF(Py_None);
297 _res = Py_None;
298 return _res;
299 }
300
Icn_GetLabel(PyObject * _self,PyObject * _args)301 static PyObject *Icn_GetLabel(PyObject *_self, PyObject *_args)
302 {
303 PyObject *_res = NULL;
304 OSErr _err;
305 SInt16 labelNumber;
306 RGBColor labelColor;
307 Str255 labelString;
308 #ifndef GetLabel
309 PyMac_PRECHECK(GetLabel);
310 #endif
311 if (!PyArg_ParseTuple(_args, "hO&",
312 &labelNumber,
313 PyMac_GetStr255, labelString))
314 return NULL;
315 _err = GetLabel(labelNumber,
316 &labelColor,
317 labelString);
318 if (_err != noErr) return PyMac_Error(_err);
319 _res = Py_BuildValue("O&",
320 QdRGB_New, &labelColor);
321 return _res;
322 }
323
Icn_PtInIconID(PyObject * _self,PyObject * _args)324 static PyObject *Icn_PtInIconID(PyObject *_self, PyObject *_args)
325 {
326 PyObject *_res = NULL;
327 Boolean _rv;
328 Point testPt;
329 Rect iconRect;
330 IconAlignmentType align;
331 SInt16 iconID;
332 #ifndef PtInIconID
333 PyMac_PRECHECK(PtInIconID);
334 #endif
335 if (!PyArg_ParseTuple(_args, "O&O&hh",
336 PyMac_GetPoint, &testPt,
337 PyMac_GetRect, &iconRect,
338 &align,
339 &iconID))
340 return NULL;
341 _rv = PtInIconID(testPt,
342 &iconRect,
343 align,
344 iconID);
345 _res = Py_BuildValue("b",
346 _rv);
347 return _res;
348 }
349
Icn_PtInIconSuite(PyObject * _self,PyObject * _args)350 static PyObject *Icn_PtInIconSuite(PyObject *_self, PyObject *_args)
351 {
352 PyObject *_res = NULL;
353 Boolean _rv;
354 Point testPt;
355 Rect iconRect;
356 IconAlignmentType align;
357 IconSuiteRef theIconSuite;
358 #ifndef PtInIconSuite
359 PyMac_PRECHECK(PtInIconSuite);
360 #endif
361 if (!PyArg_ParseTuple(_args, "O&O&hO&",
362 PyMac_GetPoint, &testPt,
363 PyMac_GetRect, &iconRect,
364 &align,
365 ResObj_Convert, &theIconSuite))
366 return NULL;
367 _rv = PtInIconSuite(testPt,
368 &iconRect,
369 align,
370 theIconSuite);
371 _res = Py_BuildValue("b",
372 _rv);
373 return _res;
374 }
375
Icn_RectInIconID(PyObject * _self,PyObject * _args)376 static PyObject *Icn_RectInIconID(PyObject *_self, PyObject *_args)
377 {
378 PyObject *_res = NULL;
379 Boolean _rv;
380 Rect testRect;
381 Rect iconRect;
382 IconAlignmentType align;
383 SInt16 iconID;
384 #ifndef RectInIconID
385 PyMac_PRECHECK(RectInIconID);
386 #endif
387 if (!PyArg_ParseTuple(_args, "O&O&hh",
388 PyMac_GetRect, &testRect,
389 PyMac_GetRect, &iconRect,
390 &align,
391 &iconID))
392 return NULL;
393 _rv = RectInIconID(&testRect,
394 &iconRect,
395 align,
396 iconID);
397 _res = Py_BuildValue("b",
398 _rv);
399 return _res;
400 }
401
Icn_RectInIconSuite(PyObject * _self,PyObject * _args)402 static PyObject *Icn_RectInIconSuite(PyObject *_self, PyObject *_args)
403 {
404 PyObject *_res = NULL;
405 Boolean _rv;
406 Rect testRect;
407 Rect iconRect;
408 IconAlignmentType align;
409 IconSuiteRef theIconSuite;
410 #ifndef RectInIconSuite
411 PyMac_PRECHECK(RectInIconSuite);
412 #endif
413 if (!PyArg_ParseTuple(_args, "O&O&hO&",
414 PyMac_GetRect, &testRect,
415 PyMac_GetRect, &iconRect,
416 &align,
417 ResObj_Convert, &theIconSuite))
418 return NULL;
419 _rv = RectInIconSuite(&testRect,
420 &iconRect,
421 align,
422 theIconSuite);
423 _res = Py_BuildValue("b",
424 _rv);
425 return _res;
426 }
427
Icn_IconIDToRgn(PyObject * _self,PyObject * _args)428 static PyObject *Icn_IconIDToRgn(PyObject *_self, PyObject *_args)
429 {
430 PyObject *_res = NULL;
431 OSErr _err;
432 RgnHandle theRgn;
433 Rect iconRect;
434 IconAlignmentType align;
435 SInt16 iconID;
436 #ifndef IconIDToRgn
437 PyMac_PRECHECK(IconIDToRgn);
438 #endif
439 if (!PyArg_ParseTuple(_args, "O&O&hh",
440 ResObj_Convert, &theRgn,
441 PyMac_GetRect, &iconRect,
442 &align,
443 &iconID))
444 return NULL;
445 _err = IconIDToRgn(theRgn,
446 &iconRect,
447 align,
448 iconID);
449 if (_err != noErr) return PyMac_Error(_err);
450 Py_INCREF(Py_None);
451 _res = Py_None;
452 return _res;
453 }
454
Icn_IconSuiteToRgn(PyObject * _self,PyObject * _args)455 static PyObject *Icn_IconSuiteToRgn(PyObject *_self, PyObject *_args)
456 {
457 PyObject *_res = NULL;
458 OSErr _err;
459 RgnHandle theRgn;
460 Rect iconRect;
461 IconAlignmentType align;
462 IconSuiteRef theIconSuite;
463 #ifndef IconSuiteToRgn
464 PyMac_PRECHECK(IconSuiteToRgn);
465 #endif
466 if (!PyArg_ParseTuple(_args, "O&O&hO&",
467 ResObj_Convert, &theRgn,
468 PyMac_GetRect, &iconRect,
469 &align,
470 ResObj_Convert, &theIconSuite))
471 return NULL;
472 _err = IconSuiteToRgn(theRgn,
473 &iconRect,
474 align,
475 theIconSuite);
476 if (_err != noErr) return PyMac_Error(_err);
477 Py_INCREF(Py_None);
478 _res = Py_None;
479 return _res;
480 }
481
Icn_SetSuiteLabel(PyObject * _self,PyObject * _args)482 static PyObject *Icn_SetSuiteLabel(PyObject *_self, PyObject *_args)
483 {
484 PyObject *_res = NULL;
485 OSErr _err;
486 IconSuiteRef theSuite;
487 SInt16 theLabel;
488 #ifndef SetSuiteLabel
489 PyMac_PRECHECK(SetSuiteLabel);
490 #endif
491 if (!PyArg_ParseTuple(_args, "O&h",
492 ResObj_Convert, &theSuite,
493 &theLabel))
494 return NULL;
495 _err = SetSuiteLabel(theSuite,
496 theLabel);
497 if (_err != noErr) return PyMac_Error(_err);
498 Py_INCREF(Py_None);
499 _res = Py_None;
500 return _res;
501 }
502
Icn_GetSuiteLabel(PyObject * _self,PyObject * _args)503 static PyObject *Icn_GetSuiteLabel(PyObject *_self, PyObject *_args)
504 {
505 PyObject *_res = NULL;
506 SInt16 _rv;
507 IconSuiteRef theSuite;
508 #ifndef GetSuiteLabel
509 PyMac_PRECHECK(GetSuiteLabel);
510 #endif
511 if (!PyArg_ParseTuple(_args, "O&",
512 ResObj_Convert, &theSuite))
513 return NULL;
514 _rv = GetSuiteLabel(theSuite);
515 _res = Py_BuildValue("h",
516 _rv);
517 return _res;
518 }
519
Icn_PlotIconHandle(PyObject * _self,PyObject * _args)520 static PyObject *Icn_PlotIconHandle(PyObject *_self, PyObject *_args)
521 {
522 PyObject *_res = NULL;
523 OSErr _err;
524 Rect theRect;
525 IconAlignmentType align;
526 IconTransformType transform;
527 Handle theIcon;
528 #ifndef PlotIconHandle
529 PyMac_PRECHECK(PlotIconHandle);
530 #endif
531 if (!PyArg_ParseTuple(_args, "O&hhO&",
532 PyMac_GetRect, &theRect,
533 &align,
534 &transform,
535 ResObj_Convert, &theIcon))
536 return NULL;
537 _err = PlotIconHandle(&theRect,
538 align,
539 transform,
540 theIcon);
541 if (_err != noErr) return PyMac_Error(_err);
542 Py_INCREF(Py_None);
543 _res = Py_None;
544 return _res;
545 }
546
Icn_PlotSICNHandle(PyObject * _self,PyObject * _args)547 static PyObject *Icn_PlotSICNHandle(PyObject *_self, PyObject *_args)
548 {
549 PyObject *_res = NULL;
550 OSErr _err;
551 Rect theRect;
552 IconAlignmentType align;
553 IconTransformType transform;
554 Handle theSICN;
555 #ifndef PlotSICNHandle
556 PyMac_PRECHECK(PlotSICNHandle);
557 #endif
558 if (!PyArg_ParseTuple(_args, "O&hhO&",
559 PyMac_GetRect, &theRect,
560 &align,
561 &transform,
562 ResObj_Convert, &theSICN))
563 return NULL;
564 _err = PlotSICNHandle(&theRect,
565 align,
566 transform,
567 theSICN);
568 if (_err != noErr) return PyMac_Error(_err);
569 Py_INCREF(Py_None);
570 _res = Py_None;
571 return _res;
572 }
573
Icn_PlotCIconHandle(PyObject * _self,PyObject * _args)574 static PyObject *Icn_PlotCIconHandle(PyObject *_self, PyObject *_args)
575 {
576 PyObject *_res = NULL;
577 OSErr _err;
578 Rect theRect;
579 IconAlignmentType align;
580 IconTransformType transform;
581 CIconHandle theCIcon;
582 #ifndef PlotCIconHandle
583 PyMac_PRECHECK(PlotCIconHandle);
584 #endif
585 if (!PyArg_ParseTuple(_args, "O&hhO&",
586 PyMac_GetRect, &theRect,
587 &align,
588 &transform,
589 ResObj_Convert, &theCIcon))
590 return NULL;
591 _err = PlotCIconHandle(&theRect,
592 align,
593 transform,
594 theCIcon);
595 if (_err != noErr) return PyMac_Error(_err);
596 Py_INCREF(Py_None);
597 _res = Py_None;
598 return _res;
599 }
600
Icn_IconRefToIconFamily(PyObject * _self,PyObject * _args)601 static PyObject *Icn_IconRefToIconFamily(PyObject *_self, PyObject *_args)
602 {
603 PyObject *_res = NULL;
604 OSErr _err;
605 IconRef theIconRef;
606 IconSelectorValue whichIcons;
607 IconFamilyHandle iconFamily;
608 #ifndef IconRefToIconFamily
609 PyMac_PRECHECK(IconRefToIconFamily);
610 #endif
611 if (!PyArg_ParseTuple(_args, "O&l",
612 ResObj_Convert, &theIconRef,
613 &whichIcons))
614 return NULL;
615 _err = IconRefToIconFamily(theIconRef,
616 whichIcons,
617 &iconFamily);
618 if (_err != noErr) return PyMac_Error(_err);
619 _res = Py_BuildValue("O&",
620 ResObj_New, iconFamily);
621 return _res;
622 }
623
Icn_IconFamilyToIconSuite(PyObject * _self,PyObject * _args)624 static PyObject *Icn_IconFamilyToIconSuite(PyObject *_self, PyObject *_args)
625 {
626 PyObject *_res = NULL;
627 OSErr _err;
628 IconFamilyHandle iconFamily;
629 IconSelectorValue whichIcons;
630 IconSuiteRef iconSuite;
631 #ifndef IconFamilyToIconSuite
632 PyMac_PRECHECK(IconFamilyToIconSuite);
633 #endif
634 if (!PyArg_ParseTuple(_args, "O&l",
635 ResObj_Convert, &iconFamily,
636 &whichIcons))
637 return NULL;
638 _err = IconFamilyToIconSuite(iconFamily,
639 whichIcons,
640 &iconSuite);
641 if (_err != noErr) return PyMac_Error(_err);
642 _res = Py_BuildValue("O&",
643 ResObj_New, iconSuite);
644 return _res;
645 }
646
Icn_IconSuiteToIconFamily(PyObject * _self,PyObject * _args)647 static PyObject *Icn_IconSuiteToIconFamily(PyObject *_self, PyObject *_args)
648 {
649 PyObject *_res = NULL;
650 OSErr _err;
651 IconSuiteRef iconSuite;
652 IconSelectorValue whichIcons;
653 IconFamilyHandle iconFamily;
654 #ifndef IconSuiteToIconFamily
655 PyMac_PRECHECK(IconSuiteToIconFamily);
656 #endif
657 if (!PyArg_ParseTuple(_args, "O&l",
658 ResObj_Convert, &iconSuite,
659 &whichIcons))
660 return NULL;
661 _err = IconSuiteToIconFamily(iconSuite,
662 whichIcons,
663 &iconFamily);
664 if (_err != noErr) return PyMac_Error(_err);
665 _res = Py_BuildValue("O&",
666 ResObj_New, iconFamily);
667 return _res;
668 }
669
Icn_SetIconFamilyData(PyObject * _self,PyObject * _args)670 static PyObject *Icn_SetIconFamilyData(PyObject *_self, PyObject *_args)
671 {
672 PyObject *_res = NULL;
673 OSErr _err;
674 IconFamilyHandle iconFamily;
675 OSType iconType;
676 Handle h;
677 #ifndef SetIconFamilyData
678 PyMac_PRECHECK(SetIconFamilyData);
679 #endif
680 if (!PyArg_ParseTuple(_args, "O&O&O&",
681 ResObj_Convert, &iconFamily,
682 PyMac_GetOSType, &iconType,
683 ResObj_Convert, &h))
684 return NULL;
685 _err = SetIconFamilyData(iconFamily,
686 iconType,
687 h);
688 if (_err != noErr) return PyMac_Error(_err);
689 Py_INCREF(Py_None);
690 _res = Py_None;
691 return _res;
692 }
693
Icn_GetIconFamilyData(PyObject * _self,PyObject * _args)694 static PyObject *Icn_GetIconFamilyData(PyObject *_self, PyObject *_args)
695 {
696 PyObject *_res = NULL;
697 OSErr _err;
698 IconFamilyHandle iconFamily;
699 OSType iconType;
700 Handle h;
701 #ifndef GetIconFamilyData
702 PyMac_PRECHECK(GetIconFamilyData);
703 #endif
704 if (!PyArg_ParseTuple(_args, "O&O&O&",
705 ResObj_Convert, &iconFamily,
706 PyMac_GetOSType, &iconType,
707 ResObj_Convert, &h))
708 return NULL;
709 _err = GetIconFamilyData(iconFamily,
710 iconType,
711 h);
712 if (_err != noErr) return PyMac_Error(_err);
713 Py_INCREF(Py_None);
714 _res = Py_None;
715 return _res;
716 }
717
Icn_GetIconRefOwners(PyObject * _self,PyObject * _args)718 static PyObject *Icn_GetIconRefOwners(PyObject *_self, PyObject *_args)
719 {
720 PyObject *_res = NULL;
721 OSErr _err;
722 IconRef theIconRef;
723 UInt16 owners;
724 #ifndef GetIconRefOwners
725 PyMac_PRECHECK(GetIconRefOwners);
726 #endif
727 if (!PyArg_ParseTuple(_args, "O&",
728 ResObj_Convert, &theIconRef))
729 return NULL;
730 _err = GetIconRefOwners(theIconRef,
731 &owners);
732 if (_err != noErr) return PyMac_Error(_err);
733 _res = Py_BuildValue("H",
734 owners);
735 return _res;
736 }
737
Icn_AcquireIconRef(PyObject * _self,PyObject * _args)738 static PyObject *Icn_AcquireIconRef(PyObject *_self, PyObject *_args)
739 {
740 PyObject *_res = NULL;
741 OSErr _err;
742 IconRef theIconRef;
743 #ifndef AcquireIconRef
744 PyMac_PRECHECK(AcquireIconRef);
745 #endif
746 if (!PyArg_ParseTuple(_args, "O&",
747 ResObj_Convert, &theIconRef))
748 return NULL;
749 _err = AcquireIconRef(theIconRef);
750 if (_err != noErr) return PyMac_Error(_err);
751 Py_INCREF(Py_None);
752 _res = Py_None;
753 return _res;
754 }
755
Icn_ReleaseIconRef(PyObject * _self,PyObject * _args)756 static PyObject *Icn_ReleaseIconRef(PyObject *_self, PyObject *_args)
757 {
758 PyObject *_res = NULL;
759 OSErr _err;
760 IconRef theIconRef;
761 #ifndef ReleaseIconRef
762 PyMac_PRECHECK(ReleaseIconRef);
763 #endif
764 if (!PyArg_ParseTuple(_args, "O&",
765 ResObj_Convert, &theIconRef))
766 return NULL;
767 _err = ReleaseIconRef(theIconRef);
768 if (_err != noErr) return PyMac_Error(_err);
769 Py_INCREF(Py_None);
770 _res = Py_None;
771 return _res;
772 }
773
Icn_GetIconRefFromFile(PyObject * _self,PyObject * _args)774 static PyObject *Icn_GetIconRefFromFile(PyObject *_self, PyObject *_args)
775 {
776 PyObject *_res = NULL;
777 OSErr _err;
778 FSSpec theFile;
779 IconRef theIconRef;
780 SInt16 theLabel;
781 #ifndef GetIconRefFromFile
782 PyMac_PRECHECK(GetIconRefFromFile);
783 #endif
784 if (!PyArg_ParseTuple(_args, "O&",
785 PyMac_GetFSSpec, &theFile))
786 return NULL;
787 _err = GetIconRefFromFile(&theFile,
788 &theIconRef,
789 &theLabel);
790 if (_err != noErr) return PyMac_Error(_err);
791 _res = Py_BuildValue("O&h",
792 ResObj_New, theIconRef,
793 theLabel);
794 return _res;
795 }
796
Icn_GetIconRef(PyObject * _self,PyObject * _args)797 static PyObject *Icn_GetIconRef(PyObject *_self, PyObject *_args)
798 {
799 PyObject *_res = NULL;
800 OSErr _err;
801 SInt16 vRefNum;
802 OSType creator;
803 OSType iconType;
804 IconRef theIconRef;
805 #ifndef GetIconRef
806 PyMac_PRECHECK(GetIconRef);
807 #endif
808 if (!PyArg_ParseTuple(_args, "hO&O&",
809 &vRefNum,
810 PyMac_GetOSType, &creator,
811 PyMac_GetOSType, &iconType))
812 return NULL;
813 _err = GetIconRef(vRefNum,
814 creator,
815 iconType,
816 &theIconRef);
817 if (_err != noErr) return PyMac_Error(_err);
818 _res = Py_BuildValue("O&",
819 ResObj_New, theIconRef);
820 return _res;
821 }
822
Icn_GetIconRefFromFolder(PyObject * _self,PyObject * _args)823 static PyObject *Icn_GetIconRefFromFolder(PyObject *_self, PyObject *_args)
824 {
825 PyObject *_res = NULL;
826 OSErr _err;
827 SInt16 vRefNum;
828 SInt32 parentFolderID;
829 SInt32 folderID;
830 SInt8 attributes;
831 SInt8 accessPrivileges;
832 IconRef theIconRef;
833 #ifndef GetIconRefFromFolder
834 PyMac_PRECHECK(GetIconRefFromFolder);
835 #endif
836 if (!PyArg_ParseTuple(_args, "hllbb",
837 &vRefNum,
838 &parentFolderID,
839 &folderID,
840 &attributes,
841 &accessPrivileges))
842 return NULL;
843 _err = GetIconRefFromFolder(vRefNum,
844 parentFolderID,
845 folderID,
846 attributes,
847 accessPrivileges,
848 &theIconRef);
849 if (_err != noErr) return PyMac_Error(_err);
850 _res = Py_BuildValue("O&",
851 ResObj_New, theIconRef);
852 return _res;
853 }
854
Icn_RegisterIconRefFromIconFamily(PyObject * _self,PyObject * _args)855 static PyObject *Icn_RegisterIconRefFromIconFamily(PyObject *_self, PyObject *_args)
856 {
857 PyObject *_res = NULL;
858 OSErr _err;
859 OSType creator;
860 OSType iconType;
861 IconFamilyHandle iconFamily;
862 IconRef theIconRef;
863 #ifndef RegisterIconRefFromIconFamily
864 PyMac_PRECHECK(RegisterIconRefFromIconFamily);
865 #endif
866 if (!PyArg_ParseTuple(_args, "O&O&O&",
867 PyMac_GetOSType, &creator,
868 PyMac_GetOSType, &iconType,
869 ResObj_Convert, &iconFamily))
870 return NULL;
871 _err = RegisterIconRefFromIconFamily(creator,
872 iconType,
873 iconFamily,
874 &theIconRef);
875 if (_err != noErr) return PyMac_Error(_err);
876 _res = Py_BuildValue("O&",
877 ResObj_New, theIconRef);
878 return _res;
879 }
880
Icn_RegisterIconRefFromResource(PyObject * _self,PyObject * _args)881 static PyObject *Icn_RegisterIconRefFromResource(PyObject *_self, PyObject *_args)
882 {
883 PyObject *_res = NULL;
884 OSErr _err;
885 OSType creator;
886 OSType iconType;
887 FSSpec resourceFile;
888 SInt16 resourceID;
889 IconRef theIconRef;
890 #ifndef RegisterIconRefFromResource
891 PyMac_PRECHECK(RegisterIconRefFromResource);
892 #endif
893 if (!PyArg_ParseTuple(_args, "O&O&O&h",
894 PyMac_GetOSType, &creator,
895 PyMac_GetOSType, &iconType,
896 PyMac_GetFSSpec, &resourceFile,
897 &resourceID))
898 return NULL;
899 _err = RegisterIconRefFromResource(creator,
900 iconType,
901 &resourceFile,
902 resourceID,
903 &theIconRef);
904 if (_err != noErr) return PyMac_Error(_err);
905 _res = Py_BuildValue("O&",
906 ResObj_New, theIconRef);
907 return _res;
908 }
909
Icn_RegisterIconRefFromFSRef(PyObject * _self,PyObject * _args)910 static PyObject *Icn_RegisterIconRefFromFSRef(PyObject *_self, PyObject *_args)
911 {
912 PyObject *_res = NULL;
913 OSStatus _err;
914 OSType creator;
915 OSType iconType;
916 FSRef iconFile;
917 IconRef theIconRef;
918 #ifndef RegisterIconRefFromFSRef
919 PyMac_PRECHECK(RegisterIconRefFromFSRef);
920 #endif
921 if (!PyArg_ParseTuple(_args, "O&O&O&",
922 PyMac_GetOSType, &creator,
923 PyMac_GetOSType, &iconType,
924 PyMac_GetFSRef, &iconFile))
925 return NULL;
926 _err = RegisterIconRefFromFSRef(creator,
927 iconType,
928 &iconFile,
929 &theIconRef);
930 if (_err != noErr) return PyMac_Error(_err);
931 _res = Py_BuildValue("O&",
932 ResObj_New, theIconRef);
933 return _res;
934 }
935
Icn_UnregisterIconRef(PyObject * _self,PyObject * _args)936 static PyObject *Icn_UnregisterIconRef(PyObject *_self, PyObject *_args)
937 {
938 PyObject *_res = NULL;
939 OSErr _err;
940 OSType creator;
941 OSType iconType;
942 #ifndef UnregisterIconRef
943 PyMac_PRECHECK(UnregisterIconRef);
944 #endif
945 if (!PyArg_ParseTuple(_args, "O&O&",
946 PyMac_GetOSType, &creator,
947 PyMac_GetOSType, &iconType))
948 return NULL;
949 _err = UnregisterIconRef(creator,
950 iconType);
951 if (_err != noErr) return PyMac_Error(_err);
952 Py_INCREF(Py_None);
953 _res = Py_None;
954 return _res;
955 }
956
Icn_UpdateIconRef(PyObject * _self,PyObject * _args)957 static PyObject *Icn_UpdateIconRef(PyObject *_self, PyObject *_args)
958 {
959 PyObject *_res = NULL;
960 OSErr _err;
961 IconRef theIconRef;
962 #ifndef UpdateIconRef
963 PyMac_PRECHECK(UpdateIconRef);
964 #endif
965 if (!PyArg_ParseTuple(_args, "O&",
966 ResObj_Convert, &theIconRef))
967 return NULL;
968 _err = UpdateIconRef(theIconRef);
969 if (_err != noErr) return PyMac_Error(_err);
970 Py_INCREF(Py_None);
971 _res = Py_None;
972 return _res;
973 }
974
Icn_OverrideIconRefFromResource(PyObject * _self,PyObject * _args)975 static PyObject *Icn_OverrideIconRefFromResource(PyObject *_self, PyObject *_args)
976 {
977 PyObject *_res = NULL;
978 OSErr _err;
979 IconRef theIconRef;
980 FSSpec resourceFile;
981 SInt16 resourceID;
982 #ifndef OverrideIconRefFromResource
983 PyMac_PRECHECK(OverrideIconRefFromResource);
984 #endif
985 if (!PyArg_ParseTuple(_args, "O&O&h",
986 ResObj_Convert, &theIconRef,
987 PyMac_GetFSSpec, &resourceFile,
988 &resourceID))
989 return NULL;
990 _err = OverrideIconRefFromResource(theIconRef,
991 &resourceFile,
992 resourceID);
993 if (_err != noErr) return PyMac_Error(_err);
994 Py_INCREF(Py_None);
995 _res = Py_None;
996 return _res;
997 }
998
Icn_OverrideIconRef(PyObject * _self,PyObject * _args)999 static PyObject *Icn_OverrideIconRef(PyObject *_self, PyObject *_args)
1000 {
1001 PyObject *_res = NULL;
1002 OSErr _err;
1003 IconRef oldIconRef;
1004 IconRef newIconRef;
1005 #ifndef OverrideIconRef
1006 PyMac_PRECHECK(OverrideIconRef);
1007 #endif
1008 if (!PyArg_ParseTuple(_args, "O&O&",
1009 ResObj_Convert, &oldIconRef,
1010 ResObj_Convert, &newIconRef))
1011 return NULL;
1012 _err = OverrideIconRef(oldIconRef,
1013 newIconRef);
1014 if (_err != noErr) return PyMac_Error(_err);
1015 Py_INCREF(Py_None);
1016 _res = Py_None;
1017 return _res;
1018 }
1019
Icn_RemoveIconRefOverride(PyObject * _self,PyObject * _args)1020 static PyObject *Icn_RemoveIconRefOverride(PyObject *_self, PyObject *_args)
1021 {
1022 PyObject *_res = NULL;
1023 OSErr _err;
1024 IconRef theIconRef;
1025 #ifndef RemoveIconRefOverride
1026 PyMac_PRECHECK(RemoveIconRefOverride);
1027 #endif
1028 if (!PyArg_ParseTuple(_args, "O&",
1029 ResObj_Convert, &theIconRef))
1030 return NULL;
1031 _err = RemoveIconRefOverride(theIconRef);
1032 if (_err != noErr) return PyMac_Error(_err);
1033 Py_INCREF(Py_None);
1034 _res = Py_None;
1035 return _res;
1036 }
1037
Icn_CompositeIconRef(PyObject * _self,PyObject * _args)1038 static PyObject *Icn_CompositeIconRef(PyObject *_self, PyObject *_args)
1039 {
1040 PyObject *_res = NULL;
1041 OSErr _err;
1042 IconRef backgroundIconRef;
1043 IconRef foregroundIconRef;
1044 IconRef compositeIconRef;
1045 #ifndef CompositeIconRef
1046 PyMac_PRECHECK(CompositeIconRef);
1047 #endif
1048 if (!PyArg_ParseTuple(_args, "O&O&",
1049 ResObj_Convert, &backgroundIconRef,
1050 ResObj_Convert, &foregroundIconRef))
1051 return NULL;
1052 _err = CompositeIconRef(backgroundIconRef,
1053 foregroundIconRef,
1054 &compositeIconRef);
1055 if (_err != noErr) return PyMac_Error(_err);
1056 _res = Py_BuildValue("O&",
1057 ResObj_New, compositeIconRef);
1058 return _res;
1059 }
1060
Icn_IsIconRefComposite(PyObject * _self,PyObject * _args)1061 static PyObject *Icn_IsIconRefComposite(PyObject *_self, PyObject *_args)
1062 {
1063 PyObject *_res = NULL;
1064 OSErr _err;
1065 IconRef compositeIconRef;
1066 IconRef backgroundIconRef;
1067 IconRef foregroundIconRef;
1068 #ifndef IsIconRefComposite
1069 PyMac_PRECHECK(IsIconRefComposite);
1070 #endif
1071 if (!PyArg_ParseTuple(_args, "O&",
1072 ResObj_Convert, &compositeIconRef))
1073 return NULL;
1074 _err = IsIconRefComposite(compositeIconRef,
1075 &backgroundIconRef,
1076 &foregroundIconRef);
1077 if (_err != noErr) return PyMac_Error(_err);
1078 _res = Py_BuildValue("O&O&",
1079 ResObj_New, backgroundIconRef,
1080 ResObj_New, foregroundIconRef);
1081 return _res;
1082 }
1083
Icn_IsValidIconRef(PyObject * _self,PyObject * _args)1084 static PyObject *Icn_IsValidIconRef(PyObject *_self, PyObject *_args)
1085 {
1086 PyObject *_res = NULL;
1087 Boolean _rv;
1088 IconRef theIconRef;
1089 #ifndef IsValidIconRef
1090 PyMac_PRECHECK(IsValidIconRef);
1091 #endif
1092 if (!PyArg_ParseTuple(_args, "O&",
1093 ResObj_Convert, &theIconRef))
1094 return NULL;
1095 _rv = IsValidIconRef(theIconRef);
1096 _res = Py_BuildValue("b",
1097 _rv);
1098 return _res;
1099 }
1100
Icn_PlotIconRef(PyObject * _self,PyObject * _args)1101 static PyObject *Icn_PlotIconRef(PyObject *_self, PyObject *_args)
1102 {
1103 PyObject *_res = NULL;
1104 OSErr _err;
1105 Rect theRect;
1106 IconAlignmentType align;
1107 IconTransformType transform;
1108 IconServicesUsageFlags theIconServicesUsageFlags;
1109 IconRef theIconRef;
1110 #ifndef PlotIconRef
1111 PyMac_PRECHECK(PlotIconRef);
1112 #endif
1113 if (!PyArg_ParseTuple(_args, "O&hhlO&",
1114 PyMac_GetRect, &theRect,
1115 &align,
1116 &transform,
1117 &theIconServicesUsageFlags,
1118 ResObj_Convert, &theIconRef))
1119 return NULL;
1120 _err = PlotIconRef(&theRect,
1121 align,
1122 transform,
1123 theIconServicesUsageFlags,
1124 theIconRef);
1125 if (_err != noErr) return PyMac_Error(_err);
1126 Py_INCREF(Py_None);
1127 _res = Py_None;
1128 return _res;
1129 }
1130
Icn_PtInIconRef(PyObject * _self,PyObject * _args)1131 static PyObject *Icn_PtInIconRef(PyObject *_self, PyObject *_args)
1132 {
1133 PyObject *_res = NULL;
1134 Boolean _rv;
1135 Point testPt;
1136 Rect iconRect;
1137 IconAlignmentType align;
1138 IconServicesUsageFlags theIconServicesUsageFlags;
1139 IconRef theIconRef;
1140 #ifndef PtInIconRef
1141 PyMac_PRECHECK(PtInIconRef);
1142 #endif
1143 if (!PyArg_ParseTuple(_args, "O&O&hlO&",
1144 PyMac_GetPoint, &testPt,
1145 PyMac_GetRect, &iconRect,
1146 &align,
1147 &theIconServicesUsageFlags,
1148 ResObj_Convert, &theIconRef))
1149 return NULL;
1150 _rv = PtInIconRef(&testPt,
1151 &iconRect,
1152 align,
1153 theIconServicesUsageFlags,
1154 theIconRef);
1155 _res = Py_BuildValue("b",
1156 _rv);
1157 return _res;
1158 }
1159
Icn_RectInIconRef(PyObject * _self,PyObject * _args)1160 static PyObject *Icn_RectInIconRef(PyObject *_self, PyObject *_args)
1161 {
1162 PyObject *_res = NULL;
1163 Boolean _rv;
1164 Rect testRect;
1165 Rect iconRect;
1166 IconAlignmentType align;
1167 IconServicesUsageFlags iconServicesUsageFlags;
1168 IconRef theIconRef;
1169 #ifndef RectInIconRef
1170 PyMac_PRECHECK(RectInIconRef);
1171 #endif
1172 if (!PyArg_ParseTuple(_args, "O&O&hlO&",
1173 PyMac_GetRect, &testRect,
1174 PyMac_GetRect, &iconRect,
1175 &align,
1176 &iconServicesUsageFlags,
1177 ResObj_Convert, &theIconRef))
1178 return NULL;
1179 _rv = RectInIconRef(&testRect,
1180 &iconRect,
1181 align,
1182 iconServicesUsageFlags,
1183 theIconRef);
1184 _res = Py_BuildValue("b",
1185 _rv);
1186 return _res;
1187 }
1188
Icn_IconRefToRgn(PyObject * _self,PyObject * _args)1189 static PyObject *Icn_IconRefToRgn(PyObject *_self, PyObject *_args)
1190 {
1191 PyObject *_res = NULL;
1192 OSErr _err;
1193 RgnHandle theRgn;
1194 Rect iconRect;
1195 IconAlignmentType align;
1196 IconServicesUsageFlags iconServicesUsageFlags;
1197 IconRef theIconRef;
1198 #ifndef IconRefToRgn
1199 PyMac_PRECHECK(IconRefToRgn);
1200 #endif
1201 if (!PyArg_ParseTuple(_args, "O&O&hlO&",
1202 ResObj_Convert, &theRgn,
1203 PyMac_GetRect, &iconRect,
1204 &align,
1205 &iconServicesUsageFlags,
1206 ResObj_Convert, &theIconRef))
1207 return NULL;
1208 _err = IconRefToRgn(theRgn,
1209 &iconRect,
1210 align,
1211 iconServicesUsageFlags,
1212 theIconRef);
1213 if (_err != noErr) return PyMac_Error(_err);
1214 Py_INCREF(Py_None);
1215 _res = Py_None;
1216 return _res;
1217 }
1218
Icn_GetIconSizesFromIconRef(PyObject * _self,PyObject * _args)1219 static PyObject *Icn_GetIconSizesFromIconRef(PyObject *_self, PyObject *_args)
1220 {
1221 PyObject *_res = NULL;
1222 OSErr _err;
1223 IconSelectorValue iconSelectorInput;
1224 IconSelectorValue iconSelectorOutputPtr;
1225 IconServicesUsageFlags iconServicesUsageFlags;
1226 IconRef theIconRef;
1227 #ifndef GetIconSizesFromIconRef
1228 PyMac_PRECHECK(GetIconSizesFromIconRef);
1229 #endif
1230 if (!PyArg_ParseTuple(_args, "llO&",
1231 &iconSelectorInput,
1232 &iconServicesUsageFlags,
1233 ResObj_Convert, &theIconRef))
1234 return NULL;
1235 _err = GetIconSizesFromIconRef(iconSelectorInput,
1236 &iconSelectorOutputPtr,
1237 iconServicesUsageFlags,
1238 theIconRef);
1239 if (_err != noErr) return PyMac_Error(_err);
1240 _res = Py_BuildValue("l",
1241 iconSelectorOutputPtr);
1242 return _res;
1243 }
1244
Icn_FlushIconRefs(PyObject * _self,PyObject * _args)1245 static PyObject *Icn_FlushIconRefs(PyObject *_self, PyObject *_args)
1246 {
1247 PyObject *_res = NULL;
1248 OSErr _err;
1249 OSType creator;
1250 OSType iconType;
1251 #ifndef FlushIconRefs
1252 PyMac_PRECHECK(FlushIconRefs);
1253 #endif
1254 if (!PyArg_ParseTuple(_args, "O&O&",
1255 PyMac_GetOSType, &creator,
1256 PyMac_GetOSType, &iconType))
1257 return NULL;
1258 _err = FlushIconRefs(creator,
1259 iconType);
1260 if (_err != noErr) return PyMac_Error(_err);
1261 Py_INCREF(Py_None);
1262 _res = Py_None;
1263 return _res;
1264 }
1265
Icn_FlushIconRefsByVolume(PyObject * _self,PyObject * _args)1266 static PyObject *Icn_FlushIconRefsByVolume(PyObject *_self, PyObject *_args)
1267 {
1268 PyObject *_res = NULL;
1269 OSErr _err;
1270 SInt16 vRefNum;
1271 #ifndef FlushIconRefsByVolume
1272 PyMac_PRECHECK(FlushIconRefsByVolume);
1273 #endif
1274 if (!PyArg_ParseTuple(_args, "h",
1275 &vRefNum))
1276 return NULL;
1277 _err = FlushIconRefsByVolume(vRefNum);
1278 if (_err != noErr) return PyMac_Error(_err);
1279 Py_INCREF(Py_None);
1280 _res = Py_None;
1281 return _res;
1282 }
1283
Icn_SetCustomIconsEnabled(PyObject * _self,PyObject * _args)1284 static PyObject *Icn_SetCustomIconsEnabled(PyObject *_self, PyObject *_args)
1285 {
1286 PyObject *_res = NULL;
1287 OSErr _err;
1288 SInt16 vRefNum;
1289 Boolean enableCustomIcons;
1290 #ifndef SetCustomIconsEnabled
1291 PyMac_PRECHECK(SetCustomIconsEnabled);
1292 #endif
1293 if (!PyArg_ParseTuple(_args, "hb",
1294 &vRefNum,
1295 &enableCustomIcons))
1296 return NULL;
1297 _err = SetCustomIconsEnabled(vRefNum,
1298 enableCustomIcons);
1299 if (_err != noErr) return PyMac_Error(_err);
1300 Py_INCREF(Py_None);
1301 _res = Py_None;
1302 return _res;
1303 }
1304
Icn_GetCustomIconsEnabled(PyObject * _self,PyObject * _args)1305 static PyObject *Icn_GetCustomIconsEnabled(PyObject *_self, PyObject *_args)
1306 {
1307 PyObject *_res = NULL;
1308 OSErr _err;
1309 SInt16 vRefNum;
1310 Boolean customIconsEnabled;
1311 #ifndef GetCustomIconsEnabled
1312 PyMac_PRECHECK(GetCustomIconsEnabled);
1313 #endif
1314 if (!PyArg_ParseTuple(_args, "h",
1315 &vRefNum))
1316 return NULL;
1317 _err = GetCustomIconsEnabled(vRefNum,
1318 &customIconsEnabled);
1319 if (_err != noErr) return PyMac_Error(_err);
1320 _res = Py_BuildValue("b",
1321 customIconsEnabled);
1322 return _res;
1323 }
1324
Icn_IsIconRefMaskEmpty(PyObject * _self,PyObject * _args)1325 static PyObject *Icn_IsIconRefMaskEmpty(PyObject *_self, PyObject *_args)
1326 {
1327 PyObject *_res = NULL;
1328 Boolean _rv;
1329 IconRef iconRef;
1330 #ifndef IsIconRefMaskEmpty
1331 PyMac_PRECHECK(IsIconRefMaskEmpty);
1332 #endif
1333 if (!PyArg_ParseTuple(_args, "O&",
1334 ResObj_Convert, &iconRef))
1335 return NULL;
1336 _rv = IsIconRefMaskEmpty(iconRef);
1337 _res = Py_BuildValue("b",
1338 _rv);
1339 return _res;
1340 }
1341
Icn_GetIconRefVariant(PyObject * _self,PyObject * _args)1342 static PyObject *Icn_GetIconRefVariant(PyObject *_self, PyObject *_args)
1343 {
1344 PyObject *_res = NULL;
1345 IconRef _rv;
1346 IconRef inIconRef;
1347 OSType inVariant;
1348 IconTransformType outTransform;
1349 #ifndef GetIconRefVariant
1350 PyMac_PRECHECK(GetIconRefVariant);
1351 #endif
1352 if (!PyArg_ParseTuple(_args, "O&O&",
1353 ResObj_Convert, &inIconRef,
1354 PyMac_GetOSType, &inVariant))
1355 return NULL;
1356 _rv = GetIconRefVariant(inIconRef,
1357 inVariant,
1358 &outTransform);
1359 _res = Py_BuildValue("O&h",
1360 ResObj_New, _rv,
1361 outTransform);
1362 return _res;
1363 }
1364
Icn_RegisterIconRefFromIconFile(PyObject * _self,PyObject * _args)1365 static PyObject *Icn_RegisterIconRefFromIconFile(PyObject *_self, PyObject *_args)
1366 {
1367 PyObject *_res = NULL;
1368 OSErr _err;
1369 OSType creator;
1370 OSType iconType;
1371 FSSpec iconFile;
1372 IconRef theIconRef;
1373 #ifndef RegisterIconRefFromIconFile
1374 PyMac_PRECHECK(RegisterIconRefFromIconFile);
1375 #endif
1376 if (!PyArg_ParseTuple(_args, "O&O&O&",
1377 PyMac_GetOSType, &creator,
1378 PyMac_GetOSType, &iconType,
1379 PyMac_GetFSSpec, &iconFile))
1380 return NULL;
1381 _err = RegisterIconRefFromIconFile(creator,
1382 iconType,
1383 &iconFile,
1384 &theIconRef);
1385 if (_err != noErr) return PyMac_Error(_err);
1386 _res = Py_BuildValue("O&",
1387 ResObj_New, theIconRef);
1388 return _res;
1389 }
1390
Icn_ReadIconFile(PyObject * _self,PyObject * _args)1391 static PyObject *Icn_ReadIconFile(PyObject *_self, PyObject *_args)
1392 {
1393 PyObject *_res = NULL;
1394 OSErr _err;
1395 FSSpec iconFile;
1396 IconFamilyHandle iconFamily;
1397 #ifndef ReadIconFile
1398 PyMac_PRECHECK(ReadIconFile);
1399 #endif
1400 if (!PyArg_ParseTuple(_args, "O&",
1401 PyMac_GetFSSpec, &iconFile))
1402 return NULL;
1403 _err = ReadIconFile(&iconFile,
1404 &iconFamily);
1405 if (_err != noErr) return PyMac_Error(_err);
1406 _res = Py_BuildValue("O&",
1407 ResObj_New, iconFamily);
1408 return _res;
1409 }
1410
Icn_ReadIconFromFSRef(PyObject * _self,PyObject * _args)1411 static PyObject *Icn_ReadIconFromFSRef(PyObject *_self, PyObject *_args)
1412 {
1413 PyObject *_res = NULL;
1414 OSStatus _err;
1415 FSRef ref;
1416 IconFamilyHandle iconFamily;
1417 #ifndef ReadIconFromFSRef
1418 PyMac_PRECHECK(ReadIconFromFSRef);
1419 #endif
1420 if (!PyArg_ParseTuple(_args, "O&",
1421 PyMac_GetFSRef, &ref))
1422 return NULL;
1423 _err = ReadIconFromFSRef(&ref,
1424 &iconFamily);
1425 if (_err != noErr) return PyMac_Error(_err);
1426 _res = Py_BuildValue("O&",
1427 ResObj_New, iconFamily);
1428 return _res;
1429 }
1430
Icn_WriteIconFile(PyObject * _self,PyObject * _args)1431 static PyObject *Icn_WriteIconFile(PyObject *_self, PyObject *_args)
1432 {
1433 PyObject *_res = NULL;
1434 OSErr _err;
1435 IconFamilyHandle iconFamily;
1436 FSSpec iconFile;
1437 #ifndef WriteIconFile
1438 PyMac_PRECHECK(WriteIconFile);
1439 #endif
1440 if (!PyArg_ParseTuple(_args, "O&O&",
1441 ResObj_Convert, &iconFamily,
1442 PyMac_GetFSSpec, &iconFile))
1443 return NULL;
1444 _err = WriteIconFile(iconFamily,
1445 &iconFile);
1446 if (_err != noErr) return PyMac_Error(_err);
1447 Py_INCREF(Py_None);
1448 _res = Py_None;
1449 return _res;
1450 }
1451 #endif /* APPLE_SUPPORTS_QUICKTIME */
1452
1453 static PyMethodDef Icn_methods[] = {
1454 #if APPLE_SUPPORTS_QUICKTIME
1455 {"GetCIcon", (PyCFunction)Icn_GetCIcon, 1,
1456 PyDoc_STR("(SInt16 iconID) -> (CIconHandle _rv)")},
1457 {"PlotCIcon", (PyCFunction)Icn_PlotCIcon, 1,
1458 PyDoc_STR("(Rect theRect, CIconHandle theIcon) -> None")},
1459 {"DisposeCIcon", (PyCFunction)Icn_DisposeCIcon, 1,
1460 PyDoc_STR("(CIconHandle theIcon) -> None")},
1461 {"GetIcon", (PyCFunction)Icn_GetIcon, 1,
1462 PyDoc_STR("(SInt16 iconID) -> (Handle _rv)")},
1463 {"PlotIcon", (PyCFunction)Icn_PlotIcon, 1,
1464 PyDoc_STR("(Rect theRect, Handle theIcon) -> None")},
1465 {"PlotIconID", (PyCFunction)Icn_PlotIconID, 1,
1466 PyDoc_STR("(Rect theRect, IconAlignmentType align, IconTransformType transform, SInt16 theResID) -> None")},
1467 {"NewIconSuite", (PyCFunction)Icn_NewIconSuite, 1,
1468 PyDoc_STR("() -> (IconSuiteRef theIconSuite)")},
1469 {"AddIconToSuite", (PyCFunction)Icn_AddIconToSuite, 1,
1470 PyDoc_STR("(Handle theIconData, IconSuiteRef theSuite, ResType theType) -> None")},
1471 {"GetIconFromSuite", (PyCFunction)Icn_GetIconFromSuite, 1,
1472 PyDoc_STR("(IconSuiteRef theSuite, ResType theType) -> (Handle theIconData)")},
1473 {"GetIconSuite", (PyCFunction)Icn_GetIconSuite, 1,
1474 PyDoc_STR("(SInt16 theResID, IconSelectorValue selector) -> (IconSuiteRef theIconSuite)")},
1475 {"DisposeIconSuite", (PyCFunction)Icn_DisposeIconSuite, 1,
1476 PyDoc_STR("(IconSuiteRef theIconSuite, Boolean disposeData) -> None")},
1477 {"PlotIconSuite", (PyCFunction)Icn_PlotIconSuite, 1,
1478 PyDoc_STR("(Rect theRect, IconAlignmentType align, IconTransformType transform, IconSuiteRef theIconSuite) -> None")},
1479 {"LoadIconCache", (PyCFunction)Icn_LoadIconCache, 1,
1480 PyDoc_STR("(Rect theRect, IconAlignmentType align, IconTransformType transform, IconCacheRef theIconCache) -> None")},
1481 {"GetLabel", (PyCFunction)Icn_GetLabel, 1,
1482 PyDoc_STR("(SInt16 labelNumber, Str255 labelString) -> (RGBColor labelColor)")},
1483 {"PtInIconID", (PyCFunction)Icn_PtInIconID, 1,
1484 PyDoc_STR("(Point testPt, Rect iconRect, IconAlignmentType align, SInt16 iconID) -> (Boolean _rv)")},
1485 {"PtInIconSuite", (PyCFunction)Icn_PtInIconSuite, 1,
1486 PyDoc_STR("(Point testPt, Rect iconRect, IconAlignmentType align, IconSuiteRef theIconSuite) -> (Boolean _rv)")},
1487 {"RectInIconID", (PyCFunction)Icn_RectInIconID, 1,
1488 PyDoc_STR("(Rect testRect, Rect iconRect, IconAlignmentType align, SInt16 iconID) -> (Boolean _rv)")},
1489 {"RectInIconSuite", (PyCFunction)Icn_RectInIconSuite, 1,
1490 PyDoc_STR("(Rect testRect, Rect iconRect, IconAlignmentType align, IconSuiteRef theIconSuite) -> (Boolean _rv)")},
1491 {"IconIDToRgn", (PyCFunction)Icn_IconIDToRgn, 1,
1492 PyDoc_STR("(RgnHandle theRgn, Rect iconRect, IconAlignmentType align, SInt16 iconID) -> None")},
1493 {"IconSuiteToRgn", (PyCFunction)Icn_IconSuiteToRgn, 1,
1494 PyDoc_STR("(RgnHandle theRgn, Rect iconRect, IconAlignmentType align, IconSuiteRef theIconSuite) -> None")},
1495 {"SetSuiteLabel", (PyCFunction)Icn_SetSuiteLabel, 1,
1496 PyDoc_STR("(IconSuiteRef theSuite, SInt16 theLabel) -> None")},
1497 {"GetSuiteLabel", (PyCFunction)Icn_GetSuiteLabel, 1,
1498 PyDoc_STR("(IconSuiteRef theSuite) -> (SInt16 _rv)")},
1499 {"PlotIconHandle", (PyCFunction)Icn_PlotIconHandle, 1,
1500 PyDoc_STR("(Rect theRect, IconAlignmentType align, IconTransformType transform, Handle theIcon) -> None")},
1501 {"PlotSICNHandle", (PyCFunction)Icn_PlotSICNHandle, 1,
1502 PyDoc_STR("(Rect theRect, IconAlignmentType align, IconTransformType transform, Handle theSICN) -> None")},
1503 {"PlotCIconHandle", (PyCFunction)Icn_PlotCIconHandle, 1,
1504 PyDoc_STR("(Rect theRect, IconAlignmentType align, IconTransformType transform, CIconHandle theCIcon) -> None")},
1505 {"IconRefToIconFamily", (PyCFunction)Icn_IconRefToIconFamily, 1,
1506 PyDoc_STR("(IconRef theIconRef, IconSelectorValue whichIcons) -> (IconFamilyHandle iconFamily)")},
1507 {"IconFamilyToIconSuite", (PyCFunction)Icn_IconFamilyToIconSuite, 1,
1508 PyDoc_STR("(IconFamilyHandle iconFamily, IconSelectorValue whichIcons) -> (IconSuiteRef iconSuite)")},
1509 {"IconSuiteToIconFamily", (PyCFunction)Icn_IconSuiteToIconFamily, 1,
1510 PyDoc_STR("(IconSuiteRef iconSuite, IconSelectorValue whichIcons) -> (IconFamilyHandle iconFamily)")},
1511 {"SetIconFamilyData", (PyCFunction)Icn_SetIconFamilyData, 1,
1512 PyDoc_STR("(IconFamilyHandle iconFamily, OSType iconType, Handle h) -> None")},
1513 {"GetIconFamilyData", (PyCFunction)Icn_GetIconFamilyData, 1,
1514 PyDoc_STR("(IconFamilyHandle iconFamily, OSType iconType, Handle h) -> None")},
1515 {"GetIconRefOwners", (PyCFunction)Icn_GetIconRefOwners, 1,
1516 PyDoc_STR("(IconRef theIconRef) -> (UInt16 owners)")},
1517 {"AcquireIconRef", (PyCFunction)Icn_AcquireIconRef, 1,
1518 PyDoc_STR("(IconRef theIconRef) -> None")},
1519 {"ReleaseIconRef", (PyCFunction)Icn_ReleaseIconRef, 1,
1520 PyDoc_STR("(IconRef theIconRef) -> None")},
1521 {"GetIconRefFromFile", (PyCFunction)Icn_GetIconRefFromFile, 1,
1522 PyDoc_STR("(FSSpec theFile) -> (IconRef theIconRef, SInt16 theLabel)")},
1523 {"GetIconRef", (PyCFunction)Icn_GetIconRef, 1,
1524 PyDoc_STR("(SInt16 vRefNum, OSType creator, OSType iconType) -> (IconRef theIconRef)")},
1525 {"GetIconRefFromFolder", (PyCFunction)Icn_GetIconRefFromFolder, 1,
1526 PyDoc_STR("(SInt16 vRefNum, SInt32 parentFolderID, SInt32 folderID, SInt8 attributes, SInt8 accessPrivileges) -> (IconRef theIconRef)")},
1527 {"RegisterIconRefFromIconFamily", (PyCFunction)Icn_RegisterIconRefFromIconFamily, 1,
1528 PyDoc_STR("(OSType creator, OSType iconType, IconFamilyHandle iconFamily) -> (IconRef theIconRef)")},
1529 {"RegisterIconRefFromResource", (PyCFunction)Icn_RegisterIconRefFromResource, 1,
1530 PyDoc_STR("(OSType creator, OSType iconType, FSSpec resourceFile, SInt16 resourceID) -> (IconRef theIconRef)")},
1531 {"RegisterIconRefFromFSRef", (PyCFunction)Icn_RegisterIconRefFromFSRef, 1,
1532 PyDoc_STR("(OSType creator, OSType iconType, FSRef iconFile) -> (IconRef theIconRef)")},
1533 {"UnregisterIconRef", (PyCFunction)Icn_UnregisterIconRef, 1,
1534 PyDoc_STR("(OSType creator, OSType iconType) -> None")},
1535 {"UpdateIconRef", (PyCFunction)Icn_UpdateIconRef, 1,
1536 PyDoc_STR("(IconRef theIconRef) -> None")},
1537 {"OverrideIconRefFromResource", (PyCFunction)Icn_OverrideIconRefFromResource, 1,
1538 PyDoc_STR("(IconRef theIconRef, FSSpec resourceFile, SInt16 resourceID) -> None")},
1539 {"OverrideIconRef", (PyCFunction)Icn_OverrideIconRef, 1,
1540 PyDoc_STR("(IconRef oldIconRef, IconRef newIconRef) -> None")},
1541 {"RemoveIconRefOverride", (PyCFunction)Icn_RemoveIconRefOverride, 1,
1542 PyDoc_STR("(IconRef theIconRef) -> None")},
1543 {"CompositeIconRef", (PyCFunction)Icn_CompositeIconRef, 1,
1544 PyDoc_STR("(IconRef backgroundIconRef, IconRef foregroundIconRef) -> (IconRef compositeIconRef)")},
1545 {"IsIconRefComposite", (PyCFunction)Icn_IsIconRefComposite, 1,
1546 PyDoc_STR("(IconRef compositeIconRef) -> (IconRef backgroundIconRef, IconRef foregroundIconRef)")},
1547 {"IsValidIconRef", (PyCFunction)Icn_IsValidIconRef, 1,
1548 PyDoc_STR("(IconRef theIconRef) -> (Boolean _rv)")},
1549 {"PlotIconRef", (PyCFunction)Icn_PlotIconRef, 1,
1550 PyDoc_STR("(Rect theRect, IconAlignmentType align, IconTransformType transform, IconServicesUsageFlags theIconServicesUsageFlags, IconRef theIconRef) -> None")},
1551 {"PtInIconRef", (PyCFunction)Icn_PtInIconRef, 1,
1552 PyDoc_STR("(Point testPt, Rect iconRect, IconAlignmentType align, IconServicesUsageFlags theIconServicesUsageFlags, IconRef theIconRef) -> (Boolean _rv)")},
1553 {"RectInIconRef", (PyCFunction)Icn_RectInIconRef, 1,
1554 PyDoc_STR("(Rect testRect, Rect iconRect, IconAlignmentType align, IconServicesUsageFlags iconServicesUsageFlags, IconRef theIconRef) -> (Boolean _rv)")},
1555 {"IconRefToRgn", (PyCFunction)Icn_IconRefToRgn, 1,
1556 PyDoc_STR("(RgnHandle theRgn, Rect iconRect, IconAlignmentType align, IconServicesUsageFlags iconServicesUsageFlags, IconRef theIconRef) -> None")},
1557 {"GetIconSizesFromIconRef", (PyCFunction)Icn_GetIconSizesFromIconRef, 1,
1558 PyDoc_STR("(IconSelectorValue iconSelectorInput, IconServicesUsageFlags iconServicesUsageFlags, IconRef theIconRef) -> (IconSelectorValue iconSelectorOutputPtr)")},
1559 {"FlushIconRefs", (PyCFunction)Icn_FlushIconRefs, 1,
1560 PyDoc_STR("(OSType creator, OSType iconType) -> None")},
1561 {"FlushIconRefsByVolume", (PyCFunction)Icn_FlushIconRefsByVolume, 1,
1562 PyDoc_STR("(SInt16 vRefNum) -> None")},
1563 {"SetCustomIconsEnabled", (PyCFunction)Icn_SetCustomIconsEnabled, 1,
1564 PyDoc_STR("(SInt16 vRefNum, Boolean enableCustomIcons) -> None")},
1565 {"GetCustomIconsEnabled", (PyCFunction)Icn_GetCustomIconsEnabled, 1,
1566 PyDoc_STR("(SInt16 vRefNum) -> (Boolean customIconsEnabled)")},
1567 {"IsIconRefMaskEmpty", (PyCFunction)Icn_IsIconRefMaskEmpty, 1,
1568 PyDoc_STR("(IconRef iconRef) -> (Boolean _rv)")},
1569 {"GetIconRefVariant", (PyCFunction)Icn_GetIconRefVariant, 1,
1570 PyDoc_STR("(IconRef inIconRef, OSType inVariant) -> (IconRef _rv, IconTransformType outTransform)")},
1571 {"RegisterIconRefFromIconFile", (PyCFunction)Icn_RegisterIconRefFromIconFile, 1,
1572 PyDoc_STR("(OSType creator, OSType iconType, FSSpec iconFile) -> (IconRef theIconRef)")},
1573 {"ReadIconFile", (PyCFunction)Icn_ReadIconFile, 1,
1574 PyDoc_STR("(FSSpec iconFile) -> (IconFamilyHandle iconFamily)")},
1575 {"ReadIconFromFSRef", (PyCFunction)Icn_ReadIconFromFSRef, 1,
1576 PyDoc_STR("(FSRef ref) -> (IconFamilyHandle iconFamily)")},
1577 {"WriteIconFile", (PyCFunction)Icn_WriteIconFile, 1,
1578 PyDoc_STR("(IconFamilyHandle iconFamily, FSSpec iconFile) -> None")},
1579 #endif /* APPLE_SUPPORTS_QUICKTIME */
1580 {NULL, NULL, 0}
1581 };
1582
1583
1584
1585
init_Icn(void)1586 void init_Icn(void)
1587 {
1588 PyObject *m;
1589 #if APPLE_SUPPORTS_QUICKTIME
1590 PyObject *d;
1591 #endif /* APPLE_SUPPORTS_QUICKTIME */
1592
1593
1594
1595
1596 m = Py_InitModule("_Icn", Icn_methods);
1597 #if APPLE_SUPPORTS_QUICKTIME
1598 d = PyModule_GetDict(m);
1599 Icn_Error = PyMac_GetOSErrException();
1600 if (Icn_Error == NULL ||
1601 PyDict_SetItemString(d, "Error", Icn_Error) != 0)
1602 return;
1603 #endif /* APPLE_SUPPORTS_QUICKTIME */
1604 }
1605
1606 /* ======================== End module _Icn ========================= */
1607
1608