Re: [Glade-users] Treeview doesnt refresh upon reopenning window



On Tue, 2007-04-24 at 15:14 +0800, Jason Brisbane wrote:
Hello,

Yes, I realised the "error of my ways" at about 3AM this morning.
Woke up and thought "Damn, why did I do that for?"

After checking the GTK doc I realised that what I should have done is
this:
- DONT destroy anything.
- Dont ceate a new treeview.
- Create the liststore as usual.
- use: gtk_tree_view_set_model (GTK_TREE_VIEW(lookup_widget(widget,
"treeview4")), GTK_TREE_MODEL(list_store));

According to the documentation, this will automatically destroy and
remove any previous model and hook the new model into the Treeview.(I
wont have to worry about memory freeing, but I *miht* have to free
the list_store. I shouldnt need to worry if the list_store is a local
variable though, should I?)

The TreeView object increments the reference count of the TreeModel in
gtk_tree_view_set_model(), so if you want automatic destruction when it
is removed or replaced in the TreeView then you need to unref it after
setting the model.  GtkTreeStore and GtkListStore objects are plain
GObjects (they are not derived from GtkObject or GInitiallyUnowned), so
ownership is not automatically claimed by the TreeView.

Your reference to a list store being a local variable may show a
misunderstanding.  You can only hold a pointer to a list store object -
they are constructed on free store with gtk_tree_store_new() (or
gtk_tree_store_newv()).

Chris





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