Re: [gtk-list] Re: Perl/Gtk: how to get the data from a Gtk::List?
- From: Des Herriott <des ops netcom net uk>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: Perl/Gtk: how to get the data from a Gtk::List?
- Date: Wed, 15 Apr 1998 08:23:11 +0100
On Apr 15, Kenneth Albanowski wrote:
> On Tue, 14 Apr 1998 email@example.com wrote:
> > Efficient but it goes against convention. It's like using public data in C++
> > or gotos in C. Say the key he chooses to store data in becomes an important
> > part of the list module... he would have to go through his entire program and
> > replace all occurances he uses the key to retrieve the data. One big mess
> > that could easily have been avoided early on.
> Since this is the first time the subject has ever come up, we can make
> decisions now to prevent various glitches. For one thing, none of the Perl
> interfaces currently store data in the the Perl shadow object (other than
> in some underscored utility slots, like '_gtk'), so it's perfectly safe to
> store data there. All access to Gtk data is via methods. It's possible
> this will change, but I don't expect it to happen.
I guess if a convention is decided on now, while the binding is still
fairly fluid, storing aribtrary data in PerlGtk objects should be OK.
If user-specified fields were to never start with an underscore, this
should be safe, should it not? That way, if it ever becomes necessary
to add other 'system' fields to objects, we can avoid a clash.
> I'm a bit puzzled by your general statement on this issue, as I really
> can't think of any other sensible way of doing this -- in _any_ GUI
> environment, not just Gtk. You've basically got three options to deal with
> list items: store data in some slot in the list items themselves, use the
> list index directly into an external array, or iterate over the labels of
> the list items. That last is relatively tedious in Gtk, since lists don't
> hold strings directly, and is less useful if you aren't just picking
I'd also considered the second option above, but it 'felt' wrong :)
Using an external array just seems very clumsy, when it should really
be up to the list item (or widgets in general) to carry the data (or a
reference to it) with it.
] [Thread Prev