Extracting data from SimpleList



Hi All,

Using the wonderful SimpleList to bypass dealing with the TreeView stuff is pretty handy. However, how does one get the data back out of the list? I've attached a small example where I am printing out the indices very easily, but I see no docs on accessing the data, except for get_row_data_from_path. How do I get the path? From my admittedly ignorant point of view, it would be super if there was a get_row_data_from_index. Anyone else think that would be useful?

--scott
#! /usr/bin/perl -w

use Glib qw/TRUE FALSE/;
use Gtk2 '-init';
use Gtk2::SimpleList;

$window = Gtk2::Window -> new('toplevel');
$window -> set_default_size(400, 300);
$window -> signal_connect(delete_event => sub { return FALSE; });
$window -> signal_connect(destroy => sub { Gtk2 -> main_quit; });

$vbox = Gtk2::VBox -> new(FALSE, 5);

$window -> add($vbox);

# Super SimpleList
$slist = Gtk2::SimpleList -> new("My Plan", "text");
@stuff = ("Learn Perl", "???", "Profit");
push @{$slist -> {data}}, @stuff;

$sw = Gtk2::ScrolledWindow -> new();
$sw -> add_with_viewport($slist);

$vbox -> pack_start($sw, TRUE, TRUE, 0);

$button = Gtk2::Button -> new("What\'s Selected\?");
$button -> signal_connect(clicked => \&shout_it, $window);

# pack quit button into $main_vbox
$vbox -> pack_start($button, FALSE, FALSE, 0);

$window -> show_all();
Gtk2 -> main;

sub shout_it {
        @indices = $slist -> get_selected_indices;
        
        foreach $i (@indices) {
                print $i . "\n"; # I'd rather print the actual data here.
        }               
}


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