Re: [gtk-list] Re: find_row_from_data issue in Perl::Gtk




Please wrap the lines of your mail messages at about 70/75 chars, thanks.

On Thu, Sep 30, 1999 at 07:41:18AM -0500, CountZero wrote:
> Ok, this may be by design, but to me it makes the whole find_row_by_data 
> pretty useless:
> 
> It only finds the data if you pass it the SAME reference to the data 
> that was used with set_row_data()

It works the same as the C version: you give it a pointer and search
for a pointer. Yes, this is, IMHO, flawed also in the C version
(something like the keyed data in gtk objects would be way better).

> I was going to go through CList->selection() and create an array of CList->get_row_data()
> elements.  This would give me a list of the selected items (or a list of the "Row Data" of the
> selected Items.  Which is a unique item identifier)  Then I do a CList->clear; and rebuild the
> list.
> Once the list was rebuilt, I was going to go through my array of "Row Data" items, and
> do a CList->find_row_by_data() on each one, and then CList->select_row() in the found
> rows.
> Now some rows may be gone, as the even that triggered the refresh may have been a delete
> event. Who knows?  But I check for -1 to be returned by find_row_by_data() so if the
> row doesn't exist anymore, no big deal.

If you clear the list you loose the data (data beeing the real data or 
the reference), no way around it, so this approach is flawed.
You may want to store the data in a column that gets hidden, but you
should not clear the list (this also saves a few cpu cycles:-).

> But anyway, I guess my question is, shouldn't find_row_by_data() derefernce the reference and
> compare the actual data, instead of just comparing references?

You can do this yourself walking all the rows in the list...

lupus



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