diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2005-03-01 19:26:38 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2005-03-01 19:26:38 +0000 |
commit | c2bd330e059813721e30818f76079185f06c7242 (patch) | |
tree | 34aa2d8fcaaba06134739d2f805f87da006c70f9 | |
parent | f63da47a9c45ebc931441c36c530e7db03386fd4 (diff) | |
download | drakx-c2bd330e059813721e30818f76079185f06c7242.tar drakx-c2bd330e059813721e30818f76079185f06c7242.tar.gz drakx-c2bd330e059813721e30818f76079185f06c7242.tar.bz2 drakx-c2bd330e059813721e30818f76079185f06c7242.tar.xz drakx-c2bd330e059813721e30818f76079185f06c7242.zip |
- handle {list_ref} in ComboBox
- handle more than one {ref} per widget
- check that the string value of the ref doesn't change when it is set
(maybe we should remove the REF or SCALAR prefix?)
-rw-r--r-- | perl-install/mygtk2.pm | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/perl-install/mygtk2.pm b/perl-install/mygtk2.pm index e45994098..6657c8acc 100644 --- a/perl-install/mygtk2.pm +++ b/perl-install/mygtk2.pm @@ -74,7 +74,7 @@ my %refs; sub gtkval_register { my ($w, $ref, $sub) = @_; - $w->{_ref} = $ref; + push @{$w->{_ref}}, $ref; $w->signal_connect(destroy => sub { delete $refs{$ref}{$w}; delete $refs{$ref} if !%{$refs{$ref}}; @@ -83,7 +83,11 @@ sub gtkval_register { } sub gtkval_modify { my ($ref, $val, @to_skip) = @_; + my $prev = "$ref"; $$ref = $val; + if ($prev ne "$ref") { + internal_error(); + } foreach (map { @$_ } values %{$refs{$ref} || {}}) { my ($f, @para) = @$_; $f->(@para) if !member($f, @to_skip); @@ -327,10 +331,22 @@ sub _gtk__ComboBox { $w->{format} = delete $opts->{format} if exists $opts->{format}; } - if (exists $opts->{list}) { - $w->{list} = delete $opts->{list}; + my $set_list = sub { $w->{formatted_list} = $w->{format} ? [ map { $w->{format}($_) } @{$w->{list}} ] : $w->{list}; + $w->get_model->clear; $w->append_text($_) foreach @{$w->{formatted_list}}; + }; + if (my $list_ref = delete $opts->{list_ref}) { + !$opts->{list} or internal_error("both list and list_ref"); + my $set = sub { + $w->{list} = $$list_ref; + $set_list->(); + }; + gtkval_register($w, $list_ref, $set); + $set->(); + } elsif (exists $opts->{list}) { + $w->{list} = delete $opts->{list}; + $set_list->(); } if ($action eq 'gtknew') { |