Re: Getting column 2 in selected row of TreeView?

Art?ras ?lajus said:
Dan Lyke wrote:
        sub { on_treeview1_selection_changed($select, $treeview,
What is this treestore? How i could get it from TreeView or SimpleList?

i'll guess from the name that it's a Gtk2::TreeStore, which is a

if you don't have the model, you can get a model from a TreeView by asking for

   $model = $treeview->get_model;     # via the accessor
   $model = $treeview->get ('model');  # as a property

the Gtk2::TreeSelection manpage shows that the 'changed' signal just gets a
reference to the object.  you can get the treeview from the selection and the
model from the treeview, and simplelist makes sure that the columns in the
view line up with the columnsin the model, so it's as easy as something like

   $simplelist->get_selection->signal_connect (changed => sub {
          my ($selection) = @_;
          my ($model, $iter) = $selection->get_selected;
          if ($iter) {
                  my $data = $model->get ($iter, 2);
                  print "you selected $data\n";
          } else {
                  print "nothing is selected\n";

[1] technically, GtkTreeStore an object which implements the GtkTreeModel
GInterface.  in gtk2-perl we use multiple inheritance to do the interface

muppet <scott at asofyet dot org>

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