This file is indexed.

/usr/share/perl5/Tkx/MegaConfig.pm is in libtkx-perl 1.09-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
package Tkx::MegaConfig;

use strict;
our $VERSION = "1.07";

my %spec;

sub _Config {
    my $class = shift;
    while (@_) {
	my($opt, $spec) = splice(@_, 0, 2);
	$spec{$class}{$opt} = $spec;
    }
}

sub m_configure {
    my $self = shift;
    my @rest;
    while (@_) {
	my($opt, $val) = splice(@_, 0, 2);
	my $spec = $spec{ref($self)}{$opt} || $spec{ref($self)}{DEFAULT};
	unless ($spec) {
	    push(@rest, $opt => $val);
	    next;
	}

	my $where = $spec->[0];
	my @where_args;
	if (ref($where) eq "ARRAY") {
	    ($where, @where_args) = @$where;
	}

	if ($where =~ s/^\.//) {
            my $fwd_opt = $where_args[0] || $opt;
	    if ($where eq "") {
		$self->Tkx::widget::m_configure($fwd_opt, $val);
		next;
	    }
            if ($where eq "*") {
                for my $kid ($self->_kids) {
                    $kid->m_configure($fwd_opt, $val);
                }
                next;
            }
	    $self->_kid($where)->m_configure($fwd_opt, $val);
	    next;
	}

	if ($where eq "METHOD") {
	    my $method = $where_args[0] || "_config_" . substr($opt, 1);
	    $self->$method($val);
	    next;
	}

	if ($where eq "PASSIVE") {
	    $self->_data->{$opt} = $val;
	    next;
	}

	die;
    }

    $self->Tkx::widget::m_configure(@rest) if @rest;   # XXX want NEXT instead
}

sub m_cget {
    my($self, $opt) = @_;
    my $spec = $spec{ref($self)}{$opt} || $spec{ref($self)}{DEFAULT};
    return $self->Tkx::widget::m_cget($opt) unless $spec;  # XXX want NEXT instead

    my $where = $spec->[0];
    my @where_args;
    if (ref($where) eq "ARRAY") {
	($where, @where_args) = @$where;
    }

    if ($where =~ s/^\.//) {
        my $fwd_opt = $where_args[0] || $opt;
	return $self->Tkx::widget::m_cget($fwd_opt) if $where eq "";
        return ($self->_kids)[0]->m_cget($fwd_opt) if $where eq "*";
	return $self->_kid($where)->m_cget($fwd_opt);
    }

    if ($where eq "METHOD") {
	my $method = $where_args[0] || "_config_" .substr($opt, 1);
	return $self->$method;
    }

    if ($where eq "PASSIVE") {
	return $self->_data->{$opt};
    }

    die;
}

1;

__END__

=head1 NAME

Tkx::MegaConfig - handle configuration options for megawidgets

=head1 SYNOPSIS

  package Foo;
  use base qw(Tkx::widget Tkx::MegaConfig);

  __PACKAGE__->_Mega("foo");
  __PACKAGE__->_Config(
      -option  => [$where, $dbName, $dbClass, $default],
  );

=head1 DESCRIPTION

The C<Tkx::MegaConfig> class provide implementations of m_configure()
and m_cget() that can handle configuration options for megawidgets.
How these methods behave is set up by calling the _Config() class
method.  The _Config() method takes a set option/option spec pairs as
argument.

An option argument is either the name of an option with leading '-'
or the string 'DEFAULT' if this spec applies to all option with no
explicit spec.

If there is no 'DEFAULT' then unmatched options are applied directly
to the megawidget root itself.  This is the same behaviour you get if
you specify:

   __PACKAGE__->_Config(
      ...
      DEFAULT => ['.'],
   );

The option spec should be an array reference.  The first element of
the array ($where) describe how this option is handled.  Some $where
specs take arguments.  If you need to provide argument replace $where
with an array reference containg [$where, @args].  The rest of the
option spec specify names and default for the options database, but is
currently ignored (feature unimplemented).

The following $where specs are understood:

=over

=item .foo

Delegate the given configuration option to the "foo" kid of the mega
widget root.  The name "." can be used to delegate to the megawidget
root itself.  The name ".*" can be used to delegate to all kids of the
megawidget root.

An argument can be given to delegate using a different
configuration name name on the "foo" widget.  Examples:

   -foo => [".inner"],                 # forward -foo
   -bg  => [[".", "-background]],      # alias
   -bg2 => [[".inner", "-background]], # forward as -background
   -background => [".*"]               # forward --background to kids

=item METHOD

Call the _config_I<opt> method.  For m_cget() no arguments are given,
while for m_configure() the new value is passed.  If an extra $where
argument is given it will be the method called instead of
_config_I<opt>.  Examples:

   __PACKAGE__->_Config(
      -foo => ["METHOD"];
      -bar => [["METHOD", "bar"]],
   }

   sub _config_foo {
       my $self = shift;
       return "foo" unless @_;
       print "Ignoring setting configuration option -foo to '$_[0]'";
   }

   sub handle_bar {
       my $self = shift;
       return "bar" unless @_;
       print "Ignoring setting configuration option -bar to '$_[0]'";
   }

=item PASSIVE

Store or retrieve option from $self->_data.

=back

=head1 LICENSE

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

Copyright 2005 ActiveState.  All rights reserved.

=head1 SEE ALSO

L<Tkx>, L<Tkx::LabEntry>

Inspiration for this module comes from L<Tk::ConfigSpecs>.