line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: Base.pm 2341 2007-08-09 21:35:05Z joern $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
#----------------------------------------------------------------------- |
4
|
|
|
|
|
|
|
# Copyright (C) 2001-2006 Jörn Reder . |
5
|
|
|
|
|
|
|
# All Rights Reserved. See file COPYRIGHT for details. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# This module is part of Video::DVDRip, which is free software; you can |
8
|
|
|
|
|
|
|
# redistribute it and/or modify it under the same terms as Perl itself. |
9
|
|
|
|
|
|
|
#----------------------------------------------------------------------- |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
package Video::DVDRip::GUI::Base; |
12
|
1
|
|
|
1
|
|
19690
|
use Locale::TextDomain qw (video.dvdrip); |
|
1
|
|
|
|
|
57960
|
|
|
1
|
|
|
|
|
8
|
|
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
28274
|
use base Video::DVDRip::Base; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
891
|
|
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
21
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
17
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
90
|
|
18
|
1
|
|
|
1
|
|
7
|
use Data::Dumper; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
63
|
|
19
|
1
|
|
|
1
|
|
6
|
use Cwd; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
1847
|
|
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
0
|
0
|
|
sub get_context { shift->{context} } |
22
|
0
|
|
|
0
|
0
|
|
sub set_context { shift->{context} = $_[1] } |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
0
|
0
|
|
sub get_form_factory { shift->{form_factory} } |
25
|
0
|
|
|
0
|
0
|
|
sub set_form_factory { shift->{form_factory} = $_[1] } |
26
|
|
|
|
|
|
|
|
27
|
0
|
|
|
0
|
0
|
|
sub get_context_object { $_[0]->{context}->get_object($_[1]) } |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
30
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
31
|
0
|
|
|
|
|
|
my %par = @_; |
32
|
0
|
|
|
|
|
|
my ( $form_factory, $context ) = @par{ 'form_factory', 'context' }; |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
0
|
|
|
|
$context ||= $form_factory->get_context if $form_factory; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $self = bless { |
37
|
|
|
|
|
|
|
form_factory => $form_factory, |
38
|
|
|
|
|
|
|
context => $context, |
39
|
|
|
|
|
|
|
}, $class; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
return $self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub create_text_tag { |
45
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
46
|
0
|
|
|
|
|
|
my $name = shift; |
47
|
0
|
|
|
|
|
|
my %par = @_; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
my $cb = delete $par{cb}; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my $tag = Gtk2::TextTag->new($name); |
52
|
0
|
|
|
|
|
|
$tag->set(%par); |
53
|
|
|
|
|
|
|
|
54
|
0
|
0
|
|
|
|
|
$tag->signal_connect( "event", $cb ) if $cb; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return $tag; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub project { |
60
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
61
|
0
|
|
|
|
|
|
return $self->get_context->get_object("project"); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub selected_title { |
65
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
66
|
0
|
|
|
|
|
|
return $self->get_context->get_object("title"); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub progress { |
70
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
71
|
0
|
|
|
|
|
|
return $self->get_context->get_object("progress"); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub progress_is_active { |
75
|
0
|
|
|
0
|
0
|
|
return $_[0]->progress->is_active; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub show_file_dialog { |
79
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
80
|
0
|
|
|
|
|
|
my %par = @_; |
81
|
0
|
|
|
|
|
|
my ( $type, $dir, $filename, $cb, $title, $confirm ) |
82
|
|
|
|
|
|
|
= @par{ 'type', 'dir', 'filename', 'cb', 'title', 'confirm' }; |
83
|
|
|
|
|
|
|
|
84
|
0
|
|
0
|
|
|
|
$type ||= "open"; |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my $cwd = cwd; |
87
|
0
|
|
|
|
|
|
chdir($dir); |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
my $form_factory = $self->get_form_factory; |
90
|
0
|
0
|
|
|
|
|
my $gtk_window = |
91
|
|
|
|
|
|
|
$form_factory |
92
|
|
|
|
|
|
|
? $form_factory->get_form_factory_gtk_window |
93
|
|
|
|
|
|
|
: undef; |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# Create a new file selection widget |
96
|
0
|
|
|
|
|
|
my $dialog = Gtk2::FileChooserDialog->new( |
97
|
|
|
|
|
|
|
$title, |
98
|
|
|
|
|
|
|
$gtk_window, |
99
|
|
|
|
|
|
|
"save", |
100
|
|
|
|
|
|
|
'gtk-cancel' => 'cancel', |
101
|
|
|
|
|
|
|
'gtk-ok' => 'ok' |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
|
$dialog->set_current_name($filename); |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
my $response = $dialog->run; |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
my $filename = $dialog->get_filename; |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
|
|
|
$dialog->destroy; |
111
|
0
|
|
|
|
|
|
chdir($cwd); |
112
|
|
|
|
|
|
|
|
113
|
0
|
0
|
|
|
|
|
if ( $response eq 'ok' ) { |
114
|
0
|
0
|
0
|
|
|
|
if ( -f $filename and $confirm ) { |
115
|
|
|
|
|
|
|
$self->confirm_window( |
116
|
|
|
|
|
|
|
message => __x( |
117
|
|
|
|
|
|
|
"Overwrite existing file '{filename}'?", |
118
|
|
|
|
|
|
|
filename => $filename |
119
|
|
|
|
|
|
|
), |
120
|
0
|
|
|
0
|
|
|
yes_callback => sub { &$cb($filename) }, |
121
|
0
|
|
|
|
|
|
); |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
else { |
124
|
0
|
|
|
|
|
|
&$cb($filename); |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
1; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
sub message_window { |
132
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
133
|
0
|
|
|
|
|
|
my %par = @_; |
134
|
0
|
|
|
|
|
|
my ($message, $ff, $modal, $type) = |
135
|
|
|
|
|
|
|
@par{'message','ff','modal','type'}; |
136
|
|
|
|
|
|
|
|
137
|
0
|
|
0
|
|
|
|
$type ||= "info"; |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
|
my $dialog = Gtk2::MessageDialog->new_with_markup( undef, |
140
|
|
|
|
|
|
|
["destroy-with-parent"], $type, "none", $message ); |
141
|
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
|
$dialog->set_position("center-on-parent"); |
143
|
0
|
|
|
|
|
|
$dialog->set_modal($modal); |
144
|
0
|
|
|
|
|
|
$dialog->add_buttons( "gtk-ok", "ok" ); |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
$dialog->signal_connect( |
147
|
|
|
|
|
|
|
"response", |
148
|
|
|
|
|
|
|
sub { |
149
|
0
|
|
|
0
|
|
|
my ( $widget, $answer ) = @_; |
150
|
0
|
|
|
|
|
|
$widget->destroy; |
151
|
0
|
|
|
|
|
|
1; |
152
|
|
|
|
|
|
|
} |
153
|
0
|
|
|
|
|
|
); |
154
|
|
|
|
|
|
|
|
155
|
0
|
|
|
|
|
|
$dialog->show; |
156
|
|
|
|
|
|
|
|
157
|
0
|
|
|
|
|
|
1; |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub error_window { |
162
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
163
|
0
|
|
|
|
|
|
my %par = @_; |
164
|
0
|
|
|
|
|
|
my ($message) = @par{'message'}; |
165
|
|
|
|
|
|
|
|
166
|
0
|
0
|
|
|
|
|
if ( $message =~ s/^msg:// ) { |
167
|
0
|
|
|
|
|
|
$message =~ s/\s+at\s+.*?line\s+\d+//; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
0
|
0
|
|
|
|
|
if ( length($message) > 500 ) { |
171
|
0
|
|
|
|
|
|
return $self->long_message_window( |
172
|
|
|
|
|
|
|
message => $message, |
173
|
|
|
|
|
|
|
title => __ "Error message" |
174
|
|
|
|
|
|
|
); |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
0
|
|
|
|
|
|
my $dialog = Gtk2::MessageDialog->new( undef, |
178
|
|
|
|
|
|
|
[ "modal", "destroy-with-parent" ], |
179
|
|
|
|
|
|
|
"error", "none", $message ); |
180
|
|
|
|
|
|
|
|
181
|
0
|
|
|
|
|
|
$dialog->set_position("center-on-parent"); |
182
|
0
|
|
|
|
|
|
$dialog->add_buttons( "gtk-ok", "ok" ); |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
$dialog->signal_connect( |
185
|
|
|
|
|
|
|
"response", |
186
|
|
|
|
|
|
|
sub { |
187
|
0
|
|
|
0
|
|
|
my ( $widget, $answer ) = @_; |
188
|
0
|
|
|
|
|
|
$widget->destroy; |
189
|
0
|
|
|
|
|
|
1; |
190
|
|
|
|
|
|
|
} |
191
|
0
|
|
|
|
|
|
); |
192
|
|
|
|
|
|
|
|
193
|
0
|
|
|
|
|
|
$dialog->show; |
194
|
|
|
|
|
|
|
|
195
|
0
|
|
|
|
|
|
1; |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
sub long_message_window { |
200
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
201
|
0
|
|
|
|
|
|
my %par = @_; |
202
|
0
|
|
|
|
|
|
my ( $message, $title, $fixed ) = @par{ 'message', 'title', 'fixed' }; |
203
|
|
|
|
|
|
|
|
204
|
0
|
|
|
|
|
|
my $frame_title = $title; |
205
|
|
|
|
|
|
|
|
206
|
0
|
0
|
|
|
|
|
$title = "dvd::rip - " . $title if $title; |
207
|
0
|
|
0
|
|
|
|
$title ||= __ "dvd::rip - Message"; |
208
|
|
|
|
|
|
|
|
209
|
0
|
|
|
|
|
|
my $ff; |
210
|
|
|
|
|
|
|
$ff = Gtk2::Ex::FormFactory->new( |
211
|
|
|
|
|
|
|
sync => 1, |
212
|
|
|
|
|
|
|
content => [ |
213
|
|
|
|
|
|
|
Gtk2::Ex::FormFactory::Window->new( |
214
|
|
|
|
|
|
|
title => $title, |
215
|
0
|
|
|
0
|
|
|
closed_hook => sub { $ff->close }, |
216
|
|
|
|
|
|
|
customize_hook => sub { |
217
|
0
|
|
|
0
|
|
|
my ($gtk_window) = @_; |
218
|
0
|
|
|
|
|
|
$_[0]->parent->set( |
219
|
|
|
|
|
|
|
default_width => 600, |
220
|
|
|
|
|
|
|
default_height => 440, |
221
|
|
|
|
|
|
|
); |
222
|
0
|
|
|
|
|
|
1; |
223
|
|
|
|
|
|
|
}, |
224
|
|
|
|
|
|
|
content => [ |
225
|
|
|
|
|
|
|
Gtk2::Ex::FormFactory::VBox->new( |
226
|
|
|
|
|
|
|
expand => 1, |
227
|
|
|
|
|
|
|
content => [ |
228
|
|
|
|
|
|
|
Gtk2::Ex::FormFactory::VBox->new( |
229
|
|
|
|
|
|
|
title => $frame_title, |
230
|
|
|
|
|
|
|
expand => 1, |
231
|
|
|
|
|
|
|
content => [ |
232
|
|
|
|
|
|
|
Gtk2::Ex::FormFactory::TextView->new( |
233
|
|
|
|
|
|
|
scrollbars => [ "never", "always" ], |
234
|
|
|
|
|
|
|
expand => 1, |
235
|
|
|
|
|
|
|
properties => { |
236
|
|
|
|
|
|
|
editable => 0, |
237
|
|
|
|
|
|
|
cursor_visible => 0, |
238
|
|
|
|
|
|
|
wrap_mode => "word", |
239
|
|
|
|
|
|
|
}, |
240
|
|
|
|
|
|
|
customize_hook => sub { |
241
|
0
|
|
|
0
|
|
|
my ($gtk_text_view) = @_; |
242
|
0
|
0
|
|
|
|
|
if ($fixed) { |
243
|
0
|
|
|
|
|
|
my $font |
244
|
|
|
|
|
|
|
= Gtk2::Pango::FontDescription |
245
|
|
|
|
|
|
|
->from_string("mono"); |
246
|
0
|
|
|
|
|
|
$gtk_text_view->modify_font( |
247
|
|
|
|
|
|
|
$font); |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
$gtk_text_view->get_buffer |
250
|
0
|
|
|
|
|
|
->set_text($message); |
251
|
0
|
|
|
|
|
|
1; |
252
|
|
|
|
|
|
|
}, |
253
|
0
|
|
|
|
|
|
), |
254
|
|
|
|
|
|
|
], |
255
|
|
|
|
|
|
|
), |
256
|
|
|
|
|
|
|
Gtk2::Ex::FormFactory::DialogButtons->new, |
257
|
|
|
|
|
|
|
], |
258
|
|
|
|
|
|
|
), |
259
|
|
|
|
|
|
|
], |
260
|
|
|
|
|
|
|
), |
261
|
|
|
|
|
|
|
], |
262
|
|
|
|
|
|
|
); |
263
|
|
|
|
|
|
|
|
264
|
0
|
|
|
|
|
|
$ff->build; |
265
|
0
|
|
|
|
|
|
$ff->update; |
266
|
0
|
|
|
|
|
|
$ff->show; |
267
|
|
|
|
|
|
|
|
268
|
0
|
|
|
|
|
|
1; |
269
|
|
|
|
|
|
|
} |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
sub confirm_window { |
272
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
273
|
0
|
|
|
|
|
|
my %par = @_; |
274
|
|
|
|
|
|
|
my ( $message, $yes_callback, $no_callback, $position, $with_cancel ) |
275
|
|
|
|
|
|
|
= @par{ |
276
|
0
|
|
|
|
|
|
'message', 'yes_callback', 'no_callback', 'position', |
277
|
|
|
|
|
|
|
'with_cancel' |
278
|
|
|
|
|
|
|
}; |
279
|
|
|
|
|
|
|
|
280
|
0
|
|
|
|
|
|
$self->get_form_factory->open_confirm_window( |
281
|
|
|
|
|
|
|
message => $message, |
282
|
|
|
|
|
|
|
yes_callback => $yes_callback, |
283
|
|
|
|
|
|
|
no_callback => $no_callback, |
284
|
|
|
|
|
|
|
position => $position, |
285
|
|
|
|
|
|
|
with_cancel => $with_cancel, |
286
|
|
|
|
|
|
|
); |
287
|
|
|
|
|
|
|
|
288
|
0
|
|
|
|
|
|
1; |
289
|
|
|
|
|
|
|
} |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
sub new_job_executor { |
292
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
293
|
|
|
|
|
|
|
|
294
|
0
|
|
|
|
|
|
return Video::DVDRip::GUI::ExecuteJobs->new( |
295
|
|
|
|
|
|
|
form_factory => $self->get_form_factory, |
296
|
|
|
|
|
|
|
@_, |
297
|
|
|
|
|
|
|
); |
298
|
|
|
|
|
|
|
} |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
sub get_optimum_screen_size_options { |
301
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
302
|
0
|
|
|
|
|
|
my ($type) = @_; |
303
|
|
|
|
|
|
|
|
304
|
0
|
0
|
|
|
|
|
return () if not $self->config("small_screen"); |
305
|
|
|
|
|
|
|
|
306
|
0
|
0
|
|
|
|
|
if ( $type eq 'page' ) { |
|
|
0
|
|
|
|
|
|
307
|
|
|
|
|
|
|
return ( |
308
|
0
|
|
|
|
|
|
scrollbars => [ "automatic", "automatic" ], |
309
|
|
|
|
|
|
|
properties => { border_width => 8 }, |
310
|
|
|
|
|
|
|
); |
311
|
|
|
|
|
|
|
} |
312
|
|
|
|
|
|
|
elsif ( $type eq 'notebook' ) { |
313
|
|
|
|
|
|
|
return ( |
314
|
0
|
|
|
|
|
|
properties => { tab_pos => "left" }, |
315
|
|
|
|
|
|
|
); |
316
|
|
|
|
|
|
|
} |
317
|
|
|
|
|
|
|
} |
318
|
|
|
|
|
|
|
|
319
|
|
|
|
|
|
|
1; |