Re: New 'GObject' as base for GtkObject?
- From: Havoc Pennington <hp redhat com>
- To: gtk-devel-list redhat com
- Cc: kenelson sequoia ece ucdavis edu
- Subject: Re: New 'GObject' as base for GtkObject?
- Date: 21 Dec 1999 22:03:04 -0500
Karl Nelson <kenelson@ece.ucdavis.edu> writes:
> I really don't like this example much. You are enforcing
> entirely in the run time. I would much perfer...
>
> void
> gtk_radio_set_active (GtkRadioIntf *object, gboolean active)
> {
> g_return_if_fail( GTK_IS_RADIO_INTF(object));
>
> GTK_GET_RADIO(object)->set_active (object, active);
> }
>
Ideally you could call the function like so:
gtk_radio_set_active(GTK_RADIO(object), TRUE);
which means this:
void
gtk_radio_set_active(GtkRadio* radio, gboolean active)
{
g_return_if_fail(GTK_IS_RADIO(radio));
radio->set_active(radio, active);
}
OK, just like Karl's except for the name of the interface.
I don't see why the user cares whether the implementation is in a base
class or in a derived class, so I wouldn't like to see the type called
GtkRadioInterface and I wouldn't like to see the casts be
different. After all both interfaces and objects are opaque types;
it's silly to make the user-visible API depend on how they are
implemented.
In particular it's weird if I cast to GtkObject to operate on pure
interface base classes and GtkClassIWant to operate on "real" base
classes; people would have to look that up in the docs every time,
there is no reason they should have to care about it.
A design goal should be that user code looks the same whether a given
interface comes with an implementation or not...
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]