summaryrefslogtreecommitdiff
path: root/gobjectmodule.c
diff options
context:
space:
mode:
authorJohan Dahlin <zilch@src.gnome.org>2003-01-18 17:25:25 +0000
committerJohan Dahlin <zilch@src.gnome.org>2003-01-18 17:25:25 +0000
commitf2a49168dd47c12f2545198fec9469c7e80bd2a2 (patch)
tree53153db4abb9fc657de8ac31c09e903e67275f46 /gobjectmodule.c
parentc3a8eaaa5b87be0be2431df129c155c37dd14fdd (diff)
downloadpygtk-f2a49168dd47c12f2545198fec9469c7e80bd2a2.tar.gz
use os.path.join in a few more places
* setup.py: use os.path.join in a few more places * pygobject-private.h: Add PyGMainLoop struct and type * gobjectmodule.c (_wrap_g_main_loop_new, _wrap_g_main_loop_quit) (_wrap_g_main_loop_is_running, _wrap_g_main_loop_run): Added GMainLoop wrapper. (initgobject): Register wrapper in gobject.MainLoop
Diffstat (limited to 'gobjectmodule.c')
-rw-r--r--gobjectmodule.c113
1 files changed, 107 insertions, 6 deletions
diff --git a/gobjectmodule.c b/gobjectmodule.c
index 4a35cc67..4f1f371a 100644
--- a/gobjectmodule.c
+++ b/gobjectmodule.c
@@ -233,7 +233,7 @@ static PyTypeObject PyGInterface_Type = {
static void
pyg_register_interface(PyObject *dict, const gchar *class_name,
- GType gtype, PyTypeObject *type)
+ GType gtype, PyTypeObject *type)
{
PyObject *o;
@@ -241,19 +241,113 @@ pyg_register_interface(PyObject *dict, const gchar *class_name,
type->tp_base = &PyGInterface_Type;
if (PyType_Ready(type) < 0) {
- g_warning("could not ready `%s'", type->tp_name);
- return;
+ g_warning("could not ready `%s'", type->tp_name);
+ return;
}
if (gtype) {
- o = pyg_type_wrapper_new(gtype);
- PyDict_SetItemString(type->tp_dict, "__gtype__", o);
- Py_DECREF(o);
+ o = pyg_type_wrapper_new(gtype);
+ PyDict_SetItemString(type->tp_dict, "__gtype__", o);
+ Py_DECREF(o);
}
PyDict_SetItemString(dict, (char *)class_name, (PyObject *)type);
}
+/* -------------- GMainLoop objects ---------------------------- */
+
+static int
+_wrap_g_main_loop_new(PyGMainLoop *self, PyObject *args, PyObject *kwargs)
+{
+
+ static char *kwlist[] = { "is_running", NULL };
+ int is_running;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+ "|b:GMainLoop.__init__",
+ kwlist, &is_running))
+ return -1;
+
+ self->loop = g_main_loop_new(NULL, is_running);
+ return 0;
+}
+
+static PyObject *
+_wrap_g_main_loop_quit (PyGMainLoop *self)
+{
+ g_main_loop_quit(self->loop);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *
+_wrap_g_main_loop_is_running (PyGMainLoop *self)
+{
+ PyObject *py_ret;
+
+ py_ret = g_main_loop_is_running(self->loop) ? Py_True : Py_False;
+ Py_INCREF(py_ret);
+ return py_ret;
+
+}
+
+static PyObject *
+_wrap_g_main_loop_run (PyGMainLoop *self)
+{
+ g_main_loop_run(self->loop);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyMethodDef _PyGMainLoop_methods[] = {
+ { "is_running", (PyCFunction)_wrap_g_main_loop_is_running, METH_NOARGS },
+ { "quit", (PyCFunction)_wrap_g_main_loop_quit, METH_NOARGS },
+ { "run", (PyCFunction)_wrap_g_main_loop_run, METH_NOARGS },
+ { NULL, NULL, 0 }
+};
+
+PyTypeObject PyGMainLoop_Type = {
+ PyObject_HEAD_INIT(NULL)
+ 0,
+ "gobject.MainLoop",
+ sizeof(PyGMainLoop),
+ 0,
+ /* methods */
+ (destructor)0,
+ (printfunc)0,
+ (getattrfunc)0,
+ (setattrfunc)0,
+ (cmpfunc)0,
+ (reprfunc)0,
+ 0,
+ 0,
+ 0,
+ (hashfunc)0,
+ (ternaryfunc)0,
+ (reprfunc)0,
+ (getattrofunc)0,
+ (setattrofunc)0,
+ 0,
+ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
+ NULL,
+ (traverseproc)0,
+ (inquiry)0,
+ (richcmpfunc)0,
+ 0,
+ (getiterfunc)0,
+ (iternextfunc)0,
+ _PyGMainLoop_methods,
+ 0,
+ 0,
+ NULL,
+ NULL,
+ (descrgetfunc)0,
+ (descrsetfunc)0,
+ 0,
+ (initproc)_wrap_g_main_loop_new,
+};
/* ---------------- gobject module functions -------------------- */
@@ -1645,6 +1739,13 @@ initgobject(void)
o=pyg_type_wrapper_new(G_TYPE_BOXED));
Py_DECREF(o);
+ PyGMainLoop_Type.ob_type = &PyType_Type;
+ PyGMainLoop_Type.tp_alloc = PyType_GenericAlloc;
+ PyGMainLoop_Type.tp_new = PyType_GenericNew;
+ if (PyType_Ready(&PyGMainLoop_Type))
+ return;
+ PyDict_SetItemString(d, "MainLoop", (PyObject *)&PyGMainLoop_Type);
+
PyGPointer_Type.ob_type = &PyType_Type;
PyGPointer_Type.tp_alloc = PyType_GenericAlloc;
PyGPointer_Type.tp_new = PyType_GenericNew;