diff -r 43c199fb1993 -r 90185416e8ff test1.pl --- a/test1.pl Thu Oct 16 11:09:43 2008 +0200 +++ b/test1.pl Thu Oct 16 12:21:33 2008 +0200 @@ -9,6 +9,8 @@ use Gtk2::GladeXML; use Gtk2::Gdk::Keysyms; # keyboard code constants +use Data::Dumper; + my $glade; my $label; my $field; @@ -16,22 +18,68 @@ # 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('label1'); -$field = $glade->get_widget('yourname_field'); +$label = $glade->get_widget('main_text1'); +$field = $glade->get_widget('entry'); $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?! + # 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); +} + + +sub on_main_about_button_clicked { + $window_about->show(); + return 1; +} + +sub on_aboutdialog1_close { + $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 $txt!" ); +} # Handles window-manager-quit: shuts down gtk2 lib sub on_main_delete_event {Gtk2->main_quit;} # Handles close-button quit -sub on_close_button_clicked {on_main_delete_event;} +sub on_main_nay_button_clicked {on_main_delete_event;}