#!/bin/perl

use strict;
use warnings;
use Gtk2;
Gtk2->init;

my $window = new Gtk2::Window('toplevel');

my $model = new Gtk2::TreeStore('Glib::String', 'Glib::String');
my $combo = new Gtk2::ComboBox;
my $renderer = Gtk2::CellRendererText->new;

$combo->set_model($model);
$combo->pack_start($renderer, 1);
$combo->add_attribute($renderer, text => 1);

foreach (1..5)
{
    my $groupIter = $model->append(undef);
    $model->set($groupIter, 0 => $_, 1 => "Group $_");
    foreach my $i(1..10)
    {
	my $itemIter = $model->append($groupIter);
	$model->set($itemIter, 0 => $_, 1 => "Item $_-$i");	
    }
}

$window->add($combo);
$window->signal_connect(destroy => sub { Gtk2->main_quit; });
$window->show_all;
Gtk2->main;
