Re: Gtk::TreeView cell background color



luca wrote:

Hello,

Jason Burchfield wrote:

When I add a Gtk::TreeModelColumn<bool>, which uses a Gtk::CellRendererToggle, to a Gtk::TreeView and try to change the cell color I get a seg fault.
Is this a bug or am I doing something wrong.  All other columns work...


tv->append_column_editable( "Test", Columns.m_col_test );


void ColorRows( Gtk::TreeView* treeview ){

   Gtk::CellRendererText* cell_renderer_text;
   Gtk::TreeViewColumn* color_column;
   vector<Gtk::TreeViewColumn*> columns = treeview->get_columns();
Gtk::TreeModel::Children children = treeview->get_model()->children();
   Gtk::TreeModel::Row row;
   CModelColumns ModelColumns;
     for( int x = 0; x < children.size(); x++ ){
         row = *(children[x]);
if( (x % 2) == 0 ) row[ModelColumns.m_col_color] = "grey";
                 else
           row[ModelColumns.m_col_color] = "white";
             for( int y = 0; y < columns.size(); y++ ){
                     color_column = treeview->get_column(y);
Gtk::CellRenderer* cell_renderer = color_column->get_first_cell_renderer();
                             cell_renderer_text =
dynamic_cast<Gtk::CellRendererText*>(cell_renderer);


Here the dyn_cast will return 0, since the CellRendererToggle is not related to CellRedererText in any way. I guess that you have simply to replace CellRendererText with CellRendererToggle for the definition of cell_renderer_text and in the dyn_cast too.

Greetings,
Luca
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Thanks everyone

I just took out the dynamic_cast... don't know why I had it in there to begin with

Jason

--
Jason Burchfield
CAS, Inc.
(256) 971-6096
Jason Burchfield cas-inc com




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