1# $Id: Storage.pm 2344 2007-08-09 21:37:41Z joern $ 2 3#----------------------------------------------------------------------- 4# Copyright (C) 2001-2006 J�rn Reder <joern AT zyn.de>. 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 11package Video::DVDRip::GUI::Project::Storage; 12 13use base qw( Video::DVDRip::GUI::Base ); 14 15use Locale::TextDomain qw (video.dvdrip); 16 17use Carp; 18use strict; 19 20sub build_factory { 21 my $self = shift; 22 23 my $dvd_device_popup; 24 if ( $self->has("hal") ) { 25 $dvd_device_popup = 26 Gtk2::Ex::FormFactory::Popup->new ( 27 attr => "project.selected_dvd_device", 28 expand_h => 0, 29 changed_hook_after => sub { 30 $self->get_context->set_object_attr ( 31 "project", "dvd_device", 32 $self->get_context->get_object_attr ( 33 "project.selected_dvd_device", 34 ), 35 ), 36 }, 37 tip => __"This is a list of connected DVD drives " 38 ."found in your system" 39 ); 40 } 41 else { 42 $dvd_device_popup = 43 Gtk2::Ex::FormFactory::Button->new ( 44 label => __"Choose DVD device file", 45 expand_h => 0, 46 clicked_hook => sub { 47 $self->choose_dvd_device_file; 48 }, 49 tip => __"Press this button to open a file chooser dialog" 50 ); 51 } 52 53 return Gtk2::Ex::FormFactory::VBox->new( 54 $self->get_optimum_screen_size_options("page"), 55 title => '[gtk-harddisk]'.__ "Storage", 56 object => "project", 57 no_frame => 1, 58 content => [ 59 Gtk2::Ex::FormFactory::Form->new( 60 title => __ "Storage path information", 61 content => [ 62 Gtk2::Ex::FormFactory::Entry->new( 63 name => "project_name", 64 attr => "project.name", 65 label => __ "Project name", 66 tip => __ "This is a short name for " 67 . "the project. All generated files " 68 . "are named like this.", 69 rules => "project-name", 70 ), 71 Gtk2::Ex::FormFactory::Entry->new( 72 attr => "project.vob_dir", 73 label => __ "VOB directory", 74 tip => __ "DVD VOB files are stored here.", 75 rules => "project-path", 76 ), 77 Gtk2::Ex::FormFactory::Entry->new( 78 attr => "project.avi_dir", 79 label => __ "AVI directory", 80 tip => __ "For transcoded AVI, MPEG and OGM files.", 81 rules => "project-path", 82 ), 83 Gtk2::Ex::FormFactory::Entry->new( 84 attr => "project.snap_dir", 85 label => __ "Temporary directory", 86 tip => __ "For temporary files", 87 rules => "project-path", 88 ), 89 Gtk2::Ex::FormFactory::Button->new( 90 label => __ "Create project", 91 stock => "gtk-add", 92 expand => 0, 93 tip => __ 94 "This asks for a project filename and creates the " 95 . "neccessary filesystem structure", 96 clicked_hook => sub { 97 $self->get_context_object("main")->save_project; 98 }, 99 inactive => "invisible", 100 active_cond => sub { 101 return 1 unless $self->project; 102 return !$self->project->created; 103 }, 104 active_depends => "project", 105 ), 106 ] 107 ), 108 Gtk2::Ex::FormFactory::VBox->new( 109 title => __ "Data source selection", 110 object => "project", 111 active_cond => sub { 112 $self->project 113 && $self->project->created; 114 }, 115 active_depends => "project.created", 116 content => [ 117 Gtk2::Ex::FormFactory::Label->new ( 118 label => __"Select a DVD device or an image directory for input", 119 ), 120 Gtk2::Ex::FormFactory::Form->new ( 121 content => [ 122 Gtk2::Ex::FormFactory::HBox->new ( 123 label => __"Choose DVD device", 124 expand_h => 0, 125 content => [ 126 $dvd_device_popup, 127 Gtk2::Ex::FormFactory::Label->new ( 128 label => __"or", 129 ), 130 Gtk2::Ex::FormFactory::Button->new ( 131 label => __"Choose DVD image directory", 132 expand_h => 0, 133 clicked_hook => sub { 134 $self->choose_dvd_image_directory; 135 }, 136 tip => __"Press this button to open a file chooser dialog" 137 ), 138 ], 139 ), 140 Gtk2::Ex::FormFactory::Entry->new( 141 label => __"Or enter by hand", 142 attr => "project.dvd_device", 143 expand => 1, 144 tip => __"dvd::rip uses this location for DVD input. " 145 ."Either it's the filename of a physical DVD " 146 ."device or the path of a full DVD image copy." 147 ), 148 Gtk2::Ex::FormFactory::Label->new( 149 label => 150 __"Important: On FreeBSD, please mount your DVD disc first\n" 151 ."(eg 'mount /cdrom'), and then specify the mountpoint above\n" 152 ."(click \"Choose DVD image directory\" and select '/cdrom').\n" 153 ), 154 ], 155 ), 156 ], 157 ), 158 Gtk2::Ex::FormFactory::HBox->new ( 159 title => __ "Choose a ripping mode", 160 object => "project", 161 active_cond => sub { 162 $self->project 163 && $self->project->created; 164 }, 165 content => [ 166 Gtk2::Ex::FormFactory::VBox->new( 167 content => [ 168 Gtk2::Ex::FormFactory::RadioButton->new( 169 attr => "project.rip_mode", 170 value => "rip", 171 expand_h => 0, 172 label => __ "Copy data from DVD to harddisk " 173 . "before encoding", 174 tip => __ "Use this mode if you have enough " 175 . "diskspace for a complete copy of " 176 . "the DVD contents. It's the fastest " 177 . "and most flexible DVD mode.", 178 ), 179 Gtk2::Ex::FormFactory::RadioButton->new( 180 attr => "project.rip_mode", 181 value => "dvd", 182 expand_h => 0, 183 label => __ "Encode DVD on the fly", 184 tip => __ "No DVD contents are copied to harddisk.", 185 ), 186 Gtk2::Ex::FormFactory::Label->new( 187 label => 188 __"Copying DVD(-image) data to harddisk before encoding is\n" 189 ."the recommended mode, because it's faster and doesn't\n" 190 ."stress your DVD reader that much. Additionally some\n" 191 ."interesting features are available only with this mode,\n" 192 ."due to internal transcode restrictions:\n\n" 193 ."- Cluster transcoding\n" 194 ."- Subtitle rendering\n" 195 ."- Faster preview grabbing and frame range transcoding\n" 196 ."- transcode's PSU core for optimized A/V sync with NTSC video\n" 197 ), 198 ] 199 ), 200 ], 201 ), 202 ], 203 ); 204} 205 206sub choose_dvd_device_file { 207 my $self = shift; 208 209 my $form_factory = $self->get_form_factory; 210 my $gtk_window = 211 $form_factory 212 ? $form_factory->get_form_factory_gtk_window 213 : undef; 214 215 my $dialog = Gtk2::FileChooserDialog->new( 216 __"Choose DVD device file", 217 $gtk_window, 218 "open", 219 'gtk-cancel' => 'cancel', 220 'gtk-ok' => 'ok' 221 ); 222 223 $dialog->set_current_folder("/dev"); 224 225 my $response = $dialog->run; 226 my $dir = $dialog->get_filename; 227 $dialog->destroy; 228 229 return if $response ne 'ok'; 230 231 $self->get_context->set_object_attr ( 232 "project", "dvd_device", $dir, 233 ); 234 235 1; 236} 237 238sub choose_dvd_image_directory { 239 my $self = shift; 240 241 my $form_factory = $self->get_form_factory; 242 my $gtk_window = 243 $form_factory 244 ? $form_factory->get_form_factory_gtk_window 245 : undef; 246 247 my $dialog = Gtk2::FileChooserDialog->new( 248 __"Choose DVD image directory", 249 $gtk_window, 250 "select-folder", 251 'gtk-cancel' => 'cancel', 252 'gtk-ok' => 'ok' 253 ); 254 255 $dialog->set_current_folder($self->config("base_project_dir")); 256 257 my $response = $dialog->run; 258 my $dir = $dialog->get_filename; 259 $dialog->destroy; 260 261 return if $response ne 'ok'; 262 263 if ( ! -d "$dir/VIDEO_TS" && ! -d "$dir/video_ts" ) { 264 $self->error_window ( 265 message => __"Selected directory is no DVD image directory. ". 266 "It has no VIDEO_TS folder." 267 ); 268 return; 269 } 270 271 $self->get_context->set_object_attr ( 272 "project", "dvd_device", $dir, 273 ); 274 275 1; 276} 277 2781; 279