Skip to content

Someone tell me what is wrong with this …. ?

I only want to render a cell for each item indiviually and mark them with a image of active or inactive…

sadly once i activate one in a row all get activated.

please help

http://pastebin.ca/1413750

{ 3 } Comments

  1. Darwin Survivor | May 6, 2009 at 1:35 am | Permalink

    Not sure if I understand correctly, but the code you linked to seems to be the code that does the drawing, not the code that sets the items as active/inactive.

    It might help if you posted the code that changed the items’ state.

  2. James Henstridge | May 6, 2009 at 3:40 am | Permalink

    You are doing it backwards. A cell renderer shouldn’t need any knowledge of the tree model it is rendering. Instead, it is the tree view widget (along with the tree view column objects) that is responsible for configuring the cell renderers prior to calling their render method.

    So for this case, I’d define a boolean gobject property on your cell renderer called “active”. In your on_render() callback, simply check the value of this property to decide which image to paint.

    When adding your cell renderer to the the tree view column, map the active property to model column 3. That way the tree view will set the active property based on the data in the model before calling render() for each row.

  3. Matthias Clasen | May 6, 2009 at 3:24 pm | Permalink

    Most likely you are keeping state in your cell renderer. You can’t do that, since a the renderer is used to render all the rows (at arbitrary times). All the data (including state like ‘active’) must come from the model via attribute mapping.

Post a Comment

Your email is never published nor shared. Required fields are marked *