use g_signal_newc

2000-12-15  Havoc Pennington  <hp@pobox.com>

* gobject.c (g_object_do_class_init): use g_signal_newc

* gsignal.c (g_signal_newc): convenience function for signals
created from C
(g_signal_new_valist): added
(g_signal_new): removed
This commit is contained in:
Havoc Pennington 2000-12-15 07:05:10 +00:00 committed by Havoc Pennington
parent 71a6ca2542
commit b3c410dee1
4 changed files with 81 additions and 41 deletions

View File

@ -1,3 +1,12 @@
2000-12-15 Havoc Pennington <hp@pobox.com>
* gobject.c (g_object_do_class_init): use g_signal_newc
* gsignal.c (g_signal_newc): convenience function for signals
created from C
(g_signal_new_valist): added
(g_signal_new): removed
Fri Dec 15 04:40:23 2000 Tim Janik <timj@gtk.org> Fri Dec 15 04:40:23 2000 Tim Janik <timj@gtk.org>
* gparam.[hc]: add an instance member value_type so the default * gparam.[hc]: add an instance member value_type so the default

View File

@ -299,25 +299,23 @@ g_object_do_class_init (GObjectClass *class)
"and a data pointer", "and a data pointer",
G_PARAM_WRITABLE)); G_PARAM_WRITABLE));
gobject_signals[PROPERTIES_CHANGED] = gobject_signals[PROPERTIES_CHANGED] =
g_signal_new ("properties_changed", g_signal_newc ("properties_changed",
G_TYPE_FROM_CLASS (class), G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE, G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE,
g_signal_type_cclosure_new (G_TYPE_FROM_CLASS (class), G_STRUCT_OFFSET (GObjectClass, properties_changed),
G_STRUCT_OFFSET (GObjectClass, properties_changed)), NULL, /* accumulator */
NULL, /* accumulator */ g_cclosure_marshal_VOID__UINT_POINTER,
g_cclosure_marshal_VOID__UINT_POINTER, G_TYPE_NONE,
G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_POINTER);
2, G_TYPE_UINT, G_TYPE_POINTER);
gobject_signals[NOTIFY] = gobject_signals[NOTIFY] =
g_signal_new ("notify", g_signal_newc ("notify",
G_TYPE_FROM_CLASS (class), G_TYPE_FROM_CLASS (class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS, G_SIGNAL_RUN_FIRST | G_SIGNAL_NO_RECURSE | G_SIGNAL_DETAILED | G_SIGNAL_NO_HOOKS,
g_signal_type_cclosure_new (G_TYPE_FROM_CLASS (class), G_STRUCT_OFFSET (GObjectClass, notify),
G_STRUCT_OFFSET (GObjectClass, notify)), NULL, /* accumulator */
NULL, /* accumulator */ g_cclosure_marshal_VOID__PARAM,
g_cclosure_marshal_VOID__PARAM, G_TYPE_NONE,
G_TYPE_NONE, 1, G_TYPE_PARAM);
1, G_TYPE_PARAM);
} }
void void

View File

@ -883,31 +883,26 @@ g_signal_list_ids (GType itype,
} }
guint guint
g_signal_new (const gchar *signal_name, g_signal_new_valist (const gchar *signal_name,
GType itype, GType itype,
GSignalFlags signal_flags, GSignalFlags signal_flags,
GClosure *class_closure, GClosure *class_closure,
GSignalAccumulator accumulator, GSignalAccumulator accumulator,
GSignalCMarshaller c_marshaller, GSignalCMarshaller c_marshaller,
GType return_type, GType return_type,
guint n_params, guint n_params,
...) va_list args)
{ {
GType *param_types; GType *param_types;
guint i; guint i;
va_list args;
guint signal_id; guint signal_id;
if (n_params > 0) if (n_params > 0)
{ {
param_types = g_new (GType, n_params); param_types = g_new (GType, n_params);
va_start (args, n_params);
for (i = 0; i < n_params; i++) for (i = 0; i < n_params; i++)
param_types[i] = va_arg (args, GType); param_types[i] = va_arg (args, GType);
va_end (args);
} }
else else
param_types = NULL; param_types = NULL;
@ -920,6 +915,35 @@ g_signal_new (const gchar *signal_name,
return signal_id; return signal_id;
} }
guint
g_signal_newc (const gchar *signal_name,
GType itype,
GSignalFlags signal_flags,
guint class_offset,
GSignalAccumulator accumulator,
GSignalCMarshaller c_marshaller,
GType return_type,
guint n_params,
...)
{
va_list args;
guint signal_id;
g_return_val_if_fail (signal_name != NULL, 0);
va_start (args, n_params);
signal_id = g_signal_new_valist (signal_name, itype, signal_flags,
g_signal_type_cclosure_new (itype,
class_offset),
accumulator, c_marshaller,
return_type, n_params, args);
va_end (args);
return signal_id;
}
guint guint
g_signal_newv (const gchar *signal_name, g_signal_newv (const gchar *signal_name,
GType itype, GType itype,

View File

@ -87,15 +87,6 @@ struct _GSignalQuery
/* --- signals --- */ /* --- signals --- */
guint g_signal_new (const gchar *signal_name,
GType itype,
GSignalFlags signal_flags,
GClosure *class_closure,
GSignalAccumulator accumulator,
GSignalCMarshaller c_marshaller,
GType return_type,
guint n_params,
...);
guint g_signal_newv (const gchar *signal_name, guint g_signal_newv (const gchar *signal_name,
GType itype, GType itype,
GSignalFlags signal_flags, GSignalFlags signal_flags,
@ -105,6 +96,24 @@ guint g_signal_newv (const gchar *signal_name,
GType return_type, GType return_type,
guint n_params, guint n_params,
GType *param_types); GType *param_types);
guint g_signal_new_valist (const gchar *signal_name,
GType itype,
GSignalFlags signal_flags,
GClosure *class_closure,
GSignalAccumulator accumulator,
GSignalCMarshaller c_marshaller,
GType return_type,
guint n_params,
va_list args);
guint g_signal_newc (const gchar *signal_name,
GType itype,
GSignalFlags signal_flags,
guint class_offset,
GSignalAccumulator accumulator,
GSignalCMarshaller c_marshaller,
GType return_type,
guint n_params,
...);
void g_signal_emitv (const GValue *instance_and_params, void g_signal_emitv (const GValue *instance_and_params,
guint signal_id, guint signal_id,
GQuark detail, GQuark detail,