| 1 | # $Id: BitrateCalc.pm 2187 2006-08-16 19:34:38Z 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::BitrateCalc; | ||
| 12 | use Locale::TextDomain qw (video.dvdrip); | ||
| 13 | |||
| 14 | use base qw(Video::DVDRip::GUI::Base); | ||
| 15 | |||
| 16 | use strict; | ||
| 17 | use Carp; | ||
| 18 | |||
| 19 | my $bitrate_ff; | ||
| 20 | |||
| 21 | sub open_window { | ||
| 22 | my $self = shift; | ||
| 23 | |||
| 24 | return if $bitrate_ff; | ||
| 25 | |||
| 26 | $self->build; | ||
| 27 | |||
| 28 | 1; | ||
| 29 | } | ||
| 30 | |||
| 31 | sub build { | ||
| 32 | my $self = shift; | ||
| 33 | |||
| 34 | my $context = $self->get_context; | ||
| 35 | |||
| 36 | $bitrate_ff = Gtk2::Ex::FormFactory->new ( | ||
| 37 | context => $context, | ||
| 38 | parent_ff => $self->get_form_factory, | ||
| 39 | sync => 1, | ||
| 40 | content => [ | ||
| 41 | Gtk2::Ex::FormFactory::Window->new ( | ||
| 42 | title => __"dvd::rip - Storage and bitrate calculation details", | ||
| 43 | customize_hook => sub { | ||
| 44 | my ($gtk_window) = @_; | ||
| 45 | $_[0]->parent->set( | ||
| 46 | default_width => 400, | ||
| 47 | default_height => 400, | ||
| 48 | ); | ||
| 49 | 1; | ||
| 50 | }, | ||
| 51 | closed_hook => sub { | ||
| 52 | $bitrate_ff->close if $bitrate_ff; | ||
| 53 | $bitrate_ff = undef; | ||
| 54 | 1; | ||
| 55 | }, | ||
| 56 | content => [ | ||
| 57 | Gtk2::Ex::FormFactory::VBox->new ( | ||
| 58 | expand => 1, | ||
| 59 | content => [ | ||
| 60 | $self->build_calc_list, | ||
| 61 | Gtk2::Ex::FormFactory::DialogButtons->new ( | ||
| 62 | clicked_hook_after => sub { | ||
| 63 | $bitrate_ff->close; | ||
| 64 | $bitrate_ff=undef; | ||
| 65 | }, | ||
| 66 | ), | ||
| 67 | ], | ||
| 68 | ), | ||
| 69 | ], | ||
| 70 | ), | ||
| 71 | |||
| 72 | ], | ||
| 73 | ); | ||
| 74 | |||
| 75 | $bitrate_ff->build; | ||
| 76 | $bitrate_ff->update; | ||
| 77 | $bitrate_ff->show; | ||
| 78 | |||
| 79 | 1; | ||
| 80 | } | ||
| 81 | |||
| 82 | sub build_calc_list { | ||
| 83 | my $self = shift; | ||
| 84 | |||
| 85 | Gtk2::SimpleList->add_column_type( | ||
| 86 | 'bitrate_calc_text', | ||
| 87 | type => "Glib::Scalar", | ||
| 88 | renderer => "Gtk2::CellRendererText", | ||
| 89 | attr => sub { | ||
| 90 | my ($treecol, $cell, $model, $iter, $col_num) = @_; | ||
| 91 | my $info = $model->get($iter, $col_num); | ||
| 92 | my $op = $model->get($iter, 1); | ||
| 93 | $cell->set ( text => $info ); | ||
| 94 | $cell->set ( weight => $op =~ /[=~]/ ? 700 : 500); | ||
| 95 | 1; | ||
| 96 | }, | ||
| 97 | ); | ||
| 98 | |||
| 99 | return Gtk2::Ex::FormFactory::VBox->new ( | ||
| 100 | expand => 1, | ||
| 101 | content => [ | ||
| 102 | Gtk2::Ex::FormFactory::List->new ( | ||
| 103 | attr => "bitrate_calc.sheet", | ||
| 104 | expand => 1, | ||
| 105 | scrollbars => [ "never", "automatic" ], | ||
| 106 | columns => [ | ||
| 107 | __"Description", __"Operator", __"Value", __"Unit" | ||
| 108 | ], | ||
| 109 | types => [ | ||
| 110 | ("bitrate_calc_text") x 4, "int" | ||
| 111 | ], | ||
| 112 | selection_mode => "none", | ||
| 113 | ), | ||
| 114 | ], | ||
| 115 | ); | ||
| 116 | } | ||
| 117 | |||
| 118 | 1; |