#!/usr/bin/perl

package Tsuyoshi::Gtk3;
use Moose;
use Gtk3 '-init';

sub BUILD {
	my ( $self ) = @_;

	$self->root_window->add($self->button);
	$self->root_window->show_all;
	Gtk3::main;

	return $self;
}
has 'button'	=> (
	is	=> 'rw',
	isa	=> 'Gtk3::Button',
	default	=> sub { return Gtk3::Button->new('quit'); },
	trigger	=> sub {
		my ( $self ) = @_;
		$self->button->signal_connect(clicked => sub { Gtk3::main_quit });
	}
);
has 'root_window'	=> (
	is	=> 'rw',
	isa	=> 'Gtk3::Window',
	default	=> sub { return Gtk3::Window->new; },
	trigger	=> sub {
		my ( $self ) = @_;
		$self->root_window->signal_connect( destroy => \&quit_app );
	}
);
sub quit_app {
    Gtk3->main_quit;
    return;
}

__PACKAGE__->meta->make_immutable;
no Moose;
1;

package main;

my $gtk = Tsuyoshi::Gtk3->new;
