Re: How to update a treeview with values from a closed dialog?



Fabricio Rocha wrote:
Hi all!

      RADiola is going on, as far as I have time to develop it :) It has been 
a great learning exercise, and I am happy that I could update my C 
knowledge (which was full of dust) and learn a lot about GTK without 
having to bug the list all the time! However, some times I really need 
some tips... and here is one more question.

      In many dialog windows, I have treeviews showing some data, and buttons 
alongside it for, as an example, adding an item. Clicking on the button 
pops a dialog, where the item is created, renamed, etc. But... When I 
click OK in this dialog, I wish that the treeview would be automatically 
updated to show the data which was edited in the dialog.

      Naively, my first attempt was to call a function for updating the 
treeview right after the call to open the dialog. Surely didn´t work, as 
the "button OK callback" for the dialog is ANOTHER function -- and, as 
this dialog serves to other purposes, it can not directly alter the 
treeview. Also, the interface functions and callbacks for each of the 
windows (the one with the treeview, and the one with the dialog) are in 
different source files, and I would not like to set the forms global.

      So, dudes, what is the technique, please?
  
I don't know what you tried, but you just need to change the model used
in the TreeView, and the view will be updated. However, that means
you'll need the TreeModel to be available for modification. If you do
not want it global, you can try passing it as the user_data argument of
a callback, or use g_object_set_data to store a pointer to it in some
widget of the dialog, retrieved later with g_object_get_data.

-- 
After an instrument has been assembled, extra components will be found
on the bench.

Eduardo M KALINOWSKI
ekalin bol com br
http://move.to/hpkb




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