From 928857551788a8c9ea698cb09c3d50010e8a5c02 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Fri, 1 Nov 2013 00:47:46 +0100 Subject: split menu closures as real functions (needed for next commit) --- perl-install/standalone/harddrake2 | 95 ++++++++++++++++++++++---------------- 1 file changed, 55 insertions(+), 40 deletions(-) (limited to 'perl-install/standalone/harddrake2') diff --git a/perl-install/standalone/harddrake2 b/perl-install/standalone/harddrake2 index 03c86c759..ac10bc3a1 100755 --- a/perl-install/standalone/harddrake2 +++ b/perl-install/standalone/harddrake2 @@ -196,52 +196,18 @@ my @menu_items = ( [ N("/_File"), undef, undef, undef, '' ], [ N("/_File") . N("/_Quit"), N("Q"), \&quit_global, undef, '' ], - [ join('', @{$menu_options{MODEMS_DETECTION}}), undef, - sub { $options{MODEMS_DETECTION} = $check_boxes{MODEMS_DETECTION}->get_active }, undef, '' ], - [ join('', @{$menu_options{PARALLEL_ZIP_DETECTION}}), undef, - sub { $options{PARALLEL_ZIP_DETECTION} = $check_boxes{PARALLEL_ZIP_DETECTION}->get_active }, undef, '' ], + [ join('', @{$menu_options{MODEMS_DETECTION}}), undef, \&handle_modem_option, undef, '' ], + [ join('', @{$menu_options{PARALLEL_ZIP_DETECTION}}), undef, \&handle_zip_option, undef, '' ], [ $menus{help}, undef, undef, undef, '' ], if_(-x "/usr/sbin/drakhelp_inst", - [ $menus{help} . N("/_Help"), undef, sub { run_program::raw({ detach => 1 }, 'drakhelp', '--id', 'harddrake') }, undef, '' ], + [ $menus{help} . N("/_Help"), undef, \&run_help, undef, '' ], ), - [ $menus{help} . N("/_Fields description"), undef, sub { - if ($current_device) { - create_dialog(N("Harddrake help"), - '' . N("Description of the fields:\n\n") . '' - . join("\n\n", map { - my $info = lookup_field($_); - if_($info->[0], formatAlaTeX(qq($info->[0]: $info->[1]))); - } sort keys %$current_device), - { use_markup => 1, transient => $w->{real_window}, height => 400, scroll => 1 }); - - } else { - create_dialog(N("Select a device!"), N("Once you've selected a device, you'll be able to see the device information in fields displayed on the right frame (\"Information\")"), { transient => $w->{real_window} }); - } - }, - undef, '' + [ $menus{help} . N("/_Fields description"), undef, \&fields_help, undef, '' ], if_(!-e "/etc/sysconfig/oem", - [ $menus{help} . N("/_Report Bug"), undef, sub { run_program::raw({ detach => 1 }, 'drakbug', '--report', 'harddrake') }, undef, '' ], + [ $menus{help} . N("/_Report Bug"), undef, \&run_drakbug, undef, '' ], ), - [ $menus{help} . N("/_About..."), undef, sub { - my $license = formatAlaTeX(translate($::license)); - $license =~ s/\n/\n\n/sg; # nicer formatting - my $w = gtknew('AboutDialog', name => N("Harddrake"), - version => mageia_release_info()->{version}, - copyright => N("Copyright (C) %s by %s", '2001-2008', 'Mandriva') . "\n" . N("Copyright (C) %s by %s", '2011', N("Mageia")), - license => $license, wrap_license => 1, - comments => N("This is HardDrake, a %s hardware configuration tool.", $distro_name), - website => 'http://www.mageia.org', - website_label => N("Mageia"), - authors => 'Thierry Vignaud ', - translator_credits => - #-PO: put here name(s) and email(s) of translator(s) (eg: "John Smith ") - N("_: Translator(s) name(s) & email(s)\n"), - transient_for => $::main_window, modal => 1, position_policy => 'center-on-parent', - ); - $w->show_all; - $w->run; - }, undef, '' + [ $menus{help} . N("/_About..."), undef, \&about, undef, '' ] ); @@ -539,6 +505,39 @@ fill_default_text($text); $w->main; +sub about() { + my $license = formatAlaTeX(translate($::license)); + $license =~ s/\n/\n\n/sg; # nicer formatting + my $w = gtknew('AboutDialog', name => N("Harddrake"), + version => mageia_release_info()->{version}, + copyright => N("Copyright (C) %s by %s", '2001-2008', 'Mandriva') . "\n" . N("Copyright (C) %s by %s", '2011', N("Mageia")), + license => $license, wrap_license => 1, + comments => N("This is HardDrake, a %s hardware configuration tool.", $distro_name), + website => 'http://www.mageia.org', + website_label => N("Mageia"), + authors => 'Thierry Vignaud ', + translator_credits => + #-PO: put here name(s) and email(s) of translator(s) (eg: "John Smith ") + N("_: Translator(s) name(s) & email(s)\n"), + transient_for => $::main_window, modal => 1, position_policy => 'center-on-parent', + ); + $w->show_all; + $w->run; +} + +sub fields_help() { + if ($current_device) { + create_dialog(N("Harddrake help"), + '' . N("Description of the fields:\n\n") . '' + . join("\n\n", map { + my $info = lookup_field($_); + if_($info->[0], formatAlaTeX(qq($info->[0]: $info->[1]))); + } sort keys %$current_device), + { use_markup => 1, transient => $w->{real_window}, height => 400, scroll => 1 }); + } else { + create_dialog(N("Select a device!"), N("Once you've selected a device, you'll be able to see the device information in fields displayed on the right frame (\"Information\")"), { transient => $w->{real_window} }); + } +} sub quit_global() { kill(15, $pid) if $pid; @@ -546,6 +545,22 @@ sub quit_global() { ugtk3->exit(0); } +sub run_drakbug() { + run_program::raw({ detach => 1 }, 'drakbug', '--report', 'harddrake'); +} + +sub run_help() { + run_program::raw({ detach => 1 }, 'drakhelp', '--id', 'harddrake'); +} + +sub handle_modem_option() { + $options{MODEMS_DETECTION} = $check_boxes{MODEMS_DETECTION}->get_active; +} + +sub handle_zip_option() { + $options{PARALLEL_ZIP_DETECTION} = $check_boxes{PARALLEL_ZIP_DETECTION}->get_active; +} + sub show_hide { my ($bool, $button) = @_; if ($bool) { $button->show } else { $button->hide } -- cgit v1.2.1