2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
/* ========================== Module _Help ========================== */
|
|
|
|
|
|
|
|
#include "Python.h"
|
|
|
|
|
2008-06-05 09:58:24 -03:00
|
|
|
#ifndef __LP64__
|
2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
|
|
|
|
#include "pymactoolbox.h"
|
|
|
|
|
|
|
|
/* Macro to test whether a weak-loaded CFM function exists */
|
|
|
|
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
|
2010-05-09 11:46:46 -03:00
|
|
|
PyErr_SetString(PyExc_NotImplementedError, \
|
|
|
|
"Not available in this shared library/OS version"); \
|
|
|
|
return NULL; \
|
2001-08-23 11:02:09 -03:00
|
|
|
}} while(0)
|
|
|
|
|
|
|
|
|
2002-08-29 18:09:00 -03:00
|
|
|
#include <Carbon/Carbon.h>
|
2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
static PyObject *Help_Error;
|
|
|
|
|
2002-08-29 18:09:00 -03:00
|
|
|
static PyObject *Help_HMGetHelpMenu(PyObject *_self, PyObject *_args)
|
2001-08-23 11:02:09 -03:00
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSStatus _err;
|
|
|
|
MenuRef outHelpMenu;
|
|
|
|
MenuItemIndex outFirstCustomItemIndex;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = HMGetHelpMenu(&outHelpMenu,
|
|
|
|
&outFirstCustomItemIndex);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("O&H",
|
|
|
|
MenuObj_New, outHelpMenu,
|
|
|
|
outFirstCustomItemIndex);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
2002-08-29 18:09:00 -03:00
|
|
|
static PyObject *Help_HMAreHelpTagsDisplayed(PyObject *_self, PyObject *_args)
|
2001-08-23 11:02:09 -03:00
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
Boolean _rv;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_rv = HMAreHelpTagsDisplayed();
|
|
|
|
_res = Py_BuildValue("b",
|
|
|
|
_rv);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
2002-08-29 18:09:00 -03:00
|
|
|
static PyObject *Help_HMSetHelpTagsDisplayed(PyObject *_self, PyObject *_args)
|
2001-08-23 11:02:09 -03:00
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSStatus _err;
|
|
|
|
Boolean inDisplayTags;
|
|
|
|
if (!PyArg_ParseTuple(_args, "b",
|
|
|
|
&inDisplayTags))
|
|
|
|
return NULL;
|
|
|
|
_err = HMSetHelpTagsDisplayed(inDisplayTags);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
2002-08-29 18:09:00 -03:00
|
|
|
static PyObject *Help_HMSetTagDelay(PyObject *_self, PyObject *_args)
|
2001-08-23 11:02:09 -03:00
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSStatus _err;
|
|
|
|
Duration inDelay;
|
|
|
|
if (!PyArg_ParseTuple(_args, "l",
|
|
|
|
&inDelay))
|
|
|
|
return NULL;
|
|
|
|
_err = HMSetTagDelay(inDelay);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
2002-08-29 18:09:00 -03:00
|
|
|
static PyObject *Help_HMGetTagDelay(PyObject *_self, PyObject *_args)
|
2001-08-23 11:02:09 -03:00
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSStatus _err;
|
|
|
|
Duration outDelay;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = HMGetTagDelay(&outDelay);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
_res = Py_BuildValue("l",
|
|
|
|
outDelay);
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
2002-08-29 18:09:00 -03:00
|
|
|
static PyObject *Help_HMSetMenuHelpFromBalloonRsrc(PyObject *_self, PyObject *_args)
|
2001-08-23 11:02:09 -03:00
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSStatus _err;
|
|
|
|
MenuRef inMenu;
|
|
|
|
SInt16 inHmnuRsrcID;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&h",
|
|
|
|
MenuObj_Convert, &inMenu,
|
|
|
|
&inHmnuRsrcID))
|
|
|
|
return NULL;
|
|
|
|
_err = HMSetMenuHelpFromBalloonRsrc(inMenu,
|
|
|
|
inHmnuRsrcID);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
2002-08-29 18:09:00 -03:00
|
|
|
static PyObject *Help_HMSetDialogHelpFromBalloonRsrc(PyObject *_self, PyObject *_args)
|
2001-08-23 11:02:09 -03:00
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSStatus _err;
|
|
|
|
DialogPtr inDialog;
|
|
|
|
SInt16 inHdlgRsrcID;
|
|
|
|
SInt16 inItemStart;
|
|
|
|
if (!PyArg_ParseTuple(_args, "O&hh",
|
|
|
|
DlgObj_Convert, &inDialog,
|
|
|
|
&inHdlgRsrcID,
|
|
|
|
&inItemStart))
|
|
|
|
return NULL;
|
|
|
|
_err = HMSetDialogHelpFromBalloonRsrc(inDialog,
|
|
|
|
inHdlgRsrcID,
|
|
|
|
inItemStart);
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
2003-12-05 20:00:17 -04:00
|
|
|
static PyObject *Help_HMHideTag(PyObject *_self, PyObject *_args)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *_res = NULL;
|
|
|
|
OSStatus _err;
|
|
|
|
if (!PyArg_ParseTuple(_args, ""))
|
|
|
|
return NULL;
|
|
|
|
_err = HMHideTag();
|
|
|
|
if (_err != noErr) return PyMac_Error(_err);
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
_res = Py_None;
|
|
|
|
return _res;
|
2003-12-05 20:00:17 -04:00
|
|
|
}
|
|
|
|
|
2008-06-05 09:58:24 -03:00
|
|
|
#endif /* __LP64__ */
|
|
|
|
|
2001-08-23 11:02:09 -03:00
|
|
|
static PyMethodDef Help_methods[] = {
|
2008-06-05 09:58:24 -03:00
|
|
|
#ifndef __LP64__
|
2010-05-09 11:46:46 -03:00
|
|
|
{"HMGetHelpMenu", (PyCFunction)Help_HMGetHelpMenu, 1,
|
|
|
|
PyDoc_STR("() -> (MenuRef outHelpMenu, MenuItemIndex outFirstCustomItemIndex)")},
|
|
|
|
{"HMAreHelpTagsDisplayed", (PyCFunction)Help_HMAreHelpTagsDisplayed, 1,
|
|
|
|
PyDoc_STR("() -> (Boolean _rv)")},
|
|
|
|
{"HMSetHelpTagsDisplayed", (PyCFunction)Help_HMSetHelpTagsDisplayed, 1,
|
|
|
|
PyDoc_STR("(Boolean inDisplayTags) -> None")},
|
|
|
|
{"HMSetTagDelay", (PyCFunction)Help_HMSetTagDelay, 1,
|
|
|
|
PyDoc_STR("(Duration inDelay) -> None")},
|
|
|
|
{"HMGetTagDelay", (PyCFunction)Help_HMGetTagDelay, 1,
|
|
|
|
PyDoc_STR("() -> (Duration outDelay)")},
|
|
|
|
{"HMSetMenuHelpFromBalloonRsrc", (PyCFunction)Help_HMSetMenuHelpFromBalloonRsrc, 1,
|
|
|
|
PyDoc_STR("(MenuRef inMenu, SInt16 inHmnuRsrcID) -> None")},
|
|
|
|
{"HMSetDialogHelpFromBalloonRsrc", (PyCFunction)Help_HMSetDialogHelpFromBalloonRsrc, 1,
|
|
|
|
PyDoc_STR("(DialogPtr inDialog, SInt16 inHdlgRsrcID, SInt16 inItemStart) -> None")},
|
|
|
|
{"HMHideTag", (PyCFunction)Help_HMHideTag, 1,
|
|
|
|
PyDoc_STR("() -> None")},
|
2008-06-05 09:58:24 -03:00
|
|
|
#endif /* __LP64__ */
|
2010-05-09 11:46:46 -03:00
|
|
|
{NULL, NULL, 0}
|
2001-08-23 11:02:09 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void init_Help(void)
|
|
|
|
{
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *m;
|
2008-06-05 09:58:24 -03:00
|
|
|
#ifndef __LP64__
|
2010-05-09 11:46:46 -03:00
|
|
|
PyObject *d;
|
2008-06-05 09:58:24 -03:00
|
|
|
#endif /* __LP64__ */
|
2001-08-23 11:02:09 -03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-05-09 11:46:46 -03:00
|
|
|
m = Py_InitModule("_Help", Help_methods);
|
2008-06-05 09:58:24 -03:00
|
|
|
#ifndef __LP64__
|
2010-05-09 11:46:46 -03:00
|
|
|
d = PyModule_GetDict(m);
|
|
|
|
Help_Error = PyMac_GetOSErrException();
|
|
|
|
if (Help_Error == NULL ||
|
|
|
|
PyDict_SetItemString(d, "Error", Help_Error) != 0)
|
|
|
|
return;
|
2008-06-05 09:58:24 -03:00
|
|
|
#endif /* __LP64__ */
|
2001-08-23 11:02:09 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ======================== End module _Help ======================== */
|
|
|
|
|