RE: [gtk-list] Re: Perl/Gtk: how to get the data from a Gtk::Lis




On 15-Apr-98 Kenneth Albanowski wrote:
> <shrug> GTK objects can store arbitrary data, using the get_data and
> set_data calls. PerlGtk objects can store arbitrary data directly
> (including references to other Perl & GTK objects) in the object as a hash
> value. I'm not sure, offhand, why one would be better or worse, only that
> the hash method is far more convenient from Perl. And, in general, Perl
> objects are assumed to be able to contain arbitrary data if they are
> hashes.
> 
> (Note that PerlGtk objects are not tied hashes, so the storing data in
> this manner is quite efficient.) 

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.

> Now, if the ListItems cannot be used in this manner, that's another issue
> altogether. I'm not familiar enough with Lists to say. 
> 
> Certainly iterating over the children of the ListItem to get the label,
> and read it, should work, but this seems relatively inefficient,
> especially if the desired data isn't just the label, but some more complex
> data for which the label is merely, well, a label. In that case, storing
> data in the ListItem (or the Label, or some other child of the ListItem) 
> seems to make the most sense. I can't think of any more reasonable way to
> do it from C. 

For his purposes it is the most portable and logical way to go about this
without going against convention.  You do make a good point about
attaching other types of data onto the list items.  Even though you would lose
portability to other languages, i don't see why it wouldn't be possible to build
such a thing into Perl/Gtk and legitimize it.

> I suppose one could derive a custom child of Gtk::Object, and insert that
> into the ListItem as a non-visible child, but this seems to be going a bit
> far. :-)

Definitley:).

> -- 
> Kenneth Albanowski (kjahds@kjahds.com, CIS: 70705,126)


--
tile
tile@primenet.com



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]