#! /usr/bin/perl -w

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

my $deg = 0;
my $label;

Glib::Timeout->add (200,sub{ &rotate_label() });

#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 geturn 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 {

#create a vbox to pack the following widgets
my $vbox = Gtk2::VBox->new(FALSE,5);

	#this will be the label who gets rotated throughout the program
	$label = Gtk2::Label->new();
	#start with it at 90deg to have max space alllocated to it
	$label->set_angle(90);
	$label->set_markup('<span foreground="DarkRed" size="x-large"><b>Rotating Label</b></span>');
		
$vbox->pack_start($label,FALSE,FALSE,4);	

	#create table to pack the labels that will demo how mnemonic text work
	my $table = Gtk2::Table->new (2, 2, FALSE);
	
		my $lbl_mnemonic_one = Gtk2::Label->new_with_mnemonic("Label _One:");
		$lbl_mnemonic_one->set_alignment (1, 1);
	$table->attach_defaults ($lbl_mnemonic_one, 0, 1, 0, 1);
		my $ent_one = Gtk2::Entry->new();
		$lbl_mnemonic_one->set_mnemonic_widget ($ent_one); 
	$table->attach_defaults ($ent_one, 1, 2, 0, 1);
		my $lbl_mnemonic_two = Gtk2::Label->new();
		$lbl_mnemonic_two->set_markup_with_mnemonic('<span foreground="maroon" size="x-large"><i>Label _Two</i></span>');
		$lbl_mnemonic_two->set_alignment (0, 0);
	$table->attach_defaults ($lbl_mnemonic_two, 0, 1, 1, 2);
		my $ent_two = Gtk2::Entry->new();
		$lbl_mnemonic_two->set_mnemonic_widget ($ent_two);
	$table->attach_defaults ($ent_two, 1, 2, 1, 2);
	
$vbox->pack_end($table,FALSE,FALSE,4);
$vbox->pack_end(Gtk2::HSeparator->new(),FALSE,FALSE,4);
	
	#create a label that will demo pango markup
	my $label_markup = Gtk2::Label->new();
	$label_markup->set_markup("<span foreground=\"yellow1\" size=\"40000\">Label with</span><s><big> Tango </big></s> Pango<span background = 'black' foreground= 'green' size ='30000'><i>markup</i></span>");
$vbox->pack_end($label_markup,FALSE,FALSE,4);	
$vbox->pack_end(Gtk2::HSeparator->new(),FALSE,FALSE,4);

$vbox->show_all();

return $vbox;

}

sub rotate_label {
$deg = $deg +5;
($deg==360)&&($deg =0);
$label->set_angle($deg);
return 1;
}
