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.

<F_gtk2-perl-xs-tree_sel.diff>
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.  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,

i would be happy with that

but i had trouble getting this to work and nobody seemed interested
in it.

maybe few people had used it.

at mdk, we do have used them. we do not see reasons to change the api
(that is both the c api and the gtk2-perl one) whereas nobody is
really asking for this.
 
what does everybody think?

i think that:
- more people will read the c doc rather than the perl-Gtk2 one
- we should minimize api changes
- api changes when nobody ask them are bogus
- if one really want the iter, he only has to do:
      "my (undef, $iter) = $sel->get_selected();"

i see no reason to gratuitously break compatiblity with first inline
try and already released apps just because "someone may want that
helper".

if one want it, he can write his own helper such as :

   package Gtk2::TreeSelection
   sub get_selected_iter {
       my ($tree_selection) = @_;
       ($tree_selection->get_selected)[1];
   }


you write that one goal of the xs tree was to closely match c api and
minimize perl changes:

"- Stick close to the C API so that you can use knowledge from the C
   API and API reference docs with the perl bindings; this is
   overruled in some places by the remaining tenets.

(...)

- Don't add new functionality. The exceptions to this rule are
  consolidation of methods where default parameters may be used, or
  where the direct analog from C is not practical.
  For example, Gtk2::Button->new and Gtk2::Button->new("label")
  instead of a separate Gtk2::Button->new_with_label.  Also, $red =
  Gtk2::Gdk::Color->new (65535, 0, 0);"




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