Debian Codegraph @

Debconf/Element/Gnome/Select.pm

raw
1 #!/usr/bin/perl
2
3 =head1 NAME
4
5 Debconf::Element::Gnome::Select - drop down select box widget
6
7 =cut
8
9 package Debconf::Element::Gnome::Select;
10 use warnings;
11 use strict;
12 use Gtk3;
13 use utf8;
14 use Debconf::Encoding qw(to_Unicode);
15 use base qw(Debconf::Element::Gnome Debconf::Element::Select);
16
17 =head1 DESCRIPTION
18
19 This is a drop down select box widget.
20
21 =cut
22
23 sub init {
24 my $this=shift;
25
26 my $default=$this->translate_default;
27 my @choices=$this->question->choices_split;
28
29 $this->SUPER::init(@_);
30
31 $this->widget(Gtk3::ComboBoxText->new);
32 $this->widget->show;
33
34 foreach my $choice (@choices) {
35 $this->widget->append_text(to_Unicode($choice));
36 }
37
38 $this->widget->set_active(0);
39 for (my $choice=0; $choice <= $#choices; $choice++) {
40 if ($choices[$choice] eq $default) {
41 $this->widget->set_active($choice);
42 last;
43 }
44 }
45
46 $this->adddescription;
47 $this->addwidget($this->widget);
48 $this->tip( $this->widget );
49 $this->addhelp;
50 }
51
52 =item value
53
54 The value is just the value field of the widget, translated back to the C
55 locale.
56
57 =cut
58
59 sub value {
60 my $this=shift;
61
62 return $this->translate_to_C_uni($this->widget->get_active_text);
63 }
64
65 # Multiple inheritance means we get Debconf::Element::visible by default.
66 *visible = \&Debconf::Element::Select::visible;
67
68 =back
69
70 =head1 AUTHOR
71
72 Eric Gillespie <[email protected]>
73 Gustavo Noronha Silva <[email protected]>
74
75 =cut
76
77 1