diff options
author | Daouda Lo <daouda@mandriva.com> | 2001-08-28 11:56:08 +0000 |
---|---|---|
committer | Daouda Lo <daouda@mandriva.com> | 2001-08-28 11:56:08 +0000 |
commit | 82fc5a0cf3cce279461093f24c66e5384c5b00db (patch) | |
tree | 34d90c891d98a3d4c845ac10c61296bb90d78835 /mdkonline | |
parent | ebb77dbfea618c6871c555e0121a30806390eea5 (diff) | |
download | mgaonline-82fc5a0cf3cce279461093f24c66e5384c5b00db.tar mgaonline-82fc5a0cf3cce279461093f24c66e5384c5b00db.tar.gz mgaonline-82fc5a0cf3cce279461093f24c66e5384c5b00db.tar.bz2 mgaonline-82fc5a0cf3cce279461093f24c66e5384c5b00db.tar.xz mgaonline-82fc5a0cf3cce279461093f24c66e5384c5b00db.zip |
upload the framework
Diffstat (limited to 'mdkonline')
-rwxr-xr-x | mdkonline | 216 |
1 files changed, 216 insertions, 0 deletions
diff --git a/mdkonline b/mdkonline new file mode 100755 index 00000000..d22eed2c --- /dev/null +++ b/mdkonline @@ -0,0 +1,216 @@ +#!/usr/bin/perl -w +# Mandrake First Time Wizard +# +# Copyright (C) 2001 MandrakeSoft Daouda Lo (daouda@mandrakesoft.com) +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# 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 Config; +use Data::Dumper; +use POSIX; +use Gtk::MozEmbed; +use Locale::GetText; + +setlocale (LC_ALL, ""); + +Locale::GetText::textdomain ("MdkOnline"); + +import Locale::GetText I_; + +sub _ { + my $s = shift @_; my $t = I_($s); + $t && ref $t or return sprintf $t, @_; + my ($T, @p) = @$t; + sprintf $T, @_[@p]; +} + +my $nb_pages=0; +my $page; +my $xpm_path="/usr/share/ftw/pixmaps"; +my $path_to_welcome="/usr/share/doc/HTM"; +my $check_custid; +my $true=1; +my $false=0; +$::isWizard = "@ARGV" =~ /--wizard/; +$::isWizard=1; +local $_ = join '', @ARGV; + +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 ); +$Main_Window->set_title(_("Mandrake Online")); +$Main_Window->set_usize(540, 430); +$Main_Window->realize(); +$Main_Window->signal_connect( "delete_event", \>k_main_quit); + +my $Button_Next= new Gtk::Button(_(" Next > ")); +my $Button_SkipWiz= new Gtk::Button(_(" Cancel ")); +my $Button_Prev= new Gtk::Button(_(" < Back ")); +my $notebook_global = new Gtk::Notebook; +$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($Button_Prev, 0, 1, 0); +$Button_SkipWiz->signal_connect( clicked => \&confirm_quit); +$hbox->pack_start($Button_SkipWiz, 0, 1, 0); +my $login_user= new Gtk::Entry(); +my $passwd_user= new Gtk::Entry(); +init_ui(); +$Main_Window->show_all; + +Gtk->main_iteration while Gtk->events_pending; +Gtk->main; + +sub init_ui { + step_wizard(); + $Button_Next->signal_connect(clicked =>\&on_next_clicked); + $Button_Prev->signal_connect(clicked =>\&on_prev_clicked); +} + +sub on_next_clicked { + $page=$notebook_global->get_current_page(); + print "$page\n" ; + $notebook_global->next_page(); + $page=$notebook_global->get_current_page(); + print "$page\n" ; +} + +sub on_prev_clicked { + $notebook_global->prev_page(); +} + +sub step_wizard { + my $vbox_welc= new Gtk::VBox(0,0); + write_on_pixmaps($vbox_welc,"welcome.png",_("Welcome to Mandrake Online"),540,100); + my $label_welc = new Gtk::Label(_("\n\nAt this step You are supposed to have a account on Mandrake Online.\n This assistant will help you to upload your configuration \n (packages, hardware configuration) to a centralized databases in \n order to keep you informed about security updates, useful upgrades.\n ")); + $vbox_welc->pack_start($label_welc,0,0,1); + $notebook_global->append_page($vbox_welc,new Gtk::Label("welcome")); + my $vbox_priv = new Gtk::VBox(0,0); + write_on_pixmaps($vbox_priv,"$x/privacy.png",_("Mandrake Privacy"),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); + +} + +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_object("clicked",\>k_main_quit); + $bbox1->add($button_quit); + + my $label = new Gtk::Label( _("Do you really want to abort the + Mandrake Online?\nTo return to fwdrake press 'Cancel'\nTo really quit the wizard 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->vbox->pack_start( $label, 1, 1, 0 ); + $window_about->show_all(); + $window_about->set_modal(1); +} + +sub load_text { + my ($text,$file)=@_; + open( FILE, $file ); + foreach $line ( <FILE> ) + { + $text->insert( $fixed_font, 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); + $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 ); + load_text($text,"/usr/share/ftw/privacy.txt"); + $vbox->pack_start( $table, $true, $true, 0 ); + +} + +sub gtkpng { new Gtk::Pixmap(gtkcreate_png(@_)) } + +sub gtkcreate_png { + my ($f) = @_; + $f =~ m|.png$| or $f="$f.png"; + if ( $f !~ /\//) { -e "$_/$f" and $f="$_/$f", last foreach $ENV{SHARE_PATH}, "$pixmaps", "pixmaps" } + my $im = Gtk::Gdk::ImlibImage->load_image($f) or die "gtkcreate_png: missing png file $f"; + $im->render($im->rgb_width, $im->rgb_height); + ($im->move_image(), $im->move_mask); +} + +sub write_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, + 120+(380-$w)/2, 62, + $step_label ); + } + }); +} + +sub gtk_main_quit { + print "Quitting Wizard\n"; + main_quit Gtk; +} + |