Re: Question about type casting.
- From: "DC A" <adc4444 hotmail com>
- To: tristan van berkom gmail com, gtk-list gnome org
- Cc:
- Subject: Re: Question about type casting.
- Date: Sat, 08 Oct 2005 05:45:21 +0000
Thanks a lot for clearify this matter. So the bottom line is when there is
no mention
about the type of widget in argument we can use GtkWidget there, right?
From: Tristan Van Berkom <tristan van berkom gmail com>
To: DC A <adc4444 hotmail com>
CC: gtk-list gnome org
Subject: Re: Question about type casting.
Date: Sat, 08 Oct 2005 01:23:51 -0400
DC A wrote:
[...]
Why we cast for the first argument of this function but not the second
one?
It seems a little wierd, but eventually you find that its just easier
to
generalize where you can:
/* gtk_button_new & gtk_vbox_new return `GtkWidget *',
* not `GtkButton *'
*/
GtkWidget *vbox = gtk_vbox_new (FALSE, 0);
GtkWidget *button = gtk_button_new ();
/* Here we cast our `GtkWidget *vbox' to GTK_BOX to suit
* the api, most gtk functions take GtkWidget arguments
* (well, at least most container implementations do), so
* its just easier to declare every widget as `GtkWidget *'
* and not its subclass.
*/
gtk_box_pack_start (GTK_BOX (vbox), button, TRUE, TRUE, 0);
Cheers,
-Tristan
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]