Re: proposed API change



On Mon, May 26, 2003 at 10:34:23PM -0400, muppet wrote:
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:

... 

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?

As for $selection->get_selected it could be made to check the evaluation
context, so we'd have

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

That way we get both at the cost of a slightly more complicated XS
function.

For $selection->get_selected_rows I'm all for returning a homogeneous
list of Gtk2::TreePath elements, because that is what you want most of
the time.   Adding the model to the list will make otherwise simple and
straightforward code more complicated and error prone.  If we really
want to stick to the C API, the call should be

    my $model;
    @paths = $selection->get_selected_rows(\$model);

If that is chosen, I think we should also have 

    $iter = $selection->get_selected(\$model);

where in either case the argument can be left out, just as it can be
NULL in the C API.

-- 
René Seindal (rene seindal dk)                  http://sights.seindal.dk/




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