[563] in The GTK GIMP ToolKit mailing list archive

home help back first fref pref prev next nref lref last post

[gtk-list] Re: More tutorial

daemon@ATHENA.MIT.EDU (Ian Main)
Tue Jul 29 13:46:11 1997

Date: Tue, 29 Jul 1997 10:46:55 -0700 (PDT)
From: Ian Main <slow@intergate.bc.ca>
To: Gtk+ mailing list <gtk-list@redhat.com>
In-Reply-To: <Pine.SOL.3.92.970729181703.23335A-100000@korillov.dtek.chalmers.se>
Resent-From: gtk-list@redhat.com
Reply-To: gtk-list@redhat.com

On Tue, 29 Jul 1997, Martin Norb{ck wrote:

> On Tue, 29 Jul 1997, Ian Main wrote:
> 
> >      /* this is a callback function. the data arg is ignored..
> >       * More on callbacks below. */
> >      void hello (gpointer *data)
> >      {
> >         g_print ("Hello World\n");
> >      }
> [SNIP]
> >         * defined above. */
> >        gtk_signal_connect (GTK_OBJECT (button), "clicked",
> >                            GTK_SIGNAL_FUNC (hello), NULL);
> One little comment.
> The clicked signal has declaration:
> void GtkButton::Clicked( GtkButton* button );
> which means that the callback really should have type
> void hello( GtkButton* button, gpointer* data );
> where the button argument is the button that sent the signal.
> 
> Since you are not using the data in this example there is nothing to worry
> about, but if you try to use it you will probably get an error.
> 
> Since the C calling convention allows any number of arguments to any function,
> the above code will work. The type checker can't check this either, because
> the hello function is casted anyway, so it's a bit of a problem really.
> 
> ----- BEGIN FLAME PROTECTION -----
> I hope I am right; I gathered this information by reading the source code. If I
> am wrong could someone please tell me, because that may fix some of the bugs
> in my programs!
> ----- END FLAME PROTECTION -----
> 
> /norpan
> 
> Signature left blank

Nope, your right.  I just did it from memory, and figured it'd be better
to have the callback function declared properly so it makes a better
template.

Thanks to everyone for your suggestions so far :)  I'm incorporating the
changes..

Ian


--
To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null


home help back first fref pref prev next nref lref last post