Jeffrey Barish wrote: > Gorshkov wrote: > >> You don't have to set the widths again every time you show them. When >> the TreeView becomes hidden/not hidden or visible/not visible, it will >> have the same properties and values it had the last time it was visible. >> The ONLY time you have set those values is when you display/realize the >> TreeView for the first time - I do it in my initialization code when I >> first create the widget. > > I know this. I am not sure what I wrote that gave you the impression that > this is what I am trying to do. I will try again. A portion of my code > that is not directly related to the treeview in question nevertheless has > to know what the column widths are in the treeview. Currently, it tries to > obtain this information by reading a file that is written by the treeview > whenever it is destroyed. Unfortunately, the treeview generally has not > been destroyed when I get to this portion of code, so the file has not been > updated. Therefore, the column widths that this portion of code reads may > be obsolete. I think you may have assumed that the portions of my code > that need to know the column widths use that information to set the column > widths. In fact, these portions are performing functions unrelated to the > treeview. The only time the treeview uses the information in the file is > on program start when the treeview is first realized. > > To preserve the decoupling afforded by the file, I have to write the file > whenever I leave the mode in which the treeview is visible. However, there > are several ways in which it is possible to leave this mode. Whenever > modifications to the program create additional ways, I need to remember to > add code to write the file. This expanding requirement is what I meant by > sticking fingers in holes in the dike. > > If I jettison the decoupling afforded by the file, then I could have the > code that needs to know the column widths either cause the file to be > written before it reads the file or simply extract the column widths from > the treeview. Either way, I have coupled disparate sections of code that > should not be coupled. >
But you're not actually decoupling anything - you're just adding a layer of indirection to it. I assume you already have a routine that is reading the information from the file once it's already been generated. Add some checks to the top of that routine - if the tree is newly created and not intialised, read the file ... but cache the information. If the the TreeView exists and HAS been initialized, you can use excerpts from my code to get the current column widths and return it to the caller. That way you only need to read the file once - the first time the TreeView is made visible - and other times grab current data, which will certainly be orders of magnitude faster than re-reading from a file. With this approach, the only time you DO have to update the file is when you destroy the window, and/or exit your application. > I also need to store the column widths in a file so that the treeview will > have the same column widths the next time I run the program. Capturing the > column widths when I destroy the treeview works fine for this requirement, > although it would be more elegant to write the file only when the column > widths actually change. > > Sorry that I am not communicating better. My bad. I've gotta stop posting before my first pot of coffee :-) Hope this answer is a little more helpful? _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list