Re: strangeness of g_signal_connect
- From: Owen Taylor <otaylor redhat com>
- To: Annamalai Gurusami <annamalai gurusami masconit com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: strangeness of g_signal_connect
- Date: Tue, 26 Jul 2005 09:15:42 -0400
On Mon, 2005-07-25 at 12:50 +0530, Annamalai Gurusami wrote:
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?
Unless you are programming in C++, either will work, since there
is an automatic cast from any type to a void *, which is what
the first argument of g_signal_connect() takes. In C++, you need
the first.
My preference is simply:
g_signal_connect (AddFile_button, "clicked",
G_CALLBACK (on_add_files_activate), "dummy");
The reason that g_signal_connect() takes a void * rather than
a GObject * for the first parameter is that you could, in theory,
have libgobject types not deriving from GObject that supports
signals. In practice, I don't know of any uses of that.
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]