Re: Updating GtkCellRendererText after editing



On Mon, Jun 16, 2003 at 05:50:49PM +0200, Sylvain Daubert wrote:

Could someone explain me how i can update my cell ?

You need to set the newtext in the store.  This means you need to know which
column of the store is associated with that renderer.  You know this when
you're adding TreeViewColumns to the TreeView, and there are various ways to
pass this info around: as user data when connecting the signal, using
set_data on the renderer, as a global data structure, etc.  Excuse me for
thinking in Python:

cell = gtk.CellRendererText()
# j is the store column to take text from
# In C you'd probably use a pointer to a struct for user data.
cell.connect("edited", edited_callback, store, j) 
column = gtk.TreeViewColumn(colname, cell, text=j, ...)

Then in your callback:

def edited_callback(renderer, path_string, newtext, store, colno):
    path = tuple(path_string.split(':')) #gtk_tree_path_new_from_string
    iter = store.get_iter(path)
    store.set(iter, colno, newtext)

The API was not very well thought out here, IMO.  

Dave Cook



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