# HG changeset patch # User Peter Gervai # Date 1224152493 -7200 # Node ID 90185416e8ffa4159d4bbcd2bc0d9c0d8543cdf6 # Parent 43c199fb199351715dff1cd47de4164c4a9b5780 test1 kind of working version * cannot close about * cannot change color diff -r 43c199fb1993 -r 90185416e8ff test1.glade --- a/test1.glade Thu Oct 16 11:09:43 2008 +0200 +++ b/test1.glade Thu Oct 16 12:21:33 2008 +0200 @@ -1,11 +1,13 @@ - + - + + True 5 + Main window * test#1 GTK_WIN_POS_CENTER_ON_PARENT - GDK_WINDOW_TYPE_HINT_DIALOG + GDK_WINDOW_TYPE_HINT_NORMAL False @@ -135,6 +137,7 @@ Licensed under RSSL (Really Scary Shit License) grin, others not grin + True @@ -146,6 +149,7 @@ True GTK_BUTTONBOX_END + False @@ -155,4 +159,135 @@ + + True + True + True + 20 + Test #1 + GTK_WIN_POS_CENTER + + + True + + + True + + + True + + + True + gtk-dialog-info + 6 + + + + + True + True + Az üdvozlő szöveg + Enter your name and +bear the consequences. + + + 1 + + + + + + + True + + + True + Thy name: + + + + + True + True + True + Yourname here + + + + 1 + + + + + 1 + + + + + + + True + + + True + True + True + gtk-ok + True + 0 + + + + + + True + True + True + _Nay + True + 0 + + + + 1 + + + + + True + True + True + gtk-about + True + 0 + + + + + 2 + + + + + True + True + True + 0 + True + #0000a079c40a + 32768 + + + + 3 + + + + + 1 + + + + + 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;}