On Sun, Dec 20, 2009 at 01:57:06PM +0000, Matthew Bucknall wrote: > I'm implementing a custom container widget which needs to only accept > child widgets which derive from GtkWidget (obviously) but also implement > a custom Interface called GpanesPanel. > > I'm not sure how to enforce this rule within my code's API. What type > should the container's child_type() method return? GPANES_TYPE_PANEL or > GTK_TYPE_WIDGET? Likewise, I'm not sure what type custom insertion > methods for my container should accept, GpanesPanel or GtkWidget? > > It doesn't seem enough to use GPANES_TYPE_PANEL/GpanesPanel because, as > it stands, any non-widget class could implement the GpanesPanel > interface but would be unusable as a container child. Returing GPANES_TYPE_PANEL would be probably better as it can be ensured that the thing is also a widget (see below). Note that GtkContainer methods do not use child_type at preset, gtk_container_add() simply checks that the child is a GtkWidget, leaving specific checks for add() implementation in subclasses. This might be an implementation detail though... > Is there anything I can put in the GpanesPanel interface definition that > states that it can only be applied to classes derived from GtkWidget? Yes, g_type_interface_add_prerequisite() can do that. Yeti _______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list