/usr/share/perl5/Gscan2pdf/EntryCompletion.pm is in gscan2pdf 2.1.0-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 | package Gscan2pdf::EntryCompletion;
use strict;
use warnings;
use Gtk3;
use Glib qw(TRUE FALSE); # To get TRUE and FALSE
BEGIN {
use Exporter ();
our ( $VERSION, @EXPORT_OK, %EXPORT_TAGS );
$VERSION = '2.1.0';
use base qw(Exporter Gtk3::Entry);
%EXPORT_TAGS = (); # eg: TAG => [ qw!name1 name2! ],
# your exported package globals go here,
# as well as any optionally exported functions
@EXPORT_OK = qw();
}
sub new {
my ( $class, $default, $suggestions ) = @_;
my $self = Gtk3::Entry->new;
my $completion = Gtk3::EntryCompletion->new;
$completion->set_inline_completion(TRUE);
$completion->set_text_column(0);
$self->set_completion($completion);
my $model = Gtk3::ListStore->new('Glib::String');
$completion->set_model($model);
if ( defined $suggestions ) {
for my $suggestion ( @{$suggestions} ) {
$model->set( $model->append, 0, $suggestion );
}
}
$self->set_activates_default(TRUE);
if ( defined $default ) { $self->set_text($default) }
bless $self, $class;
return $self;
}
sub update {
my ( $self, $suggestions ) = @_;
my $text = $self->get_text;
my $completion = $self->get_completion;
my $model = $completion->get_model;
my $flag = FALSE;
my $iter = $model->get_iter_first;
$model->foreach(
sub {
my ( $model, $path, $iter ) = @_;
my $suggestion = $model->get( $iter, 0 );
if ( $suggestion eq $text ) { $flag = TRUE }
return $flag; # FALSE=continue
}
);
if ( not $flag ) {
$model->set( $model->append, 0, $text );
push @{$suggestions}, $text;
}
return $text;
}
1;
__END__
|