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

On Fri, 2005-01-14 at 08:21, Raul Dias wrote:
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);
                           (0, "Thing 2", Gtk2::CellRendererText->new,
                            text => THING_2_COLUMN);
                           (1, "Thing 1", Gtk2::CellRendererText->new,
                            text => THING_1_COLUMN);


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.

you don't create a renderer for those columns in the first place. they
are then in the store, but not the view. the view knows nothing about
their existence. this is a side benefit of the MVC arch. you can make
arbitrary views of stores picking and choosing what and how you want to
show it, if at all.


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