From da5d831cb620d5083b459b3449444395ce47d112 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Mon, 8 Mar 2004 09:03:41 +0000 Subject: fix crash on "preview" button --- perl-install/standalone/draksplash | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'perl-install') diff --git a/perl-install/standalone/draksplash b/perl-install/standalone/draksplash index e847b673f..1f427fa35 100755 --- a/perl-install/standalone/draksplash +++ b/perl-install/standalone/draksplash @@ -28,6 +28,7 @@ my $tmp_path = '/tmp/draksplash/'; ! -d $tmp_path and mkdir($tmp_path); my $thm_path = '/usr/share/bootsplash/themes/'; my $thm_conf_path = '/etc/bootsplash/themes/'; +my $img_file; my $prev_window; @@ -160,9 +161,9 @@ $first{widgets}{button}{file}->signal_connect(clicked => sub { my $file_dialog = gtkset_modal(Gtk2::FileSelection->new(N("choose image")), 1); $file_dialog->set_transient_for($window->{rwindow}); - $file_dialog->set_filename($first{widgets}{label}{file}->get_text ne N("choose image file") ? $first{widgets}{label}{file}->get_text : '~/'); + $file_dialog->set_filename($img_file || '~/'); $file_dialog->cancel_button->signal_connect(clicked => sub { $file_dialog->destroy }); - $file_dialog->ok_button->signal_connect(clicked => sub { $first{widgets}{label}{file}->set_text($file_dialog->get_filename); $file_dialog->destroy }); + $file_dialog->ok_button->signal_connect(clicked => sub { $img_file = $file_dialog->get_filename; $file_dialog->destroy }); $file_dialog->show; }); #- changing theme name @@ -215,7 +216,7 @@ sub write_boot_thm { -d $thm_path.$theme{name}.'/images/' or mkdir($thm_path.$theme{name}.'/images/'); #- copy image to dest by convert - system('convert -scale '.$theme{res}{res} . ' ' . $first{widgets}{label}{file}->get.' '.$thm_path.$theme{name}.'/images/bootsplash-'.$theme{res}{res}.'.jpg'); + 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 @@ -268,7 +269,7 @@ sub get_this_thm_res_conf() { and thm_in_this_res(1) and read_boot_conf(); -f $thm_path.$theme{name}."/images/bootsplash-".$theme{res}{res}.".jpg" - and $first{widgets}{label}{file}->set_text($thm_path.$theme{name}."/images/bootsplash-".$theme{res}{res}.".jpg"); + and $img_file = $thm_path . $theme{name} . "/images/bootsplash-" . $theme{res}{res} . ".jpg"; return 1; } @@ -441,8 +442,7 @@ sub make_boot_frame() { #$boot_conf_frame{widgets}{button}{annul}->signal_connect(clicked => sub { show_act( \%first ) } ); #- made a preview $boot_conf_frame{widgets}{button}{prev}->signal_connect(clicked => sub { - my $w = $first{widgets}{label}{file}; - unless (-f $w->get_text) { + unless (-f $img_file) { $in->ask_warn(N("Notice"), N("You must choose an image file first!")); return 0; } @@ -457,7 +457,7 @@ sub make_boot_frame() { my $prog_tl_y = $theme{boot_conf}{py}; my $prog_width = $theme{boot_conf}{pw}; my $prog_height = $theme{boot_conf}{ph}; - show_prev($first{widgets}{label}{file}->get,$txt_tl_x,$txt_tl_y,$txt_width,$txt_height,$prog_tl_x,$prog_tl_y,$prog_width,$prog_height); + show_prev($txt_tl_x,$txt_tl_y,$txt_width,$txt_height,$prog_tl_x,$prog_tl_y,$prog_width,$prog_height); }); $boot_conf_frame{frame}->show_all; # - check scales values are possibly correct @@ -488,14 +488,14 @@ sub kill_preview() { undef($prev_pix); } #- Desc => create a new window with a preview of splash screen -#- Args => $file (str) full path to preview file +#- Args => $img_file (str) full path to preview file sub show_prev { - my ($file, $txt_tl_x, $txt_tl_y, $txt_width, $txt_height, $prog_tl_x, $prog_tl_y, $prog_width, $prog_height) = @_; + my ($txt_tl_x, $txt_tl_y, $txt_width, $txt_height, $prog_tl_x, $prog_tl_y, $prog_width, $prog_height) = @_; $prev_window or $prev_window = new Gtk2::Window('toplevel'); #-PO First %s is theme name, second %s (in parenthesis) is resolution $prev_window->set_title(N("%s BootSplash (%s) preview", $theme{name}, $theme{res}{res})); - $prev_pic = gtkcreate_pixbuf($file); + $prev_pic = gtkcreate_pixbuf($img_file); $prev_pic->scale_simple($theme{res}{w}, $theme{res}{h},0); $prev_pix = $prev_pic->render_pixmap_and_mask($prev_pic); $prev_canvas && $prev_canvas->isa('Gtk2::Widget') -- cgit v1.2.1