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) |
1
|
46 |
# FATAL: invalid enum GtkStateType value what, expecting: normal / GTK_STATE_NORMAL, |
|
47 |
# active / GTK_STATE_ACTIVE, prelight / GTK_STATE_PRELIGHT, selected / GTK_STATE_SELECTED, |
|
48 |
# insensitive / GTK_STATE_INSENSITIVE |
3
|
49 |
#$label->modify_bg( 'prelight', $color); |
|
50 |
#$label->modify_fg( 'active', $color); |
|
51 |
#$label->modify_text( 'normal', $color); |
|
52 |
|
|
53 |
$eventbox->modify_bg( 'normal', $color); |
|
54 |
#$glade->get_widget('frame1')->modify_bg( 'normal', $color); |
|
55 |
|
|
56 |
$window_about->modify_bg( 'prelight', $color); |
1
|
57 |
} |
|
58 |
|
|
59 |
|
|
60 |
sub on_main_about_button_clicked { |
|
61 |
$window_about->show(); |
|
62 |
return 1; |
|
63 |
} |
|
64 |
|
2
|
65 |
sub on_aboutdialog1_response { |
1
|
66 |
$window_about->hide(); |
|
67 |
return 1; |
|
68 |
} |
|
69 |
|
|
70 |
sub on_entry_key_release_event { |
|
71 |
my $widget = shift; |
|
72 |
my $event = shift; |
|
73 |
|
|
74 |
if( $event->keyval == $Gtk2::Gdk::Keysyms{KP_Enter} || |
|
75 |
$event->keyval == $Gtk2::Gdk::Keysyms{Return} ) { |
|
76 |
on_main_ok_button_clicked(); |
|
77 |
return 1; |
|
78 |
} |
|
79 |
return 0; |
|
80 |
} |
|
81 |
|
|
82 |
|
|
83 |
sub on_main_ok_button_clicked { |
|
84 |
my $txt = $field->get_text(); |
|
85 |
$label->set_markup( "hello <b>$txt</b>!" ); |
|
86 |
} |
0
|
87 |
|
|
88 |
# Handles window-manager-quit: shuts down gtk2 lib |
|
89 |
sub on_main_delete_event {Gtk2->main_quit;} |
|
90 |
|
|
91 |
# Handles close-button quit |
1
|
92 |
sub on_main_nay_button_clicked {on_main_delete_event;} |