This file is indexed.

/usr/share/perl5/Lire/UI/Prefs.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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
package Lire::UI::Prefs;

use strict;

use Curses;
use Curses::UI;
use Lire::Config;
use Lire::Utils qw/ check_object_param /;
use Locale::TextDomain 'lire';

use Carp;

=pod

=head1 NAME

Lire::UI::Prefs - Preferences management

=head1 SYNOPSIS

  use Lire::UI::Prefs;

=head1 DESCRIPTION

XXX FIXME

=cut

sub new {
    my ( $class, $ui, $config ) = @_;

    check_object_param( $ui, 'ui', 'Curses::UI' );
    check_object_param( $config, 'config', 'Lire::Config::ConfigFile' );

    my $self = bless( { '_ui' => $ui, '_cfg_file' => $config },
                      $class );
    $self->_create_prefs_win();

    return $self;
}

sub show {
    my $self = $_[0];

    my $prefs_win = $self->{ '_ui' }->getobj( 'prefs_win' );
    my $section_menu = $prefs_win->getobj( 'section_menu' );
    $section_menu->{'-selected'} = 0;
    $section_menu->run_event( '-onchange' );
    $prefs_win->modalfocus();
    $self->{ '_ui' }->delete( 'prefs_win' );

    return;
}

sub _create_prefs_win {
    my $self = $_[0];

    my $ui = $self->{'_ui'};
    my $prefs_win = $ui->add( 'prefs_win', 'Window',
                              '-title' => __( 'Lire Preferences' ),
                              '-y' => 1, '-border' => 1,
                              '-ipadleft' => 1, '-ipadright' => 1,
                              '-ipadtop' => 1 );
    $prefs_win->userdata( $self );
    $self->_create_section_menu( $prefs_win );

    my $width = $prefs_win->getobj( 'section_menu' )->canvaswidth() + 2;
    $prefs_win->add( 'options_list', 'Listbox',
                     '-values' => [],
                     '-labels' => {},
                     '-ipadleft' => 1, '-ipadright' => 1,
                     '-y' => 1,
                     '-width' => $width,
                     '-height' => ( $prefs_win->canvasheight() - 1 ),
                     '-onchange' => \&_option_change_cb,
                     '-onselchange' => \&_option_selchange_cb,
                     '-border' => 1 );

    $prefs_win->add( 'option_summary', 'Label',
                     '-text' => '', '-bold' => 1,
                     '-width' => ( $prefs_win->canvaswidth() - $width - 3 ),
                     '-x' => $width + 2 );
    $prefs_win->add( 'option_help', 'TextViewer',
                     '-x' => $width + 1, '-y' => 14,
                     '-border' => 0, '-padbottom' => 2,
                     '-wrapping' => 1, '-vscrollbar' => 1,
                     '-ipadleft' => 1, '-ipadright' => 1,
                     '-text' => '' );
    $self->_create_buttons( $prefs_win );

    return;
}

sub _create_section_menu {
    my ( $self, $win ) = @_;

    my @values = ( 'report', 'responder', 'operation',
                   'path', 'docbook', 'programs' );
    my @labels = ( __( 'Reports' ),
                   __( 'Responder Preferences' ),
                   __( 'Operational Preferences' ),
                   __( 'Lire Paths' ),
                   __( 'Docbook Paths' ),
                   __( 'Program Paths' ) );
    my $labels = {};
    for ( my $i = 0; $i < @values; $i++ ) {
        $labels->{$values[$i]} = $labels[$i];
    }
    my $section_menu = $win->add( 'section_menu', 'Popupmenu',
                                  '-selected' => 0,
                                  '-labels' => $labels,
                                  '-values' => \@values,
                                  '-onchange' => \&_section_change_cb );
    return;
}

sub _create_buttons {
    my ( $self, $win ) = @_;

    my $buttons = $win->add( 'buttons', 'Buttonbox',
                             '-buttons' => [ { '-label' => __( '< Cancel >' ),
                                               '-onpress' => \&_cancel_cb },
                                             { '-label' => __( '< OK >' ),
                                               '-onpress' => \&_ok_cb, }  ],
                             '-padleft' => 30,
                             '-y' => -1, '-buttonalignment' => 'right' );

    return;
}

sub _get_var {
    my ( $self, $name ) = @_;

    if ( ! $self->{'_cfg_file'}->is_set( $name ) ) {
        my $clone = Lire::Config->get_var( $name )->clone();
        $self->{'_cfg_file'}->set( $clone );
    }

    return $self->{'_cfg_file'}->get( $name );
}

# callback functions
sub _section_change_cb {
    my $widget = $_[0];

    my $self = $widget->parent()->userdata();
    my $options =
      $self->{'_cfg_file'}->spec()->components_by_section( $widget->get() );
    my $options_list = $widget->parent()->getobj( 'options_list' );
    my $labels = { map { $_ => $_->name() } @$options };

    $options_list->{'-values'} = $options;
    $options_list->{'-labels'} = $labels;
    $options_list->{'-ypos'} = 0;
    $options_list->run_event( '-onselchange' );

    $options_list->draw();

    return;
}

sub _option_selchange_cb {
    my $widget = $_[0];

    $widget->{'-selected'} = $widget->{'-ypos'};
    $widget->run_event( '-onchange' );

    return;
}

sub _option_change_cb {
    my $widget = $_[0];

    $widget->{'-ypos'} = $widget->{'-selected'};
    my $self = $widget->parent()->userdata();
    my $option = $widget->get();
    my $opt_summary = $widget->parent()->getobj( 'option_summary' );
    my $opt_help = $widget->parent()->getobj( 'option_help' );

    $opt_help->cursor_up( undef, $opt_help->{'-yscrpos'} )
      if ( $opt_help->{'-yscrpos'} > 1 );

    if ( !defined $option ) {
        $widget->{'-ypos'} = 0;
        $widget->{'-selected'} = undef;
        $opt_summary->text( '' );
        $opt_help->text( '' );
    } else {
        $widget->parent()->delete( 'option_widget' )
          if $widget->parent()->getobj( 'option_widget' );
        $widget->parent()->add( 'option_widget', 'Lire::UI::Widget',
                                '-x' => $opt_summary->{'-x'},
                                '-y' => $opt_summary->{'-y'} + 2,
                                '-height' => 11,
                                'value' => $self->_get_var( $option->name() ));
        $opt_summary->text( $option->summary() );
        $opt_help->text( $option->text_description()
                         || __( 'No help available.' ) );
        $widget->parent()->intellidraw();
    }

    return;
}

sub _cancel_cb {
    my $buttons = $_[0];

    my $prefs_win = $buttons->parent();
    $prefs_win->loose_focus();
    my $self = $prefs_win->userdata();
    $self->{'_cfg_file'}->revert();

    return;
}

sub _ok_cb {
    my $buttons = $_[0];

    my $prefs_win = $buttons->parent();
    $prefs_win->loose_focus();
    my $self = $prefs_win->userdata();
    $self->{'_cfg_file'}->save();

    return;
}

# keep perl happy
1;

__END__

=pod

=head1 SEE ALSO

Lire::UI(3pm)

=head1 VERSION

$Id: Prefs.pm,v 1.20 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