| 1 | # $Id: Depend.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::Depend; | ||
| 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 $depend_ff; | ||
| 20 | |||
| 21 | sub open_window { | ||
| 22 | my $self = shift; | ||
| 23 | |||
| 24 | return if $depend_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 | $depend_ff = Gtk2::Ex::FormFactory->new( | ||
| 37 | context => $context, | ||
| 38 | parent_ff => $self->get_form_factory, | ||
| 39 | sync => 0, | ||
| 40 | content => [ | ||
| 41 | Gtk2::Ex::FormFactory::Window->new( | ||
| 42 | title => __ "dvd::rip - Dependency check", | ||
| 43 | customize_hook => sub { | ||
| 44 | my ($gtk_window) = @_; | ||
| 45 | $_[0]->parent->set( | ||
| 46 | default_width => 640, | ||
| 47 | default_height => 480, | ||
| 48 | ); | ||
| 49 | 1; | ||
| 50 | }, | ||
| 51 | closed_hook => sub { | ||
| 52 | $depend_ff->close if $depend_ff; | ||
| 53 | $depend_ff = undef; | ||
| 54 | 1; | ||
| 55 | }, | ||
| 56 | content => [ | ||
| 57 | Gtk2::Ex::FormFactory::Table->new( | ||
| 58 | title => __ "Required tools", | ||
| 59 | expand => 1, | ||
| 60 | layout => " | ||
| 61 | +>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+ | ||
| 62 | ^ Dependency list | | ||
| 63 | | | | ||
| 64 | +---------------------------------+ | ||
| 65 | | Notes | | ||
| 66 | +-----------------------+--------]+ | ||
| 67 | | | Buttons | | ||
| 68 | +-----------------------+---------+ | ||
| 69 | ", | ||
| 70 | content => [ | ||
| 71 | $self->build_depend_list, | ||
| 72 | $self->build_depend_notes, | ||
| 73 | Gtk2::Ex::FormFactory::HBox->new( | ||
| 74 | content => [ | ||
| 75 | Gtk2::Ex::FormFactory::Button->new( | ||
| 76 | label => __ " Text version ", | ||
| 77 | stock => "gtk-justify-left", | ||
| 78 | clicked_hook => sub { | ||
| 79 | $self->show_text_version; | ||
| 80 | }, | ||
| 81 | tooltip => __ | ||
| 82 | "Text version, suitable for bug reports" | ||
| 83 | ), | ||
| 84 | Gtk2::Ex::FormFactory::Button->new( | ||
| 85 | label => __ " Ok ", | ||
| 86 | stock => "gtk-ok", | ||
| 87 | clicked_hook => sub { | ||
| 88 | $depend_ff->close; | ||
| 89 | $depend_ff = undef; | ||
| 90 | }, | ||
| 91 | ), | ||
| 92 | ], | ||
| 93 | ), | ||
| 94 | ], | ||
| 95 | ), | ||
| 96 | ], | ||
| 97 | ), | ||
| 98 | |||
| 99 | ], | ||
| 100 | ); | ||
| 101 | |||
| 102 | $depend_ff->build; | ||
| 103 | $depend_ff->update; | ||
| 104 | $depend_ff->show; | ||
| 105 | |||
| 106 | 1; | ||
| 107 | } | ||
| 108 | |||
| 109 | sub build_depend_list { | ||
| 110 | my $self = shift; | ||
| 111 | |||
| 112 | Gtk2::SimpleList->add_column_type( | ||
| 113 | 'depend_tool_text', | ||
| 114 | type => "Glib::Scalar", | ||
| 115 | renderer => "Gtk2::CellRendererText", | ||
| 116 | attr => sub { | ||
| 117 | my ( $treecol, $cell, $model, $iter, $col_num ) = @_; | ||
| 118 | my $info = $model->get( $iter, $col_num ); | ||
| 119 | my $ok = $model->get( $iter, 8 ); | ||
| 120 | $cell->set( text => $info ); | ||
| 121 | $cell->set( foreground => $ok ? "#000000" : "#ff0000" ); | ||
| 122 | $cell->set( weight => $col_num == 0 ? 700 : 500 ); | ||
| 123 | 1; | ||
| 124 | }, | ||
| 125 | ); | ||
| 126 | |||
| 127 | return Gtk2::Ex::FormFactory::List->new( | ||
| 128 | attr => "depend.tools", | ||
| 129 | expand => 1, | ||
| 130 | scrollbars => [ "never", "automatic" ], | ||
| 131 | columns => [ | ||
| 132 | __ "Name", | ||
| 133 | __ "Comment", | ||
| 134 | __ "Mandatory", | ||
| 135 | __ "Suggested", | ||
| 136 | __ "Minimum", | ||
| 137 | __ "Maximum", | ||
| 138 | __ "Installed", | ||
| 139 | __ "Ok", | ||
| 140 | "color_control" | ||
| 141 | ], | ||
| 142 | types => [ ("depend_tool_text") x 8, "int" ], | ||
| 143 | selection_mode => "none", | ||
| 144 | customize_hook => sub { | ||
| 145 | my ($gtk_simple_list) = @_; | ||
| 146 | ( $gtk_simple_list->get_columns )[8]->set( visible => 0 ); | ||
| 147 | 1; | ||
| 148 | }, | ||
| 149 | ); | ||
| 150 | } | ||
| 151 | |||
| 152 | sub build_depend_notes { | ||
| 153 | my $self = shift; | ||
| 154 | |||
| 155 | return Gtk2::Ex::FormFactory::Label->new( | ||
| 156 | label => __( | ||
| 157 | "- Mandatory tools must be present with the minimum version listed.\n" | ||
| 158 | . "- Non mandatory tools may be missing or too old - features are disabled then.\n" | ||
| 159 | . "- Suggested numbers are the versions the author works with, so they are well tested." | ||
| 160 | ) | ||
| 161 | |||
| 162 | ); | ||
| 163 | } | ||
| 164 | |||
| 165 | sub show_text_version { | ||
| 166 | my $self = shift; | ||
| 167 | |||
| 168 | my $message = $self->depend_object->installed_tools_as_text; | ||
| 169 | |||
| 170 | $self->long_message_window( | ||
| 171 | title => __ "Installed tools", | ||
| 172 | message => $message, | ||
| 173 | fixed => 1, | ||
| 174 | ); | ||
| 175 | |||
| 176 | 1; | ||
| 177 | } | ||
| 178 | |||
| 179 | 1; | ||
| 180 |