summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/draksplash
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/standalone/draksplash')
-rwxr-xr-xperl-install/standalone/draksplash97
1 files changed, 41 insertions, 56 deletions
diff --git a/perl-install/standalone/draksplash b/perl-install/standalone/draksplash
index 527631bd6..4a59407bd 100755
--- a/perl-install/standalone/draksplash
+++ b/perl-install/standalone/draksplash
@@ -4,7 +4,7 @@ use strict;
use lib qw(/usr/lib/libDrakX);
use standalone;
use common;
-use ugtk2 qw(:helpers :wrappers :create);
+use ugtk2 qw(:create :dialogs :helpers :wrappers);
use interactive;
#- convenience variables for true and false
@@ -25,7 +25,7 @@ unless ($in->do_pkgs->is_installed('ImageMagick')) {
#- application vars
my $tmp_path = '/tmp/draksplash/';
-! -d $tmp_path and mkdir($tmp_path);
+mkdir($tmp_path) if !-d $tmp_path;
my $thm_path = '/usr/share/bootsplash/themes/';
my $boot_conf_path = '/etc/bootsplash/themes/';
my $cfg_path = "/cfg/";
@@ -158,7 +158,7 @@ $first{widgets}{combo}{res}->entry->signal_connect(changed => sub {
$boot_conf_frame{frame} = Gtk2::Frame->new(N("Configure bootsplash picture"));
&make_boot_frame;
$first_vbox->add($boot_conf_frame{frame});
- member($theme{name}, giv_exist_thm()) && thm_in_this_res() && get_this_thm_res_conf() || $in->ask_warn(N("Notice"), N("This theme does not yet have a bootsplash in %s !", $theme{res}{res}));
+ member($theme{name}, giv_exist_thm()) && thm_in_this_res() && get_this_thm_res_conf() || $in->ask_warn(N("Notice"), N("This theme does not yet have a bootsplash in %s!", $theme{res}{res}));
});
#- go to bootsplash configuration step 2
#$first{widgets}{button}{boot_conf}->signal_connect(clicked => sub{show_act(\%boot_conf_frame) } );
@@ -220,46 +220,44 @@ sub write_boot_thm {
system('convert -scale '.$theme{res}{res} . ' ' . $img_file . ' ' . $thm_path.$theme{name} . '/images/bootsplash-' . $theme{res}{res} . '.jpg');
system('/usr/share/bootsplash/scripts/rewritejpeg '.$thm_path.$theme{name}.'/images/bootsplash-'.$theme{res}{res}.'.jpg');
#- write conf files
- my $cfg_cont = '# This is the configuration file for the '.$theme{res}{res}.' bootsplash picture
+ output($cfg_file, qq(# This is the configuration file for the $theme{res}{res} bootsplash picture
# this file is necessary to specify the coordinates of the text box on the
# splash screen.
# tx is the x coordinate of the text window in characters. default is 24
# multiply width font width for coordinate in pixels.
-tx='.$theme{boot_conf}{tx}.'
+tx=$theme{boot_conf}{tx}
# ty is the y coordinate of the text window in characters. default is 14
-ty='.$theme{boot_conf}{ty}.'
+ty=$theme{boot_conf}{ty}
# tw is the width of the text window in characters. default is 130
# note: this should at least be 80 as on the standard linux text console
-tw='.$theme{boot_conf}{tw}.'
+tw=$theme{boot_conf}{tw}
# th is the height of the text window in characters. default is 44
# NOTE: this should at least be 25 as on the standard linux text console
-th='.$theme{boot_conf}{th}.'
+th=$theme{boot_conf}{th}
# px is the progress bar x coordinate of its upper left corner
-px='.$theme{boot_conf}{px}.'
+px=$theme{boot_conf}{px}
# py is the progress bar y coordinate of its upper left corner
-py='.$theme{boot_conf}{py}.'
+py=$theme{boot_conf}{py}
# pw is the with of the progress bar
-pw='.$theme{boot_conf}{pw}.'
+pw=$theme{boot_conf}{pw}
# ph is the height of the progress bar
-ph='.$theme{boot_conf}{ph}.'
+ph=$theme{boot_conf}{ph}
# pc is the color of the progress bar
-pc='.$theme{boot_conf}{pc}.'';
- my $globalconf_cont = '# Display logo on console.
-LOGO_CONSOLE='.$logo.'
+pc=$theme{boot_conf}{pc}));
+ output($globalconf_file, qq(# Display logo on console.
+LOGO_CONSOLE=$logo
# Make kernel message quiet by default.
-QUIET='.$quiet;
- output($globalconf_file, $globalconf_cont);
- output($cfg_file, $cfg_cont);
+QUIET=$quiet));
}
@@ -269,25 +267,17 @@ sub get_this_thm_res_conf() {
and $theme{name} = $first{widgets}{combo}{name}->entry->get_text
and thm_in_this_res(1)
and read_boot_conf();
- -f $thm_path.$theme{name}."/images/bootsplash-".$theme{res}{res}.".jpg"
- and $img_file = $thm_path . $theme{name} . "/images/bootsplash-" . $theme{res}{res} . ".jpg";
+ my $file = $thm_path.$theme{name}."/images/bootsplash-".$theme{res}{res}.".jpg";
+ $img_file = $file if -f $file;
return 1;
}
sub read_boot_conf {
chdir($boot_conf_path);
- my $line;
- if (-f $theme{name} . "/$cfg_path/bootsplash-" . $theme{res}{res} . '.cfg') {
- local *CFG;
- open CFG, $theme{name} . "/$cfg_path/bootsplash-" . $theme{res}{res} . '.cfg';
- while ($line = <CFG>) {
- $line =~ m/^([a-z][a-z])=([^\n]+)/
- and $theme{boot_conf}{$1} = $2;
- }
- close CFG;
+ my $file = $theme{name} . "/$cfg_path/bootsplash-" . $theme{res}{res} . '.cfg';
+ if (-f $file) {
+ $theme{boot_conf} = { getVarsFromSh($file) };
&set_scale_values;
- } else {
- return 0;
}
}
@@ -316,7 +306,7 @@ sub which_res_exist() {
$first{widgets}{combo}{res}->entry->set_text($_);
last;
}
- $is_ok == 1 or $in->ask_warn(N("Notice"), N("This theme does not yet have a bootsplash in %s !", $theme{res}{res})) and return 0;
+ $is_ok == 1 or $in->ask_warn(N("Notice"), N("This theme does not yet have a bootsplash in %s!", $theme{res}{res})) and return 0;
return 1;
}
@@ -466,8 +456,8 @@ sub make_boot_frame() {
}
#- calculation of the 2 angle of text box and progress bar
set_thm_values();
- my $_w = $in->wait_message('', N("Generating preview ..."));
- my $txt_tl_yy = $theme{boot_conf}{tx}*$font_size{w};
+ my $_w = $in->wait_message('', N("Generating preview..."));
+ my $txt_tl_xx = $theme{boot_conf}{tx}*$font_size{w};
my $txt_tl_yy = $theme{boot_conf}{ty}*$font_size{h};
my $txt_width = $theme{boot_conf}{tw}*$font_size{w};
my $txt_height = $theme{boot_conf}{th}*$font_size{h};
@@ -496,38 +486,33 @@ sub set_thm_values() {
}
-my ($prev_pic, $prev_canvas);
-
#- Desc => destroy properly all widget of preview window
-sub kill_preview() {
- $prev_window->destroy; undef($prev_window);
- $prev_canvas->destroy; undef($prev_canvas);
- undef($prev_pic);
-}
#- Desc => create a new window with a preview of splash screen
#- Args => $img_file (str) full path to preview file
sub show_prev {
my ($txt_tl_xx, $txt_tl_yy, $txt_width, $txt_height, $prog_tl_xx, $prog_tl_yy, $prog_width, $prog_height) = @_;
- $prev_window
- or $prev_window = Gtk2::Window->new('toplevel');
+ $prev_window ||= Gtk2::Window->new('toplevel');
$prev_window->set_title(
#-PO: First %s is theme name, second %s (in parenthesis) is resolution
N("%s BootSplash (%s) preview", $theme{name}, $theme{res}{res}));
- $prev_pic = gtkcreate_pixbuf($img_file);
+ my $prev_pic;
+ eval { $prev_pic = gtkcreate_pixbuf($img_file) };
+ if (my $err = $@) {
+ err_dialog(N("Error"),
+ #-PO: Do not alter the <span ..> and </span> tags
+ N("The image \"%s\" cannot be load due to the following issue:\n\n<span foreground=\"Red\">%s</span>", $img_file, $err),
+ { use_markup => 1 }
+ );
+ return;
+ }
+
$prev_pic->scale_simple($theme{res}{w}, $theme{res}{h}, 'hyper');
- $prev_canvas && $prev_canvas->isa('Gtk2::Widget')
- or $prev_canvas = Gtk2::DrawingArea->new and $prev_window->add($prev_canvas);
- $prev_canvas->set_size_request($theme{res}{w}, $theme{res}{h});
- $prev_canvas->signal_connect(expose_event => sub {
- my ($w, $event) = @_;
- my ($x, $y, $width, $height) = $event->area->values;
- $prev_pic->render_to_drawable($w->window, $w->style->fg_gc('normal'), $x, $y, $x, $y, $width, $height, 'normal', 0, 0);
- $prev_canvas->window->draw_rectangle($prev_canvas->style->black_gc, $true, $txt_tl_xx, $txt_tl_yy, $txt_width, $txt_height);
- $prev_canvas->window->draw_rectangle($prev_canvas->style->black_gc, $true, $prog_tl_xx, $prog_tl_yy, $prog_width, $prog_height);
- });
- $prev_window->signal_connect(delete_event => \&kill_preview);
+ $prev_window->add(Gtk2::Image->new_from_pixbuf($prev_pic));
+ $prev_window->signal_connect(delete_event => sub {
+ $prev_window->destroy; undef($prev_window);
+ undef($prev_pic);
+ });
$prev_window->show_all;
-
}
#- Desc => define the max size of boot's scales