chaining OBJECT_new() functions?



Hi.

I made a class that defines several _new() functions, which take various
parameters.  I now want to subclass from this and keep my various _new()
functions with more or less the same parameters, and I want the behavior
to stay the same too.  I don't see anything in the documentation about
how to do it though.  anyone know?

example:

------------------------------------------------------------------------
/* from my primary class... */
GtkWidget*
gtk_grouped_toggle_new_from_widget          (GtkGroupedToggle *group)
{
    GtkGroupedToggle *new_toggle = NULL;

    new_toggle = g_object_new (GTK_TYPE_GROUPED_TOGGLE, NULL);
    if( new_toggle )
        new_toggle = gtk_grouped_toggle_add_to_list (new_toggle, group);

    return GTK_WIDGET(new_toggle);
}
------------------------------------------------------------------------
========================================================================
------------------------------------------------------------------------
/* how do I extend that without....  uhm...  maybe like this?   */
GtkWidget*
hptn_grouped_toggle_new_from_widget          (HpntGroupedToggle *group)
{
    HpntGroupedToggle *new_toggle = NULL;
    GtkGroupedToggle  *gtk_new_toggle = NULL;

    new_toggle = g_object_new (HPNT_TYPE_GROUPED_TOGGLE, NULL);
    if( new_toggle )
    {
        gtk_new_toggle = GTK_GROUPED_TOGGLE(new_toggle);
        gtk_new_toggle = gtk_grouped_toggle_add_to_list (gtk_new_toggle, group);
        if( ! gtk_new_toggle )
            new_toggle = NULL;
    }

    return GTK_WIDGET(new_toggle);
}
------------------------------------------------------------------------

I'll try it.  I welcome advice.  Thanks.

- Ben




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