Re: Question about type casting.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux