author | Peter Gervai <grin@grin.hu> |
Thu, 16 Oct 2008 15:29:50 +0200 | |
changeset 5 | 89516833532f |
parent 3 | 689bf4b363c3 |
permissions | -rwxr-xr-x |
0 | 1 |
#!/usr/bin/perl -w |
2 |
#$Id$ |
|
3 |
# |
|
4 |
||
5 |
use strict; |
|
6 |
use warnings; |
|
7 |
||
8 |
use Gtk2 '-init'; |
|
9 |
use Gtk2::GladeXML; |
|
10 |
use Gtk2::Gdk::Keysyms; # keyboard code constants |
|
11 |
||
1 | 12 |
use Data::Dumper; |
13 |
||
0 | 14 |
my $glade; |
15 |
my $label; |
|
16 |
my $field; |
|
3 | 17 |
my $eventbox; |
0 | 18 |
my $window_about; |
19 |
||
20 |
# load UI |
|
21 |
$glade = Gtk2::GladeXML->new("test1.glade"); |
|
1 | 22 |
#$glade = Gtk2::GladeXML->new("/tmp/glade/hello-world.glade"); |
0 | 23 |
|
24 |
# connect signals |
|
25 |
$glade->signal_autoconnect_from_package('main'); |
|
26 |
||
1 | 27 |
$label = $glade->get_widget('main_text1'); |
28 |
$field = $glade->get_widget('entry'); |
|
3 | 29 |
$eventbox = $glade->get_widget('eventbox1'); |
0 | 30 |
$window_about = $glade->get_widget('aboutdialog1'); |
31 |
||
1 | 32 |
print "firing up\n"; |
0 | 33 |
Gtk2->main; |
34 |
||
35 |
exit 0; |
|
36 |
||
37 |
||
1 | 38 |
sub on_colour_button_color_set { |
39 |
my $button = shift; |
|
40 |
my $color = $button->get_color(); |
|
41 |
my $alpha = $button->get_alpha(); |
|
42 |
print "Color is: ", $color->to_string(), "\n"; |
|
43 |
print "Alpha is: ", $alpha, "\n"; |
|
44 |
|
|
3 | 45 |
# Gtk2::StateType?! (man gtk2::widget) |
46 |
|
|
47 |
$eventbox->modify_bg( 'normal', $color); |
|
48 |
#$glade->get_widget('frame1')->modify_bg( 'normal', $color); |
|
1 | 49 |
} |
50 |
||
51 |
||
5
89516833532f
test1: remov unused stuff, implode long unnecessary thingz
Peter Gervai <grin@grin.hu>
parents:
3
diff
changeset
|
52 |
sub on_main_about_button_clicked { $window_about->show(); } |
89516833532f
test1: remov unused stuff, implode long unnecessary thingz
Peter Gervai <grin@grin.hu>
parents:
3
diff
changeset
|
53 |
sub on_aboutdialog1_response { $window_about->hide(); } |
1 | 54 |
|
55 |
sub on_entry_key_release_event { |
|
56 |
my $widget = shift; |
|
57 |
my $event = shift; |
|
58 |
|
|
59 |
if( $event->keyval == $Gtk2::Gdk::Keysyms{KP_Enter} || |
|
60 |
$event->keyval == $Gtk2::Gdk::Keysyms{Return} ) { |
|
61 |
on_main_ok_button_clicked(); |
|
62 |
return 1; |
|
63 |
} |
|
64 |
return 0; |
|
65 |
} |
|
66 |
||
67 |
||
68 |
sub on_main_ok_button_clicked { |
|
69 |
my $txt = $field->get_text(); |
|
70 |
$label->set_markup( "hello <b>$txt</b>!" ); |
|
71 |
} |
|
0 | 72 |
|
73 |
# Handles window-manager-quit: shuts down gtk2 lib |
|
74 |
sub on_main_delete_event {Gtk2->main_quit;} |
|
75 |
||
76 |
# Handles close-button quit |
|
1 | 77 |
sub on_main_nay_button_clicked {on_main_delete_event;} |