custom gtkwidget destruction



Hi,

I'm a little confused over destruction of my custom widgets. I'm
mainly looking at existing code for how to do things as I've found the
docs (via DevHelp) difficult to understand and to garner an idea of
when and what is needed.

Here's some typical code for one of the widgets which is (typically)
just a group of GtkWidgets:

--8<--
G_DEFINE_TYPE(EnvelopeTab, envelope_tab, GTK_TYPE_VBOX)

static void envelope_tab_destroy(GtkObject* object);
static void update_env(EnvelopeTabPrivate*);


static void envelope_tab_class_init(EnvelopeTabClass* klass)
{
    GtkObjectClass *object_class = GTK_OBJECT_CLASS(klass);

    object_class->destroy = envelope_tab_destroy;
    envelope_tab_parent_class = g_type_class_peek_parent(klass);

    g_type_class_add_private(object_class, sizeof(EnvelopeTabPrivate));
}


static void envelope_tab_destroy(GtkObject* object)
{
    GtkObjectClass* klass = GTK_OBJECT_CLASS(envelope_tab_parent_class);

    if (klass->destroy)
        klass->destroy(object);
}

--8<--

I am wondering if in this case, as there is no extra data to destroy,
is it really necessary for me to specify the destroy function?

Put another way, by specifying the destroy function, am I duplicating
by 'over-riding' the 'default destructor' and/or possibly omitting
things which should be done?

With regard to the docs, finalize and dispose are mentioned. Are these
only required if I explicitly need deeper control over the destruction
(of - in this case - the widgets my widget uses)?

Regards,
James.

-- 
_
: http://jwm-art.net/
-audio/image/text/code/



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