Re: [PATCH] fix broken api of Gtk2::TreeSelection->get_selected() [gtk2-perl regression]

muppet <scott asofyet org> writes:

this patch fix the broken api of Gtk2::TreeSelection->get_selected()

unlike C and gtk2-perl APIs, Gtk2::TreeSelection->get_selected()
return its return values in the wrong order.

so it's both wrong and a regression from inline tree of gtk2-perl

after some discussion both on and off the list a while back, it was
decided that the most common use for get_selected() was to find just
the iter, and the ability to call the function in scalar context to
retrieve that was considered more important than adhering strictly
to the C API.

why not adher to both ? see below

the model is accessible in array context as well as through
$selection->get_tree_view->get_model, and this change is documented
in the Gtk2::api manpage.

we could compromise and have scalar context return the iter and
array context return both in the C order, but i had trouble getting
this to work and nobody seemed interested in it.

here it is:

Attachment: treesel.diff
Description: Text Data

it makes the following piece of code (tested in harddrake2):

    my ($model, $iter) = $select->get_selected;
    my $iter2 = $select->get_selected;
    print "(mode,iter) = ($model, $iter) <---> iter = $iter2\n";

print the following:

(mode,iter) = (Gtk2::TreeStore=HASH(0x87e3214), Gtk2::TreeIter=SCALAR(0x87d7dd0)) <---> iter = 

traditionnal c order is kept, and you still have the iterator only in
scalar context

is everybody happy ?

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