/usr/share/perl5/Lire/UI/Widget.pm is in lire 2:2.1.1-2.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | package Lire::UI::Widget;
use strict;
use Carp;
use Curses::UI::Common;
use Lire::Utils qw/ check_object_param /;
use base qw/ Curses::UI::Widget /;
use vars qw/@CARP_NOT/;
@CARP_NOT = qw/Curses::UI::Container/;
=pod
=head1 NAME
Lire::UI::Widget - Views for Lire::Config::Value object.
=head1 SYNOPSIS
use Curses::UI;
use Lire::Config;
Lire::Config->init();
my $ui = new Curses::UI();
my $window = $ui->add( 'window', 'Window' );
my $widget = $window->add( 'widget', 'Lire::UI::Widget',
'value' => Lire::Config->get_var( 'name' ));
=head1 DESCRIPTION
Lire::UI::Widget defines Curses::UI::Widget subclasses that can be
used to edit Lire::Config::Value object.
=cut
use vars qw/ %widget_table /;
%widget_table = ( 'Lire::Config::BooleanSpec' => 'Lire::UI::BoolWidget',
'Lire::Config::ChartSpec' => 'Lire::UI::CompoundWidget',
'Lire::Config::ChartTypeSpec' => 'Lire::UI::PluginWidget',
'Lire::Config::CommandSpec' => 'Lire::UI::CommandWidget',
'Lire::Config::DirectorySpec'=>'Lire::UI::DirectoryWidget',
'Lire::Config::DlfAnalyserSpec' => 'Lire::UI::PluginWidget',
'Lire::Config::DlfConverterSpec' => 'Lire::UI::PluginWidget',
'Lire::Config::DlfSchemaSpec' => 'Lire::UI::SelectWidget',
'Lire::Config::DlfStreamSpec' => 'Lire::UI::CompoundWidget',
'Lire::Config::ExecutableSpec'=>'Lire::UI::ExecutableWidget',
'Lire::Config::FileSpec' => 'Lire::UI::FileWidget',
'Lire::Config::IntegerSpec' => 'Lire::UI::IntegerWidget',
'Lire::Config::ListSpec' => 'Lire::UI::ListWidget',
'Lire::Config::ObjectSpec' => 'Lire::UI::CompoundWidget',
'Lire::Config::OutputFormatSpec' => 'Lire::UI::PluginWidget',
'Lire::Config::PluginSpec' => 'Lire::UI::PluginWidget',
'Lire::Config::RecordSpec' => 'Lire::UI::CompoundWidget',
'Lire::Config::ReferenceSpec' => 'Lire::UI::SelectWidget',
'Lire::Config::ReportSectionSpec' => 'Lire::UI::ReportSectionWidget',
'Lire::Config::ReportSpec' => 'Lire::UI::CompoundWidget',
'Lire::Config::SelectSpec' => 'Lire::UI::SelectWidget',
'Lire::Config::XMLSpecListSpec' => 'Lire::UI::XMLSpecListWidget',
'Lire::Config::StringSpec' => 'Lire::UI::StringWidget',
);
=pod
=head2 new( %args, 'value' => $value, [ onvaluechanged => $handler ] )
The new() method is really a factory method which instantiate a proper
Lire::UI::Widget subclass based on the type of the Lire::Config::Value
$value. The onvaluechanged is an event that will be trigger whenever
the Lire::Config::Value is modified by the user.
=cut
sub new {
my $class = shift;
my %userargs = @_;
keys_to_lowercase(\%userargs);
check_object_param( $userargs{'value'}, 'value', 'Lire::Config::Value' );
my $spec_type = ref( $userargs{'value'}->spec() );
croak "no widget type defined for values of type '$spec_type'"
unless exists( $widget_table{$spec_type} );
my $widget_class = $widget_table{$spec_type};
eval "use $widget_class;";
die if $@;
return $widget_class->new( %userargs );
}
=pod
=head2 value()
Returns the Lire::Config::Value object which is edited by this view.
=cut
sub value {
return $_[0]{'value'};
}
=pod
=head2 onValueChanded( $code )
Changes the event handler connected to the 'onvaluechanged' event.
This event is trigger whenever the Lire::Config::Value associated to
this widget is modified.
=cut
sub onValueChanged {
my ( $self, $handler ) = @_;
$self->set_event( 'onvaluechanged', $handler );
return;
}
=pod
=head2 refresh_view()
This method can be called to update the view to reflect modifications
to the underlying Lire::COnfig::Value.
=cut
sub refresh_view {
croak "unimplemented refresh_view() in ", ref $_[0];
}
package Lire::UI::DummyWidget;
$INC{'Lire/UI/DummyWidget.pm'} = __FILE__;
use base qw/Curses::UI::TextViewer/;
use Carp;
sub new {
my ( $class, %args ) = @_;
return $class->SUPER::new( %args, '-text' => $args{'value'}->get() );
}
sub refresh_view {
$_[0]->text( $_[0]->{'value'}->get() );
}
# keep perl happy
1;
__END__
=pod
=head1 SEE ALSO
Lire::UI(3pm), Curses::UI(3pm)
=head1 VERSION
$Id: Widget.pm,v 1.27 2006/07/23 13:16:32 vanbaal Exp $
=head1 AUTHORS
Francis J. Lacoste <flacoste@logreport.org>
Wolfgang Sourdeau <wolfgang@logreport.org>
=head1 COPYRIGHT
Copyright (C) 2004 Stichting LogReport Foundation LogReport@LogReport.org
This file is part of Lire.
Lire is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program (see COPYING); if not, check with
http://www.gnu.org/copyleft/gpl.html.
=cut
|