#! /usr/bin/perl -w

use strict;
use Gtk2 '-init';
use Glib qw/TRUE FALSE/; 

#standard window creation, placement, and signal connecting
my $window = Gtk2::Window->new('toplevel');
$window->signal_connect('delete_event' => sub { Gtk2->main_quit; });
$window->set_border_width(5);
$window->set_position('center_always');

#this vbox will return the bulk of the gui
my $vbox = &ret_vbox();

#add and show the vbox
$window->add($vbox);
$window->show();

#our main event-loop
Gtk2->main();

sub ret_vbox {

my $vbox = Gtk2::VBox->new(FALSE,5);
	#this is one of the provided base Gtk2::TreeModel classes.
	my $list_store = Gtk2::ListStore->new(qw/Glib::String/);

	#fill it with arbitry data
	foreach (1..50) {
	
		my $iter = $list_store->append;
		$list_store->set ($iter,0 => "Pedro x  $_");
	}
	
	my $d = Gtk2::ComboBox->new_text;
	$d->set_model($list_store);
	$d->set_wrap_width (5); 
	$d->signal_connect('changed' => sub {
		my ($d) = @_;
		print $d->get_active_text."\n";
		
		});
		
	$d->set_active(0);
	
$vbox->pack_start($d,TRUE,TRUE,0);
$vbox->show_all();
return $vbox;
}

