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; |
|
17 |
my $window_about; |
|
18 |
|
|
19 |
# load UI |
|
20 |
$glade = Gtk2::GladeXML->new("test1.glade"); |
1
|
21 |
#$glade = Gtk2::GladeXML->new("/tmp/glade/hello-world.glade"); |
0
|
22 |
|
|
23 |
# connect signals |
|
24 |
$glade->signal_autoconnect_from_package('main'); |
|
25 |
|
1
|
26 |
$label = $glade->get_widget('main_text1'); |
|
27 |
$field = $glade->get_widget('entry'); |
0
|
28 |
$window_about = $glade->get_widget('aboutdialog1'); |
|
29 |
|
1
|
30 |
print "firing up\n"; |
0
|
31 |
Gtk2->main; |
|
32 |
|
|
33 |
exit 0; |
|
34 |
|
|
35 |
|
1
|
36 |
sub on_colour_button_color_set { |
|
37 |
my $button = shift; |
|
38 |
my $color = $button->get_color(); |
|
39 |
my $alpha = $button->get_alpha(); |
|
40 |
print "Color is: ", $color->to_string(), "\n"; |
|
41 |
print "Alpha is: ", $alpha, "\n"; |
|
42 |
|
|
43 |
# Gtk2::StateType?! |
|
44 |
# FATAL: invalid enum GtkStateType value what, expecting: normal / GTK_STATE_NORMAL, |
|
45 |
# active / GTK_STATE_ACTIVE, prelight / GTK_STATE_PRELIGHT, selected / GTK_STATE_SELECTED, |
|
46 |
# insensitive / GTK_STATE_INSENSITIVE |
|
47 |
$label->modify_bg( 'prelight', $color); |
|
48 |
$label->modify_fg( 'active', $color); |
|
49 |
$label->modify_text( 'normal', $color); |
|
50 |
} |
|
51 |
|
|
52 |
|
|
53 |
sub on_main_about_button_clicked { |
|
54 |
$window_about->show(); |
|
55 |
return 1; |
|
56 |
} |
|
57 |
|
2
|
58 |
sub on_aboutdialog1_response { |
1
|
59 |
$window_about->hide(); |
|
60 |
return 1; |
|
61 |
} |
|
62 |
|
|
63 |
sub on_entry_key_release_event { |
|
64 |
my $widget = shift; |
|
65 |
my $event = shift; |
|
66 |
|
|
67 |
if( $event->keyval == $Gtk2::Gdk::Keysyms{KP_Enter} || |
|
68 |
$event->keyval == $Gtk2::Gdk::Keysyms{Return} ) { |
|
69 |
on_main_ok_button_clicked(); |
|
70 |
return 1; |
|
71 |
} |
|
72 |
return 0; |
|
73 |
} |
|
74 |
|
|
75 |
|
|
76 |
sub on_main_ok_button_clicked { |
|
77 |
my $txt = $field->get_text(); |
|
78 |
$label->set_markup( "hello <b>$txt</b>!" ); |
|
79 |
} |
0
|
80 |
|
|
81 |
# Handles window-manager-quit: shuts down gtk2 lib |
|
82 |
sub on_main_delete_event {Gtk2->main_quit;} |
|
83 |
|
|
84 |
# Handles close-button quit |
1
|
85 |
sub on_main_nay_button_clicked {on_main_delete_event;} |