blib/lib/Video/DVDRip/GUI/Cluster/Title.pm untested

filter: Statementstmt 0.0% 0 / 60 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 19 Podpod 0.0% 0 / 15 totaltotal 0.0% 0 / 100 CC 4 SCAR 13.2
CC
4
Cov
0%
build_buttons
12.0
close_window
6.0
master
2.0
CRAP 3.7
1 # $Id: Title.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::Cluster::Title;
12 use Locale::TextDomain qw (video.dvdrip);
13  
14 use base Video::DVDRip::GUI::Base;
15  
16 use strict;
17 use Carp;
18  
19 sub master { shift->{master} }
20 sub title { shift->{title} }
21 sub cluster_ff { shift->{cluster_ff} }
22 sub title_ff { shift->{title_ff} }
23 sub just_added { shift->{just_added} }
24  
25 sub set_master { shift->{master} = $_[1] }
26 sub set_title { shift->{title} = $_[1] }
27 sub set_cluster_ff { shift->{cluster_ff} = $_[1] }
28 sub set_title_ff { shift->{title_ff} = $_[1] }
29 sub set_just_added { shift->{just_added} = $_[1] }
30  
31 # GUI Stuff ----------------------------------------------------------
32  
33 sub new {
34 my $class = shift;
35 my %par = @_;
36 my ( $master, $title, $cluster_ff, $just_added )
37 = @par{ 'master', 'title', 'cluster_ff', 'just_added' };
38  
39 my $self = $class->SUPER::new(@_);
40  
41 $self->set_master($master);
42 $self->set_title($title);
43 $self->set_cluster_ff($cluster_ff);
44 $self->set_just_added($just_added);
45  
46 $cluster_ff->get_form_factory->get_context->set_object(
47 cluster_title_edited => $title, );
48  
49 $cluster_ff->get_form_factory->get_context->set_object(
50 cluster_title_gui => $self, );
51  
52 return $self;
53 }
54  
55 sub open_window {
56 my $self = shift;
57  
58 my $title_ff = Gtk2::Ex::FormFactory->new(
59 parent_ff => $self->cluster_ff,
60 context => $self->cluster_ff->get_context,
61 sync => 0,
62 content => [
63 Gtk2::Ex::FormFactory::Window->new(
64 title => __ "dvd::rip - Edit cluster project",
65 closed_hook => sub {
66 $self->close_window;
67 1;
68 },
69 properties => { modal => 1, },
70 content => [ $self->build_title_form, $self->build_buttons ],
71 ),
72 ],
73 );
74  
75 $title_ff->build;
76 $title_ff->update;
77 $title_ff->show;
78  
79 $self->set_title_ff($title_ff);
80  
81 1;
82 }
83  
84 sub close_window {
85 my $self = shift;
86  
87 my $cluster_gui
88 = $self->cluster_ff->get_form_factory->get_context->get_object(
89 "cluster_gui");
90  
91 my $title_ff = $self->title_ff;
92 $title_ff->close if $title_ff;
93 $self->set_title_ff(undef);
94 $self->set_title(undef);
95  
96 $self->cluster_ff->get_form_factory->get_context->set_object(
97 cluster_title_gui => undef, );
98 $self->cluster_ff->get_form_factory->get_context->set_object(
99 cluster_title_edited => undef, );
100  
101 1;
102 }
103  
104 sub build_title_form {
105 my $self = shift;
106  
107 return Gtk2::Ex::FormFactory::Form->new(
108 title => __ "Edit cluster project properties",
109 expand => 1,
110 content => [
111 Gtk2::Ex::FormFactory::Label->new(
112 attr => "cluster_title_edited.info",
113 label => __ "Project",
114 ),
115 Gtk2::Ex::FormFactory::Entry->new(
116 attr => "cluster_title_edited.frames_per_chunk",
117 label => __ "Number of frames per chunk",
118 tip => __
119 "The smaller the chunks the higher the parallelism, "
120 . "but overall bitrate distribution may suffer if set "
121 . "too low",
122 rules => "positive-integer",
123 ),
124 Gtk2::Ex::FormFactory::YesNo->new(
125 attr => "cluster_title_edited.with_cleanup",
126 label => __ "Cleanup temporary files after merging?",
127 true_label => __"Yes",
128 false_label => __"No",
129 ),
130 Gtk2::Ex::FormFactory::YesNo->new(
131 attr => "cluster_title_edited.with_vob_remove",
132 label => __ "Cleanup original VOB files when finished?",
133 true_label => __"Yes",
134 false_label => __"No",
135 ),
136 ],
137 );
138 }
139  
140 sub build_buttons {
141 my $self = shift;
142  
143 return Gtk2::Ex::FormFactory::DialogButtons->new(
144 clicked_hook_after => sub {
145 my ($button) = @_;
146 if ( $button eq 'ok' ) {
147 $self->title->project->save;
148 }
149 else {
150 $self->master->remove_project(
151 project => $self->title->project )
152 if $self->just_added;
153 }
154 $self->close_window;
155 1;
156 },
157 );
158 }
159  
160 1;