Re: [gtk-list] Re: GtkCList: How to get current selection?
- From: Jay Painter <jpaint serv net>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: GtkCList: How to get current selection?
- Date: Tue, 14 Jul 1998 13:46:28 -0700 (PDT)
> You're gonna hate me for this answer but I'm sorry I cant help it.
> Use this:
> GList *sList;
> int rNum;
> sList = GTK_CLIST(clist)->selection;
> By the way, this is NOT the ONLY thing for which one has to rely on the
> internal structure of GtkCList. Recently I have been in need of a whole
This is how you are _suppose_ to get that information. The instance
structures in GTK are not opaque. They have never been. Maybe they
should be, but that in itself brings up other questions of convention
GList *gtk_clist_get_selections (GtkCList *clist);
Okay, what does this function do? Do we return
GTK_CLIST(clist)->selection? Well, then the user might try to modify that
list not realizing CList depends on it. Do we allocate a new list?
That's inviting memory leaks. Do we decide to never return lists in GTK,
and always pass a callback that is called for each item in the list?
That's a little inconvinent.
It's not that I don't agree that it would be nice to make more of the
internal representation of GTK widgets opaque, it's just that until we
have definate conventions on how to do it we shouldn't.
Also, remember how much faster it is to de-reference a pointer than it is
to call a function. A guy at work who writes video drivers gave me a
"good talkin to" about some code I wrote, describing that a function call
takes about 45 clock cycles on a Pentium.
] [Thread Prev