updating window size when GtkTreeModel column changes



Hello,

I'm trying to let the window size of my GTK+2 app adjust dynamically
when the GtkTreeModel it displays is changed.  I calculate the width of
the window by adding up the widths of each of the columns displayed in
the GtkTreeView that the window contains, using either
gtk_tree_view_column_get_width() or the width from
gtk_tree_view_column_cell_get_size().  Either function works the first
time I invoke it, so the initial size of my window is OK.

While the app is running, however, I want the window to resize when a
cell in one of the columns is changed.  For instance, if the size of the
cell changes from 10 characters to 20, say, then I want the window to
increase in width accordingly (just as the column itself does).  Or 
decrease if the column gets smaller.  I change the value of the cell in 
the column via a separate dialog box, which invokes gtk_list_store_set() 
in order to set the new value.

However, if I call the same window resizing function after calling
gtk_list_store_set() that I used to set the initial size, then I find
some unexpected behaviour:

1) the column width from gtk_tree_view_column_cell_get_size() remains at
the previous value.  But changing the cell text another time then gives
me the width from the previous change.
gtk_tree_view_column_cell_get_size() turns out to be one step behind.
gtk_list_store_set() doesn't seem to make the column width get updated
in time before the resize function call needs to use it.

2)  gtk_tree_view_column_get_width() simply returns 0, which should be
wrong in any case, even if the view isn't yet synced properly to the model.

Is there anything that I'm doing obviously wrong?  Or is this one of the
bugs fixed in the new release of GTK+ ?

Drew

-- 
PGP public key available at http://people.debian.org/~dparsons/drewskey.txt
Fingerprint: A110 EAE1 D7D2 8076 5FE0  EC0A B6CE 7041 6412 4E4A



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