Re: Problems getting the TreeIter data for a custom TreeModel



On Thu, 2004-05-27 at 01:13, Zach Bean wrote:

For instance, I've got a set method that looks like this:

sub set {
  my $self = shift;
  my $iter = shift;
      
  die "not my iterator" unless $iter->[0] == $self->{_stamp};

  my %vals = @_;

  while (my ($col, $val) = each %vals) {
    if ($col == NAME_COL) {
      my $sql = "UPDATE list SET name = $val WHERE id = " . $iter->[1];
      $self->{_dbh}->do($sql);
    }
  }
}

But this doesn't seem to work, because the code that calls $model->set
uses an actual Gtk2::TreeIter.  The binding code for the TreeModel
interface converts between array references and GtkTreeIters as necessary
using the iter_from_sv and sv_from_iter functions; is there any way I can
specifically request this conversion from Perl code?  If not, is there
some other way I can get at the data inside the TreeIter?

Hrm, right now I don't see how you'd go about getting the data you
need.  The conversion helpers are currently not exported to Perl.  But
to implement real custom tree models you definitely need to be able to
handle Gtk2::TreeIters in Perl-only subroutines.

I only really see one possible solution: exporting the conversion
helpers.  That would be ugly, but the iterators returned from the
all-caps overridden tree model methods need to be converted to C
structures to survive all the marshalling and there's no way we could
intercept calls to custom methods like "set" to convert the structures 
on the fly.

muppet, what do you think?

Bye,
-Torsten




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