Re: gsignals and closure
- From: Jan-Marek Glogowski <glogow fbihome de>
- To: Marisa DeMeglio <marisa dinf ne jp>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: gsignals and closure
- Date: Fri, 25 Jun 2004 13:49:06 +0200 (CEST)
Hi
I'm trying to add parameters to my gsignal implementation. Is the use
of a closure function required to handle parameters?
You need marshallers to pass parameters.
There are two possible points of failure: signal declaration, or signal
emitting.
I will just provide an example from my code - HTH to find you problem.
BTW does your program shows any g_log messages, when run from the console?
singit_marshallers.list:
INT:STRING,INT
karaoke_data.h:
struct _SingitKaraokeDataClass
{
GObjectClass parent_class;
gint (* render) (SingitKaraokeData *skd, const gchar *text, gint
line);
...
};
karaoke_data.c:
enum {
RENDER,
...,
LAST_SIGNAL
};
static gint skd_signals[LAST_SIGNAL];
static void singit_karaoke_data_class_init
(gpointer g_class, gpointer g_class_data)
{
GObjectClass *object_class = G_OBJECT_CLASS(g_class);
SingitKaraokeDataClass *klass =
SINGIT_KARAOKE_DATA_CLASS(g_class);
skd_signals[RENDER] =
g_signal_new("render",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (SingitKaraokeDataClass, render),
NULL, NULL,
g_cclosure_user_marshal_INT__STRING_INT,
G_TYPE_INT, 2,
G_TYPE_POINTER,
G_TYPE_INT);
klass->render = NULL;
...
const gchar *line = "my line";
gint pixel_len = -1;
g_signal_emit( skd_object, skd_signals[RENDER],
0, NULL, line, &pixel_len );
...
Any other program file:
gint skd_render(SingitKaraokeData *skd, const gchar *text,
gint line, gpointer data)
{
return line;
}
HTH
Jan-Marek
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]