proposed API change



talking offlist with renà about various functions on the
Gtk2::TreeSelection brought up some API questions which i'd like to pose
to you guys.

there are a few functions which look like this in C:


 gboolean gtk_tree_selection_get_selected (GtkTreeSelection * selection,
                                           GtkTreeModel ** model,
                                           GtkTreeIter * iter);
 GList * gtk_tree_selection_get_selected_rows
                                          (GtkTreeSelection * selection,
                                           GtkTreeModel ** model);

in both functions, model is a return parameter.
i have bound these to perl[1] like this:

 ($iter, $model) = $selection->get_selected;
 ($model, @paths) = $selection->get_selected_rows;


there are a few problems with this --- in both cases the returned
parameters are in a different order than you might suspect; also in both
cases you are typically only interested in getting the iter/paths,
because you can get to the model trivially as
$selection->get_tree_view->get_model.  even worse, the nonhomogeneous
list returned from get_selected_rows prevents you from using the return
value directly in a map or foreach (you'd have to shift off or in some
other way remove the model).


so what do you say if we just omit the model from these functions
altogether?   the proposed API would be

  $iter = $selection->get_selected;
  @paths = $selection->get_selected_rows;
  $model = $selection->get_tree_view->get_model;

so far the only drawback i see is the difference from the documented
API.  is there some other reason that we're missing for needing the
model there?


[1] gtk_tree_selection_get_selected_rows is new in Gtk 2.2.0, but easy
to implement, so i added a substitute implementation for it when 2.0.x
is present.

-- 
muppet <scott at asofyet dot org>




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