Re: access to GtkTableChild struct?

On 08/23/00 jes martnet com wrote:
The Gtk+ docs refer to a struct GtkTableChild which contains
info relating a widget to the table layout.  Can I access this
structure from Perl?

E.g., how would I write a Perl function that takes a table and
returns all the widgets that live in the first row (i.e.,
top_attach == 0)?

  sub in_row {
    my ($table, $row) = @_;
    my @result;

    foreach my $child ($table->children) {
      push(@result, $child) if $child->top_attach == $row;
    return @result;

This fails on two counts: the $child items are widgets, which have no
table layout data, and of course there is no 'top_attach' method.

The docs are not clear (to me) how I would do this in C either, so I hope
someone has a suggestion.

Currently it's not possible to access a GtkTableChild from perl: it's
an internal structure used by GtkTable and so I don't want
to expose it unless it's really necessary: what do people think?
A workaround is to record within the child widgets the info you may
need later, as was suggested.
A possible implementation could involve a foreach handler:

$table->foreach_child (sub {
        my $info = shift;
        print $info->{top_attach}, "\n";
        info->{widget}->hide() if $info->{xpadding}; # kill those fat bastards
        return 1;

That is the info is accessed using a hash ref (and can only be read, BTW)
and the loop continues as long as the subroutine returns true.


Paolo Molaro, Open Source Developer, Linuxcare, Inc.
+39.049.8043411 tel, +39.049.8043412 fax
lupus linuxcare com,
Linuxcare. Support for the revolution.

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