| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#include "Python.h" |
| 5 |
#include "pymactoolbox.h" |
| 6 |
|
| 7 |
#if APPLE_SUPPORTS_QUICKTIME |
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\ |
| 12 |
PyErr_SetString(PyExc_NotImplementedError, \ |
| 13 |
"Not available in this shared library/OS version"); \ |
| 14 |
return NULL; \ |
| 15 |
}} while(0) |
| 16 |
|
| 17 |
|
| 18 |
#include <Carbon/Carbon.h> |
| 19 |
|
| 20 |
extern int CFStringRef_New(CFStringRef *); |
| 21 |
|
| 22 |
extern int CFStringRef_Convert(PyObject *, CFStringRef *); |
| 23 |
extern int CFBundleRef_Convert(PyObject *, CFBundleRef *); |
| 24 |
|
| 25 |
int EventTargetRef_Convert(PyObject *, EventTargetRef *); |
| 26 |
PyObject *EventHandlerCallRef_New(EventHandlerCallRef itself); |
| 27 |
PyObject *EventRef_New(EventRef itself); |
| 28 |
|
| 29 |
|
| 30 |
static int |
| 31 |
EventTypeSpec_Convert(PyObject *v, EventTypeSpec *out) |
| 32 |
{ |
| 33 |
if (PyArg_Parse(v, "(O&l)", |
| 34 |
PyMac_GetOSType, &(out->eventClass), |
| 35 |
&(out->eventKind))) |
| 36 |
return 1; |
| 37 |
return 0; |
| 38 |
} |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
#if 0 |
| 45 |
static PyObject* |
| 46 |
HIPoint_New(HIPoint *in) |
| 47 |
{ |
| 48 |
return Py_BuildValue("ff", in->x, in->y); |
| 49 |
} |
| 50 |
|
| 51 |
static int |
| 52 |
HIPoint_Convert(PyObject *v, HIPoint *out) |
| 53 |
{ |
| 54 |
if (PyArg_ParseTuple(v, "ff", &(out->x), &(out->y))) |
| 55 |
return 1; |
| 56 |
return NULL; |
| 57 |
} |
| 58 |
#endif |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
static int |
| 65 |
EventHotKeyID_Convert(PyObject *v, EventHotKeyID *out) |
| 66 |
{ |
| 67 |
if (PyArg_ParseTuple(v, "ll", &out->signature, &out->id)) |
| 68 |
return 1; |
| 69 |
return 0; |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
static EventHandlerUPP myEventHandlerUPP; |
| 77 |
|
| 78 |
static pascal OSStatus |
| 79 |
myEventHandler(EventHandlerCallRef handlerRef, EventRef event, void *outPyObject) { |
| 80 |
PyObject *retValue; |
| 81 |
int status; |
| 82 |
|
| 83 |
retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&", |
| 84 |
EventHandlerCallRef_New, handlerRef, |
| 85 |
EventRef_New, event); |
| 86 |
if (retValue == NULL) { |
| 87 |
PySys_WriteStderr("Error in event handler callback:\n"); |
| 88 |
PyErr_Print(); |
| 89 |
status = noErr; |
| 90 |
} else { |
| 91 |
if (retValue == Py_None) |
| 92 |
status = noErr; |
| 93 |
else if (PyInt_Check(retValue)) { |
| 94 |
status = PyInt_AsLong(retValue); |
| 95 |
} else |
| 96 |
status = noErr; |
| 97 |
Py_DECREF(retValue); |
| 98 |
} |
| 99 |
|
| 100 |
return status; |
| 101 |
} |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
static PyObject *CarbonEvents_Error; |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
PyTypeObject EventRef_Type; |
| 111 |
|
| 112 |
#define EventRef_Check(x) ((x)->ob_type == &EventRef_Type || PyObject_TypeCheck((x), &EventRef_Type)) |
| 113 |
|
| 114 |
typedef struct EventRefObject { |
| 115 |
PyObject_HEAD |
| 116 |
EventRef ob_itself; |
| 117 |
} EventRefObject; |
| 118 |
|
| 119 |
PyObject *EventRef_New(EventRef itself) |
| 120 |
{ |
| 121 |
EventRefObject *it; |
| 122 |
it = PyObject_NEW(EventRefObject, &EventRef_Type); |
| 123 |
if (it == NULL) return NULL; |
| 124 |
it->ob_itself = itself; |
| 125 |
return (PyObject *)it; |
| 126 |
} |
| 127 |
|
| 128 |
int EventRef_Convert(PyObject *v, EventRef *p_itself) |
| 129 |
{ |
| 130 |
if (!EventRef_Check(v)) |
| 131 |
{ |
| 132 |
PyErr_SetString(PyExc_TypeError, "EventRef required"); |
| 133 |
return 0; |
| 134 |
} |
| 135 |
*p_itself = ((EventRefObject *)v)->ob_itself; |
| 136 |
return 1; |
| 137 |
} |
| 138 |
|
| 139 |
static void EventRef_dealloc(EventRefObject *self) |
| 140 |
{ |
| 141 |
|
| 142 |
self->ob_type->tp_free((PyObject *)self); |
| 143 |
} |
| 144 |
|
| 145 |
static PyObject *EventRef_RetainEvent(EventRefObject *_self, PyObject *_args) |
| 146 |
{ |
| 147 |
PyObject *_res = NULL; |
| 148 |
EventRef _rv; |
| 149 |
if (!PyArg_ParseTuple(_args, "")) |
| 150 |
return NULL; |
| 151 |
_rv = RetainEvent(_self->ob_itself); |
| 152 |
_res = Py_BuildValue("O&", |
| 153 |
EventRef_New, _rv); |
| 154 |
return _res; |
| 155 |
} |
| 156 |
|
| 157 |
static PyObject *EventRef_GetEventRetainCount(EventRefObject *_self, PyObject *_args) |
| 158 |
{ |
| 159 |
PyObject *_res = NULL; |
| 160 |
UInt32 _rv; |
| 161 |
if (!PyArg_ParseTuple(_args, "")) |
| 162 |
return NULL; |
| 163 |
_rv = GetEventRetainCount(_self->ob_itself); |
| 164 |
_res = Py_BuildValue("l", |
| 165 |
_rv); |
| 166 |
return _res; |
| 167 |
} |
| 168 |
|
| 169 |
static PyObject *EventRef_ReleaseEvent(EventRefObject *_self, PyObject *_args) |
| 170 |
{ |
| 171 |
PyObject *_res = NULL; |
| 172 |
if (!PyArg_ParseTuple(_args, "")) |
| 173 |
return NULL; |
| 174 |
ReleaseEvent(_self->ob_itself); |
| 175 |
Py_INCREF(Py_None); |
| 176 |
_res = Py_None; |
| 177 |
return _res; |
| 178 |
} |
| 179 |
|
| 180 |
static PyObject *EventRef_SetEventParameter(EventRefObject *_self, PyObject *_args) |
| 181 |
{ |
| 182 |
PyObject *_res = NULL; |
| 183 |
OSStatus _err; |
| 184 |
OSType inName; |
| 185 |
OSType inType; |
| 186 |
char *inDataPtr__in__; |
| 187 |
long inDataPtr__len__; |
| 188 |
int inDataPtr__in_len__; |
| 189 |
if (!PyArg_ParseTuple(_args, "O&O&s#", |
| 190 |
PyMac_GetOSType, &inName, |
| 191 |
PyMac_GetOSType, &inType, |
| 192 |
&inDataPtr__in__, &inDataPtr__in_len__)) |
| 193 |
return NULL; |
| 194 |
inDataPtr__len__ = inDataPtr__in_len__; |
| 195 |
_err = SetEventParameter(_self->ob_itself, |
| 196 |
inName, |
| 197 |
inType, |
| 198 |
inDataPtr__len__, inDataPtr__in__); |
| 199 |
if (_err != noErr) return PyMac_Error(_err); |
| 200 |
Py_INCREF(Py_None); |
| 201 |
_res = Py_None; |
| 202 |
return _res; |
| 203 |
} |
| 204 |
|
| 205 |
static PyObject *EventRef_GetEventClass(EventRefObject *_self, PyObject *_args) |
| 206 |
{ |
| 207 |
PyObject *_res = NULL; |
| 208 |
UInt32 _rv; |
| 209 |
if (!PyArg_ParseTuple(_args, "")) |
| 210 |
return NULL; |
| 211 |
_rv = GetEventClass(_self->ob_itself); |
| 212 |
_res = Py_BuildValue("l", |
| 213 |
_rv); |
| 214 |
return _res; |
| 215 |
} |
| 216 |
|
| 217 |
static PyObject *EventRef_GetEventKind(EventRefObject *_self, PyObject *_args) |
| 218 |
{ |
| 219 |
PyObject *_res = NULL; |
| 220 |
UInt32 _rv; |
| 221 |
if (!PyArg_ParseTuple(_args, "")) |
| 222 |
return NULL; |
| 223 |
_rv = GetEventKind(_self->ob_itself); |
| 224 |
_res = Py_BuildValue("l", |
| 225 |
_rv); |
| 226 |
return _res; |
| 227 |
} |
| 228 |
|
| 229 |
static PyObject *EventRef_GetEventTime(EventRefObject *_self, PyObject *_args) |
| 230 |
{ |
| 231 |
PyObject *_res = NULL; |
| 232 |
double _rv; |
| 233 |
if (!PyArg_ParseTuple(_args, "")) |
| 234 |
return NULL; |
| 235 |
_rv = GetEventTime(_self->ob_itself); |
| 236 |
_res = Py_BuildValue("d", |
| 237 |
_rv); |
| 238 |
return _res; |
| 239 |
} |
| 240 |
|
| 241 |
static PyObject *EventRef_SetEventTime(EventRefObject *_self, PyObject *_args) |
| 242 |
{ |
| 243 |
PyObject *_res = NULL; |
| 244 |
OSStatus _err; |
| 245 |
double inTime; |
| 246 |
if (!PyArg_ParseTuple(_args, "d", |
| 247 |
&inTime)) |
| 248 |
return NULL; |
| 249 |
_err = SetEventTime(_self->ob_itself, |
| 250 |
inTime); |
| 251 |
if (_err != noErr) return PyMac_Error(_err); |
| 252 |
Py_INCREF(Py_None); |
| 253 |
_res = Py_None; |
| 254 |
return _res; |
| 255 |
} |
| 256 |
|
| 257 |
static PyObject *EventRef_IsUserCancelEventRef(EventRefObject *_self, PyObject *_args) |
| 258 |
{ |
| 259 |
PyObject *_res = NULL; |
| 260 |
Boolean _rv; |
| 261 |
if (!PyArg_ParseTuple(_args, "")) |
| 262 |
return NULL; |
| 263 |
_rv = IsUserCancelEventRef(_self->ob_itself); |
| 264 |
_res = Py_BuildValue("b", |
| 265 |
_rv); |
| 266 |
return _res; |
| 267 |
} |
| 268 |
|
| 269 |
static PyObject *EventRef_ConvertEventRefToEventRecord(EventRefObject *_self, PyObject *_args) |
| 270 |
{ |
| 271 |
PyObject *_res = NULL; |
| 272 |
Boolean _rv; |
| 273 |
EventRecord outEvent; |
| 274 |
if (!PyArg_ParseTuple(_args, "")) |
| 275 |
return NULL; |
| 276 |
_rv = ConvertEventRefToEventRecord(_self->ob_itself, |
| 277 |
&outEvent); |
| 278 |
_res = Py_BuildValue("bO&", |
| 279 |
_rv, |
| 280 |
PyMac_BuildEventRecord, &outEvent); |
| 281 |
return _res; |
| 282 |
} |
| 283 |
|
| 284 |
static PyObject *EventRef_IsEventInMask(EventRefObject *_self, PyObject *_args) |
| 285 |
{ |
| 286 |
PyObject *_res = NULL; |
| 287 |
Boolean _rv; |
| 288 |
UInt16 inMask; |
| 289 |
if (!PyArg_ParseTuple(_args, "H", |
| 290 |
&inMask)) |
| 291 |
return NULL; |
| 292 |
_rv = IsEventInMask(_self->ob_itself, |
| 293 |
inMask); |
| 294 |
_res = Py_BuildValue("b", |
| 295 |
_rv); |
| 296 |
return _res; |
| 297 |
} |
| 298 |
|
| 299 |
static PyObject *EventRef_SendEventToEventTarget(EventRefObject *_self, PyObject *_args) |
| 300 |
{ |
| 301 |
PyObject *_res = NULL; |
| 302 |
OSStatus _err; |
| 303 |
EventTargetRef inTarget; |
| 304 |
if (!PyArg_ParseTuple(_args, "O&", |
| 305 |
EventTargetRef_Convert, &inTarget)) |
| 306 |
return NULL; |
| 307 |
_err = SendEventToEventTarget(_self->ob_itself, |
| 308 |
inTarget); |
| 309 |
if (_err != noErr) return PyMac_Error(_err); |
| 310 |
Py_INCREF(Py_None); |
| 311 |
_res = Py_None; |
| 312 |
return _res; |
| 313 |
} |
| 314 |
|
| 315 |
static PyObject *EventRef_GetEventParameter(EventRefObject *_self, PyObject *_args) |
| 316 |
{ |
| 317 |
PyObject *_res = NULL; |
| 318 |
|
| 319 |
UInt32 bufferSize; |
| 320 |
EventParamName inName; |
| 321 |
EventParamType inType; |
| 322 |
OSErr _err; |
| 323 |
void * buffer; |
| 324 |
|
| 325 |
if (!PyArg_ParseTuple(_args, "O&O&", PyMac_GetOSType, &inName, PyMac_GetOSType, &inType)) |
| 326 |
return NULL; |
| 327 |
|
| 328 |
|
| 329 |
_err = GetEventParameter(_self->ob_itself, inName, inType, NULL, 0, &bufferSize, NULL); |
| 330 |
|
| 331 |
if (_err != noErr) |
| 332 |
return PyMac_Error(_err); |
| 333 |
buffer = PyMem_NEW(char, bufferSize); |
| 334 |
if (buffer == NULL) |
| 335 |
return PyErr_NoMemory(); |
| 336 |
|
| 337 |
_err = GetEventParameter(_self->ob_itself, inName, inType, NULL, bufferSize, NULL, buffer); |
| 338 |
|
| 339 |
if (_err != noErr) { |
| 340 |
PyMem_DEL(buffer); |
| 341 |
return PyMac_Error(_err); |
| 342 |
} |
| 343 |
_res = Py_BuildValue("s#", buffer, bufferSize); |
| 344 |
PyMem_DEL(buffer); |
| 345 |
return _res; |
| 346 |
|
| 347 |
} |
| 348 |
|
| 349 |
static PyMethodDef EventRef_methods[] = { |
| 350 |
{"RetainEvent", (PyCFunction)EventRef_RetainEvent, 1, |
| 351 |
PyDoc_STR("() -> (EventRef _rv)")}, |
| 352 |
{"GetEventRetainCount", (PyCFunction)EventRef_GetEventRetainCount, 1, |
| 353 |
PyDoc_STR("() -> (UInt32 _rv)")}, |
| 354 |
{"ReleaseEvent", (PyCFunction)EventRef_ReleaseEvent, 1, |
| 355 |
PyDoc_STR("() -> None")}, |
| 356 |
{"SetEventParameter", (PyCFunction)EventRef_SetEventParameter, 1, |
| 357 |
PyDoc_STR("(OSType inName, OSType inType, Buffer inDataPtr) -> None")}, |
| 358 |
{"GetEventClass", (PyCFunction)EventRef_GetEventClass, 1, |
| 359 |
PyDoc_STR("() -> (UInt32 _rv)")}, |
| 360 |
{"GetEventKind", (PyCFunction)EventRef_GetEventKind, 1, |
| 361 |
PyDoc_STR("() -> (UInt32 _rv)")}, |
| 362 |
{"GetEventTime", (PyCFunction)EventRef_GetEventTime, 1, |
| 363 |
PyDoc_STR("() -> (double _rv)")}, |
| 364 |
{"SetEventTime", (PyCFunction)EventRef_SetEventTime, 1, |
| 365 |
PyDoc_STR("(double inTime) -> None")}, |
| 366 |
{"IsUserCancelEventRef", (PyCFunction)EventRef_IsUserCancelEventRef, 1, |
| 367 |
PyDoc_STR("() -> (Boolean _rv)")}, |
| 368 |
{"ConvertEventRefToEventRecord", (PyCFunction)EventRef_ConvertEventRefToEventRecord, 1, |
| 369 |
PyDoc_STR("() -> (Boolean _rv, EventRecord outEvent)")}, |
| 370 |
{"IsEventInMask", (PyCFunction)EventRef_IsEventInMask, 1, |
| 371 |
PyDoc_STR("(UInt16 inMask) -> (Boolean _rv)")}, |
| 372 |
{"SendEventToEventTarget", (PyCFunction)EventRef_SendEventToEventTarget, 1, |
| 373 |
PyDoc_STR("(EventTargetRef inTarget) -> None")}, |
| 374 |
{"GetEventParameter", (PyCFunction)EventRef_GetEventParameter, 1, |
| 375 |
PyDoc_STR("(EventParamName eventName, EventParamType eventType) -> (String eventParamData)")}, |
| 376 |
{NULL, NULL, 0} |
| 377 |
}; |
| 378 |
|
| 379 |
#define EventRef_getsetlist NULL |
| 380 |
|
| 381 |
|
| 382 |
#define EventRef_compare NULL |
| 383 |
|
| 384 |
#define EventRef_repr NULL |
| 385 |
|
| 386 |
#define EventRef_hash NULL |
| 387 |
#define EventRef_tp_init 0 |
| 388 |
|
| 389 |
#define EventRef_tp_alloc PyType_GenericAlloc |
| 390 |
|
| 391 |
static PyObject *EventRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
| 392 |
{ |
| 393 |
PyObject *_self; |
| 394 |
EventRef itself; |
| 395 |
char *kw[] = {"itself", 0}; |
| 396 |
|
| 397 |
if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventRef_Convert, &itself)) return NULL; |
| 398 |
if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; |
| 399 |
((EventRefObject *)_self)->ob_itself = itself; |
| 400 |
return _self; |
| 401 |
} |
| 402 |
|
| 403 |
#define EventRef_tp_free PyObject_Del |
| 404 |
|
| 405 |
|
| 406 |
PyTypeObject EventRef_Type = { |
| 407 |
PyObject_HEAD_INIT(NULL) |
| 408 |
0, |
| 409 |
"_CarbonEvt.EventRef", |
| 410 |
sizeof(EventRefObject), |
| 411 |
0, |
| 412 |
|
| 413 |
(destructor) EventRef_dealloc, |
| 414 |
0, |
| 415 |
(getattrfunc)0, |
| 416 |
(setattrfunc)0, |
| 417 |
(cmpfunc) EventRef_compare, |
| 418 |
(reprfunc) EventRef_repr, |
| 419 |
(PyNumberMethods *)0, |
| 420 |
(PySequenceMethods *)0, |
| 421 |
(PyMappingMethods *)0, |
| 422 |
(hashfunc) EventRef_hash, |
| 423 |
0, |
| 424 |
0, |
| 425 |
PyObject_GenericGetAttr, |
| 426 |
PyObject_GenericSetAttr, |
| 427 |
0, |
| 428 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, |
| 429 |
0, |
| 430 |
0, |
| 431 |
0, |
| 432 |
0, |
| 433 |
0, |
| 434 |
0, |
| 435 |
0, |
| 436 |
EventRef_methods, |
| 437 |
0, |
| 438 |
EventRef_getsetlist, |
| 439 |
0, |
| 440 |
0, |
| 441 |
0, |
| 442 |
0, |
| 443 |
0, |
| 444 |
EventRef_tp_init, |
| 445 |
EventRef_tp_alloc, |
| 446 |
EventRef_tp_new, |
| 447 |
EventRef_tp_free, |
| 448 |
}; |
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
PyTypeObject EventQueueRef_Type; |
| 456 |
|
| 457 |
#define EventQueueRef_Check(x) ((x)->ob_type == &EventQueueRef_Type || PyObject_TypeCheck((x), &EventQueueRef_Type)) |
| 458 |
|
| 459 |
typedef struct EventQueueRefObject { |
| 460 |
PyObject_HEAD |
| 461 |
EventQueueRef ob_itself; |
| 462 |
} EventQueueRefObject; |
| 463 |
|
| 464 |
PyObject *EventQueueRef_New(EventQueueRef itself) |
| 465 |
{ |
| 466 |
EventQueueRefObject *it; |
| 467 |
it = PyObject_NEW(EventQueueRefObject, &EventQueueRef_Type); |
| 468 |
if (it == NULL) return NULL; |
| 469 |
it->ob_itself = itself; |
| 470 |
return (PyObject *)it; |
| 471 |
} |
| 472 |
|
| 473 |
int EventQueueRef_Convert(PyObject *v, EventQueueRef *p_itself) |
| 474 |
{ |
| 475 |
if (!EventQueueRef_Check(v)) |
| 476 |
{ |
| 477 |
PyErr_SetString(PyExc_TypeError, "EventQueueRef required"); |
| 478 |
return 0; |
| 479 |
} |
| 480 |
*p_itself = ((EventQueueRefObject *)v)->ob_itself; |
| 481 |
return 1; |
| 482 |
} |
| 483 |
|
| 484 |
static void EventQueueRef_dealloc(EventQueueRefObject *self) |
| 485 |
{ |
| 486 |
|
| 487 |
self->ob_type->tp_free((PyObject *)self); |
| 488 |
} |
| 489 |
|
| 490 |
static PyObject *EventQueueRef_PostEventToQueue(EventQueueRefObject *_self, PyObject *_args) |
| 491 |
{ |
| 492 |
PyObject *_res = NULL; |
| 493 |
OSStatus _err; |
| 494 |
EventRef inEvent; |
| 495 |
SInt16 inPriority; |
| 496 |
if (!PyArg_ParseTuple(_args, "O&h", |
| 497 |
EventRef_Convert, &inEvent, |
| 498 |
&inPriority)) |
| 499 |
return NULL; |
| 500 |
_err = PostEventToQueue(_self->ob_itself, |
| 501 |
inEvent, |
| 502 |
inPriority); |
| 503 |
if (_err != noErr) return PyMac_Error(_err); |
| 504 |
Py_INCREF(Py_None); |
| 505 |
_res = Py_None; |
| 506 |
return _res; |
| 507 |
} |
| 508 |
|
| 509 |
static PyObject *EventQueueRef_FlushEventsMatchingListFromQueue(EventQueueRefObject *_self, PyObject *_args) |
| 510 |
{ |
| 511 |
PyObject *_res = NULL; |
| 512 |
OSStatus _err; |
| 513 |
UInt32 inNumTypes; |
| 514 |
EventTypeSpec inList; |
| 515 |
if (!PyArg_ParseTuple(_args, "lO&", |
| 516 |
&inNumTypes, |
| 517 |
EventTypeSpec_Convert, &inList)) |
| 518 |
return NULL; |
| 519 |
_err = FlushEventsMatchingListFromQueue(_self->ob_itself, |
| 520 |
inNumTypes, |
| 521 |
&inList); |
| 522 |
if (_err != noErr) return PyMac_Error(_err); |
| 523 |
Py_INCREF(Py_None); |
| 524 |
_res = Py_None; |
| 525 |
return _res; |
| 526 |
} |
| 527 |
|
| 528 |
static PyObject *EventQueueRef_FlushEventQueue(EventQueueRefObject *_self, PyObject *_args) |
| 529 |
{ |
| 530 |
PyObject *_res = NULL; |
| 531 |
OSStatus _err; |
| 532 |
if (!PyArg_ParseTuple(_args, "")) |
| 533 |
return NULL; |
| 534 |
_err = FlushEventQueue(_self->ob_itself); |
| 535 |
if (_err != noErr) return PyMac_Error(_err); |
| 536 |
Py_INCREF(Py_None); |
| 537 |
_res = Py_None; |
| 538 |
return _res; |
| 539 |
} |
| 540 |
|
| 541 |
static PyObject *EventQueueRef_GetNumEventsInQueue(EventQueueRefObject *_self, PyObject *_args) |
| 542 |
{ |
| 543 |
PyObject *_res = NULL; |
| 544 |
UInt32 _rv; |
| 545 |
if (!PyArg_ParseTuple(_args, "")) |
| 546 |
return NULL; |
| 547 |
_rv = GetNumEventsInQueue(_self->ob_itself); |
| 548 |
_res = Py_BuildValue("l", |
| 549 |
_rv); |
| 550 |
return _res; |
| 551 |
} |
| 552 |
|
| 553 |
static PyObject *EventQueueRef_RemoveEventFromQueue(EventQueueRefObject *_self, PyObject *_args) |
| 554 |
{ |
| 555 |
PyObject *_res = NULL; |
| 556 |
OSStatus _err; |
| 557 |
EventRef inEvent; |
| 558 |
if (!PyArg_ParseTuple(_args, "O&", |
| 559 |
EventRef_Convert, &inEvent)) |
| 560 |
return NULL; |
| 561 |
_err = RemoveEventFromQueue(_self->ob_itself, |
| 562 |
inEvent); |
| 563 |
if (_err != noErr) return PyMac_Error(_err); |
| 564 |
Py_INCREF(Py_None); |
| 565 |
_res = Py_None; |
| 566 |
return _res; |
| 567 |
} |
| 568 |
|
| 569 |
static PyObject *EventQueueRef_IsEventInQueue(EventQueueRefObject *_self, PyObject *_args) |
| 570 |
{ |
| 571 |
PyObject *_res = NULL; |
| 572 |
Boolean _rv; |
| 573 |
EventRef inEvent; |
| 574 |
if (!PyArg_ParseTuple(_args, "O&", |
| 575 |
EventRef_Convert, &inEvent)) |
| 576 |
return NULL; |
| 577 |
_rv = IsEventInQueue(_self->ob_itself, |
| 578 |
inEvent); |
| 579 |
_res = Py_BuildValue("b", |
| 580 |
_rv); |
| 581 |
return _res; |
| 582 |
} |
| 583 |
|
| 584 |
static PyMethodDef EventQueueRef_methods[] = { |
| 585 |
{"PostEventToQueue", (PyCFunction)EventQueueRef_PostEventToQueue, 1, |
| 586 |
PyDoc_STR("(EventRef inEvent, SInt16 inPriority) -> None")}, |
| 587 |
{"FlushEventsMatchingListFromQueue", (PyCFunction)EventQueueRef_FlushEventsMatchingListFromQueue, 1, |
| 588 |
PyDoc_STR("(UInt32 inNumTypes, EventTypeSpec inList) -> None")}, |
| 589 |
{"FlushEventQueue", (PyCFunction)EventQueueRef_FlushEventQueue, 1, |
| 590 |
PyDoc_STR("() -> None")}, |
| 591 |
{"GetNumEventsInQueue", (PyCFunction)EventQueueRef_GetNumEventsInQueue, 1, |
| 592 |
PyDoc_STR("() -> (UInt32 _rv)")}, |
| 593 |
{"RemoveEventFromQueue", (PyCFunction)EventQueueRef_RemoveEventFromQueue, 1, |
| 594 |
PyDoc_STR("(EventRef inEvent) -> None")}, |
| 595 |
{"IsEventInQueue", (PyCFunction)EventQueueRef_IsEventInQueue, 1, |
| 596 |
PyDoc_STR("(EventRef inEvent) -> (Boolean _rv)")}, |
| 597 |
{NULL, NULL, 0} |
| 598 |
}; |
| 599 |
|
| 600 |
#define EventQueueRef_getsetlist NULL |
| 601 |
|
| 602 |
|
| 603 |
#define EventQueueRef_compare NULL |
| 604 |
|
| 605 |
#define EventQueueRef_repr NULL |
| 606 |
|
| 607 |
#define EventQueueRef_hash NULL |
| 608 |
#define EventQueueRef_tp_init 0 |
| 609 |
|
| 610 |
#define EventQueueRef_tp_alloc PyType_GenericAlloc |
| 611 |
|
| 612 |
static PyObject *EventQueueRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
| 613 |
{ |
| 614 |
PyObject *_self; |
| 615 |
EventQueueRef itself; |
| 616 |
char *kw[] = {"itself", 0}; |
| 617 |
|
| 618 |
if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventQueueRef_Convert, &itself)) return NULL; |
| 619 |
if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; |
| 620 |
((EventQueueRefObject *)_self)->ob_itself = itself; |
| 621 |
return _self; |
| 622 |
} |
| 623 |
|
| 624 |
#define EventQueueRef_tp_free PyObject_Del |
| 625 |
|
| 626 |
|
| 627 |
PyTypeObject EventQueueRef_Type = { |
| 628 |
PyObject_HEAD_INIT(NULL) |
| 629 |
0, |
| 630 |
"_CarbonEvt.EventQueueRef", |
| 631 |
sizeof(EventQueueRefObject), |
| 632 |
0, |
| 633 |
|
| 634 |
(destructor) EventQueueRef_dealloc, |
| 635 |
0, |
| 636 |
(getattrfunc)0, |
| 637 |
(setattrfunc)0, |
| 638 |
(cmpfunc) EventQueueRef_compare, |
| 639 |
(reprfunc) EventQueueRef_repr, |
| 640 |
(PyNumberMethods *)0, |
| 641 |
(PySequenceMethods *)0, |
| 642 |
(PyMappingMethods *)0, |
| 643 |
(hashfunc) EventQueueRef_hash, |
| 644 |
0, |
| 645 |
0, |
| 646 |
PyObject_GenericGetAttr, |
| 647 |
PyObject_GenericSetAttr, |
| 648 |
0, |
| 649 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, |
| 650 |
0, |
| 651 |
0, |
| 652 |
0, |
| 653 |
0, |
| 654 |
0, |
| 655 |
0, |
| 656 |
0, |
| 657 |
EventQueueRef_methods, |
| 658 |
0, |
| 659 |
EventQueueRef_getsetlist, |
| 660 |
0, |
| 661 |
0, |
| 662 |
0, |
| 663 |
0, |
| 664 |
0, |
| 665 |
EventQueueRef_tp_init, |
| 666 |
EventQueueRef_tp_alloc, |
| 667 |
EventQueueRef_tp_new, |
| 668 |
EventQueueRef_tp_free, |
| 669 |
}; |
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
PyTypeObject EventLoopRef_Type; |
| 677 |
|
| 678 |
#define EventLoopRef_Check(x) ((x)->ob_type == &EventLoopRef_Type || PyObject_TypeCheck((x), &EventLoopRef_Type)) |
| 679 |
|
| 680 |
typedef struct EventLoopRefObject { |
| 681 |
PyObject_HEAD |
| 682 |
EventLoopRef ob_itself; |
| 683 |
} EventLoopRefObject; |
| 684 |
|
| 685 |
PyObject *EventLoopRef_New(EventLoopRef itself) |
| 686 |
{ |
| 687 |
EventLoopRefObject *it; |
| 688 |
it = PyObject_NEW(EventLoopRefObject, &EventLoopRef_Type); |
| 689 |
if (it == NULL) return NULL; |
| 690 |
it->ob_itself = itself; |
| 691 |
return (PyObject *)it; |
| 692 |
} |
| 693 |
|
| 694 |
int EventLoopRef_Convert(PyObject *v, EventLoopRef *p_itself) |
| 695 |
{ |
| 696 |
if (!EventLoopRef_Check(v)) |
| 697 |
{ |
| 698 |
PyErr_SetString(PyExc_TypeError, "EventLoopRef required"); |
| 699 |
return 0; |
| 700 |
} |
| 701 |
*p_itself = ((EventLoopRefObject *)v)->ob_itself; |
| 702 |
return 1; |
| 703 |
} |
| 704 |
|
| 705 |
static void EventLoopRef_dealloc(EventLoopRefObject *self) |
| 706 |
{ |
| 707 |
|
| 708 |
self->ob_type->tp_free((PyObject *)self); |
| 709 |
} |
| 710 |
|
| 711 |
static PyObject *EventLoopRef_QuitEventLoop(EventLoopRefObject *_self, PyObject *_args) |
| 712 |
{ |
| 713 |
PyObject *_res = NULL; |
| 714 |
OSStatus _err; |
| 715 |
if (!PyArg_ParseTuple(_args, "")) |
| 716 |
return NULL; |
| 717 |
_err = QuitEventLoop(_self->ob_itself); |
| 718 |
if (_err != noErr) return PyMac_Error(_err); |
| 719 |
Py_INCREF(Py_None); |
| 720 |
_res = Py_None; |
| 721 |
return _res; |
| 722 |
} |
| 723 |
|
| 724 |
static PyMethodDef EventLoopRef_methods[] = { |
| 725 |
{"QuitEventLoop", (PyCFunction)EventLoopRef_QuitEventLoop, 1, |
| 726 |
PyDoc_STR("() -> None")}, |
| 727 |
{NULL, NULL, 0} |
| 728 |
}; |
| 729 |
|
| 730 |
#define EventLoopRef_getsetlist NULL |
| 731 |
|
| 732 |
|
| 733 |
#define EventLoopRef_compare NULL |
| 734 |
|
| 735 |
#define EventLoopRef_repr NULL |
| 736 |
|
| 737 |
#define EventLoopRef_hash NULL |
| 738 |
#define EventLoopRef_tp_init 0 |
| 739 |
|
| 740 |
#define EventLoopRef_tp_alloc PyType_GenericAlloc |
| 741 |
|
| 742 |
static PyObject *EventLoopRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
| 743 |
{ |
| 744 |
PyObject *_self; |
| 745 |
EventLoopRef itself; |
| 746 |
char *kw[] = {"itself", 0}; |
| 747 |
|
| 748 |
if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventLoopRef_Convert, &itself)) return NULL; |
| 749 |
if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; |
| 750 |
((EventLoopRefObject *)_self)->ob_itself = itself; |
| 751 |
return _self; |
| 752 |
} |
| 753 |
|
| 754 |
#define EventLoopRef_tp_free PyObject_Del |
| 755 |
|
| 756 |
|
| 757 |
PyTypeObject EventLoopRef_Type = { |
| 758 |
PyObject_HEAD_INIT(NULL) |
| 759 |
0, |
| 760 |
"_CarbonEvt.EventLoopRef", |
| 761 |
sizeof(EventLoopRefObject), |
| 762 |
0, |
| 763 |
|
| 764 |
(destructor) EventLoopRef_dealloc, |
| 765 |
0, |
| 766 |
(getattrfunc)0, |
| 767 |
(setattrfunc)0, |
| 768 |
(cmpfunc) EventLoopRef_compare, |
| 769 |
(reprfunc) EventLoopRef_repr, |
| 770 |
(PyNumberMethods *)0, |
| 771 |
(PySequenceMethods *)0, |
| 772 |
(PyMappingMethods *)0, |
| 773 |
(hashfunc) EventLoopRef_hash, |
| 774 |
0, |
| 775 |
0, |
| 776 |
PyObject_GenericGetAttr, |
| 777 |
PyObject_GenericSetAttr, |
| 778 |
0, |
| 779 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, |
| 780 |
0, |
| 781 |
0, |
| 782 |
0, |
| 783 |
0, |
| 784 |
0, |
| 785 |
0, |
| 786 |
0, |
| 787 |
EventLoopRef_methods, |
| 788 |
0, |
| 789 |
EventLoopRef_getsetlist, |
| 790 |
0, |
| 791 |
0, |
| 792 |
0, |
| 793 |
0, |
| 794 |
0, |
| 795 |
EventLoopRef_tp_init, |
| 796 |
EventLoopRef_tp_alloc, |
| 797 |
EventLoopRef_tp_new, |
| 798 |
EventLoopRef_tp_free, |
| 799 |
}; |
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
PyTypeObject EventLoopTimerRef_Type; |
| 807 |
|
| 808 |
#define EventLoopTimerRef_Check(x) ((x)->ob_type == &EventLoopTimerRef_Type || PyObject_TypeCheck((x), &EventLoopTimerRef_Type)) |
| 809 |
|
| 810 |
typedef struct EventLoopTimerRefObject { |
| 811 |
PyObject_HEAD |
| 812 |
EventLoopTimerRef ob_itself; |
| 813 |
} EventLoopTimerRefObject; |
| 814 |
|
| 815 |
PyObject *EventLoopTimerRef_New(EventLoopTimerRef itself) |
| 816 |
{ |
| 817 |
EventLoopTimerRefObject *it; |
| 818 |
it = PyObject_NEW(EventLoopTimerRefObject, &EventLoopTimerRef_Type); |
| 819 |
if (it == NULL) return NULL; |
| 820 |
it->ob_itself = itself; |
| 821 |
return (PyObject *)it; |
| 822 |
} |
| 823 |
|
| 824 |
int EventLoopTimerRef_Convert(PyObject *v, EventLoopTimerRef *p_itself) |
| 825 |
{ |
| 826 |
if (!EventLoopTimerRef_Check(v)) |
| 827 |
{ |
| 828 |
PyErr_SetString(PyExc_TypeError, "EventLoopTimerRef required"); |
| 829 |
return 0; |
| 830 |
} |
| 831 |
*p_itself = ((EventLoopTimerRefObject *)v)->ob_itself; |
| 832 |
return 1; |
| 833 |
} |
| 834 |
|
| 835 |
static void EventLoopTimerRef_dealloc(EventLoopTimerRefObject *self) |
| 836 |
{ |
| 837 |
|
| 838 |
self->ob_type->tp_free((PyObject *)self); |
| 839 |
} |
| 840 |
|
| 841 |
static PyObject *EventLoopTimerRef_RemoveEventLoopTimer(EventLoopTimerRefObject *_self, PyObject *_args) |
| 842 |
{ |
| 843 |
PyObject *_res = NULL; |
| 844 |
OSStatus _err; |
| 845 |
if (!PyArg_ParseTuple(_args, "")) |
| 846 |
return NULL; |
| 847 |
_err = RemoveEventLoopTimer(_self->ob_itself); |
| 848 |
if (_err != noErr) return PyMac_Error(_err); |
| 849 |
Py_INCREF(Py_None); |
| 850 |
_res = Py_None; |
| 851 |
return _res; |
| 852 |
} |
| 853 |
|
| 854 |
static PyObject *EventLoopTimerRef_SetEventLoopTimerNextFireTime(EventLoopTimerRefObject *_self, PyObject *_args) |
| 855 |
{ |
| 856 |
PyObject *_res = NULL; |
| 857 |
OSStatus _err; |
| 858 |
double inNextFire; |
| 859 |
if (!PyArg_ParseTuple(_args, "d", |
| 860 |
&inNextFire)) |
| 861 |
return NULL; |
| 862 |
_err = SetEventLoopTimerNextFireTime(_self->ob_itself, |
| 863 |
inNextFire); |
| 864 |
if (_err != noErr) return PyMac_Error(_err); |
| 865 |
Py_INCREF(Py_None); |
| 866 |
_res = Py_None; |
| 867 |
return _res; |
| 868 |
} |
| 869 |
|
| 870 |
static PyMethodDef EventLoopTimerRef_methods[] = { |
| 871 |
{"RemoveEventLoopTimer", (PyCFunction)EventLoopTimerRef_RemoveEventLoopTimer, 1, |
| 872 |
PyDoc_STR("() -> None")}, |
| 873 |
{"SetEventLoopTimerNextFireTime", (PyCFunction)EventLoopTimerRef_SetEventLoopTimerNextFireTime, 1, |
| 874 |
PyDoc_STR("(double inNextFire) -> None")}, |
| 875 |
{NULL, NULL, 0} |
| 876 |
}; |
| 877 |
|
| 878 |
#define EventLoopTimerRef_getsetlist NULL |
| 879 |
|
| 880 |
|
| 881 |
#define EventLoopTimerRef_compare NULL |
| 882 |
|
| 883 |
#define EventLoopTimerRef_repr NULL |
| 884 |
|
| 885 |
#define EventLoopTimerRef_hash NULL |
| 886 |
#define EventLoopTimerRef_tp_init 0 |
| 887 |
|
| 888 |
#define EventLoopTimerRef_tp_alloc PyType_GenericAlloc |
| 889 |
|
| 890 |
static PyObject *EventLoopTimerRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
| 891 |
{ |
| 892 |
PyObject *_self; |
| 893 |
EventLoopTimerRef itself; |
| 894 |
char *kw[] = {"itself", 0}; |
| 895 |
|
| 896 |
if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventLoopTimerRef_Convert, &itself)) return NULL; |
| 897 |
if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; |
| 898 |
((EventLoopTimerRefObject *)_self)->ob_itself = itself; |
| 899 |
return _self; |
| 900 |
} |
| 901 |
|
| 902 |
#define EventLoopTimerRef_tp_free PyObject_Del |
| 903 |
|
| 904 |
|
| 905 |
PyTypeObject EventLoopTimerRef_Type = { |
| 906 |
PyObject_HEAD_INIT(NULL) |
| 907 |
0, |
| 908 |
"_CarbonEvt.EventLoopTimerRef", |
| 909 |
sizeof(EventLoopTimerRefObject), |
| 910 |
0, |
| 911 |
|
| 912 |
(destructor) EventLoopTimerRef_dealloc, |
| 913 |
0, |
| 914 |
(getattrfunc)0, |
| 915 |
(setattrfunc)0, |
| 916 |
(cmpfunc) EventLoopTimerRef_compare, |
| 917 |
(reprfunc) EventLoopTimerRef_repr, |
| 918 |
(PyNumberMethods *)0, |
| 919 |
(PySequenceMethods *)0, |
| 920 |
(PyMappingMethods *)0, |
| 921 |
(hashfunc) EventLoopTimerRef_hash, |
| 922 |
0, |
| 923 |
0, |
| 924 |
PyObject_GenericGetAttr, |
| 925 |
PyObject_GenericSetAttr, |
| 926 |
0, |
| 927 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, |
| 928 |
0, |
| 929 |
0, |
| 930 |
0, |
| 931 |
0, |
| 932 |
0, |
| 933 |
0, |
| 934 |
0, |
| 935 |
EventLoopTimerRef_methods, |
| 936 |
0, |
| 937 |
EventLoopTimerRef_getsetlist, |
| 938 |
0, |
| 939 |
0, |
| 940 |
0, |
| 941 |
0, |
| 942 |
0, |
| 943 |
EventLoopTimerRef_tp_init, |
| 944 |
EventLoopTimerRef_tp_alloc, |
| 945 |
EventLoopTimerRef_tp_new, |
| 946 |
EventLoopTimerRef_tp_free, |
| 947 |
}; |
| 948 |
|
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
|
| 953 |
|
| 954 |
PyTypeObject EventHandlerRef_Type; |
| 955 |
|
| 956 |
#define EventHandlerRef_Check(x) ((x)->ob_type == &EventHandlerRef_Type || PyObject_TypeCheck((x), &EventHandlerRef_Type)) |
| 957 |
|
| 958 |
typedef struct EventHandlerRefObject { |
| 959 |
PyObject_HEAD |
| 960 |
EventHandlerRef ob_itself; |
| 961 |
PyObject *ob_callback; |
| 962 |
} EventHandlerRefObject; |
| 963 |
|
| 964 |
PyObject *EventHandlerRef_New(EventHandlerRef itself) |
| 965 |
{ |
| 966 |
EventHandlerRefObject *it; |
| 967 |
it = PyObject_NEW(EventHandlerRefObject, &EventHandlerRef_Type); |
| 968 |
if (it == NULL) return NULL; |
| 969 |
it->ob_itself = itself; |
| 970 |
it->ob_callback = NULL; |
| 971 |
return (PyObject *)it; |
| 972 |
} |
| 973 |
|
| 974 |
int EventHandlerRef_Convert(PyObject *v, EventHandlerRef *p_itself) |
| 975 |
{ |
| 976 |
if (!EventHandlerRef_Check(v)) |
| 977 |
{ |
| 978 |
PyErr_SetString(PyExc_TypeError, "EventHandlerRef required"); |
| 979 |
return 0; |
| 980 |
} |
| 981 |
*p_itself = ((EventHandlerRefObject *)v)->ob_itself; |
| 982 |
return 1; |
| 983 |
} |
| 984 |
|
| 985 |
static void EventHandlerRef_dealloc(EventHandlerRefObject *self) |
| 986 |
{ |
| 987 |
if (self->ob_itself != NULL) { |
| 988 |
RemoveEventHandler(self->ob_itself); |
| 989 |
Py_DECREF(self->ob_callback); |
| 990 |
} |
| 991 |
self->ob_type->tp_free((PyObject *)self); |
| 992 |
} |
| 993 |
|
| 994 |
static PyObject *EventHandlerRef_AddEventTypesToHandler(EventHandlerRefObject *_self, PyObject *_args) |
| 995 |
{ |
| 996 |
PyObject *_res = NULL; |
| 997 |
OSStatus _err; |
| 998 |
UInt32 inNumTypes; |
| 999 |
EventTypeSpec inList; |
| 1000 |
if (_self->ob_itself == NULL) { |
| 1001 |
PyErr_SetString(CarbonEvents_Error, "Handler has been removed"); |
| 1002 |
return NULL; |
| 1003 |
} |
| 1004 |
if (!PyArg_ParseTuple(_args, "lO&", |
| 1005 |
&inNumTypes, |
| 1006 |
EventTypeSpec_Convert, &inList)) |
| 1007 |
return NULL; |
| 1008 |
_err = AddEventTypesToHandler(_self->ob_itself, |
| 1009 |
inNumTypes, |
| 1010 |
&inList); |
| 1011 |
if (_err != noErr) return PyMac_Error(_err); |
| 1012 |
Py_INCREF(Py_None); |
| 1013 |
_res = Py_None; |
| 1014 |
return _res; |
| 1015 |
} |
| 1016 |
|
| 1017 |
static PyObject *EventHandlerRef_RemoveEventTypesFromHandler(EventHandlerRefObject *_self, PyObject *_args) |
| 1018 |
{ |
| 1019 |
PyObject *_res = NULL; |
| 1020 |
OSStatus _err; |
| 1021 |
UInt32 inNumTypes; |
| 1022 |
EventTypeSpec inList; |
| 1023 |
if (_self->ob_itself == NULL) { |
| 1024 |
PyErr_SetString(CarbonEvents_Error, "Handler has been removed"); |
| 1025 |
return NULL; |
| 1026 |
} |
| 1027 |
if (!PyArg_ParseTuple(_args, "lO&", |
| 1028 |
&inNumTypes, |
| 1029 |
EventTypeSpec_Convert, &inList)) |
| 1030 |
return NULL; |
| 1031 |
_err = RemoveEventTypesFromHandler(_self->ob_itself, |
| 1032 |
inNumTypes, |
| 1033 |
&inList); |
| 1034 |
if (_err != noErr) return PyMac_Error(_err); |
| 1035 |
Py_INCREF(Py_None); |
| 1036 |
_res = Py_None; |
| 1037 |
return _res; |
| 1038 |
} |
| 1039 |
|
| 1040 |
static PyObject *EventHandlerRef_RemoveEventHandler(EventHandlerRefObject *_self, PyObject *_args) |
| 1041 |
{ |
| 1042 |
PyObject *_res = NULL; |
| 1043 |
|
| 1044 |
OSStatus _err; |
| 1045 |
if (_self->ob_itself == NULL) { |
| 1046 |
PyErr_SetString(CarbonEvents_Error, "Handler has been removed"); |
| 1047 |
return NULL; |
| 1048 |
} |
| 1049 |
if (!PyArg_ParseTuple(_args, "")) |
| 1050 |
return NULL; |
| 1051 |
_err = RemoveEventHandler(_self->ob_itself); |
| 1052 |
if (_err != noErr) return PyMac_Error(_err); |
| 1053 |
_self->ob_itself = NULL; |
| 1054 |
Py_CLEAR(_self->ob_callback); |
| 1055 |
Py_INCREF(Py_None); |
| 1056 |
_res = Py_None; |
| 1057 |
return _res; |
| 1058 |
} |
| 1059 |
|
| 1060 |
static PyMethodDef EventHandlerRef_methods[] = { |
| 1061 |
{"AddEventTypesToHandler", (PyCFunction)EventHandlerRef_AddEventTypesToHandler, 1, |
| 1062 |
PyDoc_STR("(UInt32 inNumTypes, EventTypeSpec inList) -> None")}, |
| 1063 |
{"RemoveEventTypesFromHandler", (PyCFunction)EventHandlerRef_RemoveEventTypesFromHandler, 1, |
| 1064 |
PyDoc_STR("(UInt32 inNumTypes, EventTypeSpec inList) -> None")}, |
| 1065 |
{"RemoveEventHandler", (PyCFunction)EventHandlerRef_RemoveEventHandler, 1, |
| 1066 |
PyDoc_STR("() -> None")}, |
| 1067 |
{NULL, NULL, 0} |
| 1068 |
}; |
| 1069 |
|
| 1070 |
#define EventHandlerRef_getsetlist NULL |
| 1071 |
|
| 1072 |
|
| 1073 |
#define EventHandlerRef_compare NULL |
| 1074 |
|
| 1075 |
#define EventHandlerRef_repr NULL |
| 1076 |
|
| 1077 |
#define EventHandlerRef_hash NULL |
| 1078 |
#define EventHandlerRef_tp_init 0 |
| 1079 |
|
| 1080 |
#define EventHandlerRef_tp_alloc PyType_GenericAlloc |
| 1081 |
|
| 1082 |
static PyObject *EventHandlerRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
| 1083 |
{ |
| 1084 |
PyObject *_self; |
| 1085 |
EventHandlerRef itself; |
| 1086 |
char *kw[] = {"itself", 0}; |
| 1087 |
|
| 1088 |
if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventHandlerRef_Convert, &itself)) return NULL; |
| 1089 |
if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; |
| 1090 |
((EventHandlerRefObject *)_self)->ob_itself = itself; |
| 1091 |
return _self; |
| 1092 |
} |
| 1093 |
|
| 1094 |
#define EventHandlerRef_tp_free PyObject_Del |
| 1095 |
|
| 1096 |
|
| 1097 |
PyTypeObject EventHandlerRef_Type = { |
| 1098 |
PyObject_HEAD_INIT(NULL) |
| 1099 |
0, |
| 1100 |
"_CarbonEvt.EventHandlerRef", |
| 1101 |
sizeof(EventHandlerRefObject), |
| 1102 |
0, |
| 1103 |
|
| 1104 |
(destructor) EventHandlerRef_dealloc, |
| 1105 |
0, |
| 1106 |
(getattrfunc)0, |
| 1107 |
(setattrfunc)0, |
| 1108 |
(cmpfunc) EventHandlerRef_compare, |
| 1109 |
(reprfunc) EventHandlerRef_repr, |
| 1110 |
(PyNumberMethods *)0, |
| 1111 |
(PySequenceMethods *)0, |
| 1112 |
(PyMappingMethods *)0, |
| 1113 |
(hashfunc) EventHandlerRef_hash, |
| 1114 |
0, |
| 1115 |
0, |
| 1116 |
PyObject_GenericGetAttr, |
| 1117 |
PyObject_GenericSetAttr, |
| 1118 |
0, |
| 1119 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, |
| 1120 |
0, |
| 1121 |
0, |
| 1122 |
0, |
| 1123 |
0, |
| 1124 |
0, |
| 1125 |
0, |
| 1126 |
0, |
| 1127 |
EventHandlerRef_methods, |
| 1128 |
0, |
| 1129 |
EventHandlerRef_getsetlist, |
| 1130 |
0, |
| 1131 |
0, |
| 1132 |
0, |
| 1133 |
0, |
| 1134 |
0, |
| 1135 |
EventHandlerRef_tp_init, |
| 1136 |
EventHandlerRef_tp_alloc, |
| 1137 |
EventHandlerRef_tp_new, |
| 1138 |
EventHandlerRef_tp_free, |
| 1139 |
}; |
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
|
| 1144 |
|
| 1145 |
|
| 1146 |
PyTypeObject EventHandlerCallRef_Type; |
| 1147 |
|
| 1148 |
#define EventHandlerCallRef_Check(x) ((x)->ob_type == &EventHandlerCallRef_Type || PyObject_TypeCheck((x), &EventHandlerCallRef_Type)) |
| 1149 |
|
| 1150 |
typedef struct EventHandlerCallRefObject { |
| 1151 |
PyObject_HEAD |
| 1152 |
EventHandlerCallRef ob_itself; |
| 1153 |
} EventHandlerCallRefObject; |
| 1154 |
|
| 1155 |
PyObject *EventHandlerCallRef_New(EventHandlerCallRef itself) |
| 1156 |
{ |
| 1157 |
EventHandlerCallRefObject *it; |
| 1158 |
it = PyObject_NEW(EventHandlerCallRefObject, &EventHandlerCallRef_Type); |
| 1159 |
if (it == NULL) return NULL; |
| 1160 |
it->ob_itself = itself; |
| 1161 |
return (PyObject *)it; |
| 1162 |
} |
| 1163 |
|
| 1164 |
int EventHandlerCallRef_Convert(PyObject *v, EventHandlerCallRef *p_itself) |
| 1165 |
{ |
| 1166 |
if (!EventHandlerCallRef_Check(v)) |
| 1167 |
{ |
| 1168 |
PyErr_SetString(PyExc_TypeError, "EventHandlerCallRef required"); |
| 1169 |
return 0; |
| 1170 |
} |
| 1171 |
*p_itself = ((EventHandlerCallRefObject *)v)->ob_itself; |
| 1172 |
return 1; |
| 1173 |
} |
| 1174 |
|
| 1175 |
static void EventHandlerCallRef_dealloc(EventHandlerCallRefObject *self) |
| 1176 |
{ |
| 1177 |
|
| 1178 |
self->ob_type->tp_free((PyObject *)self); |
| 1179 |
} |
| 1180 |
|
| 1181 |
static PyObject *EventHandlerCallRef_CallNextEventHandler(EventHandlerCallRefObject *_self, PyObject *_args) |
| 1182 |
{ |
| 1183 |
PyObject *_res = NULL; |
| 1184 |
OSStatus _err; |
| 1185 |
EventRef inEvent; |
| 1186 |
if (!PyArg_ParseTuple(_args, "O&", |
| 1187 |
EventRef_Convert, &inEvent)) |
| 1188 |
return NULL; |
| 1189 |
_err = CallNextEventHandler(_self->ob_itself, |
| 1190 |
inEvent); |
| 1191 |
if (_err != noErr) return PyMac_Error(_err); |
| 1192 |
Py_INCREF(Py_None); |
| 1193 |
_res = Py_None; |
| 1194 |
return _res; |
| 1195 |
} |
| 1196 |
|
| 1197 |
static PyMethodDef EventHandlerCallRef_methods[] = { |
| 1198 |
{"CallNextEventHandler", (PyCFunction)EventHandlerCallRef_CallNextEventHandler, 1, |
| 1199 |
PyDoc_STR("(EventRef inEvent) -> None")}, |
| 1200 |
{NULL, NULL, 0} |
| 1201 |
}; |
| 1202 |
|
| 1203 |
#define EventHandlerCallRef_getsetlist NULL |
| 1204 |
|
| 1205 |
|
| 1206 |
#define EventHandlerCallRef_compare NULL |
| 1207 |
|
| 1208 |
#define EventHandlerCallRef_repr NULL |
| 1209 |
|
| 1210 |
#define EventHandlerCallRef_hash NULL |
| 1211 |
#define EventHandlerCallRef_tp_init 0 |
| 1212 |
|
| 1213 |
#define EventHandlerCallRef_tp_alloc PyType_GenericAlloc |
| 1214 |
|
| 1215 |
static PyObject *EventHandlerCallRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
| 1216 |
{ |
| 1217 |
PyObject *_self; |
| 1218 |
EventHandlerCallRef itself; |
| 1219 |
char *kw[] = {"itself", 0}; |
| 1220 |
|
| 1221 |
if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventHandlerCallRef_Convert, &itself)) return NULL; |
| 1222 |
if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; |
| 1223 |
((EventHandlerCallRefObject *)_self)->ob_itself = itself; |
| 1224 |
return _self; |
| 1225 |
} |
| 1226 |
|
| 1227 |
#define EventHandlerCallRef_tp_free PyObject_Del |
| 1228 |
|
| 1229 |
|
| 1230 |
PyTypeObject EventHandlerCallRef_Type = { |
| 1231 |
PyObject_HEAD_INIT(NULL) |
| 1232 |
0, |
| 1233 |
"_CarbonEvt.EventHandlerCallRef", |
| 1234 |
sizeof(EventHandlerCallRefObject), |
| 1235 |
0, |
| 1236 |
|
| 1237 |
(destructor) EventHandlerCallRef_dealloc, |
| 1238 |
0, |
| 1239 |
(getattrfunc)0, |
| 1240 |
(setattrfunc)0, |
| 1241 |
(cmpfunc) EventHandlerCallRef_compare, |
| 1242 |
(reprfunc) EventHandlerCallRef_repr, |
| 1243 |
(PyNumberMethods *)0, |
| 1244 |
(PySequenceMethods *)0, |
| 1245 |
(PyMappingMethods *)0, |
| 1246 |
(hashfunc) EventHandlerCallRef_hash, |
| 1247 |
0, |
| 1248 |
0, |
| 1249 |
PyObject_GenericGetAttr, |
| 1250 |
PyObject_GenericSetAttr, |
| 1251 |
0, |
| 1252 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, |
| 1253 |
0, |
| 1254 |
0, |
| 1255 |
0, |
| 1256 |
0, |
| 1257 |
0, |
| 1258 |
0, |
| 1259 |
0, |
| 1260 |
EventHandlerCallRef_methods, |
| 1261 |
0, |
| 1262 |
EventHandlerCallRef_getsetlist, |
| 1263 |
0, |
| 1264 |
0, |
| 1265 |
0, |
| 1266 |
0, |
| 1267 |
0, |
| 1268 |
EventHandlerCallRef_tp_init, |
| 1269 |
EventHandlerCallRef_tp_alloc, |
| 1270 |
EventHandlerCallRef_tp_new, |
| 1271 |
EventHandlerCallRef_tp_free, |
| 1272 |
}; |
| 1273 |
|
| 1274 |
|
| 1275 |
|
| 1276 |
|
| 1277 |
|
| 1278 |
|
| 1279 |
PyTypeObject EventTargetRef_Type; |
| 1280 |
|
| 1281 |
#define EventTargetRef_Check(x) ((x)->ob_type == &EventTargetRef_Type || PyObject_TypeCheck((x), &EventTargetRef_Type)) |
| 1282 |
|
| 1283 |
typedef struct EventTargetRefObject { |
| 1284 |
PyObject_HEAD |
| 1285 |
EventTargetRef ob_itself; |
| 1286 |
} EventTargetRefObject; |
| 1287 |
|
| 1288 |
PyObject *EventTargetRef_New(EventTargetRef itself) |
| 1289 |
{ |
| 1290 |
EventTargetRefObject *it; |
| 1291 |
it = PyObject_NEW(EventTargetRefObject, &EventTargetRef_Type); |
| 1292 |
if (it == NULL) return NULL; |
| 1293 |
it->ob_itself = itself; |
| 1294 |
return (PyObject *)it; |
| 1295 |
} |
| 1296 |
|
| 1297 |
int EventTargetRef_Convert(PyObject *v, EventTargetRef *p_itself) |
| 1298 |
{ |
| 1299 |
if (!EventTargetRef_Check(v)) |
| 1300 |
{ |
| 1301 |
PyErr_SetString(PyExc_TypeError, "EventTargetRef required"); |
| 1302 |
return 0; |
| 1303 |
} |
| 1304 |
*p_itself = ((EventTargetRefObject *)v)->ob_itself; |
| 1305 |
return 1; |
| 1306 |
} |
| 1307 |
|
| 1308 |
static void EventTargetRef_dealloc(EventTargetRefObject *self) |
| 1309 |
{ |
| 1310 |
|
| 1311 |
self->ob_type->tp_free((PyObject *)self); |
| 1312 |
} |
| 1313 |
|
| 1314 |
static PyObject *EventTargetRef_InstallStandardEventHandler(EventTargetRefObject *_self, PyObject *_args) |
| 1315 |
{ |
| 1316 |
PyObject *_res = NULL; |
| 1317 |
OSStatus _err; |
| 1318 |
if (!PyArg_ParseTuple(_args, "")) |
| 1319 |
return NULL; |
| 1320 |
_err = InstallStandardEventHandler(_self->ob_itself); |
| 1321 |
if (_err != noErr) return PyMac_Error(_err); |
| 1322 |
Py_INCREF(Py_None); |
| 1323 |
_res = Py_None; |
| 1324 |
return _res; |
| 1325 |
} |
| 1326 |
|
| 1327 |
static PyObject *EventTargetRef_InstallEventHandler(EventTargetRefObject *_self, PyObject *_args) |
| 1328 |
{ |
| 1329 |
PyObject *_res = NULL; |
| 1330 |
|
| 1331 |
EventTypeSpec inSpec; |
| 1332 |
PyObject *callback; |
| 1333 |
EventHandlerRef outRef; |
| 1334 |
OSStatus _err; |
| 1335 |
|
| 1336 |
if (!PyArg_ParseTuple(_args, "O&O", EventTypeSpec_Convert, &inSpec, &callback)) |
| 1337 |
return NULL; |
| 1338 |
|
| 1339 |
_err = InstallEventHandler(_self->ob_itself, myEventHandlerUPP, 1, &inSpec, (void *)callback, &outRef); |
| 1340 |
if (_err != noErr) return PyMac_Error(_err); |
| 1341 |
|
| 1342 |
_res = EventHandlerRef_New(outRef); |
| 1343 |
if (_res != NULL) { |
| 1344 |
((EventHandlerRefObject*)_res)->ob_callback = callback; |
| 1345 |
Py_INCREF(callback); |
| 1346 |
} |
| 1347 |
return _res; |
| 1348 |
} |
| 1349 |
|
| 1350 |
static PyMethodDef EventTargetRef_methods[] = { |
| 1351 |
{"InstallStandardEventHandler", (PyCFunction)EventTargetRef_InstallStandardEventHandler, 1, |
| 1352 |
PyDoc_STR("() -> None")}, |
| 1353 |
{"InstallEventHandler", (PyCFunction)EventTargetRef_InstallEventHandler, 1, |
| 1354 |
PyDoc_STR("(EventTypeSpec inSpec, Method callback) -> (EventHandlerRef outRef)")}, |
| 1355 |
{NULL, NULL, 0} |
| 1356 |
}; |
| 1357 |
|
| 1358 |
#define EventTargetRef_getsetlist NULL |
| 1359 |
|
| 1360 |
|
| 1361 |
#define EventTargetRef_compare NULL |
| 1362 |
|
| 1363 |
#define EventTargetRef_repr NULL |
| 1364 |
|
| 1365 |
#define EventTargetRef_hash NULL |
| 1366 |
#define EventTargetRef_tp_init 0 |
| 1367 |
|
| 1368 |
#define EventTargetRef_tp_alloc PyType_GenericAlloc |
| 1369 |
|
| 1370 |
static PyObject *EventTargetRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
| 1371 |
{ |
| 1372 |
PyObject *_self; |
| 1373 |
EventTargetRef itself; |
| 1374 |
char *kw[] = {"itself", 0}; |
| 1375 |
|
| 1376 |
if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventTargetRef_Convert, &itself)) return NULL; |
| 1377 |
if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; |
| 1378 |
((EventTargetRefObject *)_self)->ob_itself = itself; |
| 1379 |
return _self; |
| 1380 |
} |
| 1381 |
|
| 1382 |
#define EventTargetRef_tp_free PyObject_Del |
| 1383 |
|
| 1384 |
|
| 1385 |
PyTypeObject EventTargetRef_Type = { |
| 1386 |
PyObject_HEAD_INIT(NULL) |
| 1387 |
0, |
| 1388 |
"_CarbonEvt.EventTargetRef", |
| 1389 |
sizeof(EventTargetRefObject), |
| 1390 |
0, |
| 1391 |
|
| 1392 |
(destructor) EventTargetRef_dealloc, |
| 1393 |
0, |
| 1394 |
(getattrfunc)0, |
| 1395 |
(setattrfunc)0, |
| 1396 |
(cmpfunc) EventTargetRef_compare, |
| 1397 |
(reprfunc) EventTargetRef_repr, |
| 1398 |
(PyNumberMethods *)0, |
| 1399 |
(PySequenceMethods *)0, |
| 1400 |
(PyMappingMethods *)0, |
| 1401 |
(hashfunc) EventTargetRef_hash, |
| 1402 |
0, |
| 1403 |
0, |
| 1404 |
PyObject_GenericGetAttr, |
| 1405 |
PyObject_GenericSetAttr, |
| 1406 |
0, |
| 1407 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, |
| 1408 |
0, |
| 1409 |
0, |
| 1410 |
0, |
| 1411 |
0, |
| 1412 |
0, |
| 1413 |
0, |
| 1414 |
0, |
| 1415 |
EventTargetRef_methods, |
| 1416 |
0, |
| 1417 |
EventTargetRef_getsetlist, |
| 1418 |
0, |
| 1419 |
0, |
| 1420 |
0, |
| 1421 |
0, |
| 1422 |
0, |
| 1423 |
EventTargetRef_tp_init, |
| 1424 |
EventTargetRef_tp_alloc, |
| 1425 |
EventTargetRef_tp_new, |
| 1426 |
EventTargetRef_tp_free, |
| 1427 |
}; |
| 1428 |
|
| 1429 |
|
| 1430 |
|
| 1431 |
|
| 1432 |
|
| 1433 |
|
| 1434 |
PyTypeObject EventHotKeyRef_Type; |
| 1435 |
|
| 1436 |
#define EventHotKeyRef_Check(x) ((x)->ob_type == &EventHotKeyRef_Type || PyObject_TypeCheck((x), &EventHotKeyRef_Type)) |
| 1437 |
|
| 1438 |
typedef struct EventHotKeyRefObject { |
| 1439 |
PyObject_HEAD |
| 1440 |
EventHotKeyRef ob_itself; |
| 1441 |
} EventHotKeyRefObject; |
| 1442 |
|
| 1443 |
PyObject *EventHotKeyRef_New(EventHotKeyRef itself) |
| 1444 |
{ |
| 1445 |
EventHotKeyRefObject *it; |
| 1446 |
it = PyObject_NEW(EventHotKeyRefObject, &EventHotKeyRef_Type); |
| 1447 |
if (it == NULL) return NULL; |
| 1448 |
it->ob_itself = itself; |
| 1449 |
return (PyObject *)it; |
| 1450 |
} |
| 1451 |
|
| 1452 |
int EventHotKeyRef_Convert(PyObject *v, EventHotKeyRef *p_itself) |
| 1453 |
{ |
| 1454 |
if (!EventHotKeyRef_Check(v)) |
| 1455 |
{ |
| 1456 |
PyErr_SetString(PyExc_TypeError, "EventHotKeyRef required"); |
| 1457 |
return 0; |
| 1458 |
} |
| 1459 |
*p_itself = ((EventHotKeyRefObject *)v)->ob_itself; |
| 1460 |
return 1; |
| 1461 |
} |
| 1462 |
|
| 1463 |
static void EventHotKeyRef_dealloc(EventHotKeyRefObject *self) |
| 1464 |
{ |
| 1465 |
|
| 1466 |
self->ob_type->tp_free((PyObject *)self); |
| 1467 |
} |
| 1468 |
|
| 1469 |
static PyObject *EventHotKeyRef_UnregisterEventHotKey(EventHotKeyRefObject *_self, PyObject *_args) |
| 1470 |
{ |
| 1471 |
PyObject *_res = NULL; |
| 1472 |
OSStatus _err; |
| 1473 |
if (!PyArg_ParseTuple(_args, "")) |
| 1474 |
return NULL; |
| 1475 |
_err = UnregisterEventHotKey(_self->ob_itself); |
| 1476 |
if (_err != noErr) return PyMac_Error(_err); |
| 1477 |
Py_INCREF(Py_None); |
| 1478 |
_res = Py_None; |
| 1479 |
return _res; |
| 1480 |
} |
| 1481 |
|
| 1482 |
static PyMethodDef EventHotKeyRef_methods[] = { |
| 1483 |
{"UnregisterEventHotKey", (PyCFunction)EventHotKeyRef_UnregisterEventHotKey, 1, |
| 1484 |
PyDoc_STR("() -> None")}, |
| 1485 |
{NULL, NULL, 0} |
| 1486 |
}; |
| 1487 |
|
| 1488 |
#define EventHotKeyRef_getsetlist NULL |
| 1489 |
|
| 1490 |
|
| 1491 |
#define EventHotKeyRef_compare NULL |
| 1492 |
|
| 1493 |
#define EventHotKeyRef_repr NULL |
| 1494 |
|
| 1495 |
#define EventHotKeyRef_hash NULL |
| 1496 |
#define EventHotKeyRef_tp_init 0 |
| 1497 |
|
| 1498 |
#define EventHotKeyRef_tp_alloc PyType_GenericAlloc |
| 1499 |
|
| 1500 |
static PyObject *EventHotKeyRef_tp_new(PyTypeObject *type, PyObject *_args, PyObject *_kwds) |
| 1501 |
{ |
| 1502 |
PyObject *_self; |
| 1503 |
EventHotKeyRef itself; |
| 1504 |
char *kw[] = {"itself", 0}; |
| 1505 |
|
| 1506 |
if (!PyArg_ParseTupleAndKeywords(_args, _kwds, "O&", kw, EventHotKeyRef_Convert, &itself)) return NULL; |
| 1507 |
if ((_self = type->tp_alloc(type, 0)) == NULL) return NULL; |
| 1508 |
((EventHotKeyRefObject *)_self)->ob_itself = itself; |
| 1509 |
return _self; |
| 1510 |
} |
| 1511 |
|
| 1512 |
#define EventHotKeyRef_tp_free PyObject_Del |
| 1513 |
|
| 1514 |
|
| 1515 |
PyTypeObject EventHotKeyRef_Type = { |
| 1516 |
PyObject_HEAD_INIT(NULL) |
| 1517 |
0, |
| 1518 |
"_CarbonEvt.EventHotKeyRef", |
| 1519 |
sizeof(EventHotKeyRefObject), |
| 1520 |
0, |
| 1521 |
|
| 1522 |
(destructor) EventHotKeyRef_dealloc, |
| 1523 |
0, |
| 1524 |
(getattrfunc)0, |
| 1525 |
(setattrfunc)0, |
| 1526 |
(cmpfunc) EventHotKeyRef_compare, |
| 1527 |
(reprfunc) EventHotKeyRef_repr, |
| 1528 |
(PyNumberMethods *)0, |
| 1529 |
(PySequenceMethods *)0, |
| 1530 |
(PyMappingMethods *)0, |
| 1531 |
(hashfunc) EventHotKeyRef_hash, |
| 1532 |
0, |
| 1533 |
0, |
| 1534 |
PyObject_GenericGetAttr, |
| 1535 |
PyObject_GenericSetAttr, |
| 1536 |
0, |
| 1537 |
Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE, |
| 1538 |
0, |
| 1539 |
0, |
| 1540 |
0, |
| 1541 |
0, |
| 1542 |
0, |
| 1543 |
0, |
| 1544 |
0, |
| 1545 |
EventHotKeyRef_methods, |
| 1546 |
0, |
| 1547 |
EventHotKeyRef_getsetlist, |
| 1548 |
0, |
| 1549 |
0, |
| 1550 |
0, |
| 1551 |
0, |
| 1552 |
0, |
| 1553 |
EventHotKeyRef_tp_init, |
| 1554 |
EventHotKeyRef_tp_alloc, |
| 1555 |
EventHotKeyRef_tp_new, |
| 1556 |
EventHotKeyRef_tp_free, |
| 1557 |
}; |
| 1558 |
|
| 1559 |
|
| 1560 |
|
| 1561 |
|
| 1562 |
static PyObject *CarbonEvents_GetCurrentEventLoop(PyObject *_self, PyObject *_args) |
| 1563 |
{ |
| 1564 |
PyObject *_res = NULL; |
| 1565 |
EventLoopRef _rv; |
| 1566 |
if (!PyArg_ParseTuple(_args, "")) |
| 1567 |
return NULL; |
| 1568 |
_rv = GetCurrentEventLoop(); |
| 1569 |
_res = Py_BuildValue("O&", |
| 1570 |
EventLoopRef_New, _rv); |
| 1571 |
return _res; |
| 1572 |
} |
| 1573 |
|
| 1574 |
static PyObject *CarbonEvents_GetMainEventLoop(PyObject *_self, PyObject *_args) |
| 1575 |
{ |
| 1576 |
PyObject *_res = NULL; |
| 1577 |
EventLoopRef _rv; |
| 1578 |
if (!PyArg_ParseTuple(_args, "")) |
| 1579 |
return NULL; |
| 1580 |
_rv = GetMainEventLoop(); |
| 1581 |
_res = Py_BuildValue("O&", |
| 1582 |
EventLoopRef_New, _rv); |
| 1583 |
return _res; |
| 1584 |
} |
| 1585 |
|
| 1586 |
static PyObject *CarbonEvents_RunCurrentEventLoop(PyObject *_self, PyObject *_args) |
| 1587 |
{ |
| 1588 |
PyObject *_res = NULL; |
| 1589 |
OSStatus _err; |
| 1590 |
double inTimeout; |
| 1591 |
if (!PyArg_ParseTuple(_args, "d", |
| 1592 |
&inTimeout)) |
| 1593 |
return NULL; |
| 1594 |
_err = RunCurrentEventLoop(inTimeout); |
| 1595 |
if (_err != noErr) return PyMac_Error(_err); |
| 1596 |
Py_INCREF(Py_None); |
| 1597 |
_res = Py_None; |
| 1598 |
return _res; |
| 1599 |
} |
| 1600 |
|
| 1601 |
static PyObject *CarbonEvents_ReceiveNextEvent(PyObject *_self, PyObject *_args) |
| 1602 |
{ |
| 1603 |
PyObject *_res = NULL; |
| 1604 |
OSStatus _err; |
| 1605 |
UInt32 inNumTypes; |
| 1606 |
EventTypeSpec inList; |
| 1607 |
double inTimeout; |
| 1608 |
Boolean inPullEvent; |
| 1609 |
EventRef outEvent; |
| 1610 |
if (!PyArg_ParseTuple(_args, "lO&db", |
| 1611 |
&inNumTypes, |
| 1612 |
EventTypeSpec_Convert, &inList, |
| 1613 |
&inTimeout, |
| 1614 |
&inPullEvent)) |
| 1615 |
return NULL; |
| 1616 |
_err = ReceiveNextEvent(inNumTypes, |
| 1617 |
&inList, |
| 1618 |
inTimeout, |
| 1619 |
inPullEvent, |
| 1620 |
&outEvent); |
| 1621 |
if (_err != noErr) return PyMac_Error(_err); |
| 1622 |
_res = Py_BuildValue("O&", |
| 1623 |
EventRef_New, outEvent); |
| 1624 |
return _res; |
| 1625 |
} |
| 1626 |
|
| 1627 |
static PyObject *CarbonEvents_GetCurrentEventQueue(PyObject *_self, PyObject *_args) |
| 1628 |
{ |
| 1629 |
PyObject *_res = NULL; |
| 1630 |
EventQueueRef _rv; |
| 1631 |
if (!PyArg_ParseTuple(_args, "")) |
| 1632 |
return NULL; |
| 1633 |
_rv = GetCurrentEventQueue(); |
| 1634 |
_res = Py_BuildValue("O&", |
| 1635 |
EventQueueRef_New, _rv); |
| 1636 |
return _res; |
| 1637 |
} |
| 1638 |
|
| 1639 |
static PyObject *CarbonEvents_GetMainEventQueue(PyObject *_self, PyObject *_args) |
| 1640 |
{ |
| 1641 |
PyObject *_res = NULL; |
| 1642 |
EventQueueRef _rv; |
| 1643 |
if (!PyArg_ParseTuple(_args, "")) |
| 1644 |
return NULL; |
| 1645 |
_rv = GetMainEventQueue(); |
| 1646 |
_res = Py_BuildValue("O&", |
| 1647 |
EventQueueRef_New, _rv); |
| 1648 |
return _res; |
| 1649 |
} |
| 1650 |
|
| 1651 |
static PyObject *CarbonEvents_GetCurrentEventTime(PyObject *_self, PyObject *_args) |
| 1652 |
{ |
| 1653 |
PyObject *_res = NULL; |
| 1654 |
double _rv; |
| 1655 |
if (!PyArg_ParseTuple(_args, "")) |
| 1656 |
return NULL; |
| 1657 |
_rv = GetCurrentEventTime(); |
| 1658 |
_res = Py_BuildValue("d", |
| 1659 |
_rv); |
| 1660 |
return _res; |
| 1661 |
} |
| 1662 |
|
| 1663 |
static PyObject *CarbonEvents_TrackMouseLocation(PyObject *_self, PyObject *_args) |
| 1664 |
{ |
| 1665 |
PyObject *_res = NULL; |
| 1666 |
OSStatus _err; |
| 1667 |
GrafPtr inPort; |
| 1668 |
Point outPt; |
| 1669 |
UInt16 outResult; |
| 1670 |
if (!PyArg_ParseTuple(_args, "O&", |
| 1671 |
GrafObj_Convert, &inPort)) |
| 1672 |
return NULL; |
| 1673 |
_err = TrackMouseLocation(inPort, |
| 1674 |
&outPt, |
| 1675 |
&outResult); |
| 1676 |
if (_err != noErr) return PyMac_Error(_err); |
| 1677 |
_res = Py_BuildValue("O&H", |
| 1678 |
PyMac_BuildPoint, outPt, |
| 1679 |
outResult); |
| 1680 |
return _res; |
| 1681 |
} |
| 1682 |
|
| 1683 |
static PyObject *CarbonEvents_TrackMouseLocationWithOptions(PyObject *_self, PyObject *_args) |
| 1684 |
{ |
| 1685 |
PyObject *_res = NULL; |
| 1686 |
OSStatus _err; |
| 1687 |
GrafPtr inPort; |
| 1688 |
OptionBits inOptions; |
| 1689 |
double inTimeout; |
| 1690 |
Point outPt; |
| 1691 |
UInt32 outModifiers; |
| 1692 |
UInt16 outResult; |
| 1693 |
if (!PyArg_ParseTuple(_args, "O&ld", |
| 1694 |
GrafObj_Convert, &inPort, |
| 1695 |
&inOptions, |
| 1696 |
&inTimeout)) |
| 1697 |
return NULL; |
| 1698 |
_err = TrackMouseLocationWithOptions(inPort, |
| 1699 |
inOptions, |
| 1700 |
inTimeout, |
| 1701 |
&outPt, |
| 1702 |
&outModifiers, |
| 1703 |
&outResult); |
| 1704 |
if (_err != noErr) return PyMac_Error(_err); |
| 1705 |
_res = Py_BuildValue("O&lH", |
| 1706 |
PyMac_BuildPoint, outPt, |
| 1707 |
outModifiers, |
| 1708 |
outResult); |
| 1709 |
return _res; |
| 1710 |
} |
| 1711 |
|
| 1712 |
static PyObject *CarbonEvents_TrackMouseRegion(PyObject *_self, PyObject *_args) |
| 1713 |
{ |
| 1714 |
PyObject *_res = NULL; |
| 1715 |
OSStatus _err; |
| 1716 |
GrafPtr inPort; |
| 1717 |
RgnHandle inRegion; |
| 1718 |
Boolean ioWasInRgn; |
| 1719 |
UInt16 outResult; |
| 1720 |
if (!PyArg_ParseTuple(_args, "O&O&b", |
| 1721 |
GrafObj_Convert, &inPort, |
| 1722 |
ResObj_Convert, &inRegion, |
| 1723 |
&ioWasInRgn)) |
| 1724 |
return NULL; |
| 1725 |
_err = TrackMouseRegion(inPort, |
| 1726 |
inRegion, |
| 1727 |
&ioWasInRgn, |
| 1728 |
&outResult); |
| 1729 |
if (_err != noErr) return PyMac_Error(_err); |
| 1730 |
_res = Py_BuildValue("bH", |
| 1731 |
ioWasInRgn, |
| 1732 |
outResult); |
| 1733 |
return _res; |
| 1734 |
} |
| 1735 |
|
| 1736 |
static PyObject *CarbonEvents_GetLastUserEventTime(PyObject *_self, PyObject *_args) |
| 1737 |
{ |
| 1738 |
PyObject *_res = NULL; |
| 1739 |
double _rv; |
| 1740 |
if (!PyArg_ParseTuple(_args, "")) |
| 1741 |
return NULL; |
| 1742 |
_rv = GetLastUserEventTime(); |
| 1743 |
_res = Py_BuildValue("d", |
| 1744 |
_rv); |
| 1745 |
return _res; |
| 1746 |
} |
| 1747 |
|
| 1748 |
static PyObject *CarbonEvents_IsMouseCoalescingEnabled(PyObject *_self, PyObject *_args) |
| 1749 |
{ |
| 1750 |
PyObject *_res = NULL; |
| 1751 |
Boolean _rv; |
| 1752 |
if (!PyArg_ParseTuple(_args, "")) |
| 1753 |
return NULL; |
| 1754 |
_rv = IsMouseCoalescingEnabled(); |
| 1755 |
_res = Py_BuildValue("b", |
| 1756 |
_rv); |
| 1757 |
return _res; |
| 1758 |
} |
| 1759 |
|
| 1760 |
static PyObject *CarbonEvents_SetMouseCoalescingEnabled(PyObject *_self, PyObject *_args) |
| 1761 |
{ |
| 1762 |
PyObject *_res = NULL; |
| 1763 |
OSStatus _err; |
| 1764 |
Boolean inNewState; |
| 1765 |
Boolean outOldState; |
| 1766 |
if (!PyArg_ParseTuple(_args, "b", |
| 1767 |
&inNewState)) |
| 1768 |
return NULL; |
| 1769 |
_err = SetMouseCoalescingEnabled(inNewState, |
| 1770 |
&outOldState); |
| 1771 |
if (_err != noErr) return PyMac_Error(_err); |
| 1772 |
_res = Py_BuildValue("b", |
| 1773 |
outOldState); |
| 1774 |
return _res; |
| 1775 |
} |
| 1776 |
|
| 1777 |
static PyObject *CarbonEvents_GetWindowEventTarget(PyObject *_self, PyObject *_args) |
| 1778 |
{ |
| 1779 |
PyObject *_res = NULL; |
| 1780 |
EventTargetRef _rv; |
| 1781 |
WindowPtr inWindow; |
| 1782 |
if (!PyArg_ParseTuple(_args, "O&", |
| 1783 |
WinObj_Convert, &inWindow)) |
| 1784 |
return NULL; |
| 1785 |
_rv = GetWindowEventTarget(inWindow); |
| 1786 |
_res = Py_BuildValue("O&", |
| 1787 |
EventTargetRef_New, _rv); |
| 1788 |
return _res; |
| 1789 |
} |
| 1790 |
|
| 1791 |
static PyObject *CarbonEvents_GetControlEventTarget(PyObject *_self, PyObject *_args) |
| 1792 |
{ |
| 1793 |
PyObject *_res = NULL; |
| 1794 |
EventTargetRef _rv; |
| 1795 |
ControlHandle inControl; |
| 1796 |
if (!PyArg_ParseTuple(_args, "O&", |
| 1797 |
CtlObj_Convert, &inControl)) |
| 1798 |
return NULL; |
| 1799 |
_rv = GetControlEventTarget(inControl); |
| 1800 |
_res = Py_BuildValue("O&", |
| 1801 |
EventTargetRef_New, _rv); |
| 1802 |
return _res; |
| 1803 |
} |
| 1804 |
|
| 1805 |
static PyObject *CarbonEvents_GetMenuEventTarget(PyObject *_self, PyObject *_args) |
| 1806 |
{ |
| 1807 |
PyObject *_res = NULL; |
| 1808 |
EventTargetRef _rv; |
| 1809 |
MenuHandle inMenu; |
| 1810 |
if (!PyArg_ParseTuple(_args, "O&", |
| 1811 |
MenuObj_Convert, &inMenu)) |
| 1812 |
return NULL; |
| 1813 |
_rv = GetMenuEventTarget(inMenu); |
| 1814 |
_res = Py_BuildValue("O&", |
| 1815 |
EventTargetRef_New, _rv); |
| 1816 |
return _res; |
| 1817 |
} |
| 1818 |
|
| 1819 |
static PyObject *CarbonEvents_GetApplicationEventTarget(PyObject *_self, PyObject *_args) |
| 1820 |
{ |
| 1821 |
PyObject *_res = NULL; |
| 1822 |
EventTargetRef _rv; |
| 1823 |
if (!PyArg_ParseTuple(_args, "")) |
| 1824 |
return NULL; |
| 1825 |
_rv = GetApplicationEventTarget(); |
| 1826 |
_res = Py_BuildValue("O&", |
| 1827 |
EventTargetRef_New, _rv); |
| 1828 |
return _res; |
| 1829 |
} |
| 1830 |
|
| 1831 |
static PyObject *CarbonEvents_GetUserFocusEventTarget(PyObject *_self, PyObject *_args) |
| 1832 |
{ |
| 1833 |
PyObject *_res = NULL; |
| 1834 |
EventTargetRef _rv; |
| 1835 |
if (!PyArg_ParseTuple(_args, "")) |
| 1836 |
return NULL; |
| 1837 |
_rv = GetUserFocusEventTarget(); |
| 1838 |
_res = Py_BuildValue("O&", |
| 1839 |
EventTargetRef_New, _rv); |
| 1840 |
return _res; |
| 1841 |
} |
| 1842 |
|
| 1843 |
static PyObject *CarbonEvents_GetEventDispatcherTarget(PyObject *_self, PyObject *_args) |
| 1844 |
{ |
| 1845 |
PyObject *_res = NULL; |
| 1846 |
EventTargetRef _rv; |
| 1847 |
if (!PyArg_ParseTuple(_args, "")) |
| 1848 |
return NULL; |
| 1849 |
_rv = GetEventDispatcherTarget(); |
| 1850 |
_res = Py_BuildValue("O&", |
| 1851 |
EventTargetRef_New, _rv); |
| 1852 |
return _res; |
| 1853 |
} |
| 1854 |
|
| 1855 |
static PyObject *CarbonEvents_RunApplicationEventLoop(PyObject *_self, PyObject *_args) |
| 1856 |
{ |
| 1857 |
PyObject *_res = NULL; |
| 1858 |
if (!PyArg_ParseTuple(_args, "")) |
| 1859 |
return NULL; |
| 1860 |
RunApplicationEventLoop(); |
| 1861 |
Py_INCREF(Py_None); |
| 1862 |
_res = Py_None; |
| 1863 |
return _res; |
| 1864 |
} |
| 1865 |
|
| 1866 |
static PyObject *CarbonEvents_QuitApplicationEventLoop(PyObject *_self, PyObject *_args) |
| 1867 |
{ |
| 1868 |
PyObject *_res = NULL; |
| 1869 |
if (!PyArg_ParseTuple(_args, "")) |
| 1870 |
return NULL; |
| 1871 |
QuitApplicationEventLoop(); |
| 1872 |
Py_INCREF(Py_None); |
| 1873 |
_res = Py_None; |
| 1874 |
return _res; |
| 1875 |
} |
| 1876 |
|
| 1877 |
static PyObject *CarbonEvents_RunAppModalLoopForWindow(PyObject *_self, PyObject *_args) |
| 1878 |
{ |
| 1879 |
PyObject *_res = NULL; |
| 1880 |
OSStatus _err; |
| 1881 |
WindowPtr inWindow; |
| 1882 |
if (!PyArg_ParseTuple(_args, "O&", |
| 1883 |
WinObj_Convert, &inWindow)) |
| 1884 |
return NULL; |
| 1885 |
_err = RunAppModalLoopForWindow(inWindow); |
| 1886 |
if (_err != noErr) return PyMac_Error(_err); |
| 1887 |
Py_INCREF(Py_None); |
| 1888 |
_res = Py_None; |
| 1889 |
return _res; |
| 1890 |
} |
| 1891 |
|
| 1892 |
static PyObject *CarbonEvents_QuitAppModalLoopForWindow(PyObject *_self, PyObject *_args) |
| 1893 |
{ |
| 1894 |
PyObject *_res = NULL; |
| 1895 |
OSStatus _err; |
| 1896 |
WindowPtr inWindow; |
| 1897 |
if (!PyArg_ParseTuple(_args, "O&", |
| 1898 |
WinObj_Convert, &inWindow)) |
| 1899 |
return NULL; |
| 1900 |
_err = QuitAppModalLoopForWindow(inWindow); |
| 1901 |
if (_err != noErr) return PyMac_Error(_err); |
| 1902 |
Py_INCREF(Py_None); |
| 1903 |
_res = Py_None; |
| 1904 |
return _res; |
| 1905 |
} |
| 1906 |
|
| 1907 |
static PyObject *CarbonEvents_BeginAppModalStateForWindow(PyObject *_self, PyObject *_args) |
| 1908 |
{ |
| 1909 |
PyObject *_res = NULL; |
| 1910 |
OSStatus _err; |
| 1911 |
WindowPtr inWindow; |
| 1912 |
if (!PyArg_ParseTuple(_args, "O&", |
| 1913 |
WinObj_Convert, &inWindow)) |
| 1914 |
return NULL; |
| 1915 |
_err = BeginAppModalStateForWindow(inWindow); |
| 1916 |
if (_err != noErr) return PyMac_Error(_err); |
| 1917 |
Py_INCREF(Py_None); |
| 1918 |
_res = Py_None; |
| 1919 |
return _res; |
| 1920 |
} |
| 1921 |
|
| 1922 |
static PyObject *CarbonEvents_EndAppModalStateForWindow(PyObject *_self, PyObject *_args) |
| 1923 |
{ |
| 1924 |
PyObject *_res = NULL; |
| 1925 |
OSStatus _err; |
| 1926 |
WindowPtr inWindow; |
| 1927 |
if (!PyArg_ParseTuple(_args, "O&", |
| 1928 |
WinObj_Convert, &inWindow)) |
| 1929 |
return NULL; |
| 1930 |
_err = EndAppModalStateForWindow(inWindow); |
| 1931 |
if (_err != noErr) return PyMac_Error(_err); |
| 1932 |
Py_INCREF(Py_None); |
| 1933 |
_res = Py_None; |
| 1934 |
return _res; |
| 1935 |
} |
| 1936 |
|
| 1937 |
static PyObject *CarbonEvents_SetUserFocusWindow(PyObject *_self, PyObject *_args) |
| 1938 |
{ |
| 1939 |
PyObject *_res = NULL; |
| 1940 |
OSStatus _err; |
| 1941 |
WindowPtr inWindow; |
| 1942 |
if (!PyArg_ParseTuple(_args, "O&", |
| 1943 |
WinObj_Convert, &inWindow)) |
| 1944 |
return NULL; |
| 1945 |
_err = SetUserFocusWindow(inWindow); |
| 1946 |
if (_err != noErr) return PyMac_Error(_err); |
| 1947 |
Py_INCREF(Py_None); |
| 1948 |
_res = Py_None; |
| 1949 |
return _res; |
| 1950 |
} |
| 1951 |
|
| 1952 |
static PyObject *CarbonEvents_GetUserFocusWindow(PyObject *_self, PyObject *_args) |
| 1953 |
{ |
| 1954 |
PyObject *_res = NULL; |
| 1955 |
WindowPtr _rv; |
| 1956 |
if (!PyArg_ParseTuple(_args, "")) |
| 1957 |
return NULL; |
| 1958 |
_rv = GetUserFocusWindow(); |
| 1959 |
_res = Py_BuildValue("O&", |
| 1960 |
WinObj_New, _rv); |
| 1961 |
return _res; |
| 1962 |
} |
| 1963 |
|
| 1964 |
static PyObject *CarbonEvents_SetWindowDefaultButton(PyObject *_self, PyObject *_args) |
| 1965 |
{ |
| 1966 |
PyObject *_res = NULL; |
| 1967 |
OSStatus _err; |
| 1968 |
WindowPtr inWindow; |
| 1969 |
ControlHandle inControl; |
| 1970 |
if (!PyArg_ParseTuple(_args, "O&O&", |
| 1971 |
WinObj_Convert, &inWindow, |
| 1972 |
CtlObj_Convert, &inControl)) |
| 1973 |
return NULL; |
| 1974 |
_err = SetWindowDefaultButton(inWindow, |
| 1975 |
inControl); |
| 1976 |
if (_err != noErr) return PyMac_Error(_err); |
| 1977 |
Py_INCREF(Py_None); |
| 1978 |
_res = Py_None; |
| 1979 |
return _res; |
| 1980 |
} |
| 1981 |
|
| 1982 |
static PyObject *CarbonEvents_SetWindowCancelButton(PyObject *_self, PyObject *_args) |
| 1983 |
{ |
| 1984 |
PyObject *_res = NULL; |
| 1985 |
OSStatus _err; |
| 1986 |
WindowPtr inWindow; |
| 1987 |
ControlHandle inControl; |
| 1988 |
if (!PyArg_ParseTuple(_args, "O&O&", |
| 1989 |
WinObj_Convert, &inWindow, |
| 1990 |
CtlObj_Convert, &inControl)) |
| 1991 |
return NULL; |
| 1992 |
_err = SetWindowCancelButton(inWindow, |
| 1993 |
inControl); |
| 1994 |
if (_err != noErr) return PyMac_Error(_err); |
| 1995 |
Py_INCREF(Py_None); |
| 1996 |
_res = Py_None; |
| 1997 |
return _res; |
| 1998 |
} |
| 1999 |
|
| 2000 |
static PyObject *CarbonEvents_GetWindowDefaultButton(PyObject *_self, PyObject *_args) |
| 2001 |
{ |
| 2002 |
PyObject *_res = NULL; |
| 2003 |
OSStatus _err; |
| 2004 |
WindowPtr inWindow; |
| 2005 |
ControlHandle outControl; |
| 2006 |
if (!PyArg_ParseTuple(_args, "O&", |
| 2007 |
WinObj_Convert, &inWindow)) |
| 2008 |
return NULL; |
| 2009 |
_err = GetWindowDefaultButton(inWindow, |
| 2010 |
&outControl); |
| 2011 |
if (_err != noErr) return PyMac_Error(_err); |
| 2012 |
_res = Py_BuildValue("O&", |
| 2013 |
CtlObj_New, outControl); |
| 2014 |
return _res; |
| 2015 |
} |
| 2016 |
|
| 2017 |
static PyObject *CarbonEvents_GetWindowCancelButton(PyObject *_self, PyObject *_args) |
| 2018 |
{ |
| 2019 |
PyObject *_res = NULL; |
| 2020 |
OSStatus _err; |
| 2021 |
WindowPtr inWindow; |
| 2022 |
ControlHandle outControl; |
| 2023 |
if (!PyArg_ParseTuple(_args, "O&", |
| 2024 |
WinObj_Convert, &inWindow)) |
| 2025 |
return NULL; |
| 2026 |
_err = GetWindowCancelButton(inWindow, |
| 2027 |
&outControl); |
| 2028 |
if (_err != noErr) return PyMac_Error(_err); |
| 2029 |
_res = Py_BuildValue("O&", |
| 2030 |
CtlObj_New, outControl); |
| 2031 |
return _res; |
| 2032 |
} |
| 2033 |
|
| 2034 |
static PyObject *CarbonEvents_RegisterEventHotKey(PyObject *_self, PyObject *_args) |
| 2035 |
{ |
| 2036 |
PyObject *_res = NULL; |
| 2037 |
OSStatus _err; |
| 2038 |
UInt32 inHotKeyCode; |
| 2039 |
UInt32 inHotKeyModifiers; |
| 2040 |
EventHotKeyID inHotKeyID; |
| 2041 |
EventTargetRef inTarget; |
| 2042 |
OptionBits inOptions; |
| 2043 |
EventHotKeyRef outRef; |
| 2044 |
if (!PyArg_ParseTuple(_args, "llO&O&l", |
| 2045 |
&inHotKeyCode, |
| 2046 |
&inHotKeyModifiers, |
| 2047 |
EventHotKeyID_Convert, &inHotKeyID, |
| 2048 |
EventTargetRef_Convert, &inTarget, |
| 2049 |
&inOptions)) |
| 2050 |
return NULL; |
| 2051 |
_err = RegisterEventHotKey(inHotKeyCode, |
| 2052 |
inHotKeyModifiers, |
| 2053 |
inHotKeyID, |
| 2054 |
inTarget, |
| 2055 |
inOptions, |
| 2056 |
&outRef); |
| 2057 |
if (_err != noErr) return PyMac_Error(_err); |
| 2058 |
_res = Py_BuildValue("O&", |
| 2059 |
EventHotKeyRef_New, outRef); |
| 2060 |
return _res; |
| 2061 |
} |
| 2062 |
|
| 2063 |
static PyMethodDef CarbonEvents_methods[] = { |
| 2064 |
{"GetCurrentEventLoop", (PyCFunction)CarbonEvents_GetCurrentEventLoop, 1, |
| 2065 |
PyDoc_STR("() -> (EventLoopRef _rv)")}, |
| 2066 |
{"GetMainEventLoop", (PyCFunction)CarbonEvents_GetMainEventLoop, 1, |
| 2067 |
PyDoc_STR("() -> (EventLoopRef _rv)")}, |
| 2068 |
{"RunCurrentEventLoop", (PyCFunction)CarbonEvents_RunCurrentEventLoop, 1, |
| 2069 |
PyDoc_STR("(double inTimeout) -> None")}, |
| 2070 |
{"ReceiveNextEvent", (PyCFunction)CarbonEvents_ReceiveNextEvent, 1, |
| 2071 |
PyDoc_STR("(UInt32 inNumTypes, EventTypeSpec inList, double inTimeout, Boolean inPullEvent) -> (EventRef outEvent)")}, |
| 2072 |
{"GetCurrentEventQueue", (PyCFunction)CarbonEvents_GetCurrentEventQueue, 1, |
| 2073 |
PyDoc_STR("() -> (EventQueueRef _rv)")}, |
| 2074 |
{"GetMainEventQueue", (PyCFunction)CarbonEvents_GetMainEventQueue, 1, |
| 2075 |
PyDoc_STR("() -> (EventQueueRef _rv)")}, |
| 2076 |
{"GetCurrentEventTime", (PyCFunction)CarbonEvents_GetCurrentEventTime, 1, |
| 2077 |
PyDoc_STR("() -> (double _rv)")}, |
| 2078 |
{"TrackMouseLocation", (PyCFunction)CarbonEvents_TrackMouseLocation, 1, |
| 2079 |
PyDoc_STR("(GrafPtr inPort) -> (Point outPt, UInt16 outResult)")}, |
| 2080 |
{"TrackMouseLocationWithOptions", (PyCFunction)CarbonEvents_TrackMouseLocationWithOptions, 1, |
| 2081 |
PyDoc_STR("(GrafPtr inPort, OptionBits inOptions, double inTimeout) -> (Point outPt, UInt32 outModifiers, UInt16 outResult)")}, |
| 2082 |
{"TrackMouseRegion", (PyCFunction)CarbonEvents_TrackMouseRegion, 1, |
| 2083 |
PyDoc_STR("(GrafPtr inPort, RgnHandle inRegion, Boolean ioWasInRgn) -> (Boolean ioWasInRgn, UInt16 outResult)")}, |
| 2084 |
{"GetLastUserEventTime", (PyCFunction)CarbonEvents_GetLastUserEventTime, 1, |
| 2085 |
PyDoc_STR("() -> (double _rv)")}, |
| 2086 |
{"IsMouseCoalescingEnabled", (PyCFunction)CarbonEvents_IsMouseCoalescingEnabled, 1, |
| 2087 |
PyDoc_STR("() -> (Boolean _rv)")}, |
| 2088 |
{"SetMouseCoalescingEnabled", (PyCFunction)CarbonEvents_SetMouseCoalescingEnabled, 1, |
| 2089 |
PyDoc_STR("(Boolean inNewState) -> (Boolean outOldState)")}, |
| 2090 |
{"GetWindowEventTarget", (PyCFunction)CarbonEvents_GetWindowEventTarget, 1, |
| 2091 |
PyDoc_STR("(WindowPtr inWindow) -> (EventTargetRef _rv)")}, |
| 2092 |
{"GetControlEventTarget", (PyCFunction)CarbonEvents_GetControlEventTarget, 1, |
| 2093 |
PyDoc_STR("(ControlHandle inControl) -> (EventTargetRef _rv)")}, |
| 2094 |
{"GetMenuEventTarget", (PyCFunction)CarbonEvents_GetMenuEventTarget, 1, |
| 2095 |
PyDoc_STR("(MenuHandle inMenu) -> (EventTargetRef _rv)")}, |
| 2096 |
{"GetApplicationEventTarget", (PyCFunction)CarbonEvents_GetApplicationEventTarget, 1, |
| 2097 |
PyDoc_STR("() -> (EventTargetRef _rv)")}, |
| 2098 |
{"GetUserFocusEventTarget", (PyCFunction)CarbonEvents_GetUserFocusEventTarget, 1, |
| 2099 |
PyDoc_STR("() -> (EventTargetRef _rv)")}, |
| 2100 |
{"GetEventDispatcherTarget", (PyCFunction)CarbonEvents_GetEventDispatcherTarget, 1, |
| 2101 |
PyDoc_STR("() -> (EventTargetRef _rv)")}, |
| 2102 |
{"RunApplicationEventLoop", (PyCFunction)CarbonEvents_RunApplicationEventLoop, 1, |
| 2103 |
PyDoc_STR("() -> None")}, |
| 2104 |
{"QuitApplicationEventLoop", (PyCFunction)CarbonEvents_QuitApplicationEventLoop, 1, |
| 2105 |
PyDoc_STR("() -> None")}, |
| 2106 |
{"RunAppModalLoopForWindow", (PyCFunction)CarbonEvents_RunAppModalLoopForWindow, 1, |
| 2107 |
PyDoc_STR("(WindowPtr inWindow) -> None")}, |
| 2108 |
{"QuitAppModalLoopForWindow", (PyCFunction)CarbonEvents_QuitAppModalLoopForWindow, 1, |
| 2109 |
PyDoc_STR("(WindowPtr inWindow) -> None")}, |
| 2110 |
{"BeginAppModalStateForWindow", (PyCFunction)CarbonEvents_BeginAppModalStateForWindow, 1, |
| 2111 |
PyDoc_STR("(WindowPtr inWindow) -> None")}, |
| 2112 |
{"EndAppModalStateForWindow", (PyCFunction)CarbonEvents_EndAppModalStateForWindow, 1, |
| 2113 |
PyDoc_STR("(WindowPtr inWindow) -> None")}, |
| 2114 |
{"SetUserFocusWindow", (PyCFunction)CarbonEvents_SetUserFocusWindow, 1, |
| 2115 |
PyDoc_STR("(WindowPtr inWindow) -> None")}, |
| 2116 |
{"GetUserFocusWindow", (PyCFunction)CarbonEvents_GetUserFocusWindow, 1, |
| 2117 |
PyDoc_STR("() -> (WindowPtr _rv)")}, |
| 2118 |
{"SetWindowDefaultButton", (PyCFunction)CarbonEvents_SetWindowDefaultButton, 1, |
| 2119 |
PyDoc_STR("(WindowPtr inWindow, ControlHandle inControl) -> None")}, |
| 2120 |
{"SetWindowCancelButton", (PyCFunction)CarbonEvents_SetWindowCancelButton, 1, |
| 2121 |
PyDoc_STR("(WindowPtr inWindow, ControlHandle inControl) -> None")}, |
| 2122 |
{"GetWindowDefaultButton", (PyCFunction)CarbonEvents_GetWindowDefaultButton, 1, |
| 2123 |
PyDoc_STR("(WindowPtr inWindow) -> (ControlHandle outControl)")}, |
| 2124 |
{"GetWindowCancelButton", (PyCFunction)CarbonEvents_GetWindowCancelButton, 1, |
| 2125 |
PyDoc_STR("(WindowPtr inWindow) -> (ControlHandle outControl)")}, |
| 2126 |
{"RegisterEventHotKey", (PyCFunction)CarbonEvents_RegisterEventHotKey, 1, |
| 2127 |
PyDoc_STR("(UInt32 inHotKeyCode, UInt32 inHotKeyModifiers, EventHotKeyID inHotKeyID, EventTargetRef inTarget, OptionBits inOptions) -> (EventHotKeyRef outRef)")}, |
| 2128 |
{NULL, NULL, 0} |
| 2129 |
}; |
| 2130 |
|
| 2131 |
#else |
| 2132 |
|
| 2133 |
static PyMethodDef CarbonEvents_methods[] = { |
| 2134 |
{NULL, NULL, 0} |
| 2135 |
}; |
| 2136 |
|
| 2137 |
#endif |
| 2138 |
|
| 2139 |
|
| 2140 |
|
| 2141 |
void init_CarbonEvt(void) |
| 2142 |
{ |
| 2143 |
PyObject *m; |
| 2144 |
#if APPLE_SUPPORTS_QUICKTIME |
| 2145 |
PyObject *d; |
| 2146 |
#endif |
| 2147 |
|
| 2148 |
|
| 2149 |
m = Py_InitModule("_CarbonEvt", CarbonEvents_methods); |
| 2150 |
|
| 2151 |
#if APPLE_SUPPORTS_QUICKTIME |
| 2152 |
myEventHandlerUPP = NewEventHandlerUPP(myEventHandler); |
| 2153 |
d = PyModule_GetDict(m); |
| 2154 |
CarbonEvents_Error = PyMac_GetOSErrException(); |
| 2155 |
if (CarbonEvents_Error == NULL || |
| 2156 |
PyDict_SetItemString(d, "Error", CarbonEvents_Error) != 0) |
| 2157 |
return; |
| 2158 |
EventRef_Type.ob_type = &PyType_Type; |
| 2159 |
if (PyType_Ready(&EventRef_Type) < 0) return; |
| 2160 |
Py_INCREF(&EventRef_Type); |
| 2161 |
PyModule_AddObject(m, "EventRef", (PyObject *)&EventRef_Type); |
| 2162 |
|
| 2163 |
Py_INCREF(&EventRef_Type); |
| 2164 |
PyModule_AddObject(m, "EventRefType", (PyObject *)&EventRef_Type); |
| 2165 |
EventQueueRef_Type.ob_type = &PyType_Type; |
| 2166 |
if (PyType_Ready(&EventQueueRef_Type) < 0) return; |
| 2167 |
Py_INCREF(&EventQueueRef_Type); |
| 2168 |
PyModule_AddObject(m, "EventQueueRef", (PyObject *)&EventQueueRef_Type); |
| 2169 |
|
| 2170 |
Py_INCREF(&EventQueueRef_Type); |
| 2171 |
PyModule_AddObject(m, "EventQueueRefType", (PyObject *)&EventQueueRef_Type); |
| 2172 |
EventLoopRef_Type.ob_type = &PyType_Type; |
| 2173 |
if (PyType_Ready(&EventLoopRef_Type) < 0) return; |
| 2174 |
Py_INCREF(&EventLoopRef_Type); |
| 2175 |
PyModule_AddObject(m, "EventLoopRef", (PyObject *)&EventLoopRef_Type); |
| 2176 |
|
| 2177 |
Py_INCREF(&EventLoopRef_Type); |
| 2178 |
PyModule_AddObject(m, "EventLoopRefType", (PyObject *)&EventLoopRef_Type); |
| 2179 |
EventLoopTimerRef_Type.ob_type = &PyType_Type; |
| 2180 |
if (PyType_Ready(&EventLoopTimerRef_Type) < 0) return; |
| 2181 |
Py_INCREF(&EventLoopTimerRef_Type); |
| 2182 |
PyModule_AddObject(m, "EventLoopTimerRef", (PyObject *)&EventLoopTimerRef_Type); |
| 2183 |
|
| 2184 |
Py_INCREF(&EventLoopTimerRef_Type); |
| 2185 |
PyModule_AddObject(m, "EventLoopTimerRefType", (PyObject *)&EventLoopTimerRef_Type); |
| 2186 |
EventHandlerRef_Type.ob_type = &PyType_Type; |
| 2187 |
if (PyType_Ready(&EventHandlerRef_Type) < 0) return; |
| 2188 |
Py_INCREF(&EventHandlerRef_Type); |
| 2189 |
PyModule_AddObject(m, "EventHandlerRef", (PyObject *)&EventHandlerRef_Type); |
| 2190 |
|
| 2191 |
Py_INCREF(&EventHandlerRef_Type); |
| 2192 |
PyModule_AddObject(m, "EventHandlerRefType", (PyObject *)&EventHandlerRef_Type); |
| 2193 |
EventHandlerCallRef_Type.ob_type = &PyType_Type; |
| 2194 |
if (PyType_Ready(&EventHandlerCallRef_Type) < 0) return; |
| 2195 |
Py_INCREF(&EventHandlerCallRef_Type); |
| 2196 |
PyModule_AddObject(m, "EventHandlerCallRef", (PyObject *)&EventHandlerCallRef_Type); |
| 2197 |
|
| 2198 |
Py_INCREF(&EventHandlerCallRef_Type); |
| 2199 |
PyModule_AddObject(m, "EventHandlerCallRefType", (PyObject *)&EventHandlerCallRef_Type); |
| 2200 |
EventTargetRef_Type.ob_type = &PyType_Type; |
| 2201 |
if (PyType_Ready(&EventTargetRef_Type) < 0) return; |
| 2202 |
Py_INCREF(&EventTargetRef_Type); |
| 2203 |
PyModule_AddObject(m, "EventTargetRef", (PyObject *)&EventTargetRef_Type); |
| 2204 |
|
| 2205 |
Py_INCREF(&EventTargetRef_Type); |
| 2206 |
PyModule_AddObject(m, "EventTargetRefType", (PyObject *)&EventTargetRef_Type); |
| 2207 |
EventHotKeyRef_Type.ob_type = &PyType_Type; |
| 2208 |
if (PyType_Ready(&EventHotKeyRef_Type) < 0) return; |
| 2209 |
Py_INCREF(&EventHotKeyRef_Type); |
| 2210 |
PyModule_AddObject(m, "EventHotKeyRef", (PyObject *)&EventHotKeyRef_Type); |
| 2211 |
|
| 2212 |
Py_INCREF(&EventHotKeyRef_Type); |
| 2213 |
PyModule_AddObject(m, "EventHotKeyRefType", (PyObject *)&EventHotKeyRef_Type); |
| 2214 |
#endif |
| 2215 |
} |
| 2216 |
|
| 2217 |
|
| 2218 |
|