summaryrefslogtreecommitdiff
path: root/gtkmodule.c
diff options
context:
space:
mode:
authorJames Henstridge <james@daa.com.au>1999-04-20 05:13:37 +0000
committerJames Henstridge <jamesh@src.gnome.org>1999-04-20 05:13:37 +0000
commit938c63e50917fa48da6d3613aa1404d69eac9407 (patch)
tree71df2f2de2ca8bfaa27e9df52b0312e56aa6d98d /gtkmodule.c
parent5aec60a421e9f350dc07d2915d741ed9131e46a5 (diff)
downloadpygtk-938c63e50917fa48da6d3613aa1404d69eac9407.tar.gz
updated package version number.
1999-04-20 James Henstridge <james@daa.com.au> * pygtk.spec: updated package version number. * configure.in: added a check for the python thread module. If it is found, then also link _gtkmodule to the gthread library. Incremented minimum GTK version to 1.2.1. Incremented version to 0.5.13. * gtkmodule.c: call g_thread_init if python was built with thread support. This is required to turn thread support on inside gdk/gtk. * gtk.py: added new functions. (GtkList.insert_items): this function wasn't looking at the internal GtkObject for the children to insert, so would fail. * generate/gtkbase.defs (gtk_widget_accelerators_locked): new func. * generate/gtkmenus.defs (gtk_item_factory_add_foreign): new func. (gtk_menu_get_accel_group): new func. (gtk_menu_reorder_child): new func. (gtk_menu_shell_deselect): new func. * gtkmodule.c (_wrap_gtk_combo_set_popdown_strings): accept any sequence for the second argument, rather than just lists. (_wrap_gtk_init): check the return value, and throw an exception when a connection to the X server could not be made, rather than exiting. * gtk.py: got rid of some warnings when pygtk is imported when DISPLAY is not set. Not completely necessary, but it doesn't hurt. (GtkObject.remove_data) fixed small bug pointed out by Duncan Grisby.
Diffstat (limited to 'gtkmodule.c')
-rw-r--r--gtkmodule.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/gtkmodule.c b/gtkmodule.c
index ac5861bf..64b6491b 100644
--- a/gtkmodule.c
+++ b/gtkmodule.c
@@ -3247,7 +3247,16 @@ static PyObject * _wrap_gtk_init(PyObject *self, PyObject *args) {
for (i = 0; i < argc; i++)
argv[i] = strdup(PyString_AsString(PyList_GetItem(av, i)));
- gtk_init(&argc, &argv);
+ if (!gtk_init_check(&argc, &argv)) {
+ if (argv != NULL) {
+ for (i = 0; i < argc; i++)
+ if (argv[i] != NULL)
+ free(argv[i]);
+ free(argv);
+ }
+ PyErr_SetString(PyExc_RuntimeError, "cannot open display");
+ return NULL;
+ }
PySys_SetArgv(argc, argv);
if (argv != NULL) {
@@ -4095,14 +4104,18 @@ _wrap_gtk_combo_set_popdown_strings(PyObject *self, PyObject *args) {
PyObject *obj, *list, *item;
GList *glist = NULL;
int len, i;
- if (!PyArg_ParseTuple(args, "O!O!:gtk_combo_set_popdown_strings",
- &PyGtk_Type, &obj, &PyList_Type, &list))
+ if (!PyArg_ParseTuple(args, "O!O:gtk_combo_set_popdown_strings",
+ &PyGtk_Type, &obj, &list))
return NULL;
- len = PyList_Size(list);
+ if (!PySequence_Check(list)) {
+ PyErr_SetString(PyExc_TypeError, "second argument must be a sequence");
+ return NULL;
+ }
+ len = PySequence_Length(list);
for (i = 0; i < len; i++) {
- item = PyList_GetItem(list, i);
+ item = PySequence_GetItem(list, i);
if (!PyString_Check(item)) {
- PyErr_SetString(PyExc_TypeError, "list item not a string");
+ PyErr_SetString(PyExc_TypeError, "sequence item not a string");
g_list_free(glist);
return NULL;
}
@@ -5521,7 +5534,7 @@ static PyObject *_wrap_gdk_threads_enter(PyObject *self, PyObject *args) {
static PyObject *_wrap_gdk_threads_leave(PyObject *self, PyObject *args) {
if (!PyArg_ParseTuple(args, ":gdk_threads_leave"))
return NULL;
- gdk_threads_enter();
+ gdk_threads_leave();
Py_INCREF(Py_None);
return Py_None;
}
@@ -5769,6 +5782,12 @@ void init_gtk() {
else
PyGtk_FatalExceptions = PyObject_IsTrue(d);
+#ifdef WITH_THREAD
+ /* it is required that this function be called to enable the thread
+ * safety functions */
+ g_thread_init(NULL);
+#endif
+
if (PyErr_Occurred())
Py_FatalError("can't initialise module _gtk");
}