chiark / gitweb /
Callbacks from C done properly
[clg] / glib / alien / callback.c
CommitLineData
ab0ddec3 1/* Common Lisp bindings for GTK+ v2.0
2 * Copyright (C) 1999-2002 Espen S. Johnsen <espen@users.sourceforge.net>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 */
18
34f9e1d4 19/* $Id: callback.c,v 1.3 2004-11-01 00:08:50 espen Exp $ */
ab0ddec3 20
21#include <glib-object.h>
22
23#ifdef CMUCL
24#include "lisp.h"
ab0ddec3 25
34f9e1d4 26void (*log_handler) (gchar*, guint, gchar*);
ab0ddec3 27#endif
28
29
ab0ddec3 30
31GClosure*
34f9e1d4 32clg_callback_closure_new (gpointer callback_id, gpointer callback,
33 gpointer destroy_notify)
ab0ddec3 34{
35 GClosure *closure;
36
37 closure = g_closure_new_simple (sizeof (GClosure), (gpointer)callback_id);
34f9e1d4 38 g_closure_set_meta_marshal (closure, callback_id, callback);
39 g_closure_add_finalize_notifier (closure, callback_id, destroy_notify);
ab0ddec3 40
41 return closure;
42}
43
44
1ef1a285 45void
46g_logv (const gchar *log_domain,
47 GLogLevelFlags log_level,
48 const gchar *format,
49 va_list args1)
ab0ddec3 50{
1ef1a285 51 gchar *msg = g_strdup_vprintf (format, args1);
34f9e1d4 52 log_handler (log_domain, log_level, msg);
53
54 /* Normally log_handler won't return, so we will be leaking this memory */
1ef1a285 55 g_free (msg);
ab0ddec3 56}