From d63fffd3016890fc0a9efae340df6d0c5ee20ba1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Victor=20Duarte=20Martins?= Date: Thu, 27 May 2010 21:54:42 +0000 Subject: * mdkapplet_gui.pm (open_ask_powerpack_dialog): Modified to offer default options according to product and use radio buttons. * mdkapplet_gui.pm (run_ask_credentials_dialog): Added options to enhance the dialog and a package var (pwp_ad) to hold powerpack advertisement widgets. --- mdkapplet_gui.pm | 92 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 69 insertions(+), 23 deletions(-) diff --git a/mdkapplet_gui.pm b/mdkapplet_gui.pm index 4e292ee3..94f4b84d 100644 --- a/mdkapplet_gui.pm +++ b/mdkapplet_gui.pm @@ -42,6 +42,7 @@ our @EXPORT = qw( ); our @EXPORT_OK = qw( + $powerpack_ad run_ask_credentials_dialog run_no_rights_dialog open_ask_powerpack_dialog @@ -80,6 +81,35 @@ our @common = ( width => $width - 50, ); +# List of widgets advertising Powerpack +our $powerpack_ad = [ + gtknew('Label_Left', + text => N('Mandriva Powerpack brings you the best of Linux ' . + 'experience for desktop: stability and efficiency ' . + 'of open source solutions together with exclusive ' . + 'softwares and Mandriva official support.'), + @common), + gtknew('HButtonBox', + layout => 'center', + children_tight => [ + new_link_button( + 'http://www2.mandriva.com/linux/features/', + N("Mandriva Linux Features") + ) + ]), + gtknew('Label_Left', + text => 'You can order now access for Powerpack', + ), + gtknew('HButtonBox', + layout => 'center', + children_tight => [ + new_link_button( + 'http://store.mandriva.com/pwp/', + N("Online subscription") + ) + ]), +]; + sub new_portable_dialog { my ($title) = @_; ugtk2->new($title, width => $width + 20); @@ -145,8 +175,12 @@ sub iso8601_date_to_locale { POSIX::strftime("%x", 0, 0, 0, $3, $2-1, $1-1900); } +# %options keys: +# +# 'top_extra': reference to a list of widgets to shown on top of dialog. +# sub run_ask_credentials_dialog { - my ($title, $description, $callback) = @_; + my ($title, $description, $callback, %options) = @_; my $w = new_portable_dialog($title); my $password_text; @@ -166,6 +200,10 @@ sub run_ask_credentials_dialog { my @widgets = ( mdkonline::get_banner($title), + if_($options{top_extra}, + @{ $options{top_extra} }, + gtknew('HSeparator'), + ), gtknew('Label_Left', text => $description, @common), @@ -234,32 +272,40 @@ sub run_no_rights_dialog { fill_n_run_portable_dialog($w, \@widgets); } +# Returns a string of user's choice: 'powerpack' or 'free'. sub open_ask_powerpack_dialog { + my ($product, $new_version) = @_; + + # Setup radio buttons... + + my %radio_str = ( + free => N("Upgrade to Mandriva Linux Free %s", $new_version), + powerpack => N("Upgrade to Mandriva Powerpack %s", $new_version), + ); + my @radio_order = $product !~ /powerpack|flash/i + ? ('free', 'powerpack') : ('powerpack', 'free'); + my @radios = gtkradio('', map { $radio_str{$_} } @radio_order); + + + # Setup dialog widgets... - my $title = N("Would you like Powerpack?"); + my $title = N("Choose your upgrade version"); my $w = new_portable_dialog($title); my @widgets = ( - mdkonline::get_banner($title), - gtknew('Label_Left', - text => N("Since you don't have Powerpack rights you may visit mandriva store now and get Powerpack subscription."), - @common), - gtknew('HButtonBox', - layout => 'start', - children_tight => [ - interactive::gtk::add_padding( - new_link_button( - 'http://store.mandriva.com/', - N("Get Powerpack subscription!") - ) - ) - ]), - gtknew('Label_Left', - text => N("Continue to use your new Powerpack account information to upgrade, or Cancel and upgrade to the Free Edition."), - @common), + mdkonline::get_banner($product =~ /powerpack/i + ? N("Your Powerpack access has ended") + : $title), + gtknew('Label_Left', + text => N("You can now") . "\n", + @common), + @radios, ugtk2::create_okcancel($w, - N("Continue and Authenticate!"), - N("Cancel, upgrade to Free Edition")), - ); + N("Next"), + N("Cancel, don't upgrade now")), + ); - return fill_n_run_portable_dialog($w, \@widgets); + fill_n_run_portable_dialog($w, \@widgets) or return undef; + for (my $i = 0; $i < @radios; $i++) { + return $radio_order[$i] if $radios[$i]->get_active(); + } } -- cgit v1.2.1