source: trunk/StreamVision/HotKeymodule.c @ 211

Last change on this file since 211 was 211, checked in by Nicholas Riley, 14 years ago

setup.py: use HotKey? module (shared with LocationDo?) instead of
_StreamVision module

HotKeymodule?.c: the aforementioned module

StreamVision?.py: use HotKey? module instead of _StreamVision module.
Fix StreamVision?.displayTrackInfo to not crash when iTunes jealously
hides the names of iTMS tracks from us. Switch track rating keys to
shift-F10/F11 to avoid conflicting with my preferred Expose/Dashboard?
key bindings on my iBook.

File size: 1.1 KB
Line 
1#include "Python.h"
2#include "pymactoolbox.h"
3
4#include <Carbon/Carbon.h>
5
6/* from _CarbonEvtmodule.c */
7extern PyTypeObject EventHotKeyRef_Type;
8#define EventHotKeyRef_Check(x) ((x)->ob_type == &EventHotKeyRef_Type || PyObject_TypeCheck((x), &EventHotKeyRef_Type))
9typedef struct EventHotKeyRefObject {
10  PyObject_HEAD
11  EventHotKeyRef ob_itself;
12} EventHotKeyRefObject;
13
14static PyObject
15*HotKey_HotKeyAddress(PyObject *self, PyObject *args) {
16  PyObject *v;
17  if (!PyArg_ParseTuple(args, "O", &v))
18    return NULL;
19  if (!EventHotKeyRef_Check(v)) {
20    PyErr_SetString(PyExc_TypeError, "_CarbonEvt.EventHotKeyRef required");
21    return NULL;
22  }
23  return PyInt_FromLong((int)((EventHotKeyRefObject *)v)->ob_itself);
24}
25
26static PyMethodDef HotKeymodule_methods[] = {
27  {"HotKeyAddress", HotKey_HotKeyAddress, METH_VARARGS,
28   "HotKeyAddress(_CarbonEvt.EventHotKeyRef) -> integer\n\n"
29   "Return the address of the underlying EventHotKeyRef (passed as data1 in hot key NSEvents)."},
30  {NULL, NULL, 0, NULL}
31};
32
33PyMODINIT_FUNC
34initHotKey(void) {
35  (void)Py_InitModule("HotKey", HotKeymodule_methods);
36}
Note: See TracBrowser for help on using the repository browser.