[Glade-devel] commit -- add_signal signal
Damon Chaplin
damon@karuna.uklinux.net
Thu, 13 Mar 2003 20:54:43 +0000
On Sat, 2003-03-08 at 16:24, Joaquin Cuenca Abela wrote:
> I've added a "add_signal" to the GladeEditor widget (the properties
> window).
>
> To generate a prototype of the signal, you can do:
>
> static void
> glade_editor_add_signal_cb (GladeEditor *editor, const char *widget_id,
> GType widget_type, guint signal_id,
> const char *callback_name)
> {
> GSignalQuery query;
> unsigned int i;
>
> g_signal_query (signal_id, &query);
> printf ("%s %s(%s widget, ", g_type_name (query.return_type),
> callback_name, g_type_name (query.itype));
>
> for (i = 0; i < query.n_params; i++)
> printf ("%s arg%d, ", g_type_name
(query.param_types[i]), i);
>
> printf ("gpointer data);\n");
> }
>
> and hook the glade_editor_add_signal_cb to the "add_signal" of the
> GladeEditor widget.
You might want to pinch glade-2 code here, as it provides nice argument
names instead of "argXX" (at least for standard GTK+/GNOME signals).
It uses a hard-coded table, that I had to create manually. That isn't
ideal, but is the best we can do at present. (Or maybe you could put
this stuff into the widget description XML files.)
The code is in gb_widget_write_signal_handler_source() and
lookup_signal_arg_names() in glade/gbsource.c.
Damon