Author: js Date: 2009-02-14 15:39:05 +0100 (Sat, 14 Feb 2009) New Revision: 11101
Modified: branches/osx_newbuildsys/src/common/helpers.py branches/osx_newbuildsys/src/osx/nsapp_m/nsapp.m Log: Remove playFile from nsapp, use pyobjc instead.
Modified: branches/osx_newbuildsys/src/common/helpers.py =================================================================== --- branches/osx_newbuildsys/src/common/helpers.py 2009-02-14 14:27:22 UTC (rev 11100) +++ branches/osx_newbuildsys/src/common/helpers.py 2009-02-14 14:39:05 UTC (rev 11101) @@ -53,6 +53,12 @@ except Exception: pass
+if sys.platform == 'darwin': + try: + from Cocoa import NSSound + except ImportError: + pass + special_groups = (_('Transports'), _('Not in Roster'), _('Observers'), _('Groupchats'))
class InvalidFormat(Exception): @@ -771,9 +777,9 @@ return if sys.platform == 'darwin': try: - from osx import nsapp - nsapp.playFile(path_to_soundfile) - except ImportError: + snd = NSSound.alloc() + snd.initWithContentsOfFile_byReference_(path_to_soundfile, True).play() + except NameError: pass elif os.name == 'nt': try:
Modified: branches/osx_newbuildsys/src/osx/nsapp_m/nsapp.m =================================================================== --- branches/osx_newbuildsys/src/osx/nsapp_m/nsapp.m 2009-02-14 14:27:22 UTC (rev 11100) +++ branches/osx_newbuildsys/src/osx/nsapp_m/nsapp.m 2009-02-14 14:39:05 UTC (rev 11101) @@ -173,37 +173,6 @@ return Py_None; }
-static PyObject * nsapp_playFile(PyObject *self, PyObject *args) -{ - GAJIM_POOL_ALLOC - - const char* cstr = NULL; - - if (!PyArg_ParseTuple(args, "s", &cstr)) - { - return NULL; - } - - NSSound* snd = [[NSSound alloc] initWithContentsOfFile: - [[NSString alloc] initWithUTF8String: cstr] - byReference: YES]; - if (!snd) - { - Py_INCREF(Py_None); - return Py_None; - } - - if (![snd play]) - { - Py_INCREF(Py_None); - return Py_None; - } - - GAJIM_POOL_FREE - - return Py_BuildValue("b", 1); -} - static PyObject * nsapp_getBundlePath(PyObject *self, PyObject *args) { GAJIM_POOL_ALLOC @@ -237,8 +206,6 @@ "Callback to call when the network state changes"}, {"getBundlePath", nsapp_getBundlePath, METH_VARARGS, "Get the path to the bundle we were run from"}, - {"playFile", nsapp_playFile, METH_VARARGS, - "Play a sound file"}, {NULL, NULL, 0, NULL} };