diff options
author | Thierry Vignaud <tvignaud@mandriva.org> | 2004-05-24 07:12:46 +0000 |
---|---|---|
committer | Thierry Vignaud <tvignaud@mandriva.org> | 2004-05-24 07:12:46 +0000 |
commit | d11f237e444317576ab860e527e963446a214db4 (patch) | |
tree | 603935a99b5ac6ad8691c3f3fdcc2a9e0ca68a8b /perl-install | |
parent | d7fa5f19fa02b41e49c8138a0f9934ba1b8b5d5f (diff) | |
download | drakx-d11f237e444317576ab860e527e963446a214db4.tar drakx-d11f237e444317576ab860e527e963446a214db4.tar.gz drakx-d11f237e444317576ab860e527e963446a214db4.tar.bz2 drakx-d11f237e444317576ab860e527e963446a214db4.tar.xz drakx-d11f237e444317576ab860e527e963446a214db4.zip |
still provide compat stuff for OptionMenu (#9826) until all tools are
converted
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/ugtk2.pm | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/perl-install/ugtk2.pm b/perl-install/ugtk2.pm index 3fc237712..17b9e8dd6 100644 --- a/perl-install/ugtk2.pm +++ b/perl-install/ugtk2.pm @@ -1565,8 +1565,48 @@ sub toggle_expansion { # compatible with Combo since its API is quite nice. package Gtk2::OptionMenu; +use common; + +# try to get combox <==> option menu mapping +sub set_popdown_strings { + my ($w, @strs) = @_; + my $menu = Gtk2::Menu->new; + # keep string list around for ->set_text compatibilty helper + $w->{strings} = \@strs; + #$w->set_menu((ugtk2::create_factory_menu($window, [ "File", (undef) x 3, '<Branch>' ], map { [ "File/" . $_, (undef) x 3, '<Item>' ] } @strs))[0]); + $menu->append(ugtk2::gtkshow(Gtk2::MenuItem->new_with_label($_))) foreach @strs; + $w->set_menu($menu); + $w +} + +sub new_with_strings { + my ($class, $strs, $o_val) = @_; + my $w = $class->new; + $w->set_popdown_strings(@$strs); + $w->set_text($o_val) if $o_val; + $w; +} + +sub entry { + my ($w) = @_; + return $w; +} + +sub get_text { + my ($w) = @_; + $w->{strings}[$w->get_history]; +} + +sub set_text { + my ($w, $val) = @_; + each_index { + if ($_ eq $val) { + $w->set_history($::i); + return; + } + } @{$w->{strings}}; +} -sub new { Gtk2::ComboBox->new_text } |