Re: strangeness of g_signal_connect
- From: Annamalai Gurusami <annamalai gurusami EMAIL masconit com>
- To: Colossus <colossus 3000 it>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: strangeness of g_signal_connect
- Date: Mon, 25 Jul 2005 12:50:19 +0530
Colossus <colossus 3000 it> writes:
In my app I have the following:
g_signal_connect ((gpointer) AddFile_button, "clicked",
G_CALLBACK (on_add_files_activate),
"dummy");
I normally write the above call like this:
g_signal_connect( G_OBJECT(AddFile_button), "clicked",
G_CALLBACK(on_add_files_activate), "dummy");
Are both correct? Which is the preferred way to do it?
I have noticed that if the function "on_add_files_activate" is
declared with only one parameter, gpointer data , I never receive
the word dummy. Instead if the same function is declared with two
parameters:
void on_add_files_activate ( GtkWidget *useless , gpointer data);
I can successfull print the value "dummy" pointed by data.
Could gtk developers explain this strange behaviour please ?
The actual parameters of the callback function is determined by the
event and the widget handling the event. Here you are handling the
"clicked" event for a GtkButton. And for this event, the prototype of
the callback handler is
void user_function(GtkButton *button, gpointer user_data);
http://developer.gnome.org/doc/API/2.0/gtk/GtkButton.html#GtkButton-clicked
You can use it or not, but you cannot change their order or add more
arguments. Maybe others can add more information on this.
Rgds,
anna
--
Open Movie: Not only will the project be realized with Open
Source/Free Software, but also the resulting movie will be published
under an open public license. This makes it an exciting premiere as
first ever "Open Movie" project! [ http://orange.blender.org ]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]