diff -r 4e2690a764c1 -r 16118b4859a1 mercurial/osutil.c --- a/mercurial/osutil.c Wed Mar 23 01:14:43 2011 +0100 +++ b/mercurial/osutil.c Wed Mar 23 09:43:34 2011 +0100 @@ -514,6 +514,22 @@ } #endif +#ifdef __APPLE__ +#import + +static PyObject *isgui(PyObject *self) +{ + CFDictionaryRef dict = CGSessionCopyCurrentDictionary(); + + if (dict != NULL) { + CFRelease(dict); + return Py_True; + } else { + return Py_False; + } +} +#endif + static char osutil_doc[] = "Native operating system services."; static PyMethodDef methods[] = { @@ -524,6 +540,12 @@ "Open a file with POSIX-like semantics.\n" "On error, this function may raise either a WindowsError or an IOError."}, #endif +#ifdef __APPLE__ + { + "isgui", (PyCFunction)isgui, METH_NOARGS, + "Is a CoreGraphics session available?" + }, +#endif {NULL, NULL} };