File Coverage

blib/lib/Video/DVDRip/GUI/Main.pm
Criterion Covered Total %
statement 10 12 83.3
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 14 16 87.5


line stmt bran cond sub pod time code
1             # $Id: Main.pm 2372 2009-02-22 18:30:38Z 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::Main;
12              
13 1     1   3183 use strict;
  1         2  
  1         38  
14              
15 1     1   6 use base qw(Video::DVDRip::GUI::Base);
  1         1  
  1         944  
16 1     1   10 use Locale::TextDomain qw (video.dvdrip);
  1         2  
  1         11  
17              
18 1     1   3621 use Gtk2;
  0            
  0            
19             use Gtk2::Ex::FormFactory 0.65;
20             use File::Basename;
21              
22             use Video::DVDRip::Project;
23             use Video::DVDRip::Logger;
24             use Video::DVDRip::JobPlanner;
25              
26             use Video::DVDRip::GUI::Context;
27             use Video::DVDRip::GUI::Project::Storage;
28             use Video::DVDRip::GUI::Project::Title;
29             use Video::DVDRip::GUI::Project::ClipZoom;
30             use Video::DVDRip::GUI::Project::Subtitle;
31             use Video::DVDRip::GUI::Project::Transcode;
32             use Video::DVDRip::GUI::Project::Logging;
33             use Video::DVDRip::GUI::Progress;
34             use Video::DVDRip::GUI::ExecFlow;
35             use Video::DVDRip::GUI::Rules;
36              
37             sub get_form_factory { shift->{form_factory} }
38             sub get_gtk_icon_factory { shift->{gtk_icon_factory} }
39              
40             sub set_form_factory { shift->{form_factory} = $_[1] }
41             sub set_gtk_icon_factory { shift->{gtk_icon_factory} = $_[1] }
42              
43             sub get_gui_state_file {
44             return $ENV{HOME}."/.dvdrip/main-gui.state";
45             }
46              
47             sub save_gui_state {
48             my $self = shift;
49              
50             my ($win_width, $win_height) =
51             $self->get_form_factory
52             ->get_widget("main_window")
53             ->get_gtk_parent_widget
54             ->get_size;
55              
56             my $file = $self->get_gui_state_file;
57             open (my $fh, "> $file") or die "can't write $file";
58             print $fh $win_width."\t".
59             $win_height."\n";
60             close $fh;
61            
62             1;
63             }
64              
65             sub load_gui_state {
66             my $self = shift;
67              
68             my $file = $self->get_gui_state_file;
69             if ( ! -f $file ) {
70             return ( default_width => 600, default_height => 500 );
71             }
72              
73             open (my $fh, $file) or die "can't read $file";
74             my $line = <$fh>;
75             close $fh;
76              
77             chomp $line;
78             my @pos = split("\t", $line);
79              
80             return ( default_width => $pos[0], default_height => $pos[1] );
81             }
82              
83             sub window_name {
84             my $self = shift;
85              
86             my $context = $self->get_context;
87             my $project = $context->get_object("project");
88              
89             if ($project) {
90             return $self->config('program_name') . " - " . $project->name;
91             }
92             else {
93             return $self->config('program_name') . " - ";
94             }
95             }
96              
97             sub new {
98             my $class = shift;
99              
100             my $self = $class->SUPER::new(@_);
101              
102             my $logger = Video::DVDRip::Logger->new;
103             $self->set_logger($logger);
104              
105             return $self;
106             }
107              
108             sub start {
109             my $self = shift;
110             my %par = @_;
111             my ( $filename, $open_cluster_control, $function, $select_title )
112             = @par{ 'filename', 'open_cluster_control', 'function',
113             'select_title' };
114              
115             Gtk2->init;
116              
117             my $context = Video::DVDRip::GUI::Context->create;
118             $self->set_context($context);
119              
120             if ( !$open_cluster_control ) {
121             $self->build;
122             }
123              
124             $context->set_object( job_planner => Video::DVDRip::JobPlanner->new );
125             $context->set_object(
126             exec_flow_gui => Video::DVDRip::GUI::ExecFlow->new(
127             context => $context,
128             form_factory => $self->get_form_factory,
129             )
130             );
131              
132             Glib->install_exception_handler(
133             sub {
134             my ($msg) = @_;
135             if ( $msg =~ /^msg:\s*(.*?)\s+at.*?line\s+\d+/s ) {
136             $self->error_window( message => $1, );
137              
138             }
139             else {
140             my $error = __x(
141             "An internal exception was thrown!\n"
142             . "The error message was:\n\n{msg}",
143             msg => $msg
144             );
145             $self->long_message_window( message => $error );
146             }
147              
148             1;
149             }
150             );
151              
152             my $project;
153             if ( $self->dependencies_ok ) {
154             if ($filename) {
155             $self->open_project_file( filename => $filename );
156             $project = $self->get_context_object("project");
157             }
158              
159             $self->log(
160             __x("Detected transcode version: {version}",
161             version => $self->version("transcode")
162             )
163             );
164              
165             # Open Cluster Control window, if requested
166             $self->cluster_control( exit_on_close => 1 )
167             if $open_cluster_control;
168              
169             # Error check
170             if ( ( $select_title or $function )
171             and not $project
172             and $function ne 'preferences' ) {
173             $self->error_dialog(
174             message => __ "Opening project file failed. Aborting." );
175             return 0;
176             }
177              
178             $self->update_window_title;
179              
180             Glib::Idle->add(
181             sub {
182             # Select a title, if requested
183             if ($select_title) {
184             $self->log("Selecting title $select_title");
185             $context->set_object_attr( "content.selected_title_nr",
186             $select_title );
187             $project->content->set_selected_title_nr($select_title);
188             }
189              
190             # Execute a function, if requested
191             if ( $function eq 'preferences' ) {
192             $self->edit_preferences(1);
193             }
194             elsif ($function) {
195             my $title = $self->selected_title;
196             $title->set_tc_exit_afterwards('dont_save');
197             $title->set_tc_split(1) if $function eq 'transcode_split';
198             $self->get_context_object("transcode")->transcode;
199             }
200             return 0;
201             }
202             );
203             }
204              
205             Gtk2->main;
206              
207             1;
208             }
209              
210             sub build {
211             my $self = shift;
212              
213             $self->build_icon_factory;
214              
215             my $context = $self->get_context;
216              
217             $context->set_object( main => $self );
218              
219             my $rule_checker = Video::DVDRip::GUI::Rules->new;
220              
221             my $window;
222             my $ff = Gtk2::Ex::FormFactory->new(
223             context => $context,
224             rule_checker => $rule_checker,
225             sync => 1,
226             content => [
227             $window = Gtk2::Ex::FormFactory::Window->new(
228             attr => "main.window_name",
229             name => "main_window",
230             customize_hook => sub {
231             my ($gtk_window) = @_;
232             $_[0]->parent->set(
233             $self->load_gui_state,
234             );
235             1;
236             },
237             closed_hook => sub { $self->exit_program; 1 },
238             ),
239             ],
240             );
241              
242             #-- FormFactory need to be set into the object
243             #-- before building the other dependent factories
244             $self->set_form_factory($ff);
245              
246             $window->set_content(
247             [
248             $self->build_menu_factory,
249             $self->build_project_factory,
250             ]
251             );
252              
253             $ff->open;
254             $ff->update;
255              
256             $self->set_wm_icon;
257              
258             return 1;
259             }
260              
261             sub set_wm_icon {
262             my $self = shift;
263              
264             my $gtk_window
265             = $self->get_form_factory->get_widget("main_window")->get_gtk_widget;
266              
267             my $icon_file
268             = $self->search_perl_inc( rel_path => "Video/DVDRip/icon.xpm" );
269              
270             if ($icon_file) {
271             my ( $icon, $mask )
272             = Gtk2::Gdk::Pixmap->create_from_xpm( $gtk_window->window,
273             $gtk_window->style->white, $icon_file );
274              
275             $gtk_window->window->set_icon( undef, $icon, $mask );
276             $gtk_window->window->set_icon_name( $self->config('program_name') );
277             }
278              
279             1;
280             }
281              
282             sub build_menu_factory {
283             my $self = shift;
284              
285             my $context = $self->get_context;
286              
287             return Gtk2::Ex::FormFactory::Menu->new(
288             menu_tree => [
289             __"_File" => {
290             item_type => '',
291             children => [
292             __"_New Project" => {
293             item_type => '',
294             extra_data => 'gtk-new',
295             callback => sub { $self->new_project },
296             accelerator => 'N',
297             active_cond => sub { !$self->progress_is_active },
298             active_depends => "progress.is_active",
299             },
300             __"_Open Project..." => {
301             item_type => '',
302             extra_data => 'gtk-open',
303             callback => sub { $self->open_project },
304             accelerator => 'o',
305             active_cond => sub { !$self->progress_is_active },
306             active_depends => "progress.is_active",
307             },
308             __"_Save Project" => {
309             item_type => '',
310             extra_data => 'gtk-save',
311             callback => sub { $self->save_project },
312             accelerator => 's',
313             object => 'project',
314             },
315             __"Save _Project as..." => {
316             item_type => '',
317             extra_data => 'gtk-save-as',
318             callback => sub { $self->save_project_as },
319             accelerator => 's',
320             object => 'project',
321             },
322             __"_Close Project" => {
323             item_type => '',
324             extra_data => 'gtk-close',
325             callback => sub { $self->close_project },
326             accelerator => 'w',
327             object => 'project',
328             active_cond => sub {
329             $context->get_object("project") &&
330             !$self->progress_is_active
331             },
332             active_depends => [ "project", "progress.is_active"],
333             },
334              
335             "sep_quit" => { item_type => '', },
336              
337             __"_Exit" => {
338             item_type => '',
339             extra_data => 'gtk-quit',
340             callback => sub { $self->exit_program },
341             accelerator => 'q',
342             },
343             ],
344             },
345             __"_Edit" => {
346             item_type => '',
347             children => [
348             __ "Edit _Preferences..." => {
349             item_type => '',
350             extra_data => 'gtk-preferences',
351             callback => sub { $self->edit_preferences },
352             accelerator => 'p',
353             },
354             ],
355             },
356             __"_Title" => {
357             item_type => '',
358             children => [
359             __"Transcode" => {
360             item_type => '',
361             extra_data => 'gtk-convert',
362             callback => sub {
363             $context->get_object("transcode")->transcode;
364             },
365             object => 'title',
366             active_cond => sub { $context->get_object("title") &&
367             !$self->progress_is_active },
368             active_depends => "progress.is_active",
369             },
370             __"View target file" => {
371             item_type => '',
372             extra_data => 'gtk-media-play',
373             callback => sub {
374             $context->get_object("transcode")->view_avi;
375             },
376             object => 'title',
377             active_cond => sub { $context->get_object("title") &&
378             !$self->progress_is_active },
379             active_depends => "progress.is_active",
380             },
381             __"Add project to cluster" => {
382             item_type => '',
383             extra_data => 'gtk-network',
384             callback => sub {
385             $context->get_object("transcode")->add_to_cluster;
386             },
387             object => 'title',
388             active_cond => sub {
389             my $title = $self->selected_title;
390             return 0 if not $title;
391             return $title->tc_container ne 'vcd';
392             },
393             active_depends => "title.tc_container",
394             },
395              
396             "sep_vobsub" => { item_type => '', },
397              
398             __"Create vobsub" => {
399             callback => sub {
400             $context->get_object("subtitle_gui")
401             ->create_vobsub_now;
402             },
403             object => 'subtitle',
404             active_cond => sub { $context->get_object("title") &&
405             !$self->progress_is_active },
406             active_depends => "progress.is_active",
407             },
408              
409             "sep_info" => { item_type => '', },
410              
411             __"Create dvdrip-info file" => {
412             callback => sub {
413             my $title = $context->get_object("title");
414             return 1 if not $title;
415             require Video::DVDRip::InfoFile;
416             Video::DVDRip::InfoFile->new(
417             title => $title,
418             filename => $title->info_file,
419             )->write;
420             1;
421             },
422             object => 'title',
423             },
424              
425             "sep_wav" => { item_type => '', },
426              
427             __"Create WAV from selected audio track" => {
428             callback => sub {
429             $context->get_object("transcode")->create_wav;
430             },
431             object => 'title',
432             active_cond => sub { $context->get_object("title") &&
433             !$self->progress_is_active },
434             active_depends => "progress.is_active",
435             },
436             ],
437             },
438             __"_Cluster" => {
439             item_type => '',
440             children => [
441             __ "Contro_l..." => {
442             item_type => '',
443             extra_data => 'gtk-network',
444             callback => sub { $self->cluster_control },
445             accelerator => 'm',
446             },
447             ],
448             },
449             __"_Debug" => {
450             item_type => '',
451             children => [
452             __
453             "Show _Transcode commands..." => {
454             item_type => '',
455             callback => sub { $self->show_transcode_commands },
456             accelerator => 't',
457             object => 'title',
458             },
459             __ "Check _dependencies..." => {
460             item_type => '',
461             callback => sub { $self->show_dependencies },
462             accelerator => 'd',
463             },
464             ],
465             },
466             __"_Help" => {
467             item_type => '',
468             children => [
469             __"_About dvd::rip" => {
470             callback => sub { $self->show_about_dialog },
471             item_type => '',
472             extra_data => 'gtk-about',
473             accelerator => 'A',
474             },
475             ]
476             },
477             ],
478             );
479             }
480              
481             sub build_project_factory {
482             my $self = shift;
483              
484             my $context = $self->get_context;
485              
486             my $storage = Video::DVDRip::GUI::Project::Storage->new(
487             form_factory => $self->get_form_factory, );
488              
489             my $title = Video::DVDRip::GUI::Project::Title->new(
490             form_factory => $self->get_form_factory, );
491              
492             my $clip_zoom = Video::DVDRip::GUI::Project::ClipZoom->new(
493             form_factory => $self->get_form_factory, );
494              
495             my $subtitle = Video::DVDRip::GUI::Project::Subtitle->new(
496             form_factory => $self->get_form_factory, );
497              
498             my $transcode = Video::DVDRip::GUI::Project::Transcode->new(
499             form_factory => $self->get_form_factory, );
500              
501             my $logging = Video::DVDRip::GUI::Project::Logging->new(
502             form_factory => $self->get_form_factory, );
503              
504             my $progress = Video::DVDRip::GUI::Progress->new(
505             form_factory => $self->get_form_factory, );
506              
507             return Gtk2::Ex::FormFactory::VBox->new(
508             object => "project",
509             inactive => "invisible",
510             expand => 1,
511             content => [
512             Gtk2::Ex::FormFactory::Notebook->new(
513             name => "main_nb",
514             attr => "project.last_selected_nb_page",
515             expand => 1,
516             $self->get_optimum_screen_size_options("notebook"),
517             content => [
518             $storage->build_factory, $title->build_factory,
519             $clip_zoom->build_factory, $subtitle->build_factory,
520             $transcode->build_factory, $logging->build_factory,
521             ],
522             ),
523             $progress->build_factory,
524             ],
525             );
526             }
527              
528             sub build_selected_title_factory {
529             my $self = shift;
530              
531             return Gtk2::Ex::FormFactory::HBox->new(
532             object => "title",
533             title => __ "Selected DVD title",
534             content => [
535             Gtk2::Ex::FormFactory::Popup->new(
536             attr => "content.selected_title_nr",
537             tip => __"Choose a DVD title at any time here",
538              
539             ),
540             Gtk2::Ex::FormFactory::Label->new(
541             attr => "title.get_title_info",
542             ),
543             ],
544             );
545             }
546              
547             sub build_icon_factory {
548             my $self = shift;
549              
550             my $icon_factory = Gtk2::IconFactory->new;
551             $icon_factory->add_default;
552             $self->set_gtk_icon_factory($icon_factory);
553              
554             my $icon_dir
555             = $self->search_perl_inc( rel_path => "Video/DVDRip/GUI/Icons" );
556              
557             return if not -d $icon_dir;
558              
559             my ( $pixbuf, $icon_set, $name );
560              
561             foreach my $icon_file ( glob("$icon_dir/*.png") ) {
562             $pixbuf = Gtk2::Gdk::Pixbuf->new_from_file($icon_file);
563             $icon_set = Gtk2::IconSet->new_from_pixbuf($pixbuf);
564              
565             $name = basename($icon_file);
566             $name =~ s/\.[^.]+$//;
567              
568             $icon_factory->add( $name, $icon_set );
569             }
570              
571             1;
572             }
573              
574             sub new_project {
575             my $self = shift;
576              
577             return if not $self->dependencies_ok;
578              
579             return if $self->unsaved_project_open( wants => "new_project" );
580              
581             $self->close_project;
582              
583             my $project = Video::DVDRip::Project->new;
584              
585             $self->get_context->set_object( project => $project );
586             $self->get_context->set_object( "!project" => undef );
587             $self->get_context->get_object("job_planner")->set_project($project);
588              
589             $self->update_window_title;
590              
591             my $gtk_entry
592             = $self->get_form_factory->get_widget("project_name")->get_gtk_widget;
593             $gtk_entry->select_region( 0, -1 );
594             $gtk_entry->grab_focus;
595              
596             1;
597             }
598              
599             sub update_window_title {
600             my $self = shift;
601              
602             $self->get_context->update_object_attr_widgets("main.window_name");
603              
604             1;
605             }
606              
607             sub open_project {
608             my $self = shift;
609              
610             return if not $self->dependencies_ok;
611              
612             return if $self->unsaved_project_open( wants => "open_project" );
613              
614             $self->close_project;
615              
616             $self->show_file_dialog(
617             dir => $self->config('dvdrip_files_dir'),
618             filename => "",
619             cb => sub {
620             $self->open_project_file( filename => $_[0] );
621             },
622             );
623             }
624              
625             sub open_project_file {
626             my $self = shift;
627             my %par = @_;
628             my ($filename) = @par{'filename'};
629              
630             return if not $self->dependencies_ok;
631              
632             if ( not -r $filename ) {
633             $self->message_window(
634             message => __x(
635             "File '{filename}' not found or not readable.",
636             filename => $filename
637             )
638             );
639             return 1;
640             }
641              
642             my $project
643             = Video::DVDRip::Project->new_from_file( filename => $filename );
644              
645             my $context = $self->get_context;
646              
647             $context->set_object( project => $project );
648             $context->set_object( "!project" => undef );
649              
650             $self->get_context->get_object("job_planner")->set_project($project);
651              
652             $self->logger->set_project($project);
653             $self->logger->insert_project_logfile;
654              
655             $self->update_window_title;
656              
657             if ( $project->convert_message ) {
658             $self->message_window( message => $project->convert_message );
659             $project->set_convert_message("");
660             }
661              
662             1;
663             }
664              
665             sub save_project {
666             my $self = shift;
667              
668             my $context = $self->get_context;
669             my $project = $context->get_object("project");
670             my $created = $project->created;
671              
672             if ( $project->filename ) {
673             # save
674             $project->save;
675              
676             # reset changed flag
677             $self->get_context->get_proxy("project")->set_object_changed(0);
678              
679             # greys out "Project name" widget
680             $context->update_object_attr_widgets("project.name");
681            
682             return 1;
683              
684             }
685             else {
686             $self->show_file_dialog(
687             title => __ "Save project: choose filename",
688             type => "save",
689             dir => $self->config('dvdrip_files_dir'),
690             filename => $project->name . ".rip",
691             confirm => 1,
692             cb => sub {
693             $project->set_filename( $_[0] );
694             $self->save_project;
695             unless ($created) {
696             $context->update_object_widgets("project");
697             $self->logger->set_project($project);
698             $self->log( __x "Project {name} created",
699             name => $project->name );
700             }
701             },
702             );
703             return 0;
704             }
705             }
706              
707             sub save_project_as {
708             my $self = shift;
709              
710             my $context = $self->get_context;
711             my $project = $context->get_object("project");
712             my $created = $project->created;
713              
714             $self->show_file_dialog(
715             dir => $self->config('dvdrip_files_dir'),
716             filename => $project->name . ".rip",
717             confirm => 1,
718             cb => sub {
719             $project->set_filename( $_[0] );
720             $project->save;
721             $self->update_window_title;
722             unless ($created) {
723             $context->update_object_widgets("project");
724             $self->logger->set_project($project);
725             $self->log( __x "Project {name} created", name => $project->name );
726             }
727             },
728             );
729              
730             return 1;
731             }
732              
733             sub close_project {
734             my $self = shift;
735             my %par = @_;
736             my ($dont_ask) = @par{'dont_ask'};
737              
738             return if not $dont_ask and $self->unsaved_project_open;
739              
740             $self->get_context->set_object( project => undef );
741             $self->get_context->set_object( "!project" => 1 );
742             $self->get_context->get_object("job_planner")->set_project();
743              
744             $self->update_window_title;
745              
746             1;
747             }
748              
749             sub project_changed {
750             return $_[0]->get_context->get_proxy("project")->get_object_changed;
751             }
752              
753             sub unsaved_project_open {
754             my $self = shift;
755             my %par = @_;
756             my ($wants) = @par{'wants'};
757              
758             return if ! $self->get_context->get_object("project");
759             return if ! $self->project_changed;
760              
761             $self->confirm_window(
762             message => __ "Do you want to save this project first?",
763             yes_label => __ "Yes",
764             no_label => __ "No",
765             yes_callback => sub {
766             if ( $self->save_project ) {
767             $self->close_project( dont_ask => 1 );
768             $self->$wants() if $wants;
769             }
770             },
771             no_callback => sub {
772             $self->close_project( dont_ask => 1 );
773             $self->$wants() if $wants;
774             },
775             with_cancel => 1,
776             );
777              
778             1;
779             }
780              
781             sub exit_program {
782             my $self = shift;
783             my %par = @_;
784             my ($force) = @par{'force'};
785              
786             $self->save_gui_state;
787              
788             return 1
789             if not $force
790             and $self->unsaved_project_open( wants => "exit_program" );
791              
792             $self->close_project( dont_ask => $force );
793              
794             $self->get_form_factory->close;
795              
796             Gtk2->main_quit;
797             }
798              
799             sub edit_preferences {
800             my $self = shift;
801             my ($init) = @_;
802              
803             require Video::DVDRip::GUI::Preferences;
804              
805             my $pref = Video::DVDRip::GUI::Preferences->new(
806             form_factory => $self->get_form_factory, );
807              
808             $pref->open_window;
809              
810             $self->message_window (
811             modal => 1,
812             message =>
813             __"This is the first time you start dvd::rip. The Preferences ".
814             "dialog was opened automatically for you. Please review the settings, ".
815             "in particular the default DVD device and your data base directory. ".
816             "Point it to a directory with sufficient diskspace of at least ".
817             "10 GB for full DVD copies.",
818             ) if $init;
819              
820             1;
821             }
822              
823             sub cluster_control {
824             my $self = shift;
825             my %par = @_;
826             my ($exit_on_close) = @par{'exit_on_close'};
827              
828             if ( $self->get_context->get_object("cluster_gui") ) {
829             my $cluster = $self->get_context->get_object("cluster_gui");
830             $cluster->connect_master if !$cluster->master;
831             return;
832             }
833              
834             return if not $self->dependencies_ok;
835              
836             require Video::DVDRip::GUI::Cluster::Control;
837              
838             my $cluster = Video::DVDRip::GUI::Cluster::Control->new(
839             context => $self->get_context,
840             form_factory => $self->get_form_factory,
841             );
842             $cluster->set_exit_on_close($exit_on_close);
843             $cluster->open_window;
844              
845             if ( !$cluster->master ) {
846             return if !$cluster->connect_master;
847             }
848              
849             1;
850             }
851              
852             sub show_transcode_commands {
853             my $self = shift;
854              
855             my $title = $self->selected_title;
856             return unless $title;
857              
858             my $commands = "";
859              
860             $commands .= __ "Probe Command:\n"
861             . "==============\n"
862             . $title->get_probe_command() . "\n";
863              
864             $commands .= "\n\n";
865              
866             if ( $title->project->rip_mode eq 'rip' ) {
867             my $rip_method =
868             $title->tc_use_chapter_mode
869             ? "get_rip_command"
870             : "get_rip_and_scan_command";
871              
872             $commands .= __ "Rip Command:\n"
873             . "============\n"
874             . $title->$rip_method() . "\n";
875             }
876             else {
877             $commands .= __ "Scan Command:\n"
878             . "============\n"
879             . $title->get_scan_command() . "\n";
880             }
881              
882             $commands .= "\n\n";
883              
884             $commands .= __ "Grab Preview Image Command:\n"
885             . "===========================\n";
886              
887             eval {
888             $commands .= $title->get_take_snapshot_command(
889             frame => $title->preview_frame_nr )
890             . "\n";
891             };
892              
893             if ($@) {
894             $commands .= __
895             "You must first rip the selected title to see this command.\n";
896             }
897              
898             $commands .= "\n\n";
899              
900             $commands .= __ "Transcode Command:\n" . "==================\n";
901              
902             if ( $title->tc_multipass ) {
903             $commands
904             .= $title->get_transcode_command( pass => 1, split => 1 ) . "\n"
905             . $title->get_transcode_command( pass => 2, split => 1 ) . "\n";
906             }
907             else {
908             $commands .= $title->get_transcode_command( split => 1 ) . "\n";
909             }
910              
911             if ( $title->tc_container eq 'vcd' ) {
912             $commands .= "\n" . $title->get_mplex_command( split => 1 ), "\n";
913             }
914              
915             if ( $title->is_ogg ) {
916             $commands .= "\n"
917             . $title->get_merge_audio_command(
918             vob_nr => $title->get_first_audio_track,
919             avi_nr => 0,
920             ),
921             "\n";
922             }
923              
924             $commands .= "\n\n";
925              
926             my $add_audio_tracks = $title->get_additional_audio_tracks;
927              
928             if ( keys %{$add_audio_tracks} ) {
929             $commands .= __ "Additional audio tracks commands:\n"
930             . "============================\n";
931              
932             my ( $avi_nr, $vob_nr );
933             while ( ( $avi_nr, $vob_nr ) = each %{$add_audio_tracks} ) {
934             $commands .= "\n"
935             . $title->get_transcode_audio_command(
936             vob_nr => $vob_nr,
937             target_nr => $avi_nr,
938             )
939             . "\n";
940             $commands .= "\n"
941             . $title->get_merge_audio_command(
942             vob_nr => $vob_nr,
943             target_nr => $avi_nr,
944             );
945             }
946              
947             $commands .= "\n\n";
948             }
949              
950             $commands .= __ "View DVD Command:\n"
951             . "=================\n"
952             . $title->get_view_dvd_command(
953             command_tmpl => $self->config('play_dvd_command') )
954             . "\n";
955              
956             $commands .= "\n\n";
957              
958             $commands .= __ "View Files Command:\n" . "===================\n"
959             . $title->get_view_avi_command(
960             command_tmpl => $self->config('play_file_command'),
961             file => "movie.avi",
962             )
963             . "\n";
964              
965             my $create_image_command;
966             eval { $create_image_command = $title->get_create_image_command; };
967             $create_image_command = $self->stripped_exception if $@;
968              
969             my $burn_command;
970             eval { $burn_command = $title->get_burn_command; };
971             $burn_command = $self->stripped_exception if $@;
972              
973             $commands .= "\n\n";
974              
975             $commands .= __ "CD image creation command:\n"
976             . "========================\n"
977             . $create_image_command;
978              
979             $commands .= "\n\n";
980              
981             $commands .= __ "CD burning command:\n"
982             . "==================\n"
983             . $burn_command;
984              
985             $commands .= "\n\n";
986              
987             my $wav_command = eval { $title->get_create_wav_command };
988              
989             if ($wav_command) {
990              
991             $commands .= __ "WAV creation command:\n"
992             . "====================\n"
993             . $wav_command;
994              
995             }
996              
997             $self->long_message_window(
998             title => __ "Commands executed by dvd::rip",
999             message => $commands
1000             );
1001              
1002             1;
1003             }
1004              
1005             sub show_dependencies {
1006             my $self = shift;
1007              
1008             require Video::DVDRip::GUI::Depend;
1009              
1010             my $depend = Video::DVDRip::GUI::Depend->new(
1011             form_factory => $self->get_form_factory );
1012             $depend->open_window;
1013              
1014             1;
1015             }
1016              
1017             sub dependencies_ok {
1018             my $self = shift;
1019              
1020             return 1 if $self->depend_object->ok;
1021              
1022             $self->show_dependencies;
1023             $self->message_window( message => __
1024             "One or several mandatory tools are\nmissing or too old. You must install them\nbefore you can proceed with dvd::rip."
1025             );
1026              
1027             return 0;
1028             }
1029              
1030             sub show_about_dialog {
1031             my $self = shift;
1032              
1033             my $license = $self->read_text_file("license.txt");
1034             my $translators = $self->read_text_file("translators.txt");
1035              
1036             my $splash_lang_file = __"splash.en.png";
1037              
1038             my $logo_image = Gtk2::Ex::FormFactory->get_image_path (
1039             "Video/DVDRip/$splash_lang_file"
1040             );
1041              
1042             my $logo_pixbuf = $logo_image ?
1043             Gtk2::Gdk::Pixbuf->new_from_file($logo_image) :
1044             undef;
1045              
1046             my $about = Gtk2::AboutDialog->new;
1047             $about->set (
1048             name => "dvd::rip",
1049             version => $Video::DVDRip::VERSION,
1050             logo => $logo_pixbuf,
1051             license => $license,
1052             translator_credits => $translators,
1053             );
1054              
1055             $about->run;
1056             $about->destroy;
1057              
1058             1;
1059             }
1060              
1061             sub read_text_file {
1062             my $self = shift;
1063             my ($name) = @_;
1064              
1065             my $file = Gtk2::Ex::FormFactory->get_image_path("Video/DVDRip/$name");
1066              
1067             open (my $fh, $file) or die "can't read $file [$name]";
1068             my $text = do { local $/=undef; <$fh> };
1069             close $fh;
1070              
1071             return $text;
1072             }
1073              
1074             1;