GtkTreeStore and row deletion



Hi guys

In a GtkTreeView, I used to maintain in parallel the GtkTreeModel
and a GSList of objects. In this mode, the object reference was
owned by the GSList, while the row only had a pointer to the object.
At each edition operation, I first edited the GSList object, then
duplicated the operation in the tree model.

As I considered this rather as a waste of efforts, I am currently
trying to suppress this GSList as the GtkTreeModel is actually all
I need to manage all edition operations. But in this mode, the object
reference has to be owned by the row.

My problem is when the row is deleted. The only option I have found is :
1/ first retrieve the object attached to the row, and g_object_unref() it,
2/ only after that, ask the tree model to delete the row

This is not very elegant, especially in a event-oriented environment.
E.g., when emptying the view, I have first to walk through all the tree,
g_object_unref-ing all objects, before being able to call gtk_tree_store_clear().

So is there a way to be triggered _before_ the row be actually deleted,
giving me the opportunity to do my cleanup while the data are still
available ?

I'd like have found a callback when creating the column data, or a
"about-to-delete-row" signal... but not found anything ;-(

Does anyone could points me to some solution to this problem ?
Thanks in advance.

Regards
Pierre

PS: if there is no other solution, don't you think that adding a gtk_tree_model_row_about_to_delete() before 
each g_node_destroy()
could do the trick in a future version ?




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