line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Gtk2::GladeXML::Simple; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
893
|
use 5.008; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
5
|
1
|
|
|
1
|
|
14
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
33
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
79
|
|
7
|
1
|
|
|
1
|
|
941
|
use Gtk2; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use Gtk2::GladeXML; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.32'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
|
|
|
|
|
|
my ( $caller, $gladefile, $root, $domain ) = @_; |
14
|
|
|
|
|
|
|
croak "You need to specify a glade file first" unless $gladefile; |
15
|
|
|
|
|
|
|
my $self = bless {}, ref( $caller ) || $caller; |
16
|
|
|
|
|
|
|
Gtk2::Glade->set_custom_handler( sub{ $self->_custom_handler( @_ ) } ); |
17
|
|
|
|
|
|
|
$self->{xml} = Gtk2::GladeXML->new( $gladefile, $root, $domain ); |
18
|
|
|
|
|
|
|
$self->_signal_autoconnect_simple; |
19
|
|
|
|
|
|
|
$self->_get_widgets; |
20
|
|
|
|
|
|
|
return $self; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub glade_object { |
24
|
|
|
|
|
|
|
my ( $self ) = @_; |
25
|
|
|
|
|
|
|
return $self->{xml}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub get_widget { |
29
|
|
|
|
|
|
|
my ( $self, $widget ) = @_; |
30
|
|
|
|
|
|
|
return $self->{$widget}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub get_widgets { |
34
|
|
|
|
|
|
|
my ( $self ) = @_; |
35
|
|
|
|
|
|
|
return $self->glade_object->get_widget_prefix( '' ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub run { |
39
|
|
|
|
|
|
|
my ( $self ) = @_; |
40
|
|
|
|
|
|
|
Gtk2->main; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub _get_widgets { |
44
|
|
|
|
|
|
|
my ( $self ) = @_; |
45
|
|
|
|
|
|
|
$self->{ $_->get_widget_name } = $_ foreach $self->get_widgets; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _custom_handler { |
49
|
|
|
|
|
|
|
my ( $self, $xml, $func_name, $name, $str1, $str2, $int1, $int2 ) = @_; |
50
|
|
|
|
|
|
|
$self->$func_name( $str1, $str2, $int1, $int2 ); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub _signal_autoconnect_simple { |
54
|
|
|
|
|
|
|
my ( $self ) = @_; |
55
|
|
|
|
|
|
|
$self->glade_object->signal_autoconnect( \&_autoconnect_helper, $self ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub _autoconnect_helper { |
59
|
|
|
|
|
|
|
my ( $handler_name, $object, $signal_name, $signal_data, |
60
|
|
|
|
|
|
|
$connect_object, $is_after, $self ) = @_; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $connect_func = $is_after ? 'signal_connect_after' : 'signal_connect'; |
63
|
|
|
|
|
|
|
$object->$connect_func( $signal_name, |
64
|
|
|
|
|
|
|
sub { $self->$handler_name( @_ ) }, |
65
|
|
|
|
|
|
|
$signal_data ); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
__END__ |