#!/usr/bin/perl

use strict;

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

my $window = Gtk2::Window->new( "toplevel" );
$window->signal_connect( "destroy", sub { Gtk2->main_quit(); } );

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

my $model = Gtk2::ListStore->new(
				    "Glib::String",
				    "Glib::String",
				    "Glib::Int"
				);

$model->set( $model->append, 0, "Hi", 1, "There" );

my $renderer_1 = Gtk2::CellRendererText->new;
$renderer_1->set( editable => TRUE );

my $renderer_2 = Gtk2::CellRendererText->new;
$renderer_2->set( editable => TRUE );

my $column_1 = Gtk2::TreeViewColumn->new_with_attributes(
							    "Column 1",
							    $renderer_1,
							    'text'	=> 0
							);

my $column_2 = Gtk2::TreeViewColumn->new_with_attributes(
							    "Column 2",
							    $renderer_2,
							    'text'	=> 1
							);

# Replace the 2nd column's header with a GtkLabel
my $label = Gtk2::Label->new;

$label->set_markup( "<b>Column 2</b>" );
$label->set_alignment( 0.5, 0.5 );
$label->visible( 1 );

$column_2->set_widget( $label );

my $combo_model = Gtk2::ListStore->new(
					"Glib::Int",
					"Glib::String"
				      );

foreach my $thingy (
			[ 1,	"one" ],
			[ 2,	"two" ],
			[ 3,	"three" ],
			[ 4,	"four" ],
			[ 5,	"five" ]
		   )
{
	$combo_model->set(
			    $combo_model->append,
			    0,		$$thingy[0],
			    1,		$$thingy[1]
			 );
}

my $treeview = Gtk2::TreeView->new( $model );
$treeview->set_rules_hint( TRUE );

$treeview->append_column( $column_1 );
$treeview->append_column( $column_2 );


my $sw = Gtk2::ScrolledWindow->new( undef, undef );
$sw->set_shadow_type( "etched-in" );
$sw->set_policy( "never", "always" );

$sw->add( $treeview );

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

$window->add( $vbox );
$window->show_all;

Gtk2->main;