Re: Inserting paramenter into a ROW/NODE in a TreeView
- From: muppet <scott asofyet org>
- To: Raul Dias <chaos swi com br>
- Cc: gtk-perl-list gnome org
- Subject: Re: Inserting paramenter into a ROW/NODE in a TreeView
- Date: Thu, 13 Jan 2005 20:30:28 -0500
On Jan 13, 2005, at 5:34 PM, Raul Dias wrote:
- the CellRendering object which is always the same in its column (no
matter the row).
This is by design. The TreeViewColumn uses that renderer to draw each
row in the column,
The problem is that the $iter is not the same TreeIter object I used
when inserting data to the model. My bet is that it is created on the
fly with the info needed as used.
This, also, is by design. Iters are temporary objects that are only
valid until the model changes.
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.
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);
--
How come hair colors for women take an hour, but "wash out the gray"
stuff for men only five minutes? This is so unfair!
-- Elysse, complaining about commercials
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]