diff options
author | Olivier Blin <oblin@mandriva.org> | 2005-07-15 05:52:00 +0000 |
---|---|---|
committer | Olivier Blin <oblin@mandriva.org> | 2005-07-15 05:52:00 +0000 |
commit | 0e6da53df283769f71cd25ce77d40ec2dd189ccc (patch) | |
tree | fd9354036e6b55e8153c9518070bfdd9c738432a /perl-install/standalone | |
parent | ef917dd0683bc51e6d8d9628f8476aa54d1e2b01 (diff) | |
download | drakx-0e6da53df283769f71cd25ce77d40ec2dd189ccc.tar drakx-0e6da53df283769f71cd25ce77d40ec2dd189ccc.tar.gz drakx-0e6da53df283769f71cd25ce77d40ec2dd189ccc.tar.bz2 drakx-0e6da53df283769f71cd25ce77d40ec2dd189ccc.tar.xz drakx-0e6da53df283769f71cd25ce77d40ec2dd189ccc.zip |
don't add submenu if only one choice exists (and really do it)
Diffstat (limited to 'perl-install/standalone')
-rw-r--r-- | perl-install/standalone/net_applet | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/perl-install/standalone/net_applet b/perl-install/standalone/net_applet index 601201ecf..d90f90735 100644 --- a/perl-install/standalone/net_applet +++ b/perl-install/standalone/net_applet @@ -216,19 +216,22 @@ sub generate_menu { my ($action) = @_; my $name = ref($actions{$action}{name}) eq 'CODE' ? $actions{$action}{name}->($interface) : $actions{$action}{name}; my $launch = $actions{$action}{launch}; - my @choices = exists $actions{$action}{choices} && $actions{$action}{choices}->(); - if (@choices > 1) { + my @choices = exists $actions{$action}{choices} ? $actions{$action}{choices}->() : (); + my $w; + if (@choices == 0) { + $w = gtksignal_connect(gtkshow(Gtk2::MenuItem->new_with_label($name)), activate => sub { $launch->($interface) }); + } elsif (@choices > 1) { my $selected = $actions{$action}{choice_selected}; - gtkshow(create_menu($name, map { + $w = gtkshow(create_menu($name, map { my $choice = $_; my $w = gtkshow(gtkset_active(Gtk2::CheckMenuItem->new_with_label($choice), $selected->($choice))); gtksignal_connect($w, activate => sub { $launch->($choice) }); $w->set_draw_as_radio(1); $w; } $actions{$action}{choices}->())); - } else { - gtksignal_connect(gtkshow(Gtk2::MenuItem->new_with_label($name)), activate => sub { $launch->($interface) }); } + #- don't add submenu if only one choice exists + $w; }; my (@settings, @actions); @@ -266,7 +269,7 @@ sub generate_menu { $menu->append($_) foreach @actions; $menu->append(gtkshow(Gtk2::SeparatorMenuItem->new)); } - $menu->append(gtkshow(create_menu(N("Settings"), @settings))); + $menu->append(gtkshow(create_menu(N("Settings"), grep { $_ } @settings))); $menu->append(gtkshow(Gtk2::SeparatorMenuItem->new)); $menu->append($create_item->('help')); $menu->append($create_item->('quit')); |