Re: Overriding iface implementations
- From: Magnus Bergman <magnus bergman observer net>
- To: <federico ximian com>
- Cc: gtk-devel-list gnome org
- Subject: Re: Overriding iface implementations
- Date: Thu, 26 Feb 2004 15:15:27 +0100
On Wed, 25 Feb 2004 10:25:41 -0600
Federico Mena Quintero <federico ximian com> wrote:
> On Wed, 2004-02-25 at 09:03, Owen Taylor wrote:
>
> > > Namely, the file chooser uses a GtkListStore for the shortcuts
> > > list. I want to make just the bookmarks part reorderable, so I
> > > need to override::row_draggable on the source side, and
> > > ::row_drop_possible on the destination side.
> > You just add the interface again and set the functions you want
> > and don't set the others. g_type_interface_peek_parent() can
> > be used to chain up.
>
> That means deriving from GtkListStore and re-adding the interfaces,
> right?
>
> My question is more along the following lines. Can I override
> interface methods for a particular instance of a class? E.g.
>
> GtkTreeDragSourceIface my_methods = {
> my_row_draggable_func,
> NULL,
> NULL
> };
>
> list = gtk_list_store_new ();
> override_interface (list, GTK_TYPE_TREE_DRAG_SOURCE,
> my_methods);
Even thou GLib doesn't directly support it, it is of course possible. I
don't know about interfaces specifically, but it's probably in the lines
of OO in general. So I hope this helps.
First of all you must have a function pointer in each instance, not just
in the class (which is what you get by default). Something like this:
struct MyWidget{
...
void(*row_draggable_func_pointer)(struct MyWidget*)
}
Then make a function that calls the per-instance function, perhaps
something like this:
void dynamic_row_draggable_func(MyWidget* this_widget){
this_widget->row_draggable_func_pointer(this_widget);
}
And just then you can override the function per instance:
widget_instance->row_draggable_func_pointer = my_row_draggable_func;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]