Re: Inserting paramenter into a ROW/NODE in a TreeView




That said, I need something (some gtk object) that will never change  
for a row/node so I can attach information on it.

This is a TreeRowReference: see  
http://developer.gnome.org/doc/API/2.0/gtk/GtkTreeModel.html#gtk-tree- 
row-reference-new

But this won't really help you with extra row data; see below.

It won't work with a ListStore either.

So, how do I keep private data with each row/node?

Add another column to your model, but don't display it in the view.

   use constant THING_1_COLUMN => 0;
   use constant THING_2_COLUMN => 1;
   use constant PRIVATE_1_COLUMN => 2;
   use constant PRIVATE_2_COLUMN => 3;

   # create and fill the model with four columns of data
   my $model = Gtk2::ListStore->new ('Glib::String', # THING_1_COLUMN
                                     'Glib::Int', # THING_2_COLUMN
                                     'Glib::Int', # PRIVATE_1_COLUMN
                                     'Glib::Scalar); # PRIVATE_2_COLUMN

   # only show two of those columns, and in reverse order, at that.
   my $view = Gtk2::TreeView->new ($model);
   $view->insert_column_with_attributes
                           (0, "Thing 2", Gtk2::CellRendererText->new,
                            text => THING_2_COLUMN);
   $view->insert_column_with_attributes
                           (1, "Thing 1", Gtk2::CellRendererText->new,
                            text => THING_1_COLUMN);

Great!

I thought I would have to call insert_column_with_attributes to every
column and them call $renderer->set(visible => 0); to make it invisible.

The problem was that the header was still visible.

Thanks muppet!




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