Kaydet (Commit) e58962af authored tarafından Jack Jansen's avatar Jack Jansen

Fixed the first two bugs in the new file dialogs (found by Just):

- AskFileForSave didn't work for string return values
- filterProc didn't work.
üst b2a57722
...@@ -30,6 +30,7 @@ from Carbon.ControlAccessor import * # Also import Controls constants ...@@ -30,6 +30,7 @@ from Carbon.ControlAccessor import * # Also import Controls constants
import Carbon.File import Carbon.File
import macfs import macfs
import macresource import macresource
import os
_initialized = 0 _initialized = 0
...@@ -660,7 +661,7 @@ def AskFileForSave(**args): ...@@ -660,7 +661,7 @@ def AskFileForSave(**args):
# This is gross, and probably incorrect too # This is gross, and probably incorrect too
vrefnum, dirid, name = rr.selection[0].as_tuple() vrefnum, dirid, name = rr.selection[0].as_tuple()
pardir_fss = Carbon.File.FSSpec((vrefnum, dirid, '')) pardir_fss = Carbon.File.FSSpec((vrefnum, dirid, ''))
pardir_fsr = Carbon.File.FSRef(fss) pardir_fsr = Carbon.File.FSRef(pardir_fss)
pardir_path = pardir_fsr.FSRefMakePath() # This is utf-8 pardir_path = pardir_fsr.FSRefMakePath() # This is utf-8
name_utf8 = unicode(name, 'macroman').encode('utf8') name_utf8 = unicode(name, 'macroman').encode('utf8')
fullpath = os.path.join(pardir_path, name_utf8) fullpath = os.path.join(pardir_path, name_utf8)
......
...@@ -56,7 +56,7 @@ my_eventProc(NavEventCallbackMessage callBackSelector, ...@@ -56,7 +56,7 @@ my_eventProc(NavEventCallbackMessage callBackSelector,
if (!dict) return; if (!dict) return;
if ( (pyfunc = PyDict_GetItemString(dict, "eventProc")) == NULL ) { if ( (pyfunc = PyDict_GetItemString(dict, "eventProc")) == NULL ) {
PyErr_Clear(); PyErr_Print();
return; return;
} }
if ( pyfunc == Py_None ) { if ( pyfunc == Py_None ) {
...@@ -74,8 +74,8 @@ my_eventProc(NavEventCallbackMessage callBackSelector, ...@@ -74,8 +74,8 @@ my_eventProc(NavEventCallbackMessage callBackSelector,
if ( rv ) if ( rv )
Py_DECREF(rv); Py_DECREF(rv);
else { else {
fprintf(stderr, "Nav: exception in eventProc callback\n"); PySys_WriteStderr("Nav: exception in eventProc callback\n");
PyErr_Clear(); PyErr_Print();
} }
} }
...@@ -90,7 +90,7 @@ my_previewProc(NavCBRecPtr callBackParms, ...@@ -90,7 +90,7 @@ my_previewProc(NavCBRecPtr callBackParms,
if (!dict) return false; if (!dict) return false;
if ( (pyfunc = PyDict_GetItemString(dict, "previewProc")) == NULL ) { if ( (pyfunc = PyDict_GetItemString(dict, "previewProc")) == NULL ) {
PyErr_Clear(); PyErr_Print();
return false; return false;
} }
rv = PyObject_CallFunction(pyfunc, "s#", (void *)callBackParms, sizeof(NavCBRec)); rv = PyObject_CallFunction(pyfunc, "s#", (void *)callBackParms, sizeof(NavCBRec));
...@@ -98,8 +98,8 @@ my_previewProc(NavCBRecPtr callBackParms, ...@@ -98,8 +98,8 @@ my_previewProc(NavCBRecPtr callBackParms,
c_rv = PyObject_IsTrue(rv); c_rv = PyObject_IsTrue(rv);
Py_DECREF(rv); Py_DECREF(rv);
} else { } else {
fprintf(stderr, "Nav: exception in previewProc callback\n"); PySys_WriteStderr("Nav: exception in previewProc callback\n");
PyErr_Clear(); PyErr_Print();
} }
return c_rv; return c_rv;
} }
...@@ -113,20 +113,21 @@ my_filterProc(AEDesc *theItem, void *info, ...@@ -113,20 +113,21 @@ my_filterProc(AEDesc *theItem, void *info,
PyObject *pyfunc; PyObject *pyfunc;
PyObject *rv; PyObject *rv;
Boolean c_rv = false; Boolean c_rv = false;
PyObject theItemCopy;
if (!dict) return false; if (!dict) return false;
if ( (pyfunc = PyDict_GetItemString(dict, "filterProc")) == NULL ) { if ( (pyfunc = PyDict_GetItemString(dict, "filterProc")) == NULL ) {
PyErr_Clear(); PyErr_Print();
return false; return false;
} }
rv = PyObject_CallFunction(pyfunc, "O&s#h", rv = PyObject_CallFunction(pyfunc, "O&s#h",
AEDesc_New, theItem, info, sizeof(NavFileOrFolderInfo), (short)filterMode); AEDesc_NewBorrowed, theItem, info, sizeof(NavFileOrFolderInfo), (short)filterMode);
if ( rv ) { if ( rv ) {
c_rv = PyObject_IsTrue(rv); c_rv = PyObject_IsTrue(rv);
Py_DECREF(rv); Py_DECREF(rv);
} else { } else {
fprintf(stderr, "Nav: exception in filterProc callback\n"); PySys_WriteStderr("Nav: exception in filterProc callback\n");
PyErr_Clear(); PyErr_Print();
} }
return c_rv; return c_rv;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment