#include <gtk/gtk.h>
#include <gdk/gdkprivate.h>
#include <wx/gtk/win_gtk.h>
-#define GetXWindow(wxwin) GDK_WINDOW_XWINDOW(GTK_PIZZA((wxwin)->m_wxwindow)->bin_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;
}
}
wxPyInputStream::~wxPyInputStream() {
- /* do nothing */
+ if (m_wxis)
+ delete m_wxis;
}
}
-size_t wxPyCBInputStream::GetSize() const {
+wxFileOffset wxPyCBInputStream::GetLength() const {
wxPyCBInputStream* self = (wxPyCBInputStream*)this; // cast off const
if (m_seek && m_tell) {
wxFileOffset temp = self->OnSysTell();
return ret;
}
else
- return 0;
+ return wxInvalidOffset;
}
return 0;
}
+
wxFileOffset wxPyCBInputStream::OnSysSeek(wxFileOffset off, wxSeekMode mode) {
bool blocked = wxPyBeginBlockThreads();
-#if defined( __WINCE__) || defined(_LARGE_FILES) || defined(__HUGEFILES_SUPPORTED)
- // wxFileOffset is a 64-bit value...
- PyObject* arglist = Py_BuildValue("(Li)", off, mode);
-#else
- PyObject* arglist = Py_BuildValue("(ii)", off, mode);
-#endif
+ PyObject* arglist = PyTuple_New(2);
+
+ if (sizeof(wxFileOffset) > sizeof(long))
+ // wxFileOffset is a 64-bit value...
+ PyTuple_SET_ITEM(arglist, 0, PyLong_FromLongLong(off));
+ else
+ PyTuple_SET_ITEM(arglist, 0, PyInt_FromLong(off));
+
+ PyTuple_SET_ITEM(arglist, 1, PyInt_FromLong(mode));
+
+
PyObject* result = PyEval_CallObject(m_seek, arglist);
Py_DECREF(arglist);
Py_XDECREF(result);
Py_DECREF(arglist);
wxFileOffset o = 0;
if (result != NULL) {
-#if defined( __WINCE__) || defined(_LARGE_FILES) || defined(__HUGEFILES_SUPPORTED)
if (PyLong_Check(result))
o = PyLong_AsLongLong(result);
else
-#endif
o = PyInt_AsLong(result);
Py_DECREF(result);
};
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;