[Debconf-devel] Usability improvement of Gnome Multiselect
Danilo Piazzalunga
danilopiazza@libero.it
Sun, 6 Feb 2005 22:29:54 +0100
--Boundary-00=_SxoBC3bBlcEeRkU
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Hello,
I've been using the Gnome frontend for a while. Every dialog is pleasent
and usable, except the Multiselect: compared to the checked list
provided by the Dialog frontend, it is rather unusable(*).
So I've tweaked the Multiselect module and now the selection can be
performed with a checkbox, like you do with the Dialog frontend or with
gdialog/zenity applications.
The attached patch (agains current SVN) contains a working implementation,
succesfully tested with the invaluable 'make demo'.
Best Regards,
Danilo
(*) For an example, try reconfiguring the locales package.
--
Danilo Piazzalunga +--------------------+
PGP Key available at subkeys.pgp.net | Linux User #245762 |
Fingerprint: D018 815E 8C7F 2AE2 5565 | ICQ #105550412 |
0C36 B5F6 DB20 B800 CB9F +--------------------+
--Boundary-00=_SxoBC3bBlcEeRkU
Content-Type: text/x-diff;
charset="us-ascii";
name="debconf-gnome-multiselect.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="debconf-gnome-multiselect.diff"
Index: Debconf/Element/Gnome/Multiselect.pm
===================================================================
--- Debconf/Element/Gnome/Multiselect.pm (revision 1726)
+++ Debconf/Element/Gnome/Multiselect.pm (working copy)
@@ -13,6 +13,13 @@
use Debconf::Encoding qw(to_Unicode);
use base qw(Debconf::Element::Gnome Debconf::Element::Multiselect);
+use constant FALSE => 0;
+use constant TRUE => 1;
+
+use constant SELECTED_COLUMN => 0;
+use constant CHOICES_COLUMN => 1;
+use constant NUM_COLUMNS => 2;
+
sub init {
my $this=shift;
my @choices = map { to_Unicode($_) } $this->question->choices_split;
@@ -27,25 +34,37 @@
$this->widget->show;
$this->widget->set_policy('automatic', 'automatic');
- my $list_store = Gtk2::ListStore->new ('Glib::String');
-
- my $column = Gtk2::TreeViewColumn->new_with_attributes ('Choices',
- Gtk2::CellRendererText->new,
- 'text', 0);
+ my $list_store = Gtk2::ListStore->new ('Glib::Boolean', 'Glib::String');
$this->list_view(Gtk2::TreeView->new ($list_store));
- my $list_selection = $this->list_view->get_selection ();
- $list_selection->set_mode ('multiple');
$this->list_view->set_headers_visible (0);
- $this->list_view->append_column ($column);
+
+ my $renderer_toggle = Gtk2::CellRendererToggle->new;
+ $renderer_toggle->signal_connect (toggled => sub {
+ my $path_string = $_[1];
+ my $model = $_[2];
+ my $iter = $model->get_iter_from_string ($path_string);
+ $model->set ($iter,
+ SELECTED_COLUMN,
+ not $model->get ($iter, SELECTED_COLUMN));
+ }, $list_store);
+
+ $this->list_view->append_column (
+ Gtk2::TreeViewColumn->new_with_attributes ('Selected',
+ $renderer_toggle,
+ 'active', SELECTED_COLUMN));
+ $this->list_view->append_column (
+ Gtk2::TreeViewColumn->new_with_attributes ('Choices',
+ Gtk2::CellRendererText->new,
+ 'text', CHOICES_COLUMN));
$this->list_view->show;
$this->widget->add ($this->list_view);
for (my $i=0; $i <= $#choices; $i++) {
my $iter = $list_store->append ();
- $list_store->set ($iter, 0, $choices[$i]);
+ $list_store->set ($iter, CHOICES_COLUMN, $choices[$i]);
if ($default{$choices[$i]}) {
- $list_selection->select_iter ($iter);
+ $list_store->set ($iter, SELECTED_COLUMN, TRUE);
}
}
$this->addwidget($this->widget);
@@ -69,7 +88,6 @@
my $this=shift;
my $list_view = $this->list_view;
my $list_store = $list_view->get_model ();
- my $list_selection = $list_view->get_selection ();
my ($ret, $val);
my @vals;
@@ -80,7 +98,7 @@
my $iter = $list_store->get_iter_first ();
for (my $i=0; $i <= $#choices; $i++) {
- if ($list_selection->iter_is_selected ($iter)) {
+ if ($list_store->get ($iter, SELECTED_COLUMN)) {
push @vals, $choices[$i];
}
$iter = $list_store->iter_next ($iter);
--Boundary-00=_SxoBC3bBlcEeRkU--