Re: GtkImage changes
- From: Darin Adler <darin eazel com>
- To: Havoc Pennington <hp redhat com>
- Cc: Gtk Developers <gtk-devel-list redhat com>
- Subject: Re: GtkImage changes
- Date: Wed, 28 Jun 2000 17:32:49 -0700
on 6/28/00 5:14 PM, Havoc Pennington at hp@redhat.com wrote:
>> I see no accessor for getting at the representation_type.
>
> representation_type is supposed to be internal (as are all those *Data
> structs in the header). Sadly there is no way to enforce that.
There is an easy way if you are willing to spend the overhead of one more
pointer and memory block, as you well know! If the stuff was in a private
structure (what we call "details" in the Nautilus code) then the enum,
union, and everything else could be in the .c file.
> The idea is, you can only _get_ a thing that you _set_. If you set a
> pixbuf, you can get a pixbuf. If you set a pixmap, you can get a
> pixmap. If you set a pixmap and try to get a pixbuf, we
> g_return_if_fail.
A flaw in this design just occurred to me. Lets say that I use a GtkImage
and I sometimes put a pixbuf in there and other times put a stock image in.
If I want to get the pixbuf back, then I have to track somewhere else
externally whether I put the pixbuf in or not. I don't think a use like this
is so much more farfetched than any client who wants to get back the pixbuf
they set up.
It's stuff like this (and not clearly marking the fields as private in the
header) that gets people peeking in at your private fields.
My humble suggestions, either
1) eliminate the getters altogether (goes with the flow of your current
design intent),
2) add a way to get the representation type, or
3) add a boolean return value from the get functions that returns TRUE
if this was the representation or FALSE if it was not (instead of using
return_if_fail).
-- Darin
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]