| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CPANPLUS::Shell::Wx::Frame; |
|
2
|
|
|
|
|
|
|
#TODO: Create a first-time wizard |
|
3
|
|
|
|
|
|
|
#TODO: Check if CPAN/CPANPLUS is updated at startup |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
1655
|
use base qw(Wx::Frame); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
815
|
|
|
7
|
|
|
|
|
|
|
use Wx qw/:allclasses wxFD_SAVE wxFD_OVERWRITE_PROMPT wxID_OK wxID_CANCEL |
|
8
|
|
|
|
|
|
|
wxFD_OPEN wxLIST_AUTOSIZE wxYES_NO wxYES wxTB_TEXT/; |
|
9
|
|
|
|
|
|
|
use Wx::Event qw(EVT_MENU EVT_TOOL EVT_WINDOW_CREATE EVT_BUTTON EVT_TEXT_ENTER); |
|
10
|
|
|
|
|
|
|
use Wx::ArtProvider qw/:artid :clientid/; |
|
11
|
|
|
|
|
|
|
use Wx::Help qw/wxHF_DEFAULT_STYLE/; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use CPANPLUS::Shell::Wx::Configure; |
|
14
|
|
|
|
|
|
|
use CPANPLUS::Shell::Wx::ModuleTree; |
|
15
|
|
|
|
|
|
|
use CPANPLUS::Shell::Wx::ModulePanel; |
|
16
|
|
|
|
|
|
|
use CPANPLUS::Shell::Wx::util; |
|
17
|
|
|
|
|
|
|
use CPANPLUS::Shell::Wx::PODReader; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#use File::Spec; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#enable gettext support |
|
22
|
|
|
|
|
|
|
use Wx::Locale gettext => '_T'; |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
use Cwd; |
|
25
|
|
|
|
|
|
|
use Data::Dumper; |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new{ |
|
28
|
|
|
|
|
|
|
my $class = shift; |
|
29
|
|
|
|
|
|
|
my ($parent) = @_; |
|
30
|
|
|
|
|
|
|
my $self = $class->SUPER::new(); |
|
31
|
|
|
|
|
|
|
$self->{is_created}=0; |
|
32
|
|
|
|
|
|
|
$self->{parent} = $parent; |
|
33
|
|
|
|
|
|
|
EVT_WINDOW_CREATE( $self, $self, \&OnCreate ); |
|
34
|
|
|
|
|
|
|
return $self; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
sub OnCreate{ |
|
37
|
|
|
|
|
|
|
my $self = shift; |
|
38
|
|
|
|
|
|
|
my ($event) = @_; |
|
39
|
|
|
|
|
|
|
return if $self->{is_created}; |
|
40
|
|
|
|
|
|
|
$self->{list}=Wx::Window::FindWindowByName('nb_main_mod_tree_pane'); |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
print _T("Setting up UI\n"); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#set the window icon to the default |
|
45
|
|
|
|
|
|
|
$self->SetIcon(Wx::GetWxPerlIcon()); |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
#create a logging console first off log_console |
|
48
|
|
|
|
|
|
|
print _T("Switching to Logging Console..."); |
|
49
|
|
|
|
|
|
|
$self->{log} = Wx::Log::SetActiveTarget( |
|
50
|
|
|
|
|
|
|
Wx::LogTextCtrl->new( |
|
51
|
|
|
|
|
|
|
Wx::Window::FindWindowByName('log_console')) ); |
|
52
|
|
|
|
|
|
|
Wx::LogMessage(_T("Initializing Log Console...")); |
|
53
|
|
|
|
|
|
|
print _T("[DONE]\nNew messages will be redirected to Logging console, under the Log Tab\n"); |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
#create references for easier access and faster execution |
|
56
|
|
|
|
|
|
|
$self->{cpan} = CPANPLUS::Backend->new(); #only one Backend per running program |
|
57
|
|
|
|
|
|
|
$self->{config} = $self->{cpan}->configure_object; |
|
58
|
|
|
|
|
|
|
# $self->{categories}=$self->_get_categories; |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
#unused variable used to initialize cpan |
|
61
|
|
|
|
|
|
|
my $unused_var_to_init_cpanpp=$self->{cpan}->module_tree('CPANPLUS'); |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$self->{is_created}=1; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#ssetup various controls |
|
66
|
|
|
|
|
|
|
$self->_setup_toolbar(); |
|
67
|
|
|
|
|
|
|
$self->_setup_menu(); |
|
68
|
|
|
|
|
|
|
$self->_setup_modules(); |
|
69
|
|
|
|
|
|
|
# $self->_setup_actionslist(); |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
my $main_nb=Wx::Window::FindWindowByName('nb_main'); |
|
72
|
|
|
|
|
|
|
$self->{podReader}=CPANPLUS::Shell::Wx::PODReader::Embed->new($main_nb); |
|
73
|
|
|
|
|
|
|
$main_nb->AddPage( |
|
74
|
|
|
|
|
|
|
$self->{podReader}, |
|
75
|
|
|
|
|
|
|
_T("POD Reader") |
|
76
|
|
|
|
|
|
|
); |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
EVT_BUTTON($self, Wx::Window::FindWindowByName('actions_clear'),\&ClearActions); |
|
79
|
|
|
|
|
|
|
EVT_BUTTON($self, Wx::Window::FindWindowByName('actions_process'),\&ProcessActions); |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
#destroy splash screen, if any. |
|
82
|
|
|
|
|
|
|
$self->{parent}->{splash}->Destroy if $self->{parent}->{splash}; |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
#check for updated version of CPANPLUS and First Time usage |
|
85
|
|
|
|
|
|
|
$self->CheckUpdate(); |
|
86
|
|
|
|
|
|
|
$self->CheckFirstTime(); |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
#$self->ShowPrefs; #for testing |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
_uShowErr; |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub _setup_modules{ |
|
94
|
|
|
|
|
|
|
my $self=shift; |
|
95
|
|
|
|
|
|
|
print "Setting up modules...\n"; |
|
96
|
|
|
|
|
|
|
my $panel=Wx::Window::FindWindowByName('nb_main_mod_tree_pane'); |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
$self->{status_icons}=_uGetImageData(); |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# print "Setting Module tree...\n"; |
|
101
|
|
|
|
|
|
|
$self->{panel}=$panel; |
|
102
|
|
|
|
|
|
|
$panel->SetModuleTree(Wx::Window::FindWindowByName('tree_modules')); |
|
103
|
|
|
|
|
|
|
# print "Setting Image list...\n"; |
|
104
|
|
|
|
|
|
|
$panel->SetCPP($self->{cpan}); |
|
105
|
|
|
|
|
|
|
$panel->SetImageList($self->{status_icons}); |
|
106
|
|
|
|
|
|
|
$panel->SetStatusBar(Wx::Window::FindWindowByName('main_window_status')); |
|
107
|
|
|
|
|
|
|
$panel->SetPODReader($self->{podReader}); |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
print "Initializing ModulePanel...\n"; |
|
110
|
|
|
|
|
|
|
$panel->Init(); |
|
111
|
|
|
|
|
|
|
$panel->SetDblClickHandler(sub{$self->ShowPODReader(@_)}); |
|
112
|
|
|
|
|
|
|
$panel->SetInstallMenuHandler(sub{$self->SetAction(@_,_T('Install'))}); |
|
113
|
|
|
|
|
|
|
$panel->SetUpdateMenuHandler(sub{$self->SetAction(@_,_T('Update'))}); |
|
114
|
|
|
|
|
|
|
$panel->SetUninstallMenuHandler(sub{$self->SetAction(@_,_T('Uninstall'))}); |
|
115
|
|
|
|
|
|
|
$panel->SetFetchMenuHandler(sub{$self->SetAction(@_,_T('Fetch'))}); |
|
116
|
|
|
|
|
|
|
$panel->SetPrepareMenuHandler(sub{$self->SetAction(@_,_T('Prepare'))}); |
|
117
|
|
|
|
|
|
|
$panel->SetBuildMenuHandler(sub{$self->SetAction(@_,_T('Build'))}); |
|
118
|
|
|
|
|
|
|
$panel->SetTestMenuHandler(sub{$self->SetAction(@_,_T('Test'))}); |
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
#this method shows the PODReader tab and displays the documentation for the selected module |
|
122
|
|
|
|
|
|
|
sub ShowPODReader{ |
|
123
|
|
|
|
|
|
|
my $self = shift; |
|
124
|
|
|
|
|
|
|
my ($event) = @_; |
|
125
|
|
|
|
|
|
|
print "Showing POD Reader\n"; |
|
126
|
|
|
|
|
|
|
# $self->{podReader}=CPANPLUS::Shell::Wx::PODReader::Frame->new($self) unless $self->{podReader}; |
|
127
|
|
|
|
|
|
|
# $self->{podReader}->Show(1) if ($self->{podReader} && $self->{podReader}->isa('Wx::Frame')); |
|
128
|
|
|
|
|
|
|
$self->{podReader}->Search($self->{panel}->{thisName}); |
|
129
|
|
|
|
|
|
|
Wx::Window::FindWindowByName('nb_main')->ChangeSelection(3); |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
} |
|
132
|
|
|
|
|
|
|
sub SetAction{ |
|
133
|
|
|
|
|
|
|
my ($self,$menu,$cmd_event,$modName,$cmd)=@_; |
|
134
|
|
|
|
|
|
|
my $actionslist=Wx::Window::FindWindowByName('main_actions_list'); |
|
135
|
|
|
|
|
|
|
my $modtree=Wx::Window::FindWindowByName('tree_modules'); |
|
136
|
|
|
|
|
|
|
$actionslist->AddActionWithPre($modName,undef,$cmd); |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub CheckUpdate{ |
|
140
|
|
|
|
|
|
|
my $self=shift; |
|
141
|
|
|
|
|
|
|
my $cp=$self->{cpan}->module_tree('CPANPLUS'); |
|
142
|
|
|
|
|
|
|
unless ($cp->is_uptodate()){ |
|
143
|
|
|
|
|
|
|
my $reply=Wx::MessageBox(_T("CPANPLUS needs to be updated. Would you like to update now?"), _T("Update CPANPLUS?"), |
|
144
|
|
|
|
|
|
|
wxYES_NO, $self); |
|
145
|
|
|
|
|
|
|
$self->ShowUpdateWizard() if ($reply==wxYES); |
|
146
|
|
|
|
|
|
|
} |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
sub CheckFirstTime{ |
|
150
|
|
|
|
|
|
|
my $self = shift; |
|
151
|
|
|
|
|
|
|
my ($event) = @_; |
|
152
|
|
|
|
|
|
|
unless (-e _uGetPath($self->{config},'app_config')){ |
|
153
|
|
|
|
|
|
|
my $reply=Wx::MessageBox(_T("This is the first time you have run wxCPAN. Would you like to review your preferences?"), _T("Update CPANPLUS?"), |
|
154
|
|
|
|
|
|
|
wxYES_NO, $self); |
|
155
|
|
|
|
|
|
|
$self->ShowPrefs if $reply==wxYES; |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
sub ShowUpdateWizard{ |
|
159
|
|
|
|
|
|
|
my $self = shift; |
|
160
|
|
|
|
|
|
|
my ($event) = @_; |
|
161
|
|
|
|
|
|
|
use CPANPLUS::Shell::Wx::UpdateWizard; |
|
162
|
|
|
|
|
|
|
my $wizard=new CPANPLUS::Shell::Wx::UpdateWizard(); |
|
163
|
|
|
|
|
|
|
$wizard->SetCPPObject($self->{cpan}); |
|
164
|
|
|
|
|
|
|
$wizard->Run(); |
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
#opens an actions file (.cpan default extension) |
|
169
|
|
|
|
|
|
|
sub OnOpen{ |
|
170
|
|
|
|
|
|
|
my $self = shift; |
|
171
|
|
|
|
|
|
|
my ($event) = @_; |
|
172
|
|
|
|
|
|
|
my $actionslist=Wx::Window::FindWindowByName('main_actions_list'); |
|
173
|
|
|
|
|
|
|
my $dlg=Wx::FileDialog->new($self,_T("Open Actions File:"),'','',_T("CPAN Actions files (*.cpan)|*.cpan|All files (*.*)|*.*"),wxFD_OPEN); |
|
174
|
|
|
|
|
|
|
if ($dlg->ShowModal() == wxID_OK){ |
|
175
|
|
|
|
|
|
|
Wx::LogMessage( _T("Opening ").$dlg->GetPath() ); |
|
176
|
|
|
|
|
|
|
if (open(F,$dlg->GetPath())){ |
|
177
|
|
|
|
|
|
|
my @lines=; |
|
178
|
|
|
|
|
|
|
close F; |
|
179
|
|
|
|
|
|
|
return unless @lines; #check for empty file |
|
180
|
|
|
|
|
|
|
foreach $l (reverse(@lines)){ |
|
181
|
|
|
|
|
|
|
chomp($l); |
|
182
|
|
|
|
|
|
|
next if $l=~/^\s*\#/; #skip comment lines |
|
183
|
|
|
|
|
|
|
my ($name,$action)=split(',',$l); |
|
184
|
|
|
|
|
|
|
$actionslist->InsertStringItem( 0, $name ); |
|
185
|
|
|
|
|
|
|
$actionslist->SetItem( 0, 1, $action ); |
|
186
|
|
|
|
|
|
|
} |
|
187
|
|
|
|
|
|
|
} |
|
188
|
|
|
|
|
|
|
} |
|
189
|
|
|
|
|
|
|
} |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
#saves an actions file to disk |
|
192
|
|
|
|
|
|
|
sub OnSave{ |
|
193
|
|
|
|
|
|
|
my $self = shift; |
|
194
|
|
|
|
|
|
|
my ($event) = @_; |
|
195
|
|
|
|
|
|
|
my $actionslist=Wx::Window::FindWindowByName('main_actions_list'); |
|
196
|
|
|
|
|
|
|
my $numInList=$actionslist->GetItemCount(); |
|
197
|
|
|
|
|
|
|
#return if there are no items in the list |
|
198
|
|
|
|
|
|
|
unless ($numInList >0){ |
|
199
|
|
|
|
|
|
|
Wx::MessageBox(_T("There are no items in the queue.")); |
|
200
|
|
|
|
|
|
|
return; |
|
201
|
|
|
|
|
|
|
} |
|
202
|
|
|
|
|
|
|
my $dlg=Wx::FileDialog->new($self,_T("Save Actions File:"),'','',_T("CPAN Actions files (*.cpan)|*.cpan|All files (*.*)|*.*"),wxFD_SAVE|wxFD_OVERWRITE_PROMPT); |
|
203
|
|
|
|
|
|
|
if ($dlg->ShowModal() == wxID_OK){ |
|
204
|
|
|
|
|
|
|
Wx::LogMessage( _T("Saving to ").$dlg->GetPath() ); |
|
205
|
|
|
|
|
|
|
if (open(F,">".$dlg->GetPath())){ |
|
206
|
|
|
|
|
|
|
for (my $i=0;$i<$numInList;$i++){ |
|
207
|
|
|
|
|
|
|
my $item=$actionslist->GetItemText($i); |
|
208
|
|
|
|
|
|
|
my $action=$actionslist->GetItem(0,1)->GetText(); |
|
209
|
|
|
|
|
|
|
print F "$item,$action\n"; |
|
210
|
|
|
|
|
|
|
} |
|
211
|
|
|
|
|
|
|
close F; |
|
212
|
|
|
|
|
|
|
} |
|
213
|
|
|
|
|
|
|
} |
|
214
|
|
|
|
|
|
|
} |
|
215
|
|
|
|
|
|
|
sub ClearActions{ |
|
216
|
|
|
|
|
|
|
my $self = shift; |
|
217
|
|
|
|
|
|
|
my ($event) = @_; |
|
218
|
|
|
|
|
|
|
my $actionslist=Wx::Window::FindWindowByName('main_actions_list'); |
|
219
|
|
|
|
|
|
|
$actionslist->DeleteAllItems(); |
|
220
|
|
|
|
|
|
|
} |
|
221
|
|
|
|
|
|
|
sub ProcessActions{ |
|
222
|
|
|
|
|
|
|
my $self = shift; |
|
223
|
|
|
|
|
|
|
my ($event) = @_; |
|
224
|
|
|
|
|
|
|
my $actionslist=Wx::Window::FindWindowByName('main_actions_list'); |
|
225
|
|
|
|
|
|
|
while ($modName=$actionslist->GetItemText(0)){ |
|
226
|
|
|
|
|
|
|
my $action=$actionslist->GetItem(0,1)->GetText(); |
|
227
|
|
|
|
|
|
|
$action = "create" if $action eq "Build"; |
|
228
|
|
|
|
|
|
|
Wx::LogMessage(_T("Processing $action for $modName.")); |
|
229
|
|
|
|
|
|
|
my $mod=$self->{cpan}->module_tree($modName); |
|
230
|
|
|
|
|
|
|
if ($mod){ |
|
231
|
|
|
|
|
|
|
my $bool=0; |
|
232
|
|
|
|
|
|
|
eval "\$bool = \$mod->".lc($action)."();"; |
|
233
|
|
|
|
|
|
|
print $@ if $@; |
|
234
|
|
|
|
|
|
|
Wx::LogMessage(_T("FAILED TO INSTALL ").$modName._T(". OUTPUT:")) if $bool; |
|
235
|
|
|
|
|
|
|
_uShowErr; |
|
236
|
|
|
|
|
|
|
} |
|
237
|
|
|
|
|
|
|
$actionslist->DeleteItem(0); |
|
238
|
|
|
|
|
|
|
} |
|
239
|
|
|
|
|
|
|
} |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
sub ShowConfigDump{ |
|
242
|
|
|
|
|
|
|
my $self = shift; |
|
243
|
|
|
|
|
|
|
my ($event) = @_; |
|
244
|
|
|
|
|
|
|
Wx::Window::FindWindowByName('log_console')->AppendText(Dumper($self->{config})); |
|
245
|
|
|
|
|
|
|
} |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
#exit program, destroy window |
|
248
|
|
|
|
|
|
|
sub OnQuit{ |
|
249
|
|
|
|
|
|
|
my $self = shift; |
|
250
|
|
|
|
|
|
|
$self->Close(1); |
|
251
|
|
|
|
|
|
|
} |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
#show preferences dialog |
|
254
|
|
|
|
|
|
|
sub ShowPrefs{ |
|
255
|
|
|
|
|
|
|
Wx::LogMessage _T("Displaying Preferences..."); |
|
256
|
|
|
|
|
|
|
my $self = shift; |
|
257
|
|
|
|
|
|
|
my ($event) = @_; |
|
258
|
|
|
|
|
|
|
my $xrc_file = _uGetInstallPath('CPANPLUS::Shell::Wx::res::PrefsWin.xrc'); |
|
259
|
|
|
|
|
|
|
unless ( -e $xrc_file ) { |
|
260
|
|
|
|
|
|
|
Wx::LogError |
|
261
|
|
|
|
|
|
|
_T("ERROR: Unable to find XRC Resource file: $xrc_file !\n Exiting..."); |
|
262
|
|
|
|
|
|
|
return 1; |
|
263
|
|
|
|
|
|
|
} |
|
264
|
|
|
|
|
|
|
my $prefsxrc = Wx::XmlResource->new(); |
|
265
|
|
|
|
|
|
|
$prefsxrc->InitAllHandlers(); |
|
266
|
|
|
|
|
|
|
$prefsxrc->Load($xrc_file); |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
#print Dumper $self,$parent; |
|
269
|
|
|
|
|
|
|
$self->{prefsWin} = $prefsxrc->LoadDialog( $self, 'prefs_window' ) |
|
270
|
|
|
|
|
|
|
or return; |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
$self->{prefsWin}->Show(1); |
|
273
|
|
|
|
|
|
|
} |
|
274
|
|
|
|
|
|
|
#show podreader dialog |
|
275
|
|
|
|
|
|
|
#sub ShowPODReader{ |
|
276
|
|
|
|
|
|
|
# my $self = shift; |
|
277
|
|
|
|
|
|
|
# my ($event) = @_; |
|
278
|
|
|
|
|
|
|
# $self->{podReader}=CPANPLUS::Shell::Wx::PODReader::Frame->new($self) unless $self->{podReader}; |
|
279
|
|
|
|
|
|
|
# $self->{podReader}->Show(1) if ($self->{podReader}); |
|
280
|
|
|
|
|
|
|
# Wx::Window::FindWindowByName('nb_main')->ChangeSelection(3); |
|
281
|
|
|
|
|
|
|
#} |
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
sub _setup_actionslist{ |
|
284
|
|
|
|
|
|
|
$self=shift; |
|
285
|
|
|
|
|
|
|
my $actionslist=Wx::Window::FindWindowByName('main_actions_list'); |
|
286
|
|
|
|
|
|
|
$actionslist->InsertColumn( 0, _T('Module')); |
|
287
|
|
|
|
|
|
|
$actionslist->InsertColumn( 1, _T('Action') ); |
|
288
|
|
|
|
|
|
|
$actionslist->SetColumnWidth(0,wxLIST_AUTOSIZE); |
|
289
|
|
|
|
|
|
|
$actionslist->SetColumnWidth(1,wxLIST_AUTOSIZE); |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
} |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
sub _setup_menu{ |
|
295
|
|
|
|
|
|
|
$self=shift; |
|
296
|
|
|
|
|
|
|
#attach menu events |
|
297
|
|
|
|
|
|
|
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_file_quit'), \&OnQuit ); |
|
298
|
|
|
|
|
|
|
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_file_open'), \&OnOpen ); |
|
299
|
|
|
|
|
|
|
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_file_save'), \&OnSave ); |
|
300
|
|
|
|
|
|
|
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_edit_prefs'), \&ShowPrefs ); |
|
301
|
|
|
|
|
|
|
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_help_show_log_console'), \&ShowLog ); |
|
302
|
|
|
|
|
|
|
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_show_config_dump'), \&ShowConfigDump ); |
|
303
|
|
|
|
|
|
|
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_help_pod_reader'), \&ShowPODReader ); |
|
304
|
|
|
|
|
|
|
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_help_about'), \&ShowAboutBox ); |
|
305
|
|
|
|
|
|
|
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_help_help'), \&ShowHelpWindow ); |
|
306
|
|
|
|
|
|
|
EVT_MENU( $self, Wx::XmlResource::GetXRCID('mnu_help_updatewizard'), \&ShowUpdateWizard ); |
|
307
|
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
} |
|
309
|
|
|
|
|
|
|
sub _setup_toolbar{ |
|
310
|
|
|
|
|
|
|
$self=shift; |
|
311
|
|
|
|
|
|
|
my $tb=$self->GetToolBar() || $self->CreateToolBar(wxTB_TEXT); |
|
312
|
|
|
|
|
|
|
$self->{toolbar}=$tb; |
|
313
|
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
#get rid of old tools. The ones in XRC file are placeholders |
|
315
|
|
|
|
|
|
|
$tb->ClearTools(); |
|
316
|
|
|
|
|
|
|
|
|
317
|
|
|
|
|
|
|
#set up icons |
|
318
|
|
|
|
|
|
|
my $tb_icon_installed=Wx::ArtProvider::GetBitmap(wxART_TICK_MARK,wxART_TOOLBAR_C); |
|
319
|
|
|
|
|
|
|
my $tb_icon_update=Wx::ArtProvider::GetBitmap(wxART_ADD_BOOKMARK,wxART_TOOLBAR_C); |
|
320
|
|
|
|
|
|
|
my $tb_icon_remove=Wx::ArtProvider::GetBitmap(wxART_DEL_BOOKMARK,wxART_TOOLBAR_C); |
|
321
|
|
|
|
|
|
|
my $tb_icon_not_installed=Wx::ArtProvider::GetBitmap(wxART_NEW_DIR,wxART_TOOLBAR_C); |
|
322
|
|
|
|
|
|
|
my $tb_icon_unknown=Wx::ArtProvider::GetBitmap(wxART_QUESTION,wxART_TOOLBAR_C); |
|
323
|
|
|
|
|
|
|
my $tb_icon_cat=Wx::ArtProvider::GetBitmap(wxART_QUESTION,wxART_TOOLBAR_C); |
|
324
|
|
|
|
|
|
|
my $tb_icon_authors=Wx::ArtProvider::GetBitmap(wxART_HELP_SETTINGS,wxART_TOOLBAR_C); |
|
325
|
|
|
|
|
|
|
my $tb_icon_names=Wx::ArtProvider::GetBitmap(wxART_QUESTION,wxART_TOOLBAR_C); |
|
326
|
|
|
|
|
|
|
my $tb_icon_populate=Wx::ArtProvider::GetBitmap(wxART_EXECUTABLE_FILE,wxART_TOOLBAR_C); |
|
327
|
|
|
|
|
|
|
|
|
328
|
|
|
|
|
|
|
#Add the tools. for some reason, we can't attach events in this step. It breaks. |
|
329
|
|
|
|
|
|
|
my $idstart=10000; #the control IDs start here |
|
330
|
|
|
|
|
|
|
my @tb_items=( |
|
331
|
|
|
|
|
|
|
$tb->AddRadioTool($idstart,_T("Installed"),$tb_icon_installed,$tb_icon_installed,_T("Show Installed Modules")), |
|
332
|
|
|
|
|
|
|
$tb->AddRadioTool($idstart+1,_T("Updates"),$tb_icon_update,$tb_icon_update,_T("List Modules to be Updated")), |
|
333
|
|
|
|
|
|
|
$tb->AddRadioTool($idstart+2,_T("New"),$tb_icon_not_installed,$tb_icon_not_installed,_T("List New Modules")), |
|
334
|
|
|
|
|
|
|
$tb->AddRadioTool($idstart+3,_T("All"),$tb_icon_installed,$tb_icon_installed,_T("List All Modules")), |
|
335
|
|
|
|
|
|
|
$tb->AddSeparator(), |
|
336
|
|
|
|
|
|
|
$tb->AddRadioTool($idstart+4,_T("Categories"),$tb_icon_cat,$tb_icon_cat,_T("Sort List by Category")), |
|
337
|
|
|
|
|
|
|
$tb->AddRadioTool($idstart+5,_T("Names"),$tb_icon_names,$tb_icon_names,_T("Sort List by Module Name")), |
|
338
|
|
|
|
|
|
|
$tb->AddRadioTool($idstart+6,_T("Authors"),$tb_icon_authors,$tb_icon_authors,_T("Sort List By Authors")), |
|
339
|
|
|
|
|
|
|
$tb->AddSeparator(), |
|
340
|
|
|
|
|
|
|
$tb->AddTool($idstart+7,_T("Update List"),$tb_icon_populate,_T("Re-Populate the tree")) |
|
341
|
|
|
|
|
|
|
); |
|
342
|
|
|
|
|
|
|
|
|
343
|
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
#attach events |
|
345
|
|
|
|
|
|
|
EVT_TOOL( $self, $idstart, sub{$self->{list}->ShowInstalled();} ); |
|
346
|
|
|
|
|
|
|
EVT_TOOL( $self, $idstart+1, sub{$self->{list}->ShowUpdated();} ); |
|
347
|
|
|
|
|
|
|
EVT_TOOL( $self, $idstart+2, sub{$self->{list}->ShowNew();} ); |
|
348
|
|
|
|
|
|
|
EVT_TOOL( $self, $idstart+3, sub{$self->{list}->ShowAll();} ); |
|
349
|
|
|
|
|
|
|
EVT_TOOL( $self, $idstart+4, sub{$self->{list}->SortByCategory();} ); |
|
350
|
|
|
|
|
|
|
EVT_TOOL( $self, $idstart+5, sub{$self->{list}->SortByName();} ); |
|
351
|
|
|
|
|
|
|
EVT_TOOL( $self, $idstart+6, sub{$self->{list}->SortByAuthor();} ); |
|
352
|
|
|
|
|
|
|
EVT_TOOL( $self, $idstart+7, sub{$self->{list}->Populate();} ); |
|
353
|
|
|
|
|
|
|
|
|
354
|
|
|
|
|
|
|
} |
|
355
|
|
|
|
|
|
|
sub ShowAboutBox{ |
|
356
|
|
|
|
|
|
|
my $self=shift; |
|
357
|
|
|
|
|
|
|
my $info = Wx::AboutDialogInfo->new(); |
|
358
|
|
|
|
|
|
|
$info->AddArtist('Skaman Sam Tyler'); |
|
359
|
|
|
|
|
|
|
$info->AddArtist(''); |
|
360
|
|
|
|
|
|
|
$info->AddArtist(_T('Thanks to David Vignoni,')); |
|
361
|
|
|
|
|
|
|
$info->AddArtist(' http://www.icon-king.com/,'); |
|
362
|
|
|
|
|
|
|
$info->AddArtist(_T(' for the "box" in the Splash Screen,')); |
|
363
|
|
|
|
|
|
|
$info->AddArtist(_T(' Taken from the Nuvola Icon theme')); |
|
364
|
|
|
|
|
|
|
$info->AddArtist(''); |
|
365
|
|
|
|
|
|
|
$info->AddArtist(_T('Thanks to Various Artists,')); |
|
366
|
|
|
|
|
|
|
$info->AddArtist(' http://tango.freedesktop.org'); |
|
367
|
|
|
|
|
|
|
$info->AddArtist(_T(' for the "arrow" in the Splash Screen,')); |
|
368
|
|
|
|
|
|
|
$info->AddArtist(_T(' Taken from the Tango Icon theme')); |
|
369
|
|
|
|
|
|
|
$info->AddDeveloper('Skaman Sam Tyler'); |
|
370
|
|
|
|
|
|
|
$info->AddDocWriter('Skaman Sam Tyler'); |
|
371
|
|
|
|
|
|
|
# $info->AddTranslator(''); |
|
372
|
|
|
|
|
|
|
$info->SetCopyright(_T("wxCPAN is GPL'd software.")); |
|
373
|
|
|
|
|
|
|
$info->SetDescription(_T("wxCPAN is an interface to CPANPLUS. "). |
|
374
|
|
|
|
|
|
|
_T("It was written for the Google Summer of Code 2008, under the "). |
|
375
|
|
|
|
|
|
|
_T("mentoring abilities of Herbert Bruening. You can use wxCPAN to "). |
|
376
|
|
|
|
|
|
|
_T("manage your Perl installation, as well as create new Modules "). |
|
377
|
|
|
|
|
|
|
_T("to post to CPAN.")); |
|
378
|
|
|
|
|
|
|
# $info->SetIcon(''); |
|
379
|
|
|
|
|
|
|
$info->SetLicence(_T('This is GPL\'d software.')); |
|
380
|
|
|
|
|
|
|
$info->SetName('wxCPAN'); |
|
381
|
|
|
|
|
|
|
$info->SetVersion('0.01'); |
|
382
|
|
|
|
|
|
|
$info->SetWebSite('http://wxcpan.googlecode.com'); |
|
383
|
|
|
|
|
|
|
Wx::AboutBox($info); |
|
384
|
|
|
|
|
|
|
} |
|
385
|
|
|
|
|
|
|
sub ShowHelpWindow{ |
|
386
|
|
|
|
|
|
|
my $self=shift; |
|
387
|
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
use Wx::Help qw/wxHF_TOOLBAR wxHF_FLAT_TOOLBAR wxHF_CONTENTS wxHF_INDEX wxHF_SEARCH |
|
389
|
|
|
|
|
|
|
wxHF_BOOKMARKS wxHF_OPEN_FILES wxHF_PRINT wxHF_MERGE_BOOKS wxHF_ICONS_BOOK |
|
390
|
|
|
|
|
|
|
wxHF_ICONS_FOLDER wxHF_ICONS_BOOK_CHAPTER wxHF_EMBEDDED wxHF_DIALOG |
|
391
|
|
|
|
|
|
|
wxHF_FRAME wxHF_MODAL wxHF_DEFAULT_STYLE /; |
|
392
|
|
|
|
|
|
|
Wx::FileSystem::AddHandler(new Wx::ArchiveFSHandler); |
|
393
|
|
|
|
|
|
|
my $helpFile=_uGetInstallPath('CPANPLUS::Shell::Wx::help::wxCPAN.hhp'); |
|
394
|
|
|
|
|
|
|
my $helpwin=Wx::HtmlHelpController->new(); |
|
395
|
|
|
|
|
|
|
$helpwin->AddBook($helpFile,1); |
|
396
|
|
|
|
|
|
|
#my $helpwin=CPANPLUS::Shell::Wx::Frame::HelpWindow->new($self); |
|
397
|
|
|
|
|
|
|
$helpwin->DisplayContents(); |
|
398
|
|
|
|
|
|
|
} |
|
399
|
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
######################################## |
|
401
|
|
|
|
|
|
|
########### Search Button ############## |
|
402
|
|
|
|
|
|
|
######################################## |
|
403
|
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
package CPANPLUS::Shell::Wx::Frame::SearchButton; |
|
405
|
|
|
|
|
|
|
use base 'Wx::Button'; |
|
406
|
|
|
|
|
|
|
use Wx::Event qw/EVT_WINDOW_CREATE EVT_BUTTON/; |
|
407
|
|
|
|
|
|
|
|
|
408
|
|
|
|
|
|
|
sub new { |
|
409
|
|
|
|
|
|
|
my $class = shift; |
|
410
|
|
|
|
|
|
|
my $self = $class->SUPER::new(); # create an 'empty' Frame object |
|
411
|
|
|
|
|
|
|
EVT_WINDOW_CREATE( $self, $self, \&OnCreate ); |
|
412
|
|
|
|
|
|
|
|
|
413
|
|
|
|
|
|
|
return $self; |
|
414
|
|
|
|
|
|
|
} |
|
415
|
|
|
|
|
|
|
|
|
416
|
|
|
|
|
|
|
sub OnCreate { |
|
417
|
|
|
|
|
|
|
my $self = shift; |
|
418
|
|
|
|
|
|
|
EVT_BUTTON( $self, $self, \&OnClick ); |
|
419
|
|
|
|
|
|
|
} |
|
420
|
|
|
|
|
|
|
|
|
421
|
|
|
|
|
|
|
sub OnClick{ |
|
422
|
|
|
|
|
|
|
my $self=shift; |
|
423
|
|
|
|
|
|
|
my $searchbox=Wx::Window::FindWindowByName('cb_main_search')->GetValue(); |
|
424
|
|
|
|
|
|
|
my $typebox=Wx::Window::FindWindowByName('cb_search_type')->GetValue(); |
|
425
|
|
|
|
|
|
|
Wx::Window::FindWindowByName('main_window')->{list}->search( |
|
426
|
|
|
|
|
|
|
$typebox, |
|
427
|
|
|
|
|
|
|
$searchbox); |
|
428
|
|
|
|
|
|
|
|
|
429
|
|
|
|
|
|
|
} |
|
430
|
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
######################################## |
|
432
|
|
|
|
|
|
|
############# Search Box ############### |
|
433
|
|
|
|
|
|
|
######################################## |
|
434
|
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
package CPANPLUS::Shell::Wx::Frame::SearchBox; |
|
436
|
|
|
|
|
|
|
use base 'Wx::ComboBox'; |
|
437
|
|
|
|
|
|
|
use Wx::Event qw/EVT_WINDOW_CREATE EVT_TEXT_ENTER/; |
|
438
|
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
sub new { |
|
440
|
|
|
|
|
|
|
my $class = shift; |
|
441
|
|
|
|
|
|
|
my $self = $class->SUPER::new(); # create an 'empty' Frame object |
|
442
|
|
|
|
|
|
|
EVT_WINDOW_CREATE( $self, $self, \&OnCreate ); |
|
443
|
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
return $self; |
|
445
|
|
|
|
|
|
|
} |
|
446
|
|
|
|
|
|
|
|
|
447
|
|
|
|
|
|
|
sub OnCreate { |
|
448
|
|
|
|
|
|
|
my $self = shift; |
|
449
|
|
|
|
|
|
|
EVT_TEXT_ENTER( $self, $self, \&OnEnter ); |
|
450
|
|
|
|
|
|
|
} |
|
451
|
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
sub OnEnter{ |
|
453
|
|
|
|
|
|
|
my $self=shift; |
|
454
|
|
|
|
|
|
|
my $searchbox=$self->GetValue(); |
|
455
|
|
|
|
|
|
|
my $typebox=Wx::Window::FindWindowByName('cb_search_type')->GetValue(); |
|
456
|
|
|
|
|
|
|
Wx::Window::FindWindowByName('main_window')->{list}->search( |
|
457
|
|
|
|
|
|
|
$typebox, |
|
458
|
|
|
|
|
|
|
$searchbox); |
|
459
|
|
|
|
|
|
|
|
|
460
|
|
|
|
|
|
|
} |
|
461
|
|
|
|
|
|
|
######################################## |
|
462
|
|
|
|
|
|
|
############### Toolbar ################ |
|
463
|
|
|
|
|
|
|
######################################## |
|
464
|
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
package CPANPLUS::Shell::Wx::Frame::ToolBar; |
|
466
|
|
|
|
|
|
|
use Wx::Event qw(EVT_WINDOW_CREATE EVT_BUTTON); |
|
467
|
|
|
|
|
|
|
use Data::Dumper; |
|
468
|
|
|
|
|
|
|
|
|
469
|
|
|
|
|
|
|
BEGIN { |
|
470
|
|
|
|
|
|
|
use vars qw( @ISA $VERSION ); |
|
471
|
|
|
|
|
|
|
@ISA = qw( Wx::ToolBar); |
|
472
|
|
|
|
|
|
|
$VERSION = '0.01'; |
|
473
|
|
|
|
|
|
|
} |
|
474
|
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
use base 'Wx::ToolBar'; |
|
476
|
|
|
|
|
|
|
use Wx::ArtProvider qw/:artid :clientid/; |
|
477
|
|
|
|
|
|
|
|
|
478
|
|
|
|
|
|
|
sub new { |
|
479
|
|
|
|
|
|
|
my $class = shift; |
|
480
|
|
|
|
|
|
|
my $self = $class->SUPER::new(); # create an 'empty' Frame object |
|
481
|
|
|
|
|
|
|
print "Toolbar items: ".$self->GetToolsCount; |
|
482
|
|
|
|
|
|
|
|
|
483
|
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
EVT_WINDOW_CREATE( $self, $self, \&OnCreate ); |
|
485
|
|
|
|
|
|
|
return $self; |
|
486
|
|
|
|
|
|
|
} |
|
487
|
|
|
|
|
|
|
sub OnCreate { |
|
488
|
|
|
|
|
|
|
my $self = shift; |
|
489
|
|
|
|
|
|
|
my ($event)=@_; |
|
490
|
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
} |
|
492
|
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
|
|
494
|
|
|
|
|
|
|
######################################## |
|
495
|
|
|
|
|
|
|
########## Logging Console ############# |
|
496
|
|
|
|
|
|
|
######################################## |
|
497
|
|
|
|
|
|
|
|
|
498
|
|
|
|
|
|
|
package CPANPLUS::Shell::Wx::Frame::LogConsole; |
|
499
|
|
|
|
|
|
|
use Wx::Event qw(EVT_WINDOW_CREATE EVT_BUTTON EVT_TEXT); |
|
500
|
|
|
|
|
|
|
use Data::Dumper; |
|
501
|
|
|
|
|
|
|
use Wx qw/wxRED/; |
|
502
|
|
|
|
|
|
|
BEGIN { |
|
503
|
|
|
|
|
|
|
use vars qw( @ISA $VERSION ); |
|
504
|
|
|
|
|
|
|
@ISA = qw( Wx::TextCtrl Wx::Log Wx::LogTextCtrl); |
|
505
|
|
|
|
|
|
|
$VERSION = '0.01'; |
|
506
|
|
|
|
|
|
|
} |
|
507
|
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
use base 'Wx::TextCtrl'; |
|
509
|
|
|
|
|
|
|
|
|
510
|
|
|
|
|
|
|
sub new { |
|
511
|
|
|
|
|
|
|
my $class = shift; |
|
512
|
|
|
|
|
|
|
my $self = $class->SUPER::new(); # create an 'empty' Frame object |
|
513
|
|
|
|
|
|
|
EVT_TEXT($self,$self,\&DoLog); |
|
514
|
|
|
|
|
|
|
$self->{old_pos}=0; |
|
515
|
|
|
|
|
|
|
$self->{new_pos}=0; |
|
516
|
|
|
|
|
|
|
return $self; |
|
517
|
|
|
|
|
|
|
} |
|
518
|
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
#this method is called after the text is sent to the LogConsole. |
|
520
|
|
|
|
|
|
|
#it is supposed to colorize the messages based on the level, |
|
521
|
|
|
|
|
|
|
#but it doesn't seem to work correctly as of yet. |
|
522
|
|
|
|
|
|
|
#TODO Fix this so it colors correctly. |
|
523
|
|
|
|
|
|
|
sub DoLog{ |
|
524
|
|
|
|
|
|
|
my ($self,$event)=@_; |
|
525
|
|
|
|
|
|
|
$self->{new_pos}=$self->GetLastPosition(); |
|
526
|
|
|
|
|
|
|
my $txt=$self->GetRange($self->{old_pos},$self->{new_pos}); |
|
527
|
|
|
|
|
|
|
$txt=~/((\d\d\:\s*\d\d:\s*\d\d\s*[P|A]M):\s*(\[.*?\])?)\s*(.*)/; #\s*(\[.*?\])?(.*)/; |
|
528
|
|
|
|
|
|
|
my $prefix=$1;my $time=$2;my $cpan=$3;my $msg=$4; |
|
529
|
|
|
|
|
|
|
my $msg_start=$self->{old_pos}+length($prefix); |
|
530
|
|
|
|
|
|
|
$self->SetStyle($msg_start,$self->{new_pos},Wx::TextAttr->new(wxRED)); |
|
531
|
|
|
|
|
|
|
$self->{old_pos}=$self->GetLastPosition(); |
|
532
|
|
|
|
|
|
|
} |
|
533
|
|
|
|
|
|
|
sub DoLogString{ |
|
534
|
|
|
|
|
|
|
print "DoLogString ".Dumper(@_); |
|
535
|
|
|
|
|
|
|
} |
|
536
|
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
|
|
538
|
|
|
|
|
|
|
######################################## |
|
539
|
|
|
|
|
|
|
############ XRC Factory ############### |
|
540
|
|
|
|
|
|
|
######################################## |
|
541
|
|
|
|
|
|
|
package CPANPLUS::Shell::Wx::Frame::XRCFactory; |
|
542
|
|
|
|
|
|
|
use strict; |
|
543
|
|
|
|
|
|
|
use Wx; |
|
544
|
|
|
|
|
|
|
use Data::Dumper; |
|
545
|
|
|
|
|
|
|
use base "Wx::XmlSubclassFactory"; |
|
546
|
|
|
|
|
|
|
sub new { |
|
547
|
|
|
|
|
|
|
my $class = shift; |
|
548
|
|
|
|
|
|
|
my $self = $class->SUPER::new(); |
|
549
|
|
|
|
|
|
|
return $self; |
|
550
|
|
|
|
|
|
|
} |
|
551
|
|
|
|
|
|
|
sub Create { #($self,$object) |
|
552
|
|
|
|
|
|
|
my $object=$_[1]->new; |
|
553
|
|
|
|
|
|
|
# print "Creating Object: $object;\n"; |
|
554
|
|
|
|
|
|
|
return $object; |
|
555
|
|
|
|
|
|
|
} |
|
556
|
|
|
|
|
|
|
sub DoCreateResource{ |
|
557
|
|
|
|
|
|
|
print "DoCreateResource()\n"; |
|
558
|
|
|
|
|
|
|
} |
|
559
|
|
|
|
|
|
|
|
|
560
|
|
|
|
|
|
|
######################################## |
|
561
|
|
|
|
|
|
|
############ Help Window ############### |
|
562
|
|
|
|
|
|
|
######################################## |
|
563
|
|
|
|
|
|
|
package CPANPLUS::Shell::Wx::Frame::HelpWindow; |
|
564
|
|
|
|
|
|
|
use Data::Dumper; |
|
565
|
|
|
|
|
|
|
use CPANPLUS::Shell::Wx::util; |
|
566
|
|
|
|
|
|
|
|
|
567
|
|
|
|
|
|
|
use Wx qw[:everything]; |
|
568
|
|
|
|
|
|
|
use base qw(Wx::Frame); |
|
569
|
|
|
|
|
|
|
use strict; |
|
570
|
|
|
|
|
|
|
|
|
571
|
|
|
|
|
|
|
sub new { |
|
572
|
|
|
|
|
|
|
my( $self, $parent, $id, $title, $pos, $size, $style, $name ) = @_; |
|
573
|
|
|
|
|
|
|
$parent = undef unless defined $parent; |
|
574
|
|
|
|
|
|
|
$id = -1 unless defined $id; |
|
575
|
|
|
|
|
|
|
$title = "" unless defined $title; |
|
576
|
|
|
|
|
|
|
$pos = wxDefaultPosition unless defined $pos; |
|
577
|
|
|
|
|
|
|
$size = wxDefaultSize unless defined $size; |
|
578
|
|
|
|
|
|
|
$name = "" unless defined $name; |
|
579
|
|
|
|
|
|
|
|
|
580
|
|
|
|
|
|
|
Wx::InitAllImageHandlers(); |
|
581
|
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
$style = wxDEFAULT_FRAME_STYLE |
|
583
|
|
|
|
|
|
|
unless defined $style; |
|
584
|
|
|
|
|
|
|
|
|
585
|
|
|
|
|
|
|
$self = $self->SUPER::new( $parent, $id, $title, $pos, $size, $style, $name ); |
|
586
|
|
|
|
|
|
|
$self->{view} = Wx::HtmlWindow->new($self, -1); |
|
587
|
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
$self->SetTitle(_T("wxCPAN Help")); |
|
589
|
|
|
|
|
|
|
$self->SetSize(Wx::Size->new(520, 518)); |
|
590
|
|
|
|
|
|
|
|
|
591
|
|
|
|
|
|
|
$self->{sizer_1} = Wx::BoxSizer->new(wxHORIZONTAL); |
|
592
|
|
|
|
|
|
|
$self->{sizer_1}->Add($self->{view}, 1, wxEXPAND, 0); |
|
593
|
|
|
|
|
|
|
$self->SetSizer($self->{sizer_1}); |
|
594
|
|
|
|
|
|
|
$self->Layout(); |
|
595
|
|
|
|
|
|
|
|
|
596
|
|
|
|
|
|
|
$self->{view}->LoadPage(_uGetInstallPath('CPANPLUS::Shell::Wx::help::index.html')); |
|
597
|
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
# Wx::Event::EVT_HTML_LINK_CLICKED($self,$self->{view}->GetId,\&OnLinkClicked); |
|
599
|
|
|
|
|
|
|
|
|
600
|
|
|
|
|
|
|
|
|
601
|
|
|
|
|
|
|
return $self; |
|
602
|
|
|
|
|
|
|
|
|
603
|
|
|
|
|
|
|
} |
|
604
|
|
|
|
|
|
|
|
|
605
|
|
|
|
|
|
|
sub OnLinkClicked{ |
|
606
|
|
|
|
|
|
|
my ($self,$event)=@_; |
|
607
|
|
|
|
|
|
|
my $ctrl=$event->GetEventObject(); |
|
608
|
|
|
|
|
|
|
my $link=$event->GetLinkInfo()->GetHref(); |
|
609
|
|
|
|
|
|
|
$self->{view}->LoadPage(_uGetInstallPath("CPANPLUS::Shell::Wx::help::$link")); |
|
610
|
|
|
|
|
|
|
} |
|
611
|
|
|
|
|
|
|
|
|
612
|
|
|
|
|
|
|
######################################## |
|
613
|
|
|
|
|
|
|
############ Actions List ############## |
|
614
|
|
|
|
|
|
|
######################################## |
|
615
|
|
|
|
|
|
|
package CPANPLUS::Shell::Wx::Frame::ActionsList; |
|
616
|
|
|
|
|
|
|
use Data::Dumper; |
|
617
|
|
|
|
|
|
|
use CPANPLUS::Shell::Wx::util; |
|
618
|
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
use Wx qw[:everything wxDEFAULT_FRAME_STYLE wxDefaultPosition |
|
620
|
|
|
|
|
|
|
wxDefaultSize wxLIST_AUTOSIZE wxLC_REPORT wxSUNKEN_BORDER |
|
621
|
|
|
|
|
|
|
wxDefaultValidator wxLC_LIST wxIMAGE_LIST_NORMAL wxIMAGE_LIST_SMALL]; |
|
622
|
|
|
|
|
|
|
use Wx::Event qw[EVT_WINDOW_CREATE]; |
|
623
|
|
|
|
|
|
|
use base qw(Wx::ListCtrl); |
|
624
|
|
|
|
|
|
|
use strict; |
|
625
|
|
|
|
|
|
|
#enable gettext support |
|
626
|
|
|
|
|
|
|
use Wx::Locale gettext => '_T'; |
|
627
|
|
|
|
|
|
|
|
|
628
|
|
|
|
|
|
|
sub new { |
|
629
|
|
|
|
|
|
|
my( $self, $parent, $id, $pos, $size, $style, $validator, $name ) = @_; |
|
630
|
|
|
|
|
|
|
$parent = undef unless defined $parent; |
|
631
|
|
|
|
|
|
|
$id = -1 unless defined $id; |
|
632
|
|
|
|
|
|
|
$pos = wxDefaultPosition unless defined $pos; |
|
633
|
|
|
|
|
|
|
$size = wxDefaultSize unless defined $size; |
|
634
|
|
|
|
|
|
|
$validator= wxDefaultValidator unless defined $validator; |
|
635
|
|
|
|
|
|
|
$name = "ActionsList" unless defined $name; |
|
636
|
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
Wx::InitAllImageHandlers(); |
|
638
|
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
$style = wxLC_REPORT|wxSUNKEN_BORDER; |
|
640
|
|
|
|
|
|
|
#unless defined $style; |
|
641
|
|
|
|
|
|
|
|
|
642
|
|
|
|
|
|
|
$self = $self->SUPER::new($parent, $id, $pos, $size, $style ); |
|
643
|
|
|
|
|
|
|
$self->{hasCreated}=0; |
|
644
|
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
EVT_WINDOW_CREATE( $self, $self, \&OnCreate ); |
|
646
|
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
return $self; |
|
648
|
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
} |
|
650
|
|
|
|
|
|
|
sub OnCreate{ |
|
651
|
|
|
|
|
|
|
my $self=shift; |
|
652
|
|
|
|
|
|
|
return if $self->{hasCreated}; |
|
653
|
|
|
|
|
|
|
my $modtree=Wx::Window::FindWindowByName('tree_modules'); |
|
654
|
|
|
|
|
|
|
my $images=_uGetImageData; |
|
655
|
|
|
|
|
|
|
|
|
656
|
|
|
|
|
|
|
$self->SetImageList($images->imageList(),wxIMAGE_LIST_NORMAL); |
|
657
|
|
|
|
|
|
|
|
|
658
|
|
|
|
|
|
|
# $self->InsertColumn( 0, _T('Module')); |
|
659
|
|
|
|
|
|
|
# $self->InsertColumn( 1, _T('Action') ); |
|
660
|
|
|
|
|
|
|
|
|
661
|
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
$self->{lastItem}=0; |
|
663
|
|
|
|
|
|
|
$self->{hasCreated}=1; |
|
664
|
|
|
|
|
|
|
} |
|
665
|
|
|
|
|
|
|
sub ClearList{ |
|
666
|
|
|
|
|
|
|
my $self=shift; |
|
667
|
|
|
|
|
|
|
print "Clearing ".$self->GetItemCount." items\n"; |
|
668
|
|
|
|
|
|
|
$self->DeleteAllItems(); |
|
669
|
|
|
|
|
|
|
$self->InsertColumn( 0, _T('Module')); |
|
670
|
|
|
|
|
|
|
$self->InsertColumn( 1, _T('Action') ); |
|
671
|
|
|
|
|
|
|
$self->{lastItem}=0; |
|
672
|
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
} |
|
674
|
|
|
|
|
|
|
|
|
675
|
|
|
|
|
|
|
#check to make sure we have the correct columns |
|
676
|
|
|
|
|
|
|
sub _check_columns{ |
|
677
|
|
|
|
|
|
|
my $self=shift; |
|
678
|
|
|
|
|
|
|
if ($self->GetColumnCount!=2){ |
|
679
|
|
|
|
|
|
|
$self->DeleteColumn(0) while($self->GetColumnCount); |
|
680
|
|
|
|
|
|
|
$self->InsertColumn( 0, _T('Module')); |
|
681
|
|
|
|
|
|
|
$self->InsertColumn( 1, _T('Action') ); |
|
682
|
|
|
|
|
|
|
} |
|
683
|
|
|
|
|
|
|
} |
|
684
|
|
|
|
|
|
|
#Add an action to the list |
|
685
|
|
|
|
|
|
|
#TODO make icons work |
|
686
|
|
|
|
|
|
|
sub AddAction{ |
|
687
|
|
|
|
|
|
|
my ($self,$modName,$version,$action)=@_; |
|
688
|
|
|
|
|
|
|
$version=$version||0.0; |
|
689
|
|
|
|
|
|
|
my $modtree=Wx::Window::FindWindowByName('tree_modules'); |
|
690
|
|
|
|
|
|
|
my $mod=$modtree->_get_mod($modName,$version); |
|
691
|
|
|
|
|
|
|
return 0 unless $mod; |
|
692
|
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
$self->_check_columns(); #make sure we have the necessary columns |
|
694
|
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
#do nothing if we have a more updated version installed |
|
696
|
|
|
|
|
|
|
return 1 if ($version!=0.0 && $mod->installed_version > $version); |
|
697
|
|
|
|
|
|
|
|
|
698
|
|
|
|
|
|
|
#insert the item |
|
699
|
|
|
|
|
|
|
my $itemname="$modName-$version"; |
|
700
|
|
|
|
|
|
|
my $icon=$modtree->_get_status_icon($itemname); |
|
701
|
|
|
|
|
|
|
my $idx=$self->InsertStringItem( 0, $itemname); |
|
702
|
|
|
|
|
|
|
$self->SetItem( $idx, 1, $action ); |
|
703
|
|
|
|
|
|
|
$self->SetColumnWidth($_,wxLIST_AUTOSIZE) foreach(0...($self->GetColumnCount()-1)); |
|
704
|
|
|
|
|
|
|
$self->{lastItem}++; |
|
705
|
|
|
|
|
|
|
return 1; |
|
706
|
|
|
|
|
|
|
} |
|
707
|
|
|
|
|
|
|
sub AddActionWithPre{ |
|
708
|
|
|
|
|
|
|
my ($self,$modName,$version,$action)=@_; |
|
709
|
|
|
|
|
|
|
|
|
710
|
|
|
|
|
|
|
my $modtree=Wx::Window::FindWindowByName('tree_modules'); |
|
711
|
|
|
|
|
|
|
$self->AddAction($modName,$version,$action); |
|
712
|
|
|
|
|
|
|
print "Added action\n"; |
|
713
|
|
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
if (lc($action) eq lc(_T('Install')) || lc($action) eq lc(_T('Update'))){ |
|
715
|
|
|
|
|
|
|
print "$action with prereqs\n"; |
|
716
|
|
|
|
|
|
|
my @prereqs=$modtree->CheckPrerequisites($modName); |
|
717
|
|
|
|
|
|
|
#print Dumper @prereqs; |
|
718
|
|
|
|
|
|
|
foreach my $preName (@prereqs){ |
|
719
|
|
|
|
|
|
|
my $mod=$modtree->_get_mod($preName); #get the module |
|
720
|
|
|
|
|
|
|
my $type=_T("Install"); #set type to install |
|
721
|
|
|
|
|
|
|
$type=_T("Update") if ($mod->installed_version); #set type to update if already installed |
|
722
|
|
|
|
|
|
|
$self->AddAction($preName,$version,$type); #add the action |
|
723
|
|
|
|
|
|
|
} |
|
724
|
|
|
|
|
|
|
} |
|
725
|
|
|
|
|
|
|
|
|
726
|
|
|
|
|
|
|
} |
|
727
|
|
|
|
|
|
|
1; |