diff options
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/bootsplash.pm | 73 | ||||
-rwxr-xr-x | perl-install/standalone/draksplash | 57 |
2 files changed, 89 insertions, 41 deletions
diff --git a/perl-install/bootsplash.pm b/perl-install/bootsplash.pm index 72168f5f2..53cff9590 100644 --- a/perl-install/bootsplash.pm +++ b/perl-install/bootsplash.pm @@ -110,9 +110,20 @@ sub theme_read_config_for_resolution { my ($theme, $res) = @_; my $file = theme_get_config_for_resolution($theme, $res); my $contents = cat_($file); - my ($pb_x1, $pb_y1, $pb_x2, $pb_y2) = $contents =~ /^box\s+silent\s+noover\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/m; - my ($pc) = $contents =~ /^box\s+silent\s+inter\s+\d+\s+\d+\s+\d+\s+\d+\s+(#\w+)/m; - { pc => $pc, px => $pb_x1, pw => $pb_x2 - $pb_x1, py => $pb_y1, ph => $pb_y2 - $pb_y1, getVarsFromSh($file) }; + my ($bgcolor) = $contents =~ /^bgcolor=(\d+)/m; + my ($pb_x1, $pb_y1, $pb_x2, $pb_y2, $pbg_c, $ptransp) = $contents =~ /^box\s+silent\s+noover\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(#\w{6})(\w{2})/m; + my ($tb_x1, $tb_y1, $tb_x2, $tb_y2, $tc, $transp) = $contents =~ /^box\s+noover\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(#\w{6})(\w{2})/m; + my ($pc1, $pc2, $pc3, $pc4) = $contents =~ /^box\s+silent\s+inter\s+\d+\s+\d+\s+\d+\s+\d+\s+(#\w+)\s+(#\w+)\s+(#\w+)\s+(#\w+)/m; + my ($text_color) = $contents =~ /^text_color=0x(\w+)/m; + my $gradient; + if ($pc1 eq $pc2) { + $gradient = 'vertical'; + $pc2 = $pc3 + } + { pc1 => $pc1, pc2 => $pc2, gradient => $gradient, transp => hex $transp, ptransp => hex $ptransp, + tb_x => $tb_x1, tb_y => $tb_y1, tb_w => $tb_x2 - $tb_x1, tb_h => $tb_y2 - $tb_y1, tc => $tc, pbg_c => $pbg_c, + px => $pb_x1, pw => $pb_x2 - $pb_x1, py => $pb_y1, ph => $pb_y2 - $pb_y1, + getVarsFromSh($file), text_color => "#$text_color" } } sub theme_write_config_for_resolution { @@ -125,10 +136,22 @@ sub theme_write_config_for_resolution { # progress/text rectangles border/inter coordinates my ($pb_x1, $pb_x2, $pb_y1, $pb_y2) = ($conf->{px}, $conf->{px} + $conf->{pw}, $conf->{py}, $conf->{py} + $conf->{ph}); my ($pi_x1, $pi_x2, $pi_y1, $pi_y2) = ($pb_x1 + 1, $pb_x2 - 1, $pb_y1 + 1, $pb_y2 - 1); - my ($tb_x1, $tb_x2, $tb_y1, $tb_y2) = ($conf->{tx}, $conf->{tx} + $conf->{tw}, $conf->{ty}, $conf->{ty} + $conf->{th}); - my ($ti_x1, $ti_x2, $ti_y1, $ti_y2) = ($tb_x1 + 1, $tb_x2 - 1, $tb_y1 + 1, $tb_y2 - 1); - my $pc = $conf->{pc}; - + my ($tb_x1, $tb_y1, $tb_x2, $tb_y2) = ($conf->{tb_x}, $conf->{tb_y}, $conf->{tb_x} + $conf->{tb_w}, $conf->{tb_y} + $conf->{tb_h}); + my ($tx, $ty, $tw, $th) = ($tb_x1 + 10, $tb_y1 + 5, $conf->{tb_w} - 20 , $conf->{tb_h} - 10); + my ($ti_x1, $ti_x2, $ti_y1, $ti_y2) = ($tb_x1 - 1, $tb_x2 + 1, $tb_y1 + 1, $tb_y2 + 1); + my ($pc1, $pc2, $pc3, $pc4); + if ($conf->{gradient} eq 'vertical') { + ($pc1, $pc2, $pc3, $pc4) = ($conf->{pc1}, $conf->{pc1}, $conf->{pc2}, $conf->{pc2}) + } else { + ($pc1, $pc2, $pc3, $pc4) = ($conf->{pc1}, $conf->{pc2}, $conf->{pc1}, $conf->{pc2}) + } + if (!$pc1) { ($pc1, $pc2, $pc3, $pc4) = ('#ffffff', '#ffffff', '#000000', '#000000') } + my $ptransp = sprintf '%02x', $conf->{ptransp}; + my $transp = sprintf '%02x', $conf->{transp}; + $conf->{pbg_c} ||= '#aaaaaa'; + $conf->{tc} ||= '#ffffff'; + $text_color = $conf->{text_color} ? "0x$conf->{text_color}" : '0xaaaaaa'; + $text_color =~ s/#//; output($config, qq(# This is the configuration file for the $res bootsplash picture # this file is necessary to specify the coordinates of the text box on the @@ -142,21 +165,21 @@ state=1 # fgcolor is the text forground color. # bgcolor is the text background (i.e. transparent) color. -fgcolor=7 -bgcolor=0 +fgcolor=$conf->{fgcolor} +bgcolor=$conf->{bgcolor} # (tx, ty) are the (x, y) coordinates of the text window in pixels. # tw/th is the width/height of the text window in pixels. -tx=$conf->{tx} -ty=$conf->{ty} -tw=$conf->{tw} -th=$conf->{th} +tx=$tx +ty=$ty +tw=$tw +th=$th # ttf message output parameters -text_x=20 -text_y=550 -text_size=20 -text_color=0xeef4ff +text_x=$conf->{text_x} +text_y=$conf->{text_y} +text_size=$conf->{text_size} +text_color=$text_color # name of the picture file (full path recommended) jpeg=$jpeg @@ -166,10 +189,10 @@ progress_enable=1 # background # b(order) or i(nter) -box silent noover $pb_x1 $pb_y1 $pb_x2 $pb_y2 #040454 +box silent noover $pb_x1 $pb_y1 $pb_x2 $pb_y2 $conf->{pbg_c}$ptransp # progress bar -box silent inter $pi_x1 $pi_y1 $pi_x1 $pi_y2 $pc $pc $pc $pc -box silent $pi_x1 $pi_y1 $pi_x2 $pi_y2 $pc $pc $pc $pc +box silent inter $pb_x1 $pi_y1 $pb_x1 $pi_y2 $pc1 $pc2 $pc3 $pc4 +box silent $pb_x1 $pi_y1 $pb_x2 $pi_y2 $pc1 $pc2 $pc3 $pc4 # black border (top, bottom, left, right) box silent $pb_x1 $pb_y1 $pb_x2 $pb_y1 #313234 box silent $pb_x1 $pb_y2 $pb_x2 $pb_y2 #889499 @@ -177,12 +200,12 @@ box silent $pb_x1 $pb_y1 $pb_x1 $pb_y2 #313234 box silent $pb_x2 $pb_y1 $pb_x2 $pb_y2 #889499 # text box -box noover $ti_x1 $ti_y1 $ti_x2 $ti_y2 #011763 +box noover $tb_x1 $tb_y1 $tb_x2 $tb_y2 $conf->{tc}$transp # black border (top, bottom, left, right) -box $tb_x1 $tb_y1 $tb_x2 $tb_y1 #313234 -box $tb_x1 $tb_y2 $tb_x2 $tb_y2 #889499 -box $tb_x1 $tb_y1 $tb_x1 $tb_y2 #313234 -box $tb_x2 $tb_y1 $tb_x2 $tb_y2 #889499 +box $ti_x1 $tb_y1 $ti_x1 $ti_y2 #313234 +box $tb_x1 $tb_y1 $ti_x2 $tb_y1 #313234 +box $ti_x2 $ti_y1 $ti_x2 $ti_y2 #889499 +box $tb_x1 $ti_y2 $ti_x2 $ti_y2 #889499 overpaintok=1 diff --git a/perl-install/standalone/draksplash b/perl-install/standalone/draksplash index 00f9721f1..f9d830aaa 100755 --- a/perl-install/standalone/draksplash +++ b/perl-install/standalone/draksplash @@ -27,18 +27,24 @@ my $scroll = create_scrolled_window($image_area); switch_to_mode(0); my %scale_settings = ( - tx => [ 1/10, N("x coordinate of text box\nin number of characters") ], - ty => [ 1/10, N("y coordinate of text box\nin number of characters") ], - tw => [ 8/10, N("text width") ], - th => [ 8/10, N("text box height") ], + tb_x => [ 1/10, N("x coordinate of text box") ], + tb_y => [ 1/10, N("y coordinate of text box") ], + tb_w => [ 8/10, N("text box width") ], + tb_h => [ 8/10, N("text box height") ], px => [ 2/10, N("the progress bar x coordinate\nof its upper left corner") ], py => [ 7/10, N("the progress bar y coordinate\nof its upper left corner") ], pw => [ 6/10, N("the width of the progress bar") ], ph => [ 1/10, N("the height of the progress bar") ], + text_x => [ 1/10, N("x coordinate of the text") ], + text_y => [ 1/10, N("y coordinate of the text") ], + transp => [ 1/10, N("text box transparency") ], + ptransp => [ 1/10, N("progress box transparency") ], + text_size => [ 1/10, N("text size") ], ); my %adj; create_adj_widgets(); +create_simple_adj_widgets(); my %theme; set_theme('new_theme'); @@ -50,13 +56,20 @@ my $notebook = gtksignal_connect(Gtk2::Notebook->new, switch_page => sub { switch_to_mode($mode); }); $notebook->append_page(gtkpack__(Gtk2::VBox->new(0, 5), - create_scale_table('px', 'pw', 'py', 'ph'), - gtksignal_connect(Gtk2::Button->new(N("Choose progress bar color")), clicked => \&choose_color), + create_scale_table('px', 'pw', 'py', 'ph', 'ptransp'), + gtksignal_connect(Gtk2::Button->new(N("Choose progress bar color 1")), clicked => sub { choose_color('pc1') }), + gtksignal_connect(Gtk2::Button->new(N("Choose progress bar color 2")), clicked => sub { choose_color('pc2') }), + gtksignal_connect(Gtk2::Button->new(N("Choose progress bar background")), clicked => sub { choose_color('pbg_c') }), + Gtk2::Label->new(N("Gradient type")), gtksignal_connect(Gtk2::ComboBoxEntry->new_with_strings([ 'vertical', 'horizontal' ], 'vertical'), changed => sub { $theme{conf}{gradient} = $_[0]->get_child->get_text }), + gtksignal_connect(Gtk2::Button->new(N("Choose text color")), clicked => sub { choose_color('text_color') }), + create_scale_table('text_x', 'text_y', 'text_size'), gtksignal_connect(Gtk2::Button->new(N("Choose picture")), clicked => sub { choose_image('silentjpeg') })), N("Silent bootsplash")); $notebook->append_page(gtkpack__(Gtk2::VBox->new(0, 5), - create_scale_table('tx', 'tw', 'ty', 'th'), - gtksignal_connect(Gtk2::Button->new(N("Choose progress bar color")), clicked => \&choose_color), + create_scale_table('tb_x', 'tb_y', 'tb_w', 'tb_h', 'transp'), + gtksignal_connect(Gtk2::Button->new(N("Choose text zone color")), clicked => sub { choose_color('tc') }), + Gtk2::Label->new(N("Text color")), gtksignal_connect(Gtk2::ComboBoxEntry->new_with_strings([ 0 .. 15 ], 1), changed => sub { $theme{conf}{fgcolor} = $_[0]->get_child->get_text }), + Gtk2::Label->new(N("Background color")), gtksignal_connect(Gtk2::ComboBoxEntry->new_with_strings([ 0 .. 15 ], '0'), changed => sub { $theme{conf}{bgcolor} = $_[0]->get_child->get_text }), gtksignal_connect(Gtk2::Button->new(N("Choose picture")), clicked => sub { choose_image('jpeg') })), N("Verbose bootsplash")); $notebook->append_page(gtkpack__(Gtk2::VBox->new(0, 5), @@ -172,13 +185,15 @@ sub choose_image { } sub choose_color() { - my $color = gtkshow(Gtk2::ColorSelectionDialog->new(N("ProgressBar color selection"))); - my @rgb = $theme{conf}{pc} =~ /^#(.{2})(.{2})(.{2})$/ ? (map { hex($_)*255 } ($1, $2, $3)) : (); + my ($var) = @_; + my $color = gtkshow(Gtk2::ColorSelectionDialog->new(N("Color selection"))); + print "Current color $var: $theme{conf}{$var}\n"; + my @rgb = $theme{conf}{$var} =~ /^#(.{2})(.{2})(.{2})$/ ? (map { hex($_)*255 } ($1, $2, $3)) : (); $color->colorsel->set_current_color(gtkcolor(@rgb)); $color->cancel_button->signal_connect(clicked => sub { $color->destroy }); $color->ok_button->signal_connect(clicked => sub { my $colour = $color->colorsel->get_current_color; - $theme{conf}{pc} = "#" . join('', map { sprintf("%02x", $_/255) } $colour->red, $colour->green, $colour->blue); + $theme{conf}{$var} = "#" . join('', map { sprintf("%02x", $_/256) } $colour->red, $colour->green, $colour->blue); $color->destroy; }); } @@ -187,12 +202,19 @@ sub choose_color() { #- Adjustement widgets sub create_adj_widgets() { $adj{$_} = Gtk2::Adjustment->new(0, 0, 0, 1, 10, 0) foreach keys %scale_settings; - my %scale_links = (tx => 'tw', ty => 'th', px => 'pw', py => 'ph'); + my %scale_links = (tb_x => 'tb_w', tb_y => 'tb_h', px => 'pw', py => 'ph', text_x => 'px', text_y => 'py', transp => 'transp', ptransp => 'ptransp', text_size => 'text_size' ); while (my ($n1, $n2) = each(%scale_links)) { $adj{$n1}{on_change} = $adj{$n1}->signal_connect(value_changed => sub { check_scale_value($n1, $n2); apply_scale($n1) }); $adj{$n2}{on_change} = $adj{$n2}->signal_connect(value_changed => sub { check_scale_value($n2, $n1); apply_scale($n2) }); } } + +sub create_simple_adj_widgets() { + $adj{$_} = Gtk2::Adjustment->new(0, 0, 0, 1, 10, 0) foreach keys %scale_settings; + foreach my $n ('transp','ptransp', 'text_size') { + $adj{$n}{on_change} = $adj{$n}->signal_connect(value_changed => sub { apply_scale($n) }); + } +} sub create_scale_table { my @settings = @_; create_packtable({ col_spacings => 10, row_spacings => 5 }, map { @@ -201,9 +223,12 @@ sub create_scale_table { [ Gtk2::Label->new($scale_settings{$_}[1]), $w ]; } @settings); } + sub get_scale_max { my ($name) = @_; - $theme{$name =~ /[xw]$/ ? "res_w" : "res_h"}; + if ($name =~ /size/) { return 100 } + if ($name =~ /transp/) { return 255 } + $theme{$name =~ /[xw]$/ ? "res_w" : "res_h"} } sub apply_scale { my ($name) = @_; @@ -254,7 +279,7 @@ sub image_expose { $window->draw_rectangle($widget->style->white_gc, 1, @{$theme{conf}}{'px', 'py', 'pw', 'ph'}); $cross_gc = $widget->style->black_gc; } else { #- verbose or console - $window->draw_rectangle($widget->style->black_gc, 0, @{$theme{conf}}{'tx', 'ty', 'tw', 'th'}); + $window->draw_rectangle($widget->style->black_gc, 0, @{$theme{conf}}{'tb_x', 'tb_y', 'tb_w', 'tb_h'}); $cross_gc = $widget->style->white_gc; } $window->draw_line($cross_gc, $current_rect->[0]{X}, $current_rect->[0]{Y}, $current_rect->[1]{X}, $current_rect->[1]{Y}); @@ -266,7 +291,7 @@ sub update_rect() { if ($current_mode == 0) { #- silent $current_rect = bootsplash::xywh2rectangle(@{$theme{conf}}{'px', 'py', 'pw', 'ph'}); } else { #- verbose or console - $current_rect = bootsplash::xywh2rectangle(@{$theme{conf}}{'tx', 'ty', 'tw', 'th'}); + $current_rect = bootsplash::xywh2rectangle(@{$theme{conf}}{'tb_x', 'tb_y', 'tb_w', 'tb_h'}); } } @@ -281,7 +306,7 @@ sub update_theme_from_rect() { if ($current_mode == 0) { #- silent @{$theme{conf}}{'px', 'py', 'pw', 'ph'} = bootsplash::rectangle2xywh($current_rect); } else { #- verbose or console - @{$theme{conf}}{'tx', 'ty', 'tw', 'th'} = bootsplash::rectangle2xywh($current_rect); + @{$theme{conf}}{'tb_x', 'tb_y', 'tb_w', 'tb_h'} = bootsplash::rectangle2xywh($current_rect); } update_scale_values_from_conf(); $image_area->queue_draw; |