pygobject r846 - in trunk: . glib gobject



Author: johan
Date: Mon Jul 21 17:27:22 2008
New Revision: 846
URL: http://svn.gnome.org/viewvc/pygobject?rev=846&view=rev

Log:
2008-07-21  Johan Dahlin  <johan gnome org>

        * glib/Makefile.am:
        * glib/glibmodule.c (pyg_idle_add), (pyg_timeout_add),
        (pyg_timeout_add_seconds), (pyg_io_add_watch),
        (pyglib_register_api), (pyglib_register_error),
        (pyglib_register_version_tuples), (init_glib):
        * glib/pygiochannel.c (py_io_channel_next),
        (py_io_channel_shutdown), (py_io_channel_set_encoding),
        (py_io_channel_read_chars), (py_io_channel_write_chars),
        (py_io_channel_write_lines), (py_io_channel_flush),
        (py_io_channel_set_flags), (py_io_channel_read_line),
        (py_io_channel_read_lines), (py_io_channel_seek),
        (py_io_channel_init), (pyglib_iochannel_register_types):
        * glib/pygiochannel.h:
        * glib/pyglib-private.h:
        * glib/pyglib.c (pyglib_threads_enabled),
        (pyglib_gil_state_ensure), (pyglib_gil_state_release),
        (pyglib_enable_threads), (pyglib_block_threads),
        (pyglib_unblock_threads), (pyglib_set_thread_block_funcs),
        (pyglib_handler_marshal), (pyglib_destroy_notify):
        * glib/pyglib.h:
        * glib/pygsource.c (pyg_source_set_callback),
        (pyglib_source_register_types):
        * glib/pygsource.h:
        * glib/pygspawn.c (pyglib_spawn_register_types):
        * glib/pygspawn.h:
        * gobject/Makefile.am:
        * gobject/__init__.py:
        * gobject/gobjectmodule.c (pyg_set_thread_block_funcs),
        (init_gobject):
        * gobject/pygiochannel.c:
        * gobject/pygobject-private.h:
        * gobject/pygsource.c:
        Move over Source, IOChannel, Idle, Timeout and PollFD to glib from
        gobject.
        Clean up and add a bit of new api for glib.



Added:
   trunk/glib/pygiochannel.c
      - copied, changed from r845, /trunk/gobject/pygiochannel.c
   trunk/glib/pygiochannel.h
   trunk/glib/pygsource.c
      - copied, changed from r845, /trunk/gobject/pygsource.c
   trunk/glib/pygsource.h
Removed:
   trunk/gobject/pygiochannel.c
   trunk/gobject/pygsource.c
Modified:
   trunk/ChangeLog
   trunk/glib/Makefile.am
   trunk/glib/glibmodule.c
   trunk/glib/pyglib-private.h
   trunk/glib/pyglib.c
   trunk/glib/pyglib.h
   trunk/glib/pygspawn.c
   trunk/glib/pygspawn.h
   trunk/gobject/Makefile.am
   trunk/gobject/__init__.py
   trunk/gobject/gobjectmodule.c
   trunk/gobject/pygobject-private.h

Modified: trunk/glib/Makefile.am
==============================================================================
--- trunk/glib/Makefile.am	(original)
+++ trunk/glib/Makefile.am	Mon Jul 21 17:27:22 2008
@@ -30,10 +30,16 @@
 _glib_la_LIBADD = $(GLIB_LIBS) libpyglib-2.0.la
 _glib_la_SOURCES = 	 \
 	glibmodule.c	 \
-	pygspawn.c	 \
-	pygspawn.h	 \
+	pygiochannel.c 	 \
+	pygiochannel.h 	 \
 	pygmaincontext.c \
-	pygmainloop.c
+	pygmaincontext.h \
+	pygmainloop.c	 \
+	pygmainloop.h	 \
+	pygsource.c 	 \
+	pygsource.h 	 \
+	pygspawn.c	 \
+	pygspawn.h
 
 if PLATFORM_WIN32
 _glib_la_CFLAGS += -DPLATFORM_WIN32

Modified: trunk/glib/glibmodule.c
==============================================================================
--- trunk/glib/glibmodule.c	(original)
+++ trunk/glib/glibmodule.c	Mon Jul 21 17:27:22 2008
@@ -30,33 +30,16 @@
 #include "pyglib.h"
 
 #include "pyglib-private.h"
+#include "pygiochannel.h"
 #include "pygmaincontext.h"
 #include "pygmainloop.h"
+#include "pygsource.h"
 #include "pygspawn.h"
 
 #define PYGLIB_MAJOR_VERSION PYGOBJECT_MAJOR_VERSION
 #define PYGLIB_MINOR_VERSION PYGOBJECT_MINOR_VERSION
 #define PYGLIB_MICRO_VERSION PYGOBJECT_MICRO_VERSION
 
-/**
- * pyg_destroy_notify:
- * @user_data: a PyObject pointer.
- *
- * A function that can be used as a GDestroyNotify callback that will
- * call Py_DECREF on the data.
- */
-void
-pyg_destroy_notify(gpointer user_data)
-{
-    PyObject *obj = (PyObject *)user_data;
-    PyGILState_STATE state;
-
-    state = pyglib_gil_state_ensure();
-    Py_DECREF(obj);
-    pyglib_gil_state_release(state);
-}
-
-
 
 /* ---------------- glib module functions -------------------- */
 
@@ -100,33 +83,6 @@
     return 0;
 }
 
-gboolean
-pyg_handler_marshal(gpointer user_data)
-{
-    PyObject *tuple, *ret;
-    gboolean res;
-    PyGILState_STATE state;
-
-    g_return_val_if_fail(user_data != NULL, FALSE);
-
-    state = pyglib_gil_state_ensure();
-
-    tuple = (PyObject *)user_data;
-    ret = PyObject_CallObject(PyTuple_GetItem(tuple, 0),
-			      PyTuple_GetItem(tuple, 1));
-    if (!ret) {
-	PyErr_Print();
-	res = FALSE;
-    } else {
-	res = PyObject_IsTrue(ret);
-	Py_DECREF(ret);
-    }
-    
-    pyglib_gil_state_release(state);
-
-    return res;
-}
-
 static PyObject *
 pyg_idle_add(PyObject *self, PyObject *args, PyObject *kwargs)
 {
@@ -160,8 +116,8 @@
     data = Py_BuildValue("(ON)", callback, cbargs);
     if (data == NULL)
 	return NULL;
-    handler_id = g_idle_add_full(priority, pyg_handler_marshal, data,
-				 pyg_destroy_notify);
+    handler_id = g_idle_add_full(priority, pyglib_handler_marshal, data,
+				 pyglib_destroy_notify);
     return PyInt_FromLong(handler_id);
 }
 
@@ -200,8 +156,8 @@
     if (data == NULL)
 	return NULL;
     handler_id = g_timeout_add_full(priority, interval,
-				    pyg_handler_marshal, data,
-				    pyg_destroy_notify);
+				    pyglib_handler_marshal, data,
+				    pyglib_destroy_notify);
     return PyInt_FromLong(handler_id);
 }
 
@@ -239,8 +195,8 @@
     if (data == NULL)
 	return NULL;
     handler_id = g_timeout_add_seconds_full(priority, interval,
-                                            pyg_handler_marshal, data,
-                                            pyg_destroy_notify);
+                                            pyglib_handler_marshal, data,
+                                            pyglib_destroy_notify);
     return PyInt_FromLong(handler_id);
 }
 
@@ -328,7 +284,7 @@
     iochannel = g_io_channel_unix_new(fd);
     handler_id = g_io_add_watch_full(iochannel, priority, condition,
 				     iowatch_marshal, data,
-				     (GDestroyNotify)pyg_destroy_notify);
+				     (GDestroyNotify)pyglib_destroy_notify);
     g_io_channel_unref(iochannel);
     
     return PyInt_FromLong(handler_id);
@@ -613,7 +569,7 @@
 };
 
 static void
-pyg_register_api(PyObject *d)
+pyglib_register_api(PyObject *d)
 {
     PyObject *o;
 
@@ -626,7 +582,7 @@
 }
 
 static void
-pyg_register_error(PyObject *d)
+pyglib_register_error(PyObject *d)
 {
     PyObject *dict;
     PyObject *gerror_class;
@@ -644,7 +600,7 @@
 }
 
 static void
-pyg_register_version_tuples(PyObject *d)
+pyglib_register_version_tuples(PyObject *d)
 {
     PyObject *o;
 
@@ -671,11 +627,12 @@
     m = Py_InitModule("glib._glib", pyglib_functions);
     d = PyModule_GetDict(m);
 
-    pyg_register_api(d);
-    pyg_register_error(d);
-    pyg_register_version_tuples(d);
-    pyg_spawn_register_types(d);
-
+    pyglib_register_api(d);
+    pyglib_register_error(d);
+    pyglib_register_version_tuples(d);
+    pyglib_iochannel_register_types(d);
     pyglib_mainloop_register_types(d);
     pyglib_maincontext_register_types(d);
+    pyglib_source_register_types(d);
+    pyglib_spawn_register_types(d);
 }

Copied: trunk/glib/pygiochannel.c (from r845, /trunk/gobject/pygiochannel.c)
==============================================================================
--- /trunk/gobject/pygiochannel.c	(original)
+++ trunk/glib/pygiochannel.c	Mon Jul 21 17:27:22 2008
@@ -4,11 +4,12 @@
 #  include <config.h>
 #endif
 
-#include <pyglib.h>
-#include "pygobject-private.h"
-#include "pythread.h"
+#include <Python.h>
+#include <pythread.h>
 #include <structmember.h> /* for PyMemberDef */
 
+#include "pyglib.h"
+#include "pyglib-private.h"
 
 typedef struct {
     PyObject_HEAD
@@ -27,7 +28,7 @@
 
     status = g_io_channel_read_line(self->channel, &str_return, &length,
                                     &terminator_pos, &error);
-    if (pyg_error_check(&error))
+    if (pyglib_error_check(&error))
         return NULL;
 
     if (status == G_IO_STATUS_EOF) {
@@ -82,7 +83,7 @@
         return NULL;
 	
     ret = g_io_channel_shutdown(self->channel, PyObject_IsTrue(flush), &error);
-    if (pyg_error_check(&error))
+    if (pyglib_error_check(&error))
 	return NULL;
 	
     return PyInt_FromLong(ret);
@@ -160,7 +161,7 @@
         return NULL;
     
     g_io_channel_set_encoding(self->channel, encoding, &error);
-    if (pyg_error_check(&error))
+    if (pyglib_error_check(&error))
 	return NULL;
     
     Py_INCREF(Py_None);
@@ -230,11 +231,11 @@
        
         buf = PyString_AS_STRING(ret_obj) + total_read;
 
-        pyg_unblock_threads();
+        pyglib_unblock_threads();
         status = g_io_channel_read_chars(self->channel, buf, buf_size, 
                                          &single_read, &error);
-        pyg_block_threads();
-	if (pyg_error_check(&error))
+        pyglib_block_threads();
+	if (pyglib_error_check(&error))
 	    goto failure;
 	
 	total_read += single_read;
@@ -265,10 +266,10 @@
                                      kwlist, &buf, &buf_len))
         return NULL;
 	
-    pyg_unblock_threads();
+    pyglib_unblock_threads();
     status = g_io_channel_write_chars(self->channel, buf, buf_len, &count, &error);
-    pyg_block_threads();
-    if (pyg_error_check(&error))
+    pyglib_block_threads();
+    if (pyglib_error_check(&error))
 	return NULL;
 	
     return PyInt_FromLong(count);
@@ -304,11 +305,11 @@
             return NULL;
         }
         PyString_AsStringAndSize(value, &buf, &buf_len);
-        pyg_unblock_threads();
+        pyglib_unblock_threads();
         status = g_io_channel_write_chars(self->channel, buf, buf_len, &count, &error);
-        pyg_unblock_threads();
+        pyglib_unblock_threads();
         Py_DECREF(value);
-        if (pyg_error_check(&error)) {
+        if (pyglib_error_check(&error)) {
             Py_DECREF(iter);
             return NULL;
         }
@@ -330,10 +331,10 @@
                                      kwlist))
         return NULL;
 	
-    pyg_unblock_threads();
+    pyglib_unblock_threads();
     status = g_io_channel_flush(self->channel, &error);
-    pyg_block_threads();
-    if (pyg_error_check(&error))
+    pyglib_block_threads();
+    if (pyglib_error_check(&error))
 	return NULL;
 	
     return PyInt_FromLong(status);
@@ -352,7 +353,7 @@
         return NULL;
 	
     status = g_io_channel_set_flags(self->channel, flags, &error);
-    if (pyg_error_check(&error))
+    if (pyglib_error_check(&error))
 	return NULL;
 	
     return PyInt_FromLong(status);
@@ -576,7 +577,7 @@
 
     status = g_io_channel_read_line(self->channel, &str_return, &length,
                                     &terminator_pos, &error);
-    if (pyg_error_check(&error))
+    if (pyglib_error_check(&error))
         return NULL;
     ret_obj = PyString_FromStringAndSize(str_return, length);
     g_free(str_return);
@@ -603,7 +604,7 @@
     while (status == G_IO_STATUS_NORMAL) {
         status = g_io_channel_read_line(self->channel, &str_return, &length,
                                         &terminator_pos, &error);
-        if (pyg_error_check(&error)) {
+        if (pyglib_error_check(&error)) {
             Py_DECREF(line);
             return NULL;
         }
@@ -645,7 +646,7 @@
 	
     status = g_io_channel_seek_position(self->channel, offset,
                                         seek_type, &error);
-    if (pyg_error_check(&error))
+    if (pyglib_error_check(&error))
 	return NULL;
 	
     return PyInt_FromLong(status);
@@ -742,7 +743,7 @@
         self->channel = g_io_channel_unix_new(fd);
     else if (filename != NULL) {
         self->channel = g_io_channel_new_file(filename, mode, &error);
-        if (pyg_error_check(&error))
+        if (pyglib_error_check(&error))
             return -1;
     }
 #ifdef G_OS_WIN32
@@ -810,3 +811,8 @@
     (PyObject *)0,			/* tp_bases */
 };
 
+void
+pyglib_iochannel_register_types(PyObject *d)
+{
+    PYGLIB_REGISTER_TYPE(d, PyGIOChannel_Type, "IOChannel");
+}

Added: trunk/glib/pygiochannel.h
==============================================================================
--- (empty file)
+++ trunk/glib/pygiochannel.h	Mon Jul 21 17:27:22 2008
@@ -0,0 +1,29 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * pyglib - Python bindings for GLib toolkit.
+ * Copyright (C) 1998-2003  James Henstridge
+ *               2004-2008  Johan Dahlin
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+#ifndef __PYG_IOCHANNEL_H__
+#define __PYG_IOCHANNEL_H__
+
+extern PyTypeObject PyGIOChannel_Type;
+
+void pyglib_iochannel_register_types(PyObject *d);
+
+#endif /* __PYG_IOCHANNEL_H__ */

Modified: trunk/glib/pyglib-private.h
==============================================================================
--- trunk/glib/pyglib-private.h	(original)
+++ trunk/glib/pyglib-private.h	Mon Jul 21 17:27:22 2008
@@ -28,8 +28,10 @@
 G_BEGIN_DECLS
 
 struct _PyGLib_Functions {
-  gboolean threads_enabled;
-  PyObject *gerror_exception;
+    gboolean threads_enabled;
+    PyObject *gerror_exception;
+    PyGLibThreadBlockFunc block_threads;
+    PyGLibThreadBlockFunc unblock_threads;
 };
 
 #define PYGLIB_REGISTER_TYPE(d, type, name)	\

Modified: trunk/glib/pyglib.c
==============================================================================
--- trunk/glib/pyglib.c	(original)
+++ trunk/glib/pyglib.c	Mon Jul 21 17:27:22 2008
@@ -80,12 +80,16 @@
 gboolean
 pyglib_threads_enabled(void)
 {
+    g_return_val_if_fail (_PyGLib_API != NULL, FALSE);
+
     return _PyGLib_API->threads_enabled;
 }
 
 PyGILState_STATE
 pyglib_gil_state_ensure(void)
 {
+    g_return_val_if_fail (_PyGLib_API != NULL, PyGILState_LOCKED);
+
     if (!_PyGLib_API->threads_enabled)
 	return PyGILState_LOCKED;
 
@@ -95,6 +99,8 @@
 void
 pyglib_gil_state_release(PyGILState_STATE state)
 {
+    g_return_if_fail (_PyGLib_API != NULL);
+
     if (!_PyGLib_API->threads_enabled)
 	return;
 
@@ -116,6 +122,8 @@
 gboolean
 pyglib_enable_threads(void)
 {
+    g_return_val_if_fail (_PyGLib_API != NULL, FALSE);
+
     if (_PyGLib_API->threads_enabled)
 	return TRUE;
   
@@ -142,6 +150,47 @@
     PyGILState_Release(flag);
 }
 
+/**
+ * pyglib_block_threads:
+ *
+ */
+void
+pyglib_block_threads(void)
+{
+    g_return_if_fail (_PyGLib_API != NULL);
+
+    if (_PyGLib_API->block_threads != NULL)
+	(* _PyGLib_API->block_threads)();
+}
+
+/**
+ * pyglib_unblock_threads:
+ *
+ */
+void
+pyglib_unblock_threads(void)
+{
+    g_return_if_fail (_PyGLib_API != NULL);
+    if (_PyGLib_API->unblock_threads != NULL)
+	(* _PyGLib_API->unblock_threads)();
+}
+
+/**
+ * pyglib_set_thread_block_funcs:
+ *
+ * hooks to register handlers for getting GDK threads to cooperate
+ * with python threading
+ */
+void
+pyglib_set_thread_block_funcs (PyGLibThreadBlockFunc block_threads_func,
+			       PyGLibThreadBlockFunc unblock_threads_func)
+{
+    g_return_if_fail (_PyGLib_API != NULL);
+
+    _PyGLib_API->block_threads = block_threads_func;
+    _PyGLib_API->unblock_threads = unblock_threads_func;
+}
+
 
 /**
  * pyglib_error_check:
@@ -289,3 +338,50 @@
     self->context = g_main_context_ref(context);
     return (PyObject *)self;
 }
+
+gboolean
+pyglib_handler_marshal(gpointer user_data)
+{
+    PyObject *tuple, *ret;
+    gboolean res;
+    PyGILState_STATE state;
+
+    g_return_val_if_fail(user_data != NULL, FALSE);
+
+    state = pyglib_gil_state_ensure();
+
+    tuple = (PyObject *)user_data;
+    ret = PyObject_CallObject(PyTuple_GetItem(tuple, 0),
+			      PyTuple_GetItem(tuple, 1));
+    if (!ret) {
+	PyErr_Print();
+	res = FALSE;
+    } else {
+	res = PyObject_IsTrue(ret);
+	Py_DECREF(ret);
+    }
+    
+    pyglib_gil_state_release(state);
+
+    return res;
+}
+
+/**
+ * pyglib_destroy_notify:
+ * @user_data: a PyObject pointer.
+ *
+ * A function that can be used as a GDestroyNotify callback that will
+ * call Py_DECREF on the data.
+ */
+void
+pyglib_destroy_notify(gpointer user_data)
+{
+    PyObject *obj = (PyObject *)user_data;
+    PyGILState_STATE state;
+
+    g_return_if_fail (_PyGLib_API != NULL);
+    
+    state = pyglib_gil_state_ensure();
+    Py_DECREF(obj);
+    pyglib_gil_state_release(state);
+}

Modified: trunk/glib/pyglib.h
==============================================================================
--- trunk/glib/pyglib.h	(original)
+++ trunk/glib/pyglib.h	Mon Jul 21 17:27:22 2008
@@ -28,6 +28,8 @@
 
 G_BEGIN_DECLS
 
+typedef void (*PyGLibThreadBlockFunc) (void);
+
 void pyglib_init(void);
 void pyglib_init_internal(PyObject *api);
 PyGILState_STATE pyglib_gil_state_ensure(void);
@@ -37,6 +39,10 @@
 gboolean pyglib_gerror_exception_check(GError **error);
 gboolean pyglib_threads_enabled(void);
 PyObject *pyglib_main_context_new(GMainContext *context);
+gboolean pyglib_handler_marshal(gpointer user_data);
+void pyglib_destroy_notify(gpointer user_data);
+void pyglib_set_thread_block_funcs(PyGLibThreadBlockFunc block_threads_func,
+				   PyGLibThreadBlockFunc unblock_threads_func);
 
 #define pyglib_begin_allow_threads		\
     G_STMT_START {                              \

Copied: trunk/glib/pygsource.c (from r845, /trunk/gobject/pygsource.c)
==============================================================================
--- /trunk/gobject/pygsource.c	(original)
+++ trunk/glib/pygsource.c	Mon Jul 21 17:27:22 2008
@@ -27,11 +27,14 @@
 #  include <config.h>
 #endif
 
-#include "pygobject-private.h"
-#include "pythread.h"
-#include <structmember.h>
-#include <pyglib.h>
-
+#include <Python.h>
+#include <pythread.h>
+#include <structmember.h> /* for PyMemberDef */
+
+#include "pyglib.h"
+#include "pyglib-private.h"
+#include "pygmaincontext.h"
+#include "pygsource.h"
 
 #define CHECK_DESTROYED(self, ret)			G_STMT_START {	\
     if ((self)->source == NULL) {					\
@@ -158,8 +161,9 @@
     if (data == NULL)
 	return NULL;
 
-    g_source_set_callback(self->source, pyg_handler_marshal, data,
-			  pyg_destroy_notify);
+    g_source_set_callback(self->source,
+			  pyglib_handler_marshal, data,
+			  pyglib_destroy_notify);
 
     Py_INCREF(Py_None);
     return Py_None;
@@ -845,3 +849,12 @@
     (inquiry)0,				/* tp_is_gc */
     (PyObject *)0,			/* tp_bases */
 };
+
+void
+pyglib_source_register_types(PyObject *d)
+{
+    PYGLIB_REGISTER_TYPE(d, PyGSource_Type, "Source");
+    PYGLIB_REGISTER_TYPE(d, PyGIdle_Type, "Idle");
+    PYGLIB_REGISTER_TYPE(d, PyGTimeout_Type, "Timeout");
+    PYGLIB_REGISTER_TYPE(d, PyGPollFD_Type, "PollFD");
+}

Added: trunk/glib/pygsource.h
==============================================================================
--- (empty file)
+++ trunk/glib/pygsource.h	Mon Jul 21 17:27:22 2008
@@ -0,0 +1,39 @@
+/* -*- Mode: C; c-basic-offset: 4 -*-
+ * pyglib - Python bindings for GLib toolkit.
+ * Copyright (C) 1998-2003  James Henstridge
+ *               2004-2008  Johan Dahlin
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ * USA
+ */
+
+#ifndef __PYG_SOURCE_H__
+#define __PYG_SOURCE_H__
+
+extern PyTypeObject PyGSource_Type;
+extern PyTypeObject PyGIdle_Type;
+extern PyTypeObject PyGTimeout_Type;
+extern PyTypeObject PyGPollFD_Type;
+
+typedef struct
+{
+    PyObject_HEAD
+    GPollFD pollfd;
+    PyObject *fd_obj;
+} PyGPollFD;
+
+void pyglib_source_register_types(PyObject *d);
+
+#endif /* __PYG_SOURCE_H__ */

Modified: trunk/glib/pygspawn.c
==============================================================================
--- trunk/glib/pygspawn.c	(original)
+++ trunk/glib/pygspawn.c	Mon Jul 21 17:27:22 2008
@@ -290,7 +290,7 @@
 }
 
 void
-pyg_spawn_register_types(PyObject *d)
+pyglib_spawn_register_types(PyObject *d)
 {
     PyGPid_Type.tp_base = &PyInt_Type;
     PYGLIB_REGISTER_TYPE(d, PyGPid_Type, "Pid");

Modified: trunk/glib/pygspawn.h
==============================================================================
--- trunk/glib/pygspawn.h	(original)
+++ trunk/glib/pygspawn.h	Mon Jul 21 17:27:22 2008
@@ -23,7 +23,7 @@
 #define __PYG_PID_H__
 
 PyObject * pyg_pid_new(GPid pid);
-void pyg_spawn_register_types(PyObject *d);
+void pyglib_spawn_register_types(PyObject *d);
 
 PyObject * pyglib_spawn_async(PyObject *self, PyObject *args, PyObject *kwargs);
 

Modified: trunk/gobject/Makefile.am
==============================================================================
--- trunk/gobject/Makefile.am	(original)
+++ trunk/gobject/Makefile.am	Mon Jul 21 17:27:22 2008
@@ -53,8 +53,6 @@
 	pygobject-private.h \
 	pygparamspec.c \
 	pygpointer.c \
-	pygiochannel.c \
-	pygsource.c \
 	pygtype.c \
 	pygoptioncontext.c \
 	pygoptiongroup.c

Modified: trunk/gobject/__init__.py
==============================================================================
--- trunk/gobject/__init__.py	(original)
+++ trunk/gobject/__init__.py	Mon Jul 21 17:27:22 2008
@@ -32,7 +32,9 @@
      get_current_time, filename_display_name, filename_display_basename, \
      filename_from_utf8, get_application_name, set_application_name, \
      get_prgname, set_prgname, main_depth, Pid, GError, glib_version, \
-     MainLoop, MainContext, main_context_default
+     MainLoop, MainContext, main_context_default, IOChannel, Source, Idle, \
+     Timeout, PollFD
+
 from gobject.constants import *
 from _gobject import *
 _PyGObject_API = _gobject._PyGObject_API

Modified: trunk/gobject/gobjectmodule.c
==============================================================================
--- trunk/gobject/gobjectmodule.c	(original)
+++ trunk/gobject/gobjectmodule.c	Mon Jul 21 17:27:22 2008
@@ -79,6 +79,8 @@
 
     pygobject_api_functions.block_threads   = block_threads_func;
     pygobject_api_functions.unblock_threads = unblock_threads_func;
+    pyglib_set_thread_block_funcs(block_threads_func,
+				  unblock_threads_func);
 }
 
 static void
@@ -2753,13 +2755,6 @@
     PyGFlags_Type.tp_base = &PyInt_Type;
     REGISTER_GTYPE(d, PyGFlags_Type, "GFlags", G_TYPE_FLAGS);
 
-    REGISTER_TYPE(d, PyGIOChannel_Type, "IOChannel");
-
-    REGISTER_TYPE(d, PyGSource_Type, "Source");
-    REGISTER_TYPE(d, PyGIdle_Type, "Idle");
-    REGISTER_TYPE(d, PyGTimeout_Type, "Timeout");
-    REGISTER_TYPE(d, PyGPollFD_Type, "PollFD");
-
     PyType_Ready(&PyGObjectWeakRef_Type);
     PyDict_SetItemString(d, "GObjectWeakRef", (PyObject *) &PyGObjectWeakRef_Type);
 
@@ -2781,7 +2776,6 @@
 			 o=PyCObject_FromVoidPtr(&pygobject_api_functions,NULL));
     Py_DECREF(o);
 
-
     /* features */
     features = PyDict_New();
 #ifdef HAVE_FFI_H

Modified: trunk/gobject/pygobject-private.h
==============================================================================
--- trunk/gobject/pygobject-private.h	(original)
+++ trunk/gobject/pygobject-private.h	Mon Jul 21 17:27:22 2008
@@ -145,6 +145,13 @@
 extern PyTypeObject PyGProps_Type;
 extern PyTypeObject PyGPropsDescr_Type;
 extern PyTypeObject PyGPropsIter_Type;
+
+  /* Data that belongs to the GObject instance, not the Python wrapper */
+struct _PyGObjectData {
+    PyTypeObject *type; /* wrapper type for this instance */
+    GSList *closures;
+};
+
 void          pygobject_register_class   (PyObject *dict,
 					  const gchar *type_name,
 					  GType gtype, PyTypeObject *type,
@@ -236,28 +243,6 @@
 extern PyTypeObject PyGParamSpec_Type;
 PyObject * pyg_param_spec_new (GParamSpec *pspec);
 
-/* pygiochannel.c */
-extern PyTypeObject PyGIOChannel_Type;
-
-/* pygsource.c */
-extern PyTypeObject PyGSource_Type;
-extern PyTypeObject PyGIdle_Type;
-extern PyTypeObject PyGTimeout_Type;
-extern PyTypeObject PyGPollFD_Type;
-
-typedef struct
-{
-    PyObject_HEAD
-    GPollFD pollfd;
-    PyObject *fd_obj;
-} PyGPollFD;
-
-  /* Data that belongs to the GObject instance, not the Python wrapper */
-struct _PyGObjectData {
-    PyTypeObject *type; /* wrapper type for this instance */
-    GSList *closures;
-};
-
 /* pygoption.c */
 extern PyTypeObject PyGOptionContext_Type;
 extern PyTypeObject PyGOptionGroup_Type;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]