1 /* -*- Mode: C; c-basic-offset: 4 -*-
2 * pyglib - Python bindings for GLib toolkit.
3 * Copyright (C) 1998-2003 James Henstridge
4 * 2004-2008 Johan Dahlin
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
31 typedef void (*PyGLibThreadsEnabledFunc
) (void);
32 typedef void (*PyGLibThreadBlockFunc
) (void);
34 void pyglib_init(void);
35 void pyglib_init_internal(PyObject
*api
);
36 PyGILState_STATE
pyglib_gil_state_ensure(void);
37 void pyglib_gil_state_release(PyGILState_STATE state
);
38 int pyglib_enable_threads(void);
39 gboolean
pyglib_error_check(GError
**error
);
40 gboolean
pyglib_gerror_exception_check(GError
**error
);
41 PyObject
*pyglib_register_exception_for_domain(gchar
*name
,
43 gboolean
pyglib_threads_enabled(void);
44 PyObject
* pyglib_main_context_new(GMainContext
*context
);
45 void pyglib_set_thread_block_funcs(PyGLibThreadBlockFunc block_threads_func
,
46 PyGLibThreadBlockFunc unblock_threads_func
);
47 void pyglib_block_threads(void);
48 void pyglib_unblock_threads(void);
49 PyObject
* pyglib_option_context_new(GOptionContext
*context
);
50 PyObject
* pyglib_option_group_new(GOptionGroup
*group
);
51 GOptionGroup
* pyglib_option_group_transfer_group(PyObject
*self
);
52 PyObject
* pyglib_float_from_timeval(GTimeVal timeval
);
54 /* Private: for gobject <-> glib interaction only. */
55 void _pyglib_notify_on_enabling_threads(PyGLibThreadsEnabledFunc callback
);
57 #define pyglib_begin_allow_threads \
59 PyThreadState *_save = NULL; \
60 if (pyglib_threads_enabled()) \
61 _save = PyEval_SaveThread();
63 #define pyglib_end_allow_threads \
64 if (pyglib_threads_enabled()) \
65 PyEval_RestoreThread(_save); \
68 #define PYGLIB_MODULE_START(symbol, modname) \
69 DL_EXPORT(void) init##symbol(void) \
72 module = Py_InitModule(modname, symbol##_functions);
73 #define PYGLIB_MODULE_END }
74 #define PYGLIB_DEFINE_TYPE(typename, symbol, csymbol) \
75 PyTypeObject symbol = { \
76 PyObject_HEAD_INIT(NULL) \
82 #define PYGLIB_REGISTER_TYPE(d, type, name) \
84 type.tp_alloc = PyType_GenericAlloc; \
86 type.tp_new = PyType_GenericNew; \
87 if (PyType_Ready(&type)) \
89 PyDict_SetItemString(d, name, (PyObject *)&type);
93 #endif /* __PYGLIB_H__ */