From 8c847f02b2ff79db0f8ecc0a3041d964f0658c37 Mon Sep 17 00:00:00 2001 From: Pascal Rigaux Date: Sun, 16 Feb 2003 20:22:24 +0000 Subject: - factorize "Help"-button handling - fix interactive_help_get_id (happily, it was no pb :) --- perl-install/Xconfig/resolution_and_depth.pm | 7 ++----- perl-install/diskdrake/hd_gtk.pm | 2 +- perl-install/install_interactive.pm | 2 +- perl-install/install_steps_gtk.pm | 2 +- perl-install/interactive.pm | 24 ++++++++++++++++++++---- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/perl-install/Xconfig/resolution_and_depth.pm b/perl-install/Xconfig/resolution_and_depth.pm index 0efdc6671..b84b5731e 100644 --- a/perl-install/Xconfig/resolution_and_depth.pm +++ b/perl-install/Xconfig/resolution_and_depth.pm @@ -253,6 +253,7 @@ sub choose_gtk { }; $set_chosen_x_res->($chosen_x_res, $chosen_y_res); + my $help_sub = $in->interactive_help_sub_display_id('configureX_resolution'); gtkadd($W->{window}, gtkpack_($W->create_box_with_title(N("Choose the resolution and the color depth"), if_($card->{BoardName}, "(" . N("Graphics card: %s", $card->{BoardName}) . ")"), @@ -268,11 +269,7 @@ sub choose_gtk { ), ), ), - 0, gtkadd($W->create_okcancel(N("Ok"), N("Cancel"), '', - [ N("Help"), sub { - my $message = $in->interactive_help_get_id('configureX_resolution') or return; - $in->ask_warn(N("Help"), $message); - }, 1 ])), + 0, gtkadd($W->create_okcancel(N("Ok"), N("Cancel"), '', if_($help_sub, [ N("Help"), $help_sub, 1 ]))), )); $depth_combo->disable_activate; $depth_combo->set_use_arrows_always(1); diff --git a/perl-install/diskdrake/hd_gtk.pm b/perl-install/diskdrake/hd_gtk.pm index 0ee38fc49..804c57f8c 100644 --- a/perl-install/diskdrake/hd_gtk.pm +++ b/perl-install/diskdrake/hd_gtk.pm @@ -154,7 +154,7 @@ sub general_action_box { my ($box, $nowizard, $interactive_help) = @_; $_->widget->destroy foreach $box->children; - gtkadd($box, gtksignal_connect(Gtk2::Button->new(N("Help")), clicked => sub { $in->ask_warn(N("Help"), $interactive_help->()) })) if $interactive_help; + gtkadd($box, gtksignal_connect(Gtk2::Button->new(N("Help")), clicked => $interactive_help->())) if $interactive_help; my @actions = (if_($::isInstall && !$nowizard, N_("Wizard")), diskdrake::interactive::general_possible_actions($in, $all_hds), diff --git a/perl-install/install_interactive.pm b/perl-install/install_interactive.pm index f543b502d..7ec90b709 100644 --- a/perl-install/install_interactive.pm +++ b/perl-install/install_interactive.pm @@ -49,7 +49,7 @@ sub partition_with_diskdrake { require diskdrake::interactive; { local $::expert = $::expert; - diskdrake::interactive::main($o, $all_hds, $nowizard, $do_force_reload, sub { $o->interactive_help_get_id('partition_with_diskdrake') }); + diskdrake::interactive::main($o, $all_hds, $nowizard, $do_force_reload, $o->interactive_help_sub_display_id('partition_with_diskdrake')); } if (delete $o->{wizard}) { partitionWizard($o, 'nodiskdrake') or redo; diff --git a/perl-install/install_steps_gtk.pm b/perl-install/install_steps_gtk.pm index bd90b37a5..8aee1b171 100644 --- a/perl-install/install_steps_gtk.pm +++ b/perl-install/install_steps_gtk.pm @@ -260,7 +260,7 @@ sub reallyChooseGroups { )), 1, '', 0, gtkadd(Gtk2::HBox->new(0, 0), - gtksignal_connect(Gtk2::Button->new(N("Help")), clicked => sub { $o->ask_warn(N("Help"), $o->interactive_help_get_id('choosePackages')) }), + gtksignal_connect(Gtk2::Button->new(N("Help")), clicked => $o->interactive_help_sub_display_id('choosePackages')), $w_size, if_($individual, do { my $check = Gtk2::CheckButton->new(N("Individual package selection")); diff --git a/perl-install/interactive.pm b/perl-install/interactive.pm index 2af88092a..d9c4b2f3b 100644 --- a/perl-install/interactive.pm +++ b/perl-install/interactive.pm @@ -364,7 +364,7 @@ sub ask_from_normalize { ($common->{title} = $0) =~ s|.*/||; } $common->{interactive_help} ||= $o->{interactive_help}; - $common->{interactive_help} ||= $common->{interactive_help_id} && sub { $o->interactive_help_get_id($common->{interactive_help_id}) }; + $common->{interactive_help} ||= $common->{interactive_help_id} && $o->interactive_help_sub_get_id($common->{interactive_help_id}); $common->{advanced_label} ||= N("Advanced"); $common->{advanced_label_close} ||= N("Basic"); $common->{$_} = [ deref($common->{$_}) ] foreach qw(messages advanced_messages); @@ -394,7 +394,7 @@ sub ask_from_real { sub ask_browse_tree_info { my ($o, $title, $message, $common) = @_; - $common->{interactive_help} ||= $common->{interactive_help_id} && sub { $o->interactive_help_get_id($common->{interactive_help_id}) }; + $common->{interactive_help} ||= $common->{interactive_help_id} && $o->interactive_help_sub_get_id($common->{interactive_help_id}); add2hash_($common, { ok => $::isWizard ? ($::Wizard_finished ? N("Finish") : N("Next ->")) : N("Ok"), cancel => $::isWizard ? N("<- Previous") : N("Cancel") }); add2hash_($common, { title => $title, message => $message }); @@ -470,11 +470,27 @@ sub helper_separator_tree_to_tree { } +sub interactive_help_has_id { + my ($_o, $id) = @_; + exists $help::steps{$id}; +} + sub interactive_help_get_id { - my @l = map { + my ($_o, @l) = @_; + @l = map { join("\n\n", map { s/\n/ /mg; $_ } split("\n\n", translate($help::steps{$_}))) - } grep { exists $help::steps{$_} } @_; + } grep { exists $help::steps{$_} } @l; join("\n\n\n", @l); } +sub interactive_help_sub_get_id { + my ($o, $id) = @_; + $o->interactive_help_has_id($id) && sub { $o->interactive_help_get_id($id) }; +} + +sub interactive_help_sub_display_id { + my ($o, $id) = @_; + $o->interactive_help_has_id($id) && sub { $o->ask_warn(N("Help"), $o->interactive_help_get_id($id)) }; +} + 1; -- cgit v1.2.1