| 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 | |||
| 11 | package Video::DVDRip::GUI::Project::Storage; | ||
| 12 | |||
| 13 | use base qw( Video::DVDRip::GUI::Base ); | ||
| 14 | |||
| 15 | use Locale::TextDomain qw (video.dvdrip); | ||
| 16 | |||
| 17 | use Carp; | ||
| 18 | use strict; | ||
| 19 | |||
| 20 | sub 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 | ], | ||
| 149 | ), | ||
| 150 | ], | ||
| 151 | ), | ||
| 152 | Gtk2::Ex::FormFactory::HBox->new ( | ||
| 153 | title => __ "Choose a ripping mode", | ||
| 154 | object => "project", | ||
| 155 | active_cond => sub { | ||
| 156 | $self->project | ||
| 157 | && $self->project->created; | ||
| 158 | }, | ||
| 159 | content => [ | ||
| 160 | Gtk2::Ex::FormFactory::VBox->new( | ||
| 161 | content => [ | ||
| 162 | Gtk2::Ex::FormFactory::RadioButton->new( | ||
| 163 | attr => "project.rip_mode", | ||
| 164 | value => "rip", | ||
| 165 | expand_h => 0, | ||
| 166 | label => __ "Copy data from DVD to harddisk " | ||
| 167 | . "before encoding", | ||
| 168 | tip => __ "Use this mode if you have enough " | ||
| 169 | . "diskspace for a complete copy of " | ||
| 170 | . "the DVD contents. It's the fastest " | ||
| 171 | . "and most flexible DVD mode.", | ||
| 172 | ), | ||
| 173 | Gtk2::Ex::FormFactory::RadioButton->new( | ||
| 174 | attr => "project.rip_mode", | ||
| 175 | value => "dvd", | ||
| 176 | expand_h => 0, | ||
| 177 | label => __ "Encode DVD on the fly", | ||
| 178 | tip => __ "No DVD contents are copied to harddisk.", | ||
| 179 | ), | ||
| 180 | Gtk2::Ex::FormFactory::Label->new( | ||
| 181 | label => | ||
| 182 | __"Copying DVD(-image) data to harddisk before encoding is\n" | ||
| 183 | ."the recommended mode, because it's faster and doesn't\n" | ||
| 184 | ."stress your DVD reader that much. Additionally some\n" | ||
| 185 | ."interesting features are available only with this mode,\n" | ||
| 186 | ."due to internal transcode restrictions:\n\n" | ||
| 187 | ."- Cluster transcoding\n" | ||
| 188 | ."- Subtitle rendering\n" | ||
| 189 | ."- Faster preview grabbing and frame range transcoding\n" | ||
| 190 | ."- transcode's PSU core for optimized A/V sync with NTSC video\n" | ||
| 191 | ), | ||
| 192 | ] | ||
| 193 | ), | ||
| 194 | ], | ||
| 195 | ), | ||
| 196 | ], | ||
| 197 | ); | ||
| 198 | } | ||
| 199 | |||
| 200 | sub choose_dvd_device_file { | ||
| 201 | my $self = shift; | ||
| 202 | |||
| 203 | my $form_factory = $self->get_form_factory; | ||
| 204 | my $gtk_window = | ||
| 205 | $form_factory | ||
| 206 | ? $form_factory->get_form_factory_gtk_window | ||
| 207 | : undef; | ||
| 208 | |||
| 209 | my $dialog = Gtk2::FileChooserDialog->new( | ||
| 210 | __"Choose DVD device file", | ||
| 211 | $gtk_window, | ||
| 212 | "open", | ||
| 213 | 'gtk-cancel' => 'cancel', | ||
| 214 | 'gtk-ok' => 'ok' | ||
| 215 | ); | ||
| 216 | |||
| 217 | $dialog->set_current_folder("/dev"); | ||
| 218 | |||
| 219 | my $response = $dialog->run; | ||
| 220 | my $dir = $dialog->get_filename; | ||
| 221 | $dialog->destroy; | ||
| 222 | |||
| 223 | return if $response ne 'ok'; | ||
| 224 | |||
| 225 | $self->get_context->set_object_attr ( | ||
| 226 | "project", "dvd_device", $dir, | ||
| 227 | ); | ||
| 228 | |||
| 229 | 1; | ||
| 230 | } | ||
| 231 | |||
| 232 | sub choose_dvd_image_directory { | ||
| 233 | my $self = shift; | ||
| 234 | |||
| 235 | my $form_factory = $self->get_form_factory; | ||
| 236 | my $gtk_window = | ||
| 237 | $form_factory | ||
| 238 | ? $form_factory->get_form_factory_gtk_window | ||
| 239 | : undef; | ||
| 240 | |||
| 241 | my $dialog = Gtk2::FileChooserDialog->new( | ||
| 242 | __"Choose DVD image directory", | ||
| 243 | $gtk_window, | ||
| 244 | "select-folder", | ||
| 245 | 'gtk-cancel' => 'cancel', | ||
| 246 | 'gtk-ok' => 'ok' | ||
| 247 | ); | ||
| 248 | |||
| 249 | $dialog->set_current_folder($self->config("base_project_dir")); | ||
| 250 | |||
| 251 | my $response = $dialog->run; | ||
| 252 | my $dir = $dialog->get_filename; | ||
| 253 | $dialog->destroy; | ||
| 254 | |||
| 255 | return if $response ne 'ok'; | ||
| 256 | |||
| 257 | if ( ! -d "$dir/VIDEO_TS" && ! -d "$dir/video_ts" ) { | ||
| 258 | $self->error_window ( | ||
| 259 | message => __"Selected directory is no DVD image directory. ". | ||
| 260 | "It has no VIDEO_TS folder." | ||
| 261 | ); | ||
| 262 | return; | ||
| 263 | } | ||
| 264 | |||
| 265 | $self->get_context->set_object_attr ( | ||
| 266 | "project", "dvd_device", $dir, | ||
| 267 | ); | ||
| 268 | |||
| 269 | 1; | ||
| 270 | } | ||
| 271 | |||
| 272 | 1; |