<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl -w
# This file was preprocessed, do not edit!


package Debconf::Element::Gnome::Multiselect;
use strict;
use Gtk3;
use utf8;
use Debconf::Encoding qw(to_Unicode);
use base qw(Debconf::Element::Gnome Debconf::Element::Multiselect);

use constant SELECTED_COLUMN =&gt; 0;
use constant CHOICES_COLUMN  =&gt; 1;

sub init {
	my $this=shift;
	my @choices = map { to_Unicode($_) } $this-&gt;question-&gt;choices_split;
        my %default=map { to_Unicode($_) =&gt; 1 } $this-&gt;translate_default;

	$this-&gt;SUPER::init(@_);
	$this-&gt;multiline(1);

	$this-&gt;adddescription;

        $this-&gt;widget(Gtk3::ScrolledWindow-&gt;new);
        $this-&gt;widget-&gt;show;
        $this-&gt;widget-&gt;set_policy('automatic', 'automatic');
	
	my $list_store = Gtk3::ListStore-&gt;new('Glib::Boolean', 'Glib::String');
	$this-&gt;list_view(Gtk3::TreeView-&gt;new($list_store));
	$this-&gt;list_view-&gt;set_headers_visible(0);

	my $renderer_toggle = Gtk3::CellRendererToggle-&gt;new;
	$renderer_toggle-&gt;signal_connect(toggled =&gt; sub {
		my $path_string = $_[1];
		my $model = $_[2];
		my $iter = $model-&gt;get_iter_from_string($path_string);
		$model-&gt;set($iter, SELECTED_COLUMN,
		            not $model-&gt;get($iter, SELECTED_COLUMN));
	}, $list_store);

	$this-&gt;list_view-&gt;append_column(
		Gtk3::TreeViewColumn-&gt;new_with_attributes('Selected',
			$renderer_toggle, 'active', SELECTED_COLUMN));
	$this-&gt;list_view-&gt;append_column(
		Gtk3::TreeViewColumn-&gt;new_with_attributes('Choices',
			Gtk3::CellRendererText-&gt;new, 'text', CHOICES_COLUMN));
	$this-&gt;list_view-&gt;show;

	$this-&gt;widget-&gt;add($this-&gt;list_view);

	for (my $i=0; $i &lt;= $#choices; $i++) {
		my $iter = $list_store-&gt;append();
		$list_store-&gt;set($iter, CHOICES_COLUMN, $choices[$i]);
		if ($default{$choices[$i]}) {
			$list_store-&gt;set($iter, SELECTED_COLUMN, 1);
		}
	}
	$this-&gt;addwidget($this-&gt;widget);
	$this-&gt;tip($this-&gt;list_view);
	$this-&gt;addhelp;

	$this-&gt;fill(1);
	$this-&gt;expand(1);

}


sub value {
	my $this=shift;
	my $list_view = $this-&gt;list_view;
	my $list_store = $list_view-&gt;get_model();
	my ($ret, $val);
	
	my @vals;
	$this-&gt;question-&gt;template-&gt;i18n('');
	my @choices=$this-&gt;question-&gt;choices_split;
	$this-&gt;question-&gt;template-&gt;i18n(1);
	
	my $iter = $list_store-&gt;get_iter_first();
	for (my $i=0; $i &lt;= $#choices; $i++) {
		if ($list_store-&gt;get($iter, SELECTED_COLUMN)) {
			push @vals, $choices[$i];
		}
		$list_store-&gt;iter_next($iter) or last;
	}

	return join(', ', $this-&gt;order_values(@vals));
}

*visible = \&amp;Debconf::Element::Multiselect::visible;


1
</pre></body></html>