Kaydet (Commit) 0d2390c5 authored tarafından Guido van Rossum's avatar Guido van Rossum

Merge Mac and Windows mods (which mostly affect the same problem -- no

usable createfilehandler).  Define HAVE_CREATEFILEHANDLER to test
later.  Also other Mac specific patches by Jack.
üst c4c26414
...@@ -59,10 +59,19 @@ PERFORMANCE OF THIS SOFTWARE. ...@@ -59,10 +59,19 @@ PERFORMANCE OF THIS SOFTWARE.
#define TKMAJORMINOR (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION) #define TKMAJORMINOR (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION)
#if TKMAJORMINOR >= 8000 && defined(macintosh)
/* Sigh, we have to include this to get at the tcl qd pointer */
#include <tkMac.h>
#endif
#if TKMAJORMINOR < 4001 #if TKMAJORMINOR < 4001
#error "Tk 4.0 or 3.x are not supported -- use 4.1 or higher" #error "Tk 4.0 or 3.x are not supported -- use 4.1 or higher"
#endif #endif
#if TKMAJORMINOR < 8000 || !defined(MS_WINDOWS) && !defined(macintosh)
#define HAVE_CREATEFILEHANDLER
#endif
extern int Tk_GetNumMainWindows(); extern int Tk_GetNumMainWindows();
#ifdef macintosh #ifdef macintosh
...@@ -78,7 +87,11 @@ extern int Tk_GetNumMainWindows(); ...@@ -78,7 +87,11 @@ extern int Tk_GetNumMainWindows();
#include <Events.h> /* For EventRecord */ #include <Events.h> /* For EventRecord */
typedef int (*TclMacConvertEventPtr) Py_PROTO((EventRecord *eventPtr)); typedef int (*TclMacConvertEventPtr) Py_PROTO((EventRecord *eventPtr));
void TclMacSetEventProc Py_PROTO((TclMacConvertEventPtr procPtr)); /* They changed the name... */
#if TKMAJORMINOR < 8000
#define Tcl_MacSetEventProc TclMacSetEventProc
#endif
void Tcl_MacSetEventProc Py_PROTO((TclMacConvertEventPtr procPtr));
int TkMacConvertEvent Py_PROTO((EventRecord *eventPtr)); int TkMacConvertEvent Py_PROTO((EventRecord *eventPtr));
staticforward int PyMacConvertEvent Py_PROTO((EventRecord *eventPtr)); staticforward int PyMacConvertEvent Py_PROTO((EventRecord *eventPtr));
...@@ -985,7 +998,7 @@ GetFileNo(file) ...@@ -985,7 +998,7 @@ GetFileNo(file)
static PyObject* Tkapp_ClientDataDict = NULL; static PyObject* Tkapp_ClientDataDict = NULL;
#ifndef WIN32 #ifdef HAVE_CREATEFILEHANDLER
static PyObject * static PyObject *
Tkapp_CreateFileHandler(self, args) Tkapp_CreateFileHandler(self, args)
PyObject *self; PyObject *self;
...@@ -1089,7 +1102,7 @@ Tkapp_DeleteFileHandler(self, args) ...@@ -1089,7 +1102,7 @@ Tkapp_DeleteFileHandler(self, args)
Py_INCREF(Py_None); Py_INCREF(Py_None);
return Py_None; return Py_None;
} }
#endif /* WIN32 */ #endif /* HAVE_CREATEFILEHANDLER */
/**** Tktt Object (timer token) ****/ /**** Tktt Object (timer token) ****/
...@@ -1104,6 +1117,8 @@ typedef struct ...@@ -1104,6 +1117,8 @@ typedef struct
} }
TkttObject; TkttObject;
/* XXXX For now... */
#if TKMAJORMINOR < 8000 || !defined(macintosh)
static PyObject * static PyObject *
Tktt_DeleteTimerHandler(self, args) Tktt_DeleteTimerHandler(self, args)
PyObject *self; PyObject *self;
...@@ -1210,6 +1225,7 @@ TimerHandler(clientData) ...@@ -1210,6 +1225,7 @@ TimerHandler(clientData)
else else
Py_DECREF(res); Py_DECREF(res);
} }
#endif /* macintosh */
static PyObject * static PyObject *
Tkapp_CreateTimerHandler(self, args) Tkapp_CreateTimerHandler(self, args)
...@@ -1340,7 +1356,7 @@ static PyMethodDef Tkapp_methods[] = ...@@ -1340,7 +1356,7 @@ static PyMethodDef Tkapp_methods[] =
{"merge", Tkapp_Merge, 0}, {"merge", Tkapp_Merge, 0},
{"createcommand", Tkapp_CreateCommand, 1}, {"createcommand", Tkapp_CreateCommand, 1},
{"deletecommand", Tkapp_DeleteCommand, 1}, {"deletecommand", Tkapp_DeleteCommand, 1},
#ifndef WIN32 #ifdef HAVE_CREATEFILEHANDLER
{"createfilehandler", Tkapp_CreateFileHandler, 1}, {"createfilehandler", Tkapp_CreateFileHandler, 1},
{"deletefilehandler", Tkapp_DeleteFileHandler, 1}, {"deletefilehandler", Tkapp_DeleteFileHandler, 1},
#endif #endif
...@@ -1423,7 +1439,7 @@ Tkinter_Create(self, args) ...@@ -1423,7 +1439,7 @@ Tkinter_Create(self, args)
static PyMethodDef moduleMethods[] = static PyMethodDef moduleMethods[] =
{ {
{"create", Tkinter_Create, 1}, {"create", Tkinter_Create, 1},
#ifndef WIN32 #ifdef HAVE_CREATEFILEHANDLER
{"createfilehandler", Tkapp_CreateFileHandler, 1}, {"createfilehandler", Tkapp_CreateFileHandler, 1},
{"deletefilehandler", Tkapp_DeleteFileHandler, 1}, {"deletefilehandler", Tkapp_DeleteFileHandler, 1},
#endif #endif
...@@ -1505,15 +1521,22 @@ init_tkinter() ...@@ -1505,15 +1521,22 @@ init_tkinter()
ins_string(d, "TK_VERSION", TK_VERSION); ins_string(d, "TK_VERSION", TK_VERSION);
ins_string(d, "TCL_VERSION", TCL_VERSION); ins_string(d, "TCL_VERSION", TCL_VERSION);
#ifndef WIN32
if (PyOS_InputHook == NULL) if (PyOS_InputHook == NULL)
PyOS_InputHook = EventHook; PyOS_InputHook = EventHook;
#endif
if (PyErr_Occurred()) if (PyErr_Occurred())
Py_FatalError("can't initialize module _tkinter"); Py_FatalError("can't initialize module _tkinter");
#ifdef macintosh #ifdef macintosh
TclMacSetEventProc(PyMacConvertEvent); /*
** Part of this code is stolen from MacintoshInit in tkMacAppInit.
** Most of the initializations in that routine (toolbox init calls and
** such) have already been done for us, so we only need these.
*/
#if TKMAJORMINOR >= 8000
tcl_macQdPtr = &qd;
#endif
Tcl_MacSetEventProc(PyMacConvertEvent);
#if GENERATINGCFM #if GENERATINGCFM
mac_addlibresources(); mac_addlibresources();
#endif /* GENERATINGCFM */ #endif /* GENERATINGCFM */
...@@ -1556,7 +1579,7 @@ PyMacConvertEvent(eventPtr) ...@@ -1556,7 +1579,7 @@ PyMacConvertEvent(eventPtr)
return TkMacConvertEvent(eventPtr); return TkMacConvertEvent(eventPtr);
} }
#ifdef USE_GUSI #if defined(USE_GUSI) && TKMAJORMINOR < 8000
/* /*
* For Python we have to override this routine (from TclMacNotify), * For Python we have to override this routine (from TclMacNotify),
* since we use GUSI for our sockets, not Tcl streams. Hence, we have * since we use GUSI for our sockets, not Tcl streams. Hence, we have
......
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