#include <gtk/gtk.h>
#include <gdk/gdkprivate.h>
#include <wx/gtk/win_gtk.h>
-#define GetXWindow(wxwin) GDK_WINDOW_XWINDOW((wxwin)->m_widget->window)
+#define GetXWindow(wxwin) (wxwin)->m_wxwindow ? \
+ GDK_WINDOW_XWINDOW(GTK_PIZZA((wxwin)->m_wxwindow)->bin_window) : \
+ GDK_WINDOW_XWINDOW((wxwin)->m_widget->window)
#include <locale.h>
#endif
//----------------------------------------------------------------------
-#if PYTHON_API_VERSION <= 1007 && wxUSE_UNICODE
+#if PYTHON_API_VERSION < 1009 && wxUSE_UNICODE
#error Python must support Unicode to use wxWindows Unicode
#endif
goto error;
}
- // On wxGTK the locale will be changed to match the system settings, but
- // Python needs to have LC_NUMERIC set to "C" in order for the floating
- // point conversions and such to work right.
-#ifdef __WXGTK__
+ // On wxGTK the locale will be changed to match the system settings,
+ // but Python before 2.4 needs to have LC_NUMERIC set to "C" in order
+ // for the floating point conversions and such to work right.
+#if defined(__WXGTK__) && PY_VERSION_HEX < 0x02040000
setlocale(LC_NUMERIC, "C");
#endif
PyDict_SetItemString(wxPython_dict, "USE_UNICODE", PyInt_FromLong(wxUSE_UNICODE));
PyDict_SetItemString(wxPython_dict, "__WXDEBUG__", PyInt_FromLong(wxdebug));
-
+ // Make a tuple of strings that gives more info about the platform.
PyObject* PlatInfo = PyList_New(0);
PyObject* obj;
#if wxUSE_UNICODE
_AddInfoString("unicode");
#else
- _AddInfoString("ascii");
+ _AddInfoString("ansi");
#endif
#ifdef __WXGTK__
#ifdef __WXGTK20__
if (info.tstate != tstate)
wxLogMessage("*** tstate mismatch!???");
#endif
- // info.tstate = tstate; *** DO NOT update existing ones???
+ info.tstate = tstate; // allow for transient tstates
// Normally it will never change, but apparently COM callbacks
// (i.e. ActiveX controls) will (incorrectly IMHO) use a transient
// tstate which will then be garbage the next time we try to use
// it...
+
wxPyTMutex->Unlock();
return;
}
}
-size_t wxPyCBInputStream::GetSize() const {
+wxFileOffset wxPyCBInputStream::GetLength() const {
wxPyCBInputStream* self = (wxPyCBInputStream*)this; // cast off const
if (m_seek && m_tell) {
- off_t temp = self->OnSysTell();
- off_t ret = self->OnSysSeek(0, wxFromEnd);
+ wxFileOffset temp = self->OnSysTell();
+ wxFileOffset ret = self->OnSysSeek(0, wxFromEnd);
self->OnSysSeek(temp, wxFromStart);
return ret;
}
else
- return 0;
+ return wxInvalidOffset;
}
return 0;
}
-off_t wxPyCBInputStream::OnSysSeek(off_t off, wxSeekMode mode) {
+wxFileOffset wxPyCBInputStream::OnSysSeek(wxFileOffset off, wxSeekMode mode) {
bool blocked = wxPyBeginBlockThreads();
-#ifdef _LARGE_FILES
- // off_t is a 64-bit value...
+#if defined( __WINCE__) || defined(_LARGE_FILES) || wxHAS_HUGE_FILES
+ // wxFileOffset is a 64-bit value...
PyObject* arglist = Py_BuildValue("(Li)", off, mode);
#else
PyObject* arglist = Py_BuildValue("(ii)", off, mode);
}
-off_t wxPyCBInputStream::OnSysTell() const {
+wxFileOffset wxPyCBInputStream::OnSysTell() const {
bool blocked = wxPyBeginBlockThreads();
PyObject* arglist = Py_BuildValue("()");
PyObject* result = PyEval_CallObject(m_tell, arglist);
Py_DECREF(arglist);
- off_t o = 0;
+ wxFileOffset o = 0;
if (result != NULL) {
-#ifdef _LARGE_FILES
+#if defined( __WINCE__) || defined(_LARGE_FILES) || wxHAS_HUGE_FILES
if (PyLong_Check(result))
o = PyLong_AsLongLong(result);
else
if (PyString_Check(source))
Py_DECREF(uni);
#else
- char* tmpPtr; int tmpSize;
- if (PyString_AsStringAndSize(source, &tmpPtr, &tmpSize) == -1) {
- PyErr_SetString(PyExc_TypeError, "Unable to convert string");
- return NULL;
+ // Convert to a string object if it isn't already, then to wxString
+ PyObject* str = source;
+ if (!PyString_Check(source)) {
+ str = PyObject_Str(source);
+ if (PyErr_Occurred()) return NULL;
}
+ char* tmpPtr; int tmpSize;
+ PyString_AsStringAndSize(str, &tmpPtr, &tmpSize);
target = new wxString(tmpPtr, tmpSize);
+
+ if (!PyString_Check(source))
+ Py_DECREF(str);
#endif // wxUSE_UNICODE
return target;