1 /* -*- Mode: C; c-basic-offset: 4 -*-
2 * pygtk- Python bindings for the GTK toolkit.
3 * Copyright (C) 1998-2003 James Henstridge
4 * Copyright (C) 2005 Oracle
6 * Author: Manish Singh <manish.singh@oracle.com>
8 * pygsource.c: GSource wrapper
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License as published by the Free Software Foundation; either
13 * version 2.1 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this library; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
31 #include <structmember.h> /* for PyMemberDef */
33 #include "pyglib-private.h"
34 #include "pygsource.h"
38 PYGLIB_DEFINE_TYPE("gi._glib.PollFD", PyGPollFD_Type, PyGPollFD)
40 static PyMemberDef pyg_poll_fd_members[] = {
41 { "fd", T_INT, offsetof(PyGPollFD, pollfd.fd), READONLY },
42 { "events", T_USHORT, offsetof(PyGPollFD, pollfd.events), READONLY },
43 { "revents", T_USHORT, offsetof(PyGPollFD, pollfd.revents), READONLY },
48 pyg_poll_fd_dealloc(PyGPollFD *self)
50 Py_XDECREF(self->fd_obj);
55 pyg_poll_fd_repr(PyGPollFD *self)
57 return PYGLIB_PyUnicode_FromFormat("<GPollFD %d (%d) at 0x%lx>",
58 self->pollfd.fd, self->pollfd.events,
63 pyg_poll_fd_init(PyGPollFD *self, PyObject *args, PyObject *kwargs)
65 static char *kwlist[] = { "fd", "events", NULL };
70 if (!PyArg_ParseTupleAndKeywords(args, kwargs,
71 "OH:gi._glib.PollFD.__init__", kwlist,
75 fd = PyObject_AsFileDescriptor(o);
80 self->pollfd.events = events;
81 self->pollfd.revents = 0;
90 pyglib_source_register_types(PyObject *d)
92 PyGPollFD_Type.tp_dealloc = (destructor)pyg_poll_fd_dealloc;
93 PyGPollFD_Type.tp_repr = (reprfunc)pyg_poll_fd_repr;
94 PyGPollFD_Type.tp_flags = Py_TPFLAGS_DEFAULT;
95 PyGPollFD_Type.tp_members = pyg_poll_fd_members;
96 PyGPollFD_Type.tp_init = (initproc)pyg_poll_fd_init;
97 PYGLIB_REGISTER_TYPE(d, PyGPollFD_Type, "PollFD");