#!/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)
# FATAL: invalid enum GtkStateType value what, expecting: normal / GTK_STATE_NORMAL,
# active / GTK_STATE_ACTIVE, prelight / GTK_STATE_PRELIGHT, selected / GTK_STATE_SELECTED,
# insensitive / GTK_STATE_INSENSITIVE
#$label->modify_bg( 'prelight', $color);
#$label->modify_fg( 'active', $color);
#$label->modify_text( 'normal', $color);
$eventbox->modify_bg( 'normal', $color);
#$glade->get_widget('frame1')->modify_bg( 'normal', $color);
$window_about->modify_bg( 'prelight', $color);
}
sub on_main_about_button_clicked {
$window_about->show();
return 1;
}
sub on_aboutdialog1_response {
$window_about->hide();
return 1;
}
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;}