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 PyObject *pyglib_error_marshal (GError **error);
41 gboolean pyglib_gerror_exception_check(GError **error);
42 PyObject *pyglib_register_exception_for_domain(gchar *name,
44 gboolean pyglib_threads_enabled(void);
45 PyObject * pyglib_main_context_new(GMainContext *context);
46 void pyglib_set_thread_block_funcs(PyGLibThreadBlockFunc block_threads_func,
47 PyGLibThreadBlockFunc unblock_threads_func);
48 void pyglib_block_threads(void);
49 void pyglib_unblock_threads(void);
50 PyObject * pyglib_option_context_new(GOptionContext *context);
51 PyObject * pyglib_option_group_new(GOptionGroup *group);
52 GOptionGroup * pyglib_option_group_transfer_group(PyObject *self);
53 PyObject * pyglib_float_from_timeval(GTimeVal timeval);
55 /* Private: for gobject <-> glib interaction only. */
56 void _pyglib_notify_on_enabling_threads(PyGLibThreadsEnabledFunc callback);
57 PyObject* _pyglib_generic_ptr_richcompare(void* a, void *b, int op);
58 PyObject* _pyglib_generic_long_richcompare(long a, long b, int op);
60 #define pyglib_begin_allow_threads \
62 PyThreadState *_save = NULL; \
63 if (pyglib_threads_enabled()) \
64 _save = PyEval_SaveThread();
66 #define pyglib_end_allow_threads \
67 if (pyglib_threads_enabled()) \
68 PyEval_RestoreThread(_save); \
71 #define PYGLIB_REGISTER_TYPE(d, type, name) \
73 type.tp_alloc = PyType_GenericAlloc; \
75 type.tp_new = PyType_GenericNew; \
76 if (PyType_Ready(&type)) \
78 PyDict_SetItemString(d, name, (PyObject *)&type);
83 #endif /* __PYGLIB_H__ */