summaryrefslogtreecommitdiffstats
path: root/perl-install
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install')
-rw-r--r--perl-install/install_steps_gtk.pm17
-rw-r--r--perl-install/share/advertising/dwd-01.pl13
-rw-r--r--perl-install/share/advertising/dwd-02.pl9
-rw-r--r--perl-install/share/advertising/dwd-03.pl9
-rw-r--r--perl-install/ugtk2.pm125
5 files changed, 85 insertions, 88 deletions
diff --git a/perl-install/install_steps_gtk.pm b/perl-install/install_steps_gtk.pm
index 4214b5c4a..96e9d7153 100644
--- a/perl-install/install_steps_gtk.pm
+++ b/perl-install/install_steps_gtk.pm
@@ -516,7 +516,7 @@ sub installPackages {
log::l("advertising $f");
my $pl = $f; $pl =~ s/\.png$/.pl/;
my $icon_name = $f; $icon_name =~ s/\.png$/_icon.png/;
- my ($draw_text, $width, $height, $y_start, $title, @text);
+ my ($draw_text, $width, $height, $border, $y_start, @text);
-e $pl and $draw_text = 1;
eval(cat_($pl)) if $draw_text;
my $pix = gtkcreate_pixbuf($f);
@@ -531,20 +531,15 @@ sub installPackages {
$pix->render_to_drawable($darea->window, $darea->style->bg_gc('normal'), 0, 0,
($dx-$width)/2, 0, $width, $height, 'none', 0, 0);
- my ($width, $lines, $widths, $heights) = wrap_paragraph([ $title, '', @text ], $darea, 520);
- my $i = 0;
- foreach (@$lines) {
- my $layout = $darea->create_pango_layout($_);
+ my @lines = wrap_paragraph([ @text ], $darea, $border, $width);
+ foreach my $line (@lines) {
+ my $layout = $darea->create_pango_layout($line->{text});
my $draw_lay = sub {
my ($gc, $decx) = @_;
- $darea->window->draw_layout($gc,
- ($dx-$width)/2 + $widths->[$i] + $decx,
- $y_start + $heights->[$i],
- $layout);
+ $darea->window->draw_layout($gc, $line->{'x'} + $decx, $y_start + $line->{'y'}, $layout);
};
$draw_lay->($darea->style->black_gc, 0);
- $i == 0 and $draw_lay->($darea->style->black_gc, 1);
- $i++;
+ $line->{options}{bold} and $draw_lay->($darea->style->black_gc, 1);
}
}
}));
diff --git a/perl-install/share/advertising/dwd-01.pl b/perl-install/share/advertising/dwd-01.pl
index 679ba742a..46f4253d1 100644
--- a/perl-install/share/advertising/dwd-01.pl
+++ b/perl-install/share/advertising/dwd-01.pl
@@ -4,11 +4,10 @@ $width = 556;
$height = 303;
$y_start = 80;
+$border = 10; #- for leftish text
-$title = N("Congratulations for choosing Mandrake Linux!");
-
-@text = (N("Welcome to the Open Source world!"),
- '',
- N("Mandrake Linux is committed to the Open Source Model and fully respects the General Public License. This new release is the result of collaboration between MandrakeSoft's team of developers and the worldwide community of Mandrake Linux contributors."),
- '',
- N("We would like to thank everyone who participated in the development of this latest release."));
+@text = ([ N("Congratulations for choosing <b>Mandrake Linux</b>!"), center => 1 ],
+ ' ',
+ N("Mandrake Linux is committed to the Open Source Model and fully respects the <b>General Public License</b>. This new release is the result of collaboration between MandrakeSoft's team of developers and the worldwide community of Mandrake Linux <b>contributors</b>."),
+ ' ',
+ [ N("We would like to thank everyone who participated in the development of this latest release."), center => 1 ]);
diff --git a/perl-install/share/advertising/dwd-02.pl b/perl-install/share/advertising/dwd-02.pl
index 2768b792a..c3f47fcf6 100644
--- a/perl-install/share/advertising/dwd-02.pl
+++ b/perl-install/share/advertising/dwd-02.pl
@@ -4,9 +4,8 @@ $width = 556;
$height = 303;
$y_start = 80;
+$border = 10;
-$title = N("Join the Mandrake Linux community!");
-
-@text = (N("If you would like to get involved, please subscribe to the \"Cooker\" mailing list by visiting mandrake-linux.com/cooker"),
- '',
- N("To learn more about our dynamic community, please visit www.mandrake-linux.com!"));
+@text = (N("If you would like to get involved, please subscribe to the \"Cooker\" mailing list by visiting <b>mandrake-linux.com/cooker</b>"),
+ ' ',
+ N("To learn more about our dynamic community, please visit <b>www.mandrake-linux.com</b>!"));
diff --git a/perl-install/share/advertising/dwd-03.pl b/perl-install/share/advertising/dwd-03.pl
index f7caea9d6..2cd6d45ff 100644
--- a/perl-install/share/advertising/dwd-03.pl
+++ b/perl-install/share/advertising/dwd-03.pl
@@ -4,9 +4,8 @@ $width = 556;
$height = 303;
$y_start = 80;
+$border = 10;
-$title = N("What is Mandrake Linux?");
-
-@text = (N("Mandrake Linux is an Open Source distribution created with thousands of the choicest applications from the Free Software world. Mandrake Linux is one of the most widely used Linux distributions worldwide!"),
- '',
- N("Mandrake Linux includes the famous graphical desktops KDE and GNOME, plus the latest versions of the most popular Open Source applications."));
+@text = (N("Mandrake Linux is an Open Source distribution created with thousands of the choicest applications from the <b>Free Software</b> world. Mandrake Linux is one of the most widely used Linux distributions worldwide!"),
+ ' ',
+ N("Mandrake Linux includes the famous graphical desktops KDE and GNOME, plus the latest versions of the most popular Open Source applications."));
diff --git a/perl-install/ugtk2.pm b/perl-install/ugtk2.pm
index d2400c37d..430c5f734 100644
--- a/perl-install/ugtk2.pm
+++ b/perl-install/ugtk2.pm
@@ -18,7 +18,7 @@ $::o = { locale => lang::read() } if !$::isInstall;
gtkset_text gtkset_tip gtkset_visibility gtksetstyle gtkshow gtksignal_connect gtksize gtktext_append
gtktext_insert ) ],
- helpers => [ qw(add2notebook add_icon_path fill_tiled fill_tiled_coords get_text_coord gtkcolor gtkcreate_img
+ helpers => [ qw(add2notebook add_icon_path fill_tiled fill_tiled_coords gtkcolor gtkcreate_img
gtkcreate_pixbuf gtkfontinfo gtkset_background n_line_size set_back_pixbuf string_size
string_width string_height wrap_paragraph) ],
@@ -723,19 +723,10 @@ sub string_height {
}
sub get_text_coord {
- my ($text, $widget4style, $max_width, $max_height, $can_be_greater, $can_be_smaller, $centeredx, $centeredy, $o_wrap_char) = @_;
+ my ($text, $widget4style, $max_width, $currentx, $currenty, $o_wrap_char) = @_;
my $wrap_char = $o_wrap_char || ' ';
- my $idx = 0;
- my $real_width = 0;
- my $real_height = 0;
my @lines;
- my @widths;
- my @heights;
- $heights[0] = 0;
- my $max_width2 = $max_width;
- my $height = 0;
- my $width = 0;
- my $flag = 1;
+ my $current_text;
my @t = split($wrap_char, $text);
my @t2;
if ($::isInstall && $::o->{locale}{lang} =~ /ja|zh/) {
@@ -756,63 +747,77 @@ sub get_text_coord {
} else {
@t2 = @t;
}
- foreach (@t2) {
- my $l = string_width($widget4style, $_ . (!$flag ? $wrap_char : ''));
- if ($width + $l > $max_width2 && !$flag) {
- $flag = 1;
- $height += string_height($widget4style, $lines[$idx]) + 1;
- $heights[$idx+1] = $height;
- $widths[$idx] = $centeredx && !$can_be_smaller ? (max($max_width2-$width, 0))/2 : 0;
- $width = 0;
- $idx++;
- }
- $lines[$idx] = $flag ? $_ : $lines[$idx] . $wrap_char . $_;
- $width += $l;
- $flag = 0;
- $l <= $max_width2 or $max_width2 = $l;
- $width <= $real_width or $real_width = $width;
- }
- $height += string_height($widget4style, $lines[$idx]);
- $widths[$idx] = $centeredx && !$can_be_smaller ? (max($max_width2-$width, 0))/2 : 0;
-
- $height < $real_height or $real_height = $height;
- $width = $max_width;
- $height = $max_height;
- $real_width < $max_width && $can_be_smaller and $width = $real_width;
- $real_width > $max_width && $can_be_greater and $width = $real_width;
- $real_height < $max_height && $can_be_smaller and $height = $real_height;
- $real_height > $max_height && $can_be_greater and $height = $real_height;
- if ($centeredy) {
- my $dh = ($height-$real_height)/2 + (string_height($widget4style, $lines[0]))/2;
- @heights = map { $_ + $dh } @heights;
+ my $add_line = sub {
+ my ($w, $h) = string_size($widget4style, $current_text);
+ push @lines, { text => $current_text, width => $w, height => $h + 1, 'x' => $currentx, 'y' => $currenty };
+ };
+ my $width;
+ foreach my $word (@t2) {
+ my $w = string_width($widget4style, $word . $wrap_char);
+ if ($currentx + $width + $w > $max_width) {
+ $add_line->();
+ $current_text = $word;
+ $width = $w;
+ $currentx = 0;
+ $currenty += $lines[-1]{height};
+ } else {
+ $current_text .= ($current_text ne '' ? $wrap_char : '') . $word;
+ $width += $w;
+ }
}
- ($width, $height, \@lines, \@widths, \@heights);
+ #- if wrap_char was at the end, don't forget it, for cases when bold/nonbold text follows
+ $text =~ /$wrap_char$/ and $current_text .= $wrap_char;
+ $add_line->();
+
+ return @lines;
}
sub wrap_paragraph {
- my ($text, $widget4style, $max_width) = @_;
+ my ($text, $widget4style, $border, $max_width) = @_;
- my ($width, @lines, @widths, @heights);
+ $max_width -= 2*$border;
+ my @lines;
my $ydec;
- foreach (@$text) {
- if ($_ ne '') {
- my ($width_, $height, $lines, $widths, $heights) = get_text_coord($_, $widget4style, $max_width, 0, 1, 0, 1, 0);
- push @widths, @$widths;
- push @heights, map { $_ + $ydec } @$heights;
- push @lines, @$lines;
- $width = max($width, $width_);
- $ydec += $height + 1;
- } elsif (@lines) {
- #- void line
- my $yvoid = $ydec / @lines;
- push @widths, 0;
- push @heights, $yvoid;
- push @lines, '';
- $ydec += $yvoid;
+
+ foreach my $paragraph (@$text) {
+ my @paragraph_lines;
+ my $center;
+ if (ref($paragraph) eq 'ARRAY') {
+ my ($text, %options) = @$paragraph;
+ $center = $options{center};
+ $paragraph = $text;
+ }
+ if ($paragraph ne '') {
+ my @elements;
+ while ($paragraph =~ m|(.*?)<b>(.*?)</b>(.*)|) {
+ $1 ne '' and push @elements, [ $1, bold => 0 ];
+ push @elements, [ $2, bold => 1 ];
+ $paragraph = $3;
+ }
+ $paragraph ne '' and push @elements, [ $paragraph, bold => 0 ];
+
+ my $currentx;
+ foreach (@elements) {
+ my ($text, %options) = @$_;
+ my @newlines = get_text_coord($text, $widget4style, $max_width, $currentx, $ydec);
+ $currentx = $newlines[-1]{'x'} + $newlines[-1]{width};
+ $ydec = $newlines[-1]{'y'};
+ $options{bold} and $currentx++;
+ $_->{options} = \%options foreach @newlines;
+ push @paragraph_lines, @newlines;
+ }
+ $ydec = $paragraph_lines[-1]{'y'} + $paragraph_lines[-1]{height};
+ }
+ if ($center) {
+ my %widths;
+ $widths{$_->{'y'}} ||= $_->{x} + $_->{width} foreach reverse @paragraph_lines;
+ $_->{x} += ($max_width - $widths{$_->{'y'}})/2 foreach @paragraph_lines;
}
+ $_->{x} += $border foreach @paragraph_lines;
+ push @lines, @paragraph_lines;
}
- ($width, \@lines, \@widths, \@heights);
+ return @lines;
}
sub gtkcolor {