#!/usr/bin/perl -w
#$Id$
#
use strict;
use warnings;
use Gtk2 '-init';
use Gtk2::GladeXML;
use Gtk2::Gdk::Keysyms; # keyboard code constants
use Data::Dumper;
my $glade;
my $label;
my $field;
my $eventbox;
my $window_about;
# load UI
$glade = Gtk2::GladeXML->new("test1.glade");
#$glade = Gtk2::GladeXML->new("/tmp/glade/hello-world.glade");
# connect signals
$glade->signal_autoconnect_from_package('main');
$label = $glade->get_widget('main_text1');
$field = $glade->get_widget('entry');
$eventbox = $glade->get_widget('eventbox1');
$window_about = $glade->get_widget('aboutdialog1');
print "firing up\n";
Gtk2->main;
exit 0;
sub on_colour_button_color_set {
my $button = shift;
my $color = $button->get_color();
my $alpha = $button->get_alpha();
print "Color is: ", $color->to_string(), "\n";
print "Alpha is: ", $alpha, "\n";
# Gtk2::StateType?! (man gtk2::widget)
$eventbox->modify_bg( 'normal', $color);
#$glade->get_widget('frame1')->modify_bg( 'normal', $color);
}
sub on_main_about_button_clicked { $window_about->show(); }
sub on_aboutdialog1_response { $window_about->hide(); }
sub on_entry_key_release_event {
my $widget = shift;
my $event = shift;
if( $event->keyval == $Gtk2::Gdk::Keysyms{KP_Enter} ||
$event->keyval == $Gtk2::Gdk::Keysyms{Return} ) {
on_main_ok_button_clicked();
return 1;
}
return 0;
}
sub on_main_ok_button_clicked {
my $txt = $field->get_text();
$label->set_markup( "hello <b>$txt</b>!" );
}
# Handles window-manager-quit: shuts down gtk2 lib
sub on_main_delete_event {Gtk2->main_quit;}
# Handles close-button quit
sub on_main_nay_button_clicked {on_main_delete_event;}