From acac1046f6dfe01daa6090a976d61f500dd8e643 Mon Sep 17 00:00:00 2001 From: Daouda Lo Date: Mon, 17 Feb 2003 16:09:50 +0000 Subject: - new club subscription --- mdkonline | 663 +------------------------------------------------------------- 1 file changed, 2 insertions(+), 661 deletions(-) diff --git a/mdkonline b/mdkonline index 5f903a7f..3e1c0794 100755 --- a/mdkonline +++ b/mdkonline @@ -1,668 +1,9 @@ #!/usr/bin/perl -################################################################################ -# MandrakeOnline # -# # -# Copyright (C) 2001-2002 MandrakeSoft # -# -# Daouda Lo # -# # -# This program is free software; you can redistribute it and/or modify # -# it under the terms of the GNU General Public License Version 2 as # -# published by the Free Software Foundation. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU General Public License for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with this program; if not, write to the Free Software # -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -################################################################################ -use POSIX; -use Gtk; use lib qw(/usr/lib/libDrakX); use interactive; -use Config; -init Gtk; -Gtk->set_locale; -use MDK::Common; -use Digest::MD5 qw(md5 md5_hex md5_base64); -use HTTP::Request; -use HTTP::Request::Common; -use Net::HTTPS; #for https connections -use LWP::UserAgent; -use MIME::Base64 qw(encode_base64); -use Sys::Hostname; -use my_gtk qw(:helpers :wrappers :ask); - -my $VERSION = '0.17'; - -$::isStandalone = 1; +use drakfirsttime::gui; my $in = 'interactive'->vnew('su', 'default'); -#------------------------------------------------------------- -# i18n routines -# IMPORTANT: next two routines have to be redefined here to -# get correct namespace (mdkonline instead of libDrakX) -# (This version is now UTF8 compliant - Sg 2001-08-31) -#------------------------------------------------------------- - -sub _ { - my $s = shift @_; my $t = translate($s); - sprintf $t, @_; -} - -sub translate { - my ($s) = @_; - $s ? c::dgettext('mdkonline', $s) : ''; -} - -#my $authentication_host = "http://www.mandrakeexpert.com/firsttimewizard/validusercheck.php"; -my $nb_pages=6; # 0 to 5 -my $page=-1; -my $xpm_path="/usr/share/mdkonline/pixmaps"; -my $sharepath="/usr/share/mdkonline"; -my $path_to_welcome="/usr/share/doc/HTML/welcome.html"; -my $link_to_mdkonline="http://www.mandrakeexpert.com/index2.php"; -my $check_custid=0; -my $true=1; -my $false=0; -my %locations = ( _("Africa") => ['ftp.univie.ac.at/systems/linux/Mandrake/updates','ftp.lip6.fr/pub/linux/distributions/mandrake/updates'], - _("Asia") => ['ftp.surfnet.nl/pub/os/Linux/distr/Mandrake/Mandrake/updates','ftp.sunet.se/pub/Linux/distributions/mandrake/updates'], - _("Australia") => ['ftp-linux.cc.gatech.edu/pub/linux/distributions/mandrake/updates','mandrake.redbox.cz/Mandrake/updates'], - _("Europe") => ['ftp.club-internet.fr/pub/unix/linux/distributions/Mandrake/updates','ftp.gwdg.de/pub/linux/mandrake/updates'], - _("North America") =>['mandrake.secsup.org/pub/linux/mandrake/Mandrake/updates','ftp.sunet.se/pub/Linux/distributions/mandrake/updates/'], - _("South America") => ['ftp.sunet.se/pub/Linux/distributions/mandrake/updates','ftp.club-internet.fr/pub/unix/linux/distributions/Mandrake/updates'], - ); -require Gtk; -require Gtk::Gdk::ImlibImage; - -#init Gtk; -#Gtk->set_locale; -Gtk::Gdk::ImlibImage->init; - -my $Main_Window = new Gtk::Window -toplevel; -$Main_Window->set_policy($false,$false,$true); -$Main_Window->set_position( 1 ); -$Main_Window->border_width( 5 ); -# For translators : the MandrakeOnline (in one world) should not be translated. -$Main_Window->set_title("MandrakeOnline"); -$Main_Window->set_usize(540, 430); -$Main_Window->realize(); -$Main_Window->signal_connect( "delete_event", \>k_main_quit); - -my $Step_Label = new Gtk::Label(" 1/".$nb_pages." "); -my $Button_Next = new Gtk::Button(" " . _("Next") . " 2/".$nb_pages." > "); -my $Button_End = new Gtk::Button(" " . _("Finish") . " "); -my $Button_SkipWiz = new Gtk::Button(" " ._("Quit") . " "); -my $Button_Prev = new Gtk::Button(" < " . _("Back") . " "); -my $notebook_global = new Gtk::Notebook; -my $check_subs = new Gtk::CheckButton(_("I don't have a MandrakeOnline account and I want to ")); -my $button_subs = new Gtk::Button(" " . _("Subscribe") . " "); -$Button_End->show(); -$notebook_global->set_show_border($false); -$notebook_global->set_show_tabs($false); -$page=$notebook_global->get_current_page(); -my $vbox = new Gtk::VBox(0,0); -$Main_Window->add($vbox); -$vbox->pack_start($notebook_global,1,1,0); -$vbox->pack_start(new Gtk::HSeparator, 0, 0, 1); -my $hbox= new Gtk::HBox(0,5); -$vbox->pack_start($hbox, 0, 0, 1); -$hbox->pack_end($Button_Next, 0, 1, 0); -$hbox->pack_end($Step_Label, 0, 1, 0); -$hbox->pack_end($Button_Prev, 0, 1, 0); -$Button_SkipWiz->signal_connect( clicked => \&confirm_quit); -$hbox->pack_start($Button_SkipWiz, 0, 1, 0); -my $check_cron = new Gtk::CheckButton(_("Yes I want automated updates")); -my $gtkcombo_user = new Gtk::Combo(); -my $gtkcombo_mirror = new Gtk::Combo(); -my $login_user= new Gtk::Entry(); -my $passwd_user= new Gtk::Entry(); -my $box_user= new Gtk::Entry(); - -my $login = ""; -my $passwd = ""; -my $box_name = ""; -my $key = ""; - -my %actions = ( - 2 => \&test_passwd, - 3 => \&send_config, - 4 => \&send_config, - ); -my @no_back_button_pages = (0,3,4,5); - -$Button_Prev->set_sensitive(0); -init_ui(); -$Main_Window->show_all; - -Gtk->main_iteration while Gtk->events_pending; -Gtk->main; -Gtk->exit(0); -$in->exit(0); - -sub init_ui { - step_wizard(); - $Button_Next->signal_connect(clicked =>\&on_next_clicked); - $Button_Prev->signal_connect(clicked =>\&on_prev_clicked); - $Button_End->signal_connect(clicked =>\&on_end_clicked); -} - -sub gtk_main_quit { - - # remove local files - if ($login && $passwd) { - [ -f "/root/$login.$passwd.$box_name.online.log.bz2.uue" ] && unlink ("/root/$login.$passwd.$box_name.online.log.bz2.uue"); - [ -f "/root/$login.$passwd.$box_name.online.log.bz2" ] && unlink ("/root/$login.$passwd.$box_name.online.log.bz2"); - } - - # setting up the automated updates - if ($check_cron->get_active()) { - automated_upgrades(); - } - # quit - print _("Quitting Wizard\n"); - main_quit Gtk; -} - -sub isalphanum { - my ($str) = @_; - if ($str =~ /^[[:alnum:]]+$/) { - return 1; - } else { - return 0; - } -} - -sub on_end_clicked { - gtk_main_quit(); -} - -sub on_next_clicked { - $page=$notebook_global->get_current_page(); - -#---- 8<-----------to remove for page 5 test ----------- -# if ($page == 0) { -# $notebook_global->set_page(5); -# } -#-------------8<---------------------------------------- - - if ( $actions{$page} ) { - $actions{$page}->(); - } else { - $notebook_global->next_page(); - } - $page=$notebook_global->get_current_page(); - - # handle the back button state - $Button_Prev->set_sensitive(1); - foreach (@no_back_button_pages) { - /$page/ and $Button_Prev->set_sensitive(0), last; - } - - # change "Next" to "Finish" in the last page - if ($page == $nb_pages - 1) { - $hbox->remove($Button_Prev); - $hbox->remove($Step_Label); - $hbox->remove($Button_Next); - $hbox->pack_end($Button_End, 0, 1, 0); - $hbox->pack_end($Step_Label, 0, 1, 0); - $hbox->pack_end($Button_Prev, 0, 1, 0); - } - - # Update the buttons labels - $Button_Next->child->set(" "._("Next")." ".($page+2)."/".$nb_pages." > "); - $Button_Prev->child->set(" < ".$page."/".$nb_pages." "._("Back")." "); - $Step_Label->set(" ".($page+1)."/".$nb_pages." "); -} - -sub on_prev_clicked { - $page=$notebook_global->get_current_page(); - - # change "Finish" to "Next" if coming from the last page - if ($page == $nb_pages - 1) { - $hbox->remove($Button_Prev); - $hbox->remove($Button_End); - $hbox->pack_end($Button_Next, 0, 1, 0); - $hbox->pack_end($Button_Prev, 0, 1, 0); - } - - if ($page == 4) { - $notebook_global->set_page(2); # Alternatively, don't go back at all since passwd was correct - } elsif ($page == 6) { # Don't go back if informations were correctly sent (button should be deactivated) - - } else { - $notebook_global->prev_page(); - } - - $page=$notebook_global->get_current_page(); - - # handle the back button state - $Button_Prev->set_sensitive(1); - foreach (@no_back_button_pages) { - /$page/ and $Button_Prev->set_sensitive(0), last; - } - - # Update the buttons labels - $Button_Next->child->set(" "._("Next")." ".($page+2)."/".$nb_pages." > "); - if ($page > 0) { - $Button_Prev->child->set(" < ".$page."/".$nb_pages." "._("Back")." "); - } else { - $Button_Prev->child->set(" < "._("Back")." "); - } - $Step_Label->set(" ".($page+1)."/".$nb_pages." "); -} - -sub subscribe_mdkonline() { - my $browser=$ENV{'BROWSER'}; -# my $initial_user=$ENV{'INITIAL_USER'}; - my $user_current=$ENV{'USER'}; - - if (!$browser) {splash_warning( " ". _("Warning: No browser specified.") ." "); return;} - # if ($initial_user ne "root" && $initial_user ne undef) { - # system("su -m -l $initial_user -c \"$browser $link_to_mdkonline &\""); - # } else { - system("$browser $link_to_mdkonline &"); - - # } - $check_subs->set_active(0);$Button_Next->set_sensitive(1); $button_subs->set_sensitive(0); -} - -sub test_passwd () { - - my $current_page = shift; - my $result = -1; - - $login = $login_user->get_text(); - $passwd = $passwd_user->get_text(); - $box_name = $box_user->get_text(); - $test = isalphanum($box_name); - #print ("isalnum : $test"); - if ($login && $passwd && $test && $login !~ /\s+/ && $passwd !~ /\s+/) { -# NEW METHOD (http) - # first, MD5ify the password - $passwd = md5_hex ($passwd); # or md5 () or md5_base64 () - - my $ua = LWP::UserAgent->new; - $ua->agent("MdkOnlineAgent/$VERSION" . $ua->agent); - my $w = $in->wait_message('',_("Connecting...\n"),1); - my $request = HTTP::Request->new(GET => 'http://www.mandrakeexpert.com/firsttimewizard/validusercheck.php?u='.$login.'&p='.$passwd); - my $response = $ua->request($request); - # Check the outcome of the response - if ($response->is_success) { - $result = ($response->content =~ /TRUE/) ? 0 : -1; - } else { - # pb with the connection ? stay on page 2 - info_popup (_("Connection problem"), _("MandrakeOnline could not be contacted, please try again later.")); - return; - } - } else { - $result = -1; # not needed, but this way it's clear - } - - # if correct, go to page 4 - if (! $result) { - $notebook_global->next_page(); - } else { - # if incorrect, clear passwd and stay on page 2 - info_popup (_("Wrong password"), _("Your login or password was wrong.\n Either you'll have to type it again, or you'll need to create an account on MandrakeOnline.\n In the latter case, go back to the first step to connect to MandrakeOnline.\n Be aware that you must also provide a machine name \n (only alphabetical characters are admitted)")); - $passwd_user->set_text(""); - } -} - -sub send_config { - # When we arrive here, we're sure the login/passwd is correct -# print STDERR "Sending config\n"; - my $result = -1; - - report_config("/root/$login.$passwd.$box_name.online.log"); - `/usr/bin/bzip2 \\\-9 \\\-f /root/$login.$passwd.$box_name.online.log`; - - # Turn the binary file into a uuencoded ascii file - open (FILE, "/root/$login.$passwd.$box_name.online.log.bz2") or die "$!"; - my ($chunk, $buffer); - while (read(FILE, $chunk, 60*57)) { - $buffer .= $chunk; - } - close (FILE); - open (FILEOUT, "> /root/$login.$passwd.$box_name.online.log.bz2.uue") or die "$!"; - print FILEOUT encode_base64($buffer); - close (FILEOUT); - - my $ua = LWP::UserAgent->new; - $ua->agent("MdkOnlineAgent/$VERSION" . $ua->agent); - my $w = $in->wait_message('',"Sending configuration..."); - my $response = $ua->request(POST 'https://www.mandrakeonline.net/wizard.php', - - Content_Type => 'form-data', - Content => [submit => "upload_wizard", - wizard => ["/root/$login.$passwd.$box_name.online.log.bz2.uue"] - ]); - # Check the outcome of the response - #print "REPONSE: ".$response->content."\n"; - if ($response->is_success) { - $result = ($response->content =~ /^TRUE(.*)/) ? 0 : -1; - #print("key is $1\n"); - $key = $1; - } else { - # pb with the connection ? - $result = -1; - } - - # if informations were sent correctly (exit code: 0 from scp script), go to page 5 - if (! $result) { - #- added to allow .mdkupdate.rpms file creation. - open FILE, ">/root/.mdkupdate.rpms" or die "Couldn't open /root/.mdkupdate.rpms : $!"; - print FILE join ('', sort `rpm -qa`); - close FILE; - - # go to last page - $notebook_global->set_page(5); - } else { - # if incorrect, go/stay on page 4 to retry sending data - # pb with the connection ? - info_popup (_("Connection problem"), _("MandrakeOnline could not be contacted, please try again later.")); - $notebook_global->set_page(4); - } -} - -sub step_wizard { - - my $vbox_welc= new Gtk::VBox(0,0); - writ_on_pixmaps($vbox_welc,"default.png",_("Welcome to MandrakeOnline"),540,100); - my $label_welc = new Gtk::Label(_("At this step you are supposed to have an account on MandrakeOnline.\nThis assistant will help you to upload your configuration\n(packages, hardware configuration) to a centralized database in\norder to keep you informed about security updates and useful upgrades.\n")); - $label_welc->set_uposition(20,150); - $label_welc->set_justify('left'); - $vbox_welc->pack_start($label_welc,0,0,1); - my $hbox_subs= new Gtk::HBox(0,0); - $hbox_subs->set_uposition(50,300); - $vbox_welc->pack_start($hbox_subs,0,0,1); - $hbox_subs->pack_start($check_subs,0,0,1); - $button_subs->set_sensitive(0); - $check_subs->signal_connect (clicked => sub {$test_tog=$check_subs->get_active(); - $button_subs->set_sensitive($test_tog); - $Button_Next->set_sensitive(!$test_tog); }); - $button_subs->signal_connect('clicked' => \&subscribe_mdkonline); - $hbox_subs->pack_start($button_subs,0,0,1); - $notebook_global->append_page($vbox_welc,new Gtk::Label("welcome")); - - my $vbox_priv = new Gtk::VBox(0,0); - writ_on_pixmaps($vbox_priv,"default.png",_("Mandrake Privacy Policy"),540,100); - get_on_privacy($vbox_priv); - $notebook_global->append_page($vbox_priv,new Gtk::Label("club")); - - my $vbox_ident= new Gtk::VBox(0,0); - writ_on_pixmaps($vbox_ident,"default.png","MandrakeOnline"." "._("Authentication"),540,100); - my $label_log = new Gtk::Label("\n\n" . _("Enter your MandrakeOnline login, password and machine name:")); - $vbox_ident->pack_start($label_log,$false ,$false,1); - pack_box_identity($vbox_ident,_("Login:"),$login_user,_("Password:"),$passwd_user,_("Machine Name:"),$box_user); - set_boxname($box_user) if -e "/root/.mdkupdate"; - $notebook_global->append_page($vbox_ident,new Gtk::Label("login")); - - my $vbox_rev=new Gtk::VBox(0,0); - writ_on_pixmaps($vbox_rev,"default.png",_("Sending your Configuration"),540,100); - my $label_rev = new Gtk::Label(_("In order to benefit from MandrakeOnline services,\nwe are about to upload your configuration.\n\nThe Wizard will now send the following information to MandrakeSoft:\n1) the list of packages you have installed on your system,\n2) your hardware configuration.\n\nIf you feel uncomfortable with this idea, or do not want to benefit from this service,\nplease press 'Cancel'. By pressing 'Next', you allow us to keep you informed\nabout security updates and useful upgrades via personalized e-mail alerts.\nFurthermore, you benefit from discounted paid support services on\nwww.mandrakeexpert.com.\nFinally, an e-mail alias with your username\@mandrakeonline.net will be provided to you.")); - $label_rev->set_uposition(20,150); - $label_rev->set_justify('left'); - $vbox_rev->pack_start($label_rev,0,0,1); - $notebook_global->append_page($vbox_rev,new Gtk::Label("revision")); - - # building the "Error sending data" page - my $vbox_errorsend= new Gtk::VBox(0,0); - writ_on_pixmaps($vbox_errorsend,"default.png",_("Error while sending informations"),540,100); - my $label_errorsend = new Gtk::Label("\n\n" . _("There was an error while sending your personal informations.\n\nPress 'Next' to try and send your configuration again.")); - $vbox_errorsend->pack_start($label_errorsend,$false ,$false,1); - $notebook_global->append_page($vbox_errorsend,new Gtk::Label("errorsend")); - - # building the "OK data sent" page - my $vbox_oksend= new Gtk::VBox(0,0); - writ_on_pixmaps($vbox_oksend,"default.png",_("Finished"),540,100); - my $label_oksend = new Gtk::Label("\n\n" . _("Your upload was successful!") . "\n" . _("From now on you will receive security and update \nannouncements through MandrakeOnline.")."\n\n"._("MandrakeOnline offers you the ability to automate the updates.\nA program will run regulary on your system waiting for new updates\n")); - $label_oksend->set_justify('left'); - $vbox_oksend->pack_start($label_oksend,$true ,$true,1); - -#automated mode - my $frame_auto = new Gtk::Frame(_("Automated Upgrades")); - my $vbox_frame_auto = new Gtk::VBox(0,0); - $frame_auto->add($vbox_frame_auto); - $vbox_frame_auto->pack_start($check_cron,$false ,$false,1); - #$check_cron->set_uposition(70,245); - my $hboxfr1 = new Gtk::HBox(0,0); - my $hboxfr2 = new Gtk::HBox(0,0); - my $label_mirror = new Gtk::Label(_("Choose your geographical location")); - $hboxfr2->pack_start($label_mirror,$true ,$true,5); - $gtkcombo_mirror->set_popdown_strings('',sort(keys %locations)); - $hboxfr2->pack_end($gtkcombo_mirror,$true ,$true,5); - $hboxfr1->set_sensitive(0); - $hboxfr2->set_sensitive(0); - $check_cron->signal_connect (clicked => sub {my $test_cron=$check_cron->get_active(); - $hboxfr1->set_sensitive($test_cron); - $hboxfr2->set_sensitive($test_cron); }); - $vbox_frame_auto->pack_start($hboxfr1,$false ,$false,5); - $vbox_frame_auto->pack_start($hboxfr2,$false ,$false,5); - $vbox_oksend->pack_start($frame_auto, $true,$false,1); - $notebook_global->append_page($vbox_oksend,new Gtk::Label("oksend")); -} - -sub report_config { - my ($file) = @_; - #touch($file); - my $w = $in->wait_message('',_("Reading configuration\n"),1); -sub header { " -******************************************************************************** -* $_[0] -********************************************************************************"; - } -open (FILE,"> $file") || die "Couldn't open $file : $!"; -map { chomp; print FILE "$_\n" } - header("scsi"), cat_("/proc/scsi/scsi"), - header("lsmod"), cat_("/proc/modules"), - header("cmdline"), cat_("/proc/cmdline"), - header("pcmcia: stab"), cat_("$prefix/var/lib/pcmcia/stab") || cat_("$prefix/var/run/stab"), - header("usb"), cat_("/proc/bus/usb/devices"), - header("partitions"), cat_("/proc/partitions"), - header("cpuinfo"), cat_("/proc/cpuinfo"), - header("install.log"), cat_("$prefix/root/drakx/install.log"), - header("fstab"), cat_("$prefix/etc/fstab"), - header("lilo.conf"), cat_("$prefix/etc/lilo.conf"), - header("menu.lst"), cat_("$prefix/boot/grub/menu.lst"), - header("/etc/modules.conf"), cat_("$prefix/etc/modules.conf"), - header("rpm -qa"), join ('', sort `rpm -qa`), - header("mandrake version"), cat_('/etc/redhat-release'); -close(FILE); -} - -sub automated_upgrades { - # set up a daily cron to check connection and if there is one upgrade the system - open VERS, "/etc/mandrake-release" or die _("Cannot open this file for read: %s", $!); - my @info_tree; - while () { - @info_tree = split / /, $_; - } - close(VERS); - $mirror_site = $locations{$gtkcombo_mirror->entry->get_text()}[rand (2)]; - my $version=$info_tree[3]; - my $host = hostname; - output "/root/.mdkupdate", - qq(# automatically generated file. Please don't edit -LOGIN=$login -PASS=$passwd -BOX=$box_name -VER=$version -MIRROR=$mirror_site -CURRENTKEY=$key -); - output_p "/etc/cron.daily/mdkupdate", - qq(#!/bin/bash -if [ -f /root/.mdkupdate ]; then /usr/bin/mdkupdate; fi -); -chmod 0755, "/etc/cron.daily/mdkupdate"; -} - -sub set_boxname { - my ($box) = @_; - my %b = getVarsFromSh("/root/.mdkupdate"); - $box->set_text($b{BOX}); -} - -sub info_popup () { - # must have been translated by the caller - my ($title,$text) = @_; - - my $popup = new Gtk::Dialog(); - $popup->set_position(1); - - my $box = new Gtk::HButtonBox; - $popup->action_area->pack_start($box,0,0,0); - - my $button_ok = new Gtk::Button(" " . _("OK") . " "); - $button_ok->signal_connect_object("clicked",$popup => 'destroy'); - $box->add($button_ok); - - my $label = new Gtk::Label($text); - my $style = new Gtk::Style; - $style->font(Gtk::Gdk::Font->fontset_load(_("-adobe-times-bold-r-normal--14-*-100-100-p-*-iso8859-*,*-r-*"))); - $label->set_style($style); - $popup->set_title($title); - $popup->vbox->pack_start( $label, 1, 1, 0 ); - $popup->show_all(); - $popup->set_modal(1); -} - -sub confirm_quit { - my $window_about = new Gtk::Dialog(); - $window_about->set_position(1); - - my $bbox1 = new Gtk::HButtonBox; - $window_about->action_area->pack_start($bbox1,0,0,0); - - my $button_cancel = new Gtk::Button(" " . _("Cancel") . " "); - $button_cancel->signal_connect_object("clicked",$window_about => 'destroy'); - $bbox1->add($button_cancel); - - my $button_quit = new Gtk::Button(" " . _("Quit") . " "); - $button_quit->signal_connect (clicked =>\>k_main_quit); - $bbox1->add($button_quit); - - my $label = new Gtk::Label( - _("Do you really want to abort MandrakeOnline?\nTo return to the Wizard press 'Cancel'.\nTo really quit it press 'Quit'.")); - my $style1 = new Gtk::Style; - $style1->font(Gtk::Gdk::Font->fontset_load(_("-adobe-times-bold-r-normal--14-*-100-100-p-*-iso8859-*,*-r-*"))); - $label->set_style($style1); - $window_about->set_title(_("Really abort? - MandrakeOnline")); - $window_about->vbox->pack_start( $label, 1, 1, 0 ); - $window_about->show_all(); - $window_about->set_modal(1); -} - -sub pack_box_identity { - my ($vbox,$label1,$entry1,$label2,$entry2,$label3,$entry3)=@_; - my $table = new Gtk::Table( 3, 2, $true); - my $Label_wg1=new Gtk::Label($label1); - my $Label_wg2=new Gtk::Label($label2); - my $Label_wg3=new Gtk::Label($label3); - Gtk::Label::set_justify($Label_wg1,'right'); - Gtk::Label::set_justify($Label_wg2,'right'); - Gtk::Label::set_justify($Label_wg3,'right'); - $table->attach_defaults( $Label_wg1, 0, 1, 0, 1); - $table->attach_defaults( $entry1, 1, 2, 0, 1); - $table->attach_defaults( $Label_wg2, 0, 1, 1, 2); - $table->attach_defaults( $entry2, 1, 2, 1, 2); - $table->attach_defaults( $Label_wg3, 0, 1, 2, 3); - $table->attach_defaults( $entry3, 1, 2, 2, 3); - $Label_wg1->set_uposition(25,170); - $Label_wg2->set_uposition(25,200); - $Label_wg3->set_uposition(25,230); - $entry1->set_uposition(210,170); - $entry2->set_uposition(210,200); - $entry3->set_uposition(210,230); - $entry2->set_visibility($false); - $vbox->pack_start($table,$true ,$true ,0); -} - -sub load_text { - my $line; - my ($text,$file)=@_; - open( FILE, $file ) or die "load_text: missing file $file"; - foreach $line ( ) - { -# $text->insert( $fixed_font, undef, undef, $line ); - $text->insert( undef, undef, undef, $line ); - } - close( FILE ); -} - -sub get_on_privacy { - my ($vbox)=@_; - my $table=new Gtk::Table( 1, 2, $false ); - my $text=new Gtk::Text(undef,undef); - $text->set_editable($false); - my $translated = 1; - $table->attach( $text, 0, 1, 0, 1, - [ 'expand', 'shrink', 'fill' ], - [ 'expand', 'shrink', 'fill' ], - 0, 0 ); - my $vscrollbar = new Gtk::VScrollbar( $text->vadj ); - $table->attach( $vscrollbar, 1, 2, 0, 1, 'fill', - [ 'expand', 'shrink', 'fill' ], 0, 0 ); - - my @lang = qw(de es eu fr pl ro sv); - foreach $l (@lang) { - next if $ENV{LANG} !~ /$l/; - load_text($text,"$sharepath/privacy-$l.txt"); - $translated = 0; - } - $translated and load_text($text,"$sharepath/privacy.txt"); - $vbox->pack_start( $table, $true, $true, 0 ); -} - -sub writ_on_pixmaps { - my ($vbox, $pix_name, $step_label, $width, $height)=@_; - my $darea= new Gtk::DrawingArea(); - $darea->set_usize($width,$height); - $vbox->pack_start($darea,0,0,0); - my ($pix1,$pix_mask1) = gtkcreate_png("$xpm_path/$pix_name"); - my ($y1, $x1) = $pix1->get_size; - my $style= new Gtk::Style; - $style->font(Gtk::Gdk::Font->fontset_load(_("-adobe-times-bold-r-normal--17-*-100-100-p-*-iso8859-*,*-r-*"))); - my $w = $style->font->string_width(_("Welcome")); - $darea->signal_connect(expose_event => sub { - my $i; - for ($i=0;$i<($width/$y1);$i++) { - $darea->window->draw_pixmap ($darea->style->bg_gc('normal'), - $pix1, 0, 0, 0, $y1*$i, - $x1 , $y1 ); - $darea->window->draw_string( - $style->font, - $darea->style->white_gc, - 60+(380-$w)/2, 62, - $step_label ); - } - }); -} - -sub splash_warning { - my ($label) = @_; - my $win_about = new Gtk::Dialog(); - $win_about->set_position(1); - - my $bbox1 = new Gtk::HButtonBox; - $win_about->action_area->pack_start($bbox1,0,0,0); - - my $button = new Gtk::Button(" " . _("Close") . " "); - $button->signal_connect_object("clicked",$win_about => 'destroy'); - $bbox1->add($button); - - my $lab = new Gtk::Label($label); - my $style1 = new Gtk::Style; - $win_about->vbox->pack_start($lab, 1, 1, 0); - - $win_about->show_all(); - $win_about->set_modal(1); -} - - +drakfirsttime::gui->new('mdkclub'); -- cgit v1.2.1