Hi,
We're working on adding behaviors to the column-header buttons
in GtkCList/GtkCTree. One of the added behaviors is rearranging
columns using drag and drop.
When "moving" a column in this manner, I'd like the column widths
to move along with the column data. In other words, if the 5th
column is 100 pixels wide, then when I move it to column 2 it
should still be 100 pixels wide.
And there's my problem: how to find out the width of a column?
Better still, how to find the width of a column `i' in a list/tree
`lt' such that
w0 = get_column_width(lt, i)
lt.set_column_width(i, w0)
wf = get_column_width(lt, i)
assert (w0 == wf)
I've tried several methods, and they all fail in various ways to
account for the size of the widget's decorations -- the border width
around the button, the cell spacing within the list/tree, and so on.
Anybody have any suggestions? Here's what I've tried:
1. Try to get the width of the column header button:
button = lt.get_column_widget(i)["parent"]
width = button["width"]
This usually returns -1. No dice.
2. Try to get the width of the window containing the button:
button = lt.get_column_widget(i)["parent"]
window = button.get_window()
# May fail if button is not realized
width = -1
if window:
width = window.width
This gives the width of the window. But the button *and* its
decorations are painted inside the window. So if I set the
column width based on the window.width, the button gets wider.
3. Use the button's requisitioned width:
...
width = button.get_child_requisition()[0]
This appears to return the last auto-computed width of the
column. But the uesr could have manually resized the columns
after the last auto-size, so this isn't what I want either.
4. Use the button's allocation width:
...
width = button.get_allocation()[2]
This appears to be the same as method 2, above. The only
difference is that, if the widget hasn't been realized, this
technique returns 1 rather than -1.
Thanks for help.
--
Mitch Chapman
[EMAIL PROTECTED]
To unsubscribe: echo "unsubscribe" | mail [EMAIL PROTECTED]