Re: Top Level GObject



Yes, A usual practice; for example you can look at GtkContainer;
which is an interface or abstract class (however you look at it)
you'll find this type of reasoning:

gtk_container_add(GtkContainer *c, GtkWidget *w) {
        g_return_if_fail(GTK_IS_CONTAINER(c));
        /* ... check args ... */

        if (c->add)
                c->add(c, w);

}

and a bunch of dummy functions that do:

        g_warning("%s: Not Implemented!", __FUNCTION__);

which are all attached to the class upon initialization.
(before child initializations).


I hope this helps.
        -Tristan

snowswept wrote:

All,

I was wondering what is the proper way to add over-ridable functions to
my top level GObject. I have my top level object (inherits from GObject)
which has a set of functions which just return false.

What I want to do is create a bunch of objects which inherit from my top
level object and then implement the set of functions which return false
from the top level object. So, in my derived object...

static void
x_class_init (XClass *klass)
{
        GObjectClass *o_class;

        parent_class = g_type_class_peek_parent (klass);

        o_class = (GObjectClass *) klass;

        o_class->finalize = x_finalize;

        /* override my set of functions */
        o_class->a = x_a;
        o_class->b = x_b;
}

I am assuming I put these in my top level object's Class struct? Is this
the proper place? Should I be creating an interface? What is the proper
way to go about this?

Thanks for your help. s.s.

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



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