App/Plugin/Browser.pm untested

filter: Statementstmt 0.0% 0 / 61 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 71 CC 2 SCAR 12.0
CC
2
Cov
0%
refresh
6.0
BEGIN
2.0
BEGIN
2.0
CRAP 3.3
1 package Gapp::App::Plugin::Browser;
2 {
3 $Gapp::App::Plugin::Browser::VERSION = '0.007';
4 }
5  
6 use Moose;
7  
8 use Gapp::Moose;
9  
10 use MooseX::StrictConstructor;
11 use MooseX::SemiAffordanceAccessor;
12  
13 extends 'Gapp::Window';
14 with 'Gapp::App::Role::HasApp';
15  
16  
17 has 'manager' => (
18 is => 'rw',
19 isa => 'Gapp::App::Plugin::Manager',
20 required => 1,
21 weak_ref => 1,
22 );
23  
24 has '+content' => (
25 is => 'rw',
26 default => sub {
27 my ( $self ) = @_;
28 [
29 $self->vbox,
30 ],
31 },
32 lazy => 1,
33 );
34  
35 widget 'hbox' => (
36 is => 'rw',
37 traits => [qw( GappHBox )],
38 construct => sub {
39 my ( $self ) = @_;
40 content => [
41 Gapp::ScrolledWindow->new(
42 content => [ $self->view ],
43 policy => [qw(automatic automatic )],
44 fill => 1,
45 expand => 1,
46 ),
47 Gapp::Toolbar->new(
48 orientation => 'vertical',
49 content => [
50 Gapp::ToolButton->new(
51 label => 'Configure',
52 icon => 'gtk-preferences',
53 ),
54 Gapp::SeparatorToolItem->new,
55 Gapp::ToolButton->new(
56 label => 'Enable',
57 icon => 'gtk-apply',
58 ),
59 Gapp::ToolButton->new(
60 label => 'Disable',
61 icon => 'gtk-cancel',
62 ),
63 Gapp::SeparatorToolItem->new,
64 Gapp::ToolButton->new(
65 label => 'Install',
66 icon => 'gtk-connect',
67 ),
68 Gapp::ToolButton->new(
69 label => 'Uninstall',
70 icon => 'gtk-disconnect',
71 )
72 ],
73 expand => 0,
74 ),
75 ]
76 }
77 );
78  
79 widget 'vbox' => (
80 is => 'rw',
81 traits => [qw( GappVBox )],
82 construct => sub {
83 my ( $self ) = @_;
84 spacing => 6,
85 content => [
86 Gapp::HBox->new(
87 content => [
88 Gapp::Entry->new( fill => 0, expand => 0 ),
89 ],
90 fill => 1,
91 expand => 0,
92 ),
93 $self->hbox,
94
95
96 #Gapp::HBox->new(
97 # content => [
98 # Gapp::HButtonBox->new(
99 # content => [
100 # Gapp::Button->new( action => InstallPlugin ),
101 # ],
102 # fill => 0,
103 # expand => 0,
104 # ),
105 # Gapp::HButtonBox->new(
106 # content => [
107 # Gapp::Button->new( action => ConfigurePlugin ),
108 # Gapp::Button->new( action => DisablePlugin ),
109 # Gapp::Button->new( action => EnablePlugin ),
110 # ],
111 # fill => 1,
112 # expand => 1,
113 # ),
114 # ],
115 # fill => 1,
116 # expand => 0,
117 #),
118  
119 ]
120 },
121 lazy => 1,
122 );
123  
124 widget 'view' => (
125 is => 'rw',
126 traits => [qw( GappTreeView )],
127 construct => sub {
128 my ( $self ) = @_;
129 model => $self->model,
130 headers_visible => 0,
131 columns => [
132 [qw( icon Icon pixbuf 1 )],
133 [qw( plugin Plugin markup 0), sub {
134 my $text = '<b>' . $_->name . '</b>';
135 $text .= "\n";
136 $text .= $_->description;
137 return $text;
138 },
139 {expand => 1}],
140 [qw( active Active markup 3), sub {
141 ! $_ ? '<b>Enabled</b>' : 'Disabled';
142 }],
143 ]
144 },
145 lazy => 1,
146 );
147  
148 widget 'model' => (
149 is => 'rw',
150 gclass => 'Gapp::Model::List',
151 construct => sub { },
152 lazy => 1,
153 );
154  
155  
156 sub refresh {
157 my ( $self ) = @_;
158
159 my $pman = $self->manager;
160
161 my $model = $self->view->model;
162 $model->clear;
163  
164 for ( sort { lc $a->name cmp lc $b->name } $pman->meta_files ) {
165 my $img = $_->dir . '/icon.png';
166
167 my $pixbuf;
168
169 if ( -e $img ) {
170 $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file_at_size ( $img, 48, 48 );
171 }
172 else {
173 $pixbuf = $self->gobject->render_icon( 'gtk-about', 'dnd' );
174 }
175
176
177 $model->append_record( $_, $pixbuf, $pman->plugin( $_->id ), $pman->is_disabled( $_->id ) );
178
179 }
180 }
181  
182  
183  
184  
185 1;