line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# You may distribute under the terms of either the GNU General Public License |
2
|
|
|
|
|
|
|
# or the Artistic License (the same terms as Perl itself) |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# (C) Paul Evans, 2016 -- leonerd@leonerd.org.uk |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package App::Devel::MAT::Explorer::GTK::Resources; |
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
677
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
9
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
48
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
776
|
use File::ShareDir qw( module_file ); |
|
1
|
|
|
|
|
4683
|
|
|
1
|
|
|
|
|
74
|
|
14
|
1
|
|
|
1
|
|
332
|
use Gtk2; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use Exporter 'import'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
19
|
|
|
|
|
|
|
get_icon |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
22
|
|
|
|
|
|
|
all => [ @EXPORT_OK ], |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my %ICON_PATHS; # {$name} = $path |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
## Tool plugin hooks |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub Devel::MAT::UI::register_icon |
30
|
|
|
|
|
|
|
{ |
31
|
|
|
|
|
|
|
shift; |
32
|
|
|
|
|
|
|
my %args = @_; |
33
|
|
|
|
|
|
|
my $name = delete $args{name}; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $path = delete $args{svg} or die "Cannot register an icon - need an SVG path"; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
-f $path or $path = module_file( "Devel::MAT::UI", $path ); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
$ICON_PATHS{$name} = $path; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my %ICONS; # {$name}{"$w*$h"} = $pixbuf |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub get_icon |
45
|
|
|
|
|
|
|
{ |
46
|
|
|
|
|
|
|
my ( $name, %opts ) = @_; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
my $path = $ICON_PATHS{$name} or do { |
49
|
|
|
|
|
|
|
warn "Unregistered icon name $name"; |
50
|
|
|
|
|
|
|
undef; |
51
|
|
|
|
|
|
|
}; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
if( defined $opts{w} and defined $opts{h} ) { |
54
|
|
|
|
|
|
|
my $w = $opts{w}; |
55
|
|
|
|
|
|
|
my $h = $opts{h}; |
56
|
|
|
|
|
|
|
return $ICONS{$name}{"$w*$h"} ||= Gtk2::Gdk::Pixbuf->new_from_file_at_size( |
57
|
|
|
|
|
|
|
$path, $w, $h |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
else { |
61
|
|
|
|
|
|
|
return $ICONS{$name}{default} ||= Gtk2::Gdk::Pixbuf->new_from_file( |
62
|
|
|
|
|
|
|
$path |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
foreach (qw( UNDEF SCALAR REF ARRAY HASH CODE GLOB STASH LVALUE REGEXP IO FORMAT PADLIST PADNAMES PAD INVLIST )) { |
68
|
|
|
|
|
|
|
Devel::MAT::UI->register_icon( name => "type-$_", svg => "icons/type-$_.svg" ); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
foreach (qw( strong weak indirect inferred )) { |
71
|
|
|
|
|
|
|
Devel::MAT::UI->register_icon( name => "strength-$_", svg => "icons/strength-$_.svg" ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
0x55AA; |