Monday, March 17, 2008

G_OBJECT vs GTK_OBJECT

http://ts-hoop.blogspot.com/2008/03/gtkcasting.html has the post ;

看GTK的Casting發現一個小問題


It mentioned the problems of the two types casting, I read the "Foundations of GTK+ Development" and found this is the problems of the versions.

GObject is the fundamental type providing common attributes for all libraries based
on it including GTK+ and Pango. It allows objects derived from it to be constructed,
destroyed, referenced, and unreferenced. It also provides the signal system and object
property functions. You can cast an object as a GObject with G_OBJECT(). If you try to
cast an object with G_OBJECT() that is not a GObject or derived from it, GLib will throw a
critical error, and the cast will fail. This will occur with any other GTK+ casting function.

GtkObject is the base class for all GTK+ objects. It was replaced as the absolute base
class of all objects in GTK+ 2.0, but GtkObject was kept for backward compatibility of
nonwidget classes like GtkAdjustment. You can cast an object as a GtkObject with
GTK_OBJECT().

No comments: