On Thu, 2003-02-20 at 18:07, Martin Stoilov wrote:
> Hi all,
>
> I am relatively new with GTK and I believe I am misunderstanding the
> concept of the type system. That is why I need a little help here.
>
> Looking at the source files of GTK it looks like that all functions that
> resemble C++ virtual functions and the type system configures when the
> the type is created are declared as static.
> For example the widget's "realise" function. If I decide to write my own
> widget deriving from the generic widget type I would initialize the
> pointer in GtkWidgetClass to point to my own "realize" function and that
> is all right. But when I start implementing my "realize" function I
> would like to first call the "realize" function of the base class so it
> can do its job and then proceed with my own code. The base class
> function though is static and is not declared in the header file. I
> thought probably there is a good reason for that and I shouldn't be
> calling it.
>
> I thought probably I am thinking too much in C++ terms and probably
> there is another way to accomplish this. I would highly appreciate if
> somebody helps me with this.
Make a global parent_class variable:
static GtkWidgetClass *parent_class = NULL;
In your class_init:
parent_class = g_type_class_peek_parent (class);
To chain up:
if (GTK_WIDGET_CLASS (parent_class)->unrealize)
(* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget);
There are _lots_ of examples of this in GTK+.
Regards,
Owen
_______________________________________________
gtk-list mailing list
[EMAIL PROTECTED]
http://mail.gnome.org/mailman/listinfo/gtk-list