[Glade-users] Treeview doesnt refresh upon reopenning window



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?)

I wont have to recreate the entire treeview, just the
model/list_store.
AND it still keeps with the hide/show modelling that the GTK
tutorials and PHP/Mysql examples all referred to (from the SAMS
publishing website).

Thanks for your comments. They helped me rethink the issues I was
having and got me to this stage!


Regards,
Jason Brisbane


---- Original Message ----
From: damon at karuna.eclipse.co.uk
To: darkeen at westnet.com.au
Subject: Re: [Glade-users] Treeview doesnt refresh upon reopenning
window
Date: Mon, 23 Apr 2007 16:31:39 +0100

On Mon, 2007-04-23 at 22:14 +0800, Jason Brisbane wrote:
Hello All,

I am looking for a fix for a Treeview issue that I am having.

I have created a Treeview that gets its data from a database and 
populates the list with the results of the database.
This works well as even if the database table was empty (rows=0)
then it 
still displays the headers (better than I thought).

In my example, I have a treeview on one half of the screen and the

database fields showing the data on the right (table). This shows
the 
data just wonderfully.
If I add a record, or conversely if I select a record and delete
it, the 
treeview doesnt get updated.
I am calling the _show function after each time, but I dont
believe that 
the gtk_destroy_treeview is actually doing its job. Surely it
would kill 
the treeview, model, store, and everything with it when you kill
it?

Here is the "_show" code. Of course this works fine on starting
the 
window the first time but doesnt refresh.
I get the following message when the window tries to update:
(battlemaster:11819): Gtk-CRITICAL **: gtk_scrolled_window_add: 
assertion `bin->child == NULL' failed



 gtk_widget_destroy(lookup_widget(widget, "treeview4"));

That "lookup_widget" call will only work the first time, won't it?
After that the particular treeview will no longer exist.

Maybe you should get the child of the scrolled window and
gtk_container_remove() that instead.

Damon









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