Problems with treeview



Hello.

I have a treeview with 4 columns. One of them have 4 CellRendererPixbuf to render 4 icons and in other column I have when to draw this icons. The model is a TreeModel and I have parent rows and child rows. I have two problems:
1.- For the icons I have a celldata callback similar to this
void CMyTreeView::renderUnknownFlag(Gtk::CellRenderer *p_renderer, const Gtk::TreeModel::iterator& p_iter){
    Gtk::TreeModel::Row l_row;
    Gtk::CellRendererPixbuf* l_renderer;

    l_row = *p_iter;
    if(!l_row[m_columns.m_draw])
        return;
   
    if (!p_renderer)
        return;

    l_renderer = dynamic_cast<Gtk::CellRendererPixbuf*>(p_renderer);
    if (l_renderer != NULL){
        l_renderer->property_pixbuf() = m_flag_unknown;
    }
}
When  the treeview is show, it work correctly, but when I expand any row with child rows, it doesn't work correctly anymore. Icons always are drawn.

2.-  I need to delete rows and all his childs on demand, but I don't know how to delete rows and his childs. If I try to do this to erase all rows:
void CMyTreeView::removeRows(){
    Gtk::TreeModel::iterator l_iter;
   
    for(l_iter = m_tree->children().begin();l_iter != m_tree->children().end(); l_iter++)
        m_tree->erase(l_iter);
}
I get the next error:
Gtk-ERROR **: file /build/buildd/gtk+2.0-2.12.0/gtk/gtktreestore.c: line 726 (gtk_tree_store_iter_parent): assertion failed: (parent != NULL)

Thanks,
Juan Ángel


 


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