clist column autosizing issues



When I issue a $clist->columns_autosize; the columns of $clist are sized
to appropriate sizes for the content, but not the titles.  For example:

my $clist = Gtk::CList(qw(tabname, owner, partnum, tabid rowsize));

my @data = (
        [qw(systables,  informix, 1048676, 1, 104)],
        [qw(syscolumns, informix, 1048677, 2, 36)],
        [qw(sysindexes, informix, 1048678, 3, 78)],
        [qw(systabauth, informix, 1048679, 4, 28)],
);

foreach (@data) {
        $clist->append(@$_);
}

$clist->columns_autosize;

When I run code like this the rowsize column gets set to a width smaller
than the Gtk::Label.  I have tried to fix this by replacing the call to
columns_autosize with code that looks like this:

for (my $i = 0; $i < $clist->columns; $i++) {
        my $widget    = $clist->get_column_widget($i);
        my $width     = (@{$widget->allocation})[2];
        my $opt_width = $clist->optimal_column_width($i);
        $clist->set_column_width($i, $opt_width) if $width < $opt_width;
}

but $width is equal to 1 for every row.  Any ideas about what I am doing
wrong?

Here is an extra bit of strangeness; I decided to check the sizes before
and after a call to columns_autosize and here are the results (width is
the third number):

pre autosize
3 3 1 1
3 3 1 1
3 3 1 1
3 3 1 1
3 3 1 1
3 3 1 1
3 3 1 1
3 3 1 1
3 3 1 1
3 3 1 1
3 3 1 1
3 3 1 1
3 3 1 1
3 3 1 1
3 3 1 1
3 3 1 1
3 3 1 1
3 3 2 1
pre autosize
3 3 124 1
3 3 43 1
3 3 57 1
3 3 29 1
3 3 29 1
3 3 15 1
3 3 15 1
3 3 50 1
3 3 65 1
3 3 64 1
3 3 10 1
3 3 9 1
3 3 43 1
3 3 43 1
3 3 36 1
3 3 8 1
3 3 62 1
3 3 7 1


-- 
Today is Sweetmorn the 71st day of Chaos in the YOLD 3168
Or is it?

Missile Address: 33:48:3.521N  84:23:34.786W




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