summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xperl-install/standalone/draksplash185
1 files changed, 101 insertions, 84 deletions
diff --git a/perl-install/standalone/draksplash b/perl-install/standalone/draksplash
index db711bbc4..eba692af6 100755
--- a/perl-install/standalone/draksplash
+++ b/perl-install/standalone/draksplash
@@ -2,10 +2,8 @@
use lib qw(/usr/lib/libDrakX);
use MDK::Common;
-use standalone; #for center dialog and explanations
use Gtk;
use interactive;
-#use my_gtk ;
use ugtk qw(:helpers :wrappers);
init Gtk;
@@ -36,7 +34,6 @@ $in->ask_warn(_("Error"),_("package ImageMagick is required for correct working"
#- application vars
-#my $mained = 1;
my $tmp_path = '/tmp/draksplash/';
! -d $tmp_path and mkdir($tmp_path);
my $thm_path = '/usr/share/bootsplash/themes/';
@@ -80,10 +77,8 @@ my %first = ('frame'=>new Gtk::Frame(_("first step creation")),
'file'=>_("choose image file"),
'name'=>_("Theme name")
},
- 'button'=>{ 'boot_conf'=>_("Make bootsplash step 2"),
- 'lilo_conf'=>_("Go to lilosplash configuration"),
- 'kill'=>_("Quit"),
- 'save'=>_("Save theme"),
+ 'button'=>{ #'boot_conf'=>_("Make bootsplash step 2"),
+ #'lilo_conf'=>_("Go to lilosplash configuration"),
'file'=>_("Browse"),
},
'combo'=> {'res'=>['800x600', '1024x768', '1280x1024'],
@@ -94,23 +89,24 @@ my %first = ('frame'=>new Gtk::Frame(_("first step creation")),
'res',
'file',
'boot_conf',
- 'save',
- 'kill'],
+ #'save',
+ #'kill'
+ ],
);
my %boot_conf_frame = ('frame' => new Gtk::Frame( _("Configure bootsplash picture") ),
- 'widget'=> { 'label' => { 'tx'=> _("x coordinate of text box in number of character"),
- 'ty'=> _("y coordinate of text box in number of character"),
+ 'widget'=> { 'label' => { 'tx'=> _("x coordinate of text box\nin number of character"),
+ 'ty'=> _("y coordinate of text box\nin number of character"),
'tw'=> _("text width"),
'th'=> _("text box height"),
- 'px'=> _("the progress bar x coordinate of its upper left corner"),
- 'py'=> _("the progress bar y coordinate of its upper left corner"),
+ 'px'=> _("the progress bar x coordinate\nof its upper left corner"),
+ 'py'=> _("the progress bar y coordinate\nof its upper left corner"),
'pw'=> _("the width of the progress bar"),
'ph'=> _("the heigth of the progress bar"),
'pc'=> _("the color of the progress bar")
},
#- must set scale values to true to get them created by mk_frame
'scale' => {'tx'=> 1,
- 'ty'=> 1,
+ 'ty'=> 1,
'tw'=> 1,
'th'=> 1,
'px'=> 1,
@@ -118,28 +114,32 @@ my %boot_conf_frame = ('frame' => new Gtk::Frame( _("Configure bootsplash pictur
'pw'=> 1,
'ph'=> 1,
},
- 'button' => { 'annul'=> _("Go back"),
+ 'button' => { #'annul'=> _("Go back"),
'prev'=>_("Preview"),
- 'pc'=> _("Choose color"),
+ 'kill'=>_("Quit"),
+ 'save'=>_("Save theme"),
+ 'pc'=> _("Choose color"),
},
'check' => { 'logo' => _("Display logo on Console" ),
'quiet'=> _("Make kernel message quiet by default"),
},
},
- 'pos'=> [ 'tx' ,
- 'ty' ,
- 'tw' ,
- 'th' ,
- 'px' ,
- 'py' ,
- 'pw' ,
- 'ph' ,
+ 'pos'=> [ 'tx 1' ,
+ 'ty 1' ,
+ 'tw 1' ,
+ 'th 1' ,
+ 'px 1' ,
+ 'py 1' ,
+ 'pw 1' ,
+ 'ph 1' ,
'pc' ,
'logo',
'quiet',
'annul',
'prev',
+ 'save' ,
+ 'kill',
],
);
#- var action is used to hide/show the correct frame
@@ -147,11 +147,9 @@ my @action_frame = ( \%boot_conf_frame ,
\%first);
-# >>>>>>>>>> FIRST SCREEN >>>>>>>>>>
my $VB2 = new Gtk::VBox(0,5);
&mk_frame(\$VB2,\%first);
#****************************- Signal event actions
-#**************************************************
#- change resolution
$first{'widgets'}{'combo'}{'res'}->entry->signal_connect( changed => sub {
$theme{'res'}{'res'} = $first{'widgets'}{'combo'}{'res'}->entry->get_text;
@@ -160,12 +158,11 @@ $first{'widgets'}{'combo'}{'res'}->entry->signal_connect( changed => sub {
$boot_conf_frame{'frame'}->destroy ;
$boot_conf_frame{'frame'} = new Gtk::Frame(_("Configure bootsplash picture") );
&make_boot_frame;
+ $first_vbox->add($boot_conf_frame{'frame'});
member( $theme{'name'}, &giv_exist_thm) and &thm_in_this_res and &get_this_thm_res_conf or $in->ask_warn(_("Notice"),_("This theme haven't yet any bootsplash in %s !",$theme{'res'}{'res'}));
});
-#- quit button
-$first{'widgets'}{'button'}{'kill'}->signal_connect( clicked => \&CloseAppWindow);
#- go to bootsplash configuration step 2
-$first{'widgets'}{'button'}{'boot_conf'}->signal_connect( clicked => sub{show_act(\%boot_conf_frame) } );
+#$first{'widgets'}{'button'}{'boot_conf'}->signal_connect( clicked => sub{show_act(\%boot_conf_frame) } );
#- image file selection for new theme
$first{'widgets'}{'button'}{'file'}->signal_connect( clicked =>sub{
my $file_dialog = new Gtk::FileSelection('choose image');
@@ -176,16 +173,13 @@ $first{'widgets'}{'button'}{'file'}->signal_connect( clicked =>sub{
});
#- changing theme name
$first{'widgets'}{'combo'}{'name'}->entry->signal_connect( changed => sub{ &get_this_thm_res_conf; $theme{'name'} = $first{'widgets'}{'combo'}{'name'}->entry->get_text; });
-$first{'widgets'}{'button'}{'save'}->signal_connect(clicked=> sub{ &write_boot_thm });
-#**************************************************
#**************************************************
-# <<<<<<<<<< FIRST SCREEN <<<<<<<<<<
+
$first_vbox = new Gtk::VBox(0,5);
-#$first_vbox->add($boot_conf_frame{'frame'});
$first_vbox->add($first{'frame'});
-
+$first_vbox->add($boot_conf_frame{'frame'});
&make_boot_frame;
# set window attributes and show it
@@ -194,7 +188,7 @@ $window->add($first_vbox);
$window->set_policy( 0, 1, 1 );
$window->set_position('center');
$window->show_all();
-&show_act(\%first);
+#&show_act(\%first);
# Gtk event loop
main Gtk;
@@ -350,14 +344,14 @@ sub giv_exist_thm{
#- Args => action(str)
#- Return=> (bool)
sub show_act{
- my ($action) = @_;
- foreach (@action_frame){
- if($_ == $action){
- $_->{'frame'}->show_all ;
- }else{
- $_->{'frame'}->hide;
- }
- }
+# my ($action) = @_;
+# foreach (@action_frame){
+# if($_ == $action){
+# $_->{'frame'}->show_all ;
+# }else{
+# $_->{'frame'}->hide;
+# }
+# }
}
#- Desc => just add tooltips
@@ -378,40 +372,40 @@ sub tool_tip{
#- Return=> all hash{'widgets'} are created and packed in $box
sub mk_frame{
my ( $box , $ref ) = @_;
- foreach(@{$ref->{'pos'}}){
+ foreach $pos (@{$ref->{'pos'}}){
+ $pos =~ m/^(\w+)(\s+)?(\w+)?$/;
#- open a new hbox
- ${$_.'hb'} = new Gtk::HBox(0,5);
+ ${$1.'hb'} = new Gtk::HBox($3?1:0,5);
#- look for label
- $ref->{'widget'}{'label'}{$_}
- and $ref->{'widgets'}{'label'}{$_} = new Gtk::Label($ref->{'widget'}{'label'}{$_})
- and ${$_.'hb'}->add($ref->{'widgets'}{'label'}{$_});
+ $ref->{'widget'}{'label'}{$1}
+ and $ref->{'widgets'}{'label'}{$1} = new Gtk::Label($ref->{'widget'}{'label'}{$1})
+ and ${$1.'hb'}->add($ref->{'widgets'}{'label'}{$1});
#- look for scale
- $ref->{'widget'}{'scale'}{$_}
- and $ref->{'widgets'}{'scale'}{$_} = new Gtk::HScale( ${$_."_adj"} = new Gtk::Adjustment(0,0,$scale_size{$_},1,10,0))
- and ${$_."hb"}->add($ref->{'widgets'}{'scale'}{$_})
- and $ref->{'widgets'}{'scale'}{$_}->set_digits(0);
- ${$_.'_adj'} and ${$_.'_adj'}->set_value($theme{'boot_conf'}{$_});
+ $ref->{'widget'}{'scale'}{$1}
+ and $ref->{'widgets'}{'scale'}{$1} = new Gtk::HScale( ${$1."_adj"} = new Gtk::Adjustment(0,0,$scale_size{$1},1,10,0))
+ and ${$1."hb"}->add($ref->{'widgets'}{'scale'}{$1})
+ and $ref->{'widgets'}{'scale'}{$1}->set_digits(0);
+ ${$1.'_adj'} and ${$1.'_adj'}->set_value($theme{'boot_conf'}{$1});
#- look for combo
- $ref->{'widget'}{'combo'}{$_}
- and @popdown = @{$ref->{'widget'}{'combo'}{$_}}
- and $ref->{'widgets'}{'combo'}{$_} = new Gtk::Combo
- and ${$_."hb"}->add($ref->{'widgets'}{'combo'}{$_})
- and $ref->{'widgets'}{'combo'}{$_}->set_popdown_strings(@popdown);
+ $ref->{'widget'}{'combo'}{$1}
+ and @popdown = @{$ref->{'widget'}{'combo'}{$1}}
+ and $ref->{'widgets'}{'combo'}{$1} = new Gtk::Combo
+ and ${$1."hb"}->add($ref->{'widgets'}{'combo'}{$1})
+ and $ref->{'widgets'}{'combo'}{$1}->set_popdown_strings(@popdown);
#- look for checkbox
- $ref->{'widget'}{'check'}{$_}
- and $ref->{'widgets'}{'check'}{$_} = new Gtk::CheckButton( $ref->{'widget'}{'check'}{$_} )
- and ${$_."hb"}->add($ref->{'widgets'}{'check'}{$_})
- and $ref->{'widgets'}{'check'}{$_}->set_active(1);
+ $ref->{'widget'}{'check'}{$1}
+ and $ref->{'widgets'}{'check'}{$1} = new Gtk::CheckButton( $ref->{'widget'}{'check'}{$1} )
+ and ${$1."hb"}->add($ref->{'widgets'}{'check'}{$1})
+ and $ref->{'widgets'}{'check'}{$1}->set_active(1);
#- look for button
- $ref->{'widget'}{'button'}{$_}
- and $ref->{'widgets'}{'button'}{$_} = new Gtk::Button($ref->{'widget'}{'button'}{$_})
- and ${$_."hb"}->add($ref->{'widgets'}{'button'}{$_});
+ $ref->{'widget'}{'button'}{$1}
+ and $ref->{'widgets'}{'button'}{$1} = new Gtk::Button($ref->{'widget'}{'button'}{$1})
+ and ${$1."hb"}->add($ref->{'widgets'}{'button'}{$1});
#- look for tooltips
- $ref->{'widget'}{'tooltip'}{$_}
- and &tool_tip($_,\%{$ref});
- ${$box}->add(${$_."hb"});
+ $ref->{'widget'}{'tooltip'}{$1}
+ and &tool_tip($1,\%{$ref});
+ ${$box}->add(${$1."hb"});
}
- #####################la ligne en dessous est a revoir aparement##########################
$ref->{'frame'}->add(${$box});
}
@@ -448,8 +442,11 @@ sub make_boot_frame{
});
$color->show;
});
+ #- quit button
+ $boot_conf_frame{'widgets'}{'button'}{'kill'}->signal_connect( clicked => \&CloseAppWindow);
+ $boot_conf_frame{'widgets'}{'button'}{'save'}->signal_connect(clicked=> sub{ &write_boot_thm });
#- return to first screen
- $boot_conf_frame{'widgets'}{'button'}{'annul'}->signal_connect( clicked => sub { show_act( \%first ) } );
+ #$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{
if(! -f $first{'widgets'}{'label'}{'file'}->get) {
@@ -464,12 +461,18 @@ sub make_boot_frame{
my $progress_br = ($theme{'boot_conf'}{'px'}+$theme{'boot_conf'}{'pw'}).','.($theme{'boot_conf'}{'py'}+$theme{'boot_conf'}{'ph'});
my $w = $in->wait_message('', _("Generating preview ..."));
$x++;
- $com = "convert -scale $theme{'res'}{'res'} -fill black -draw 'rectangle $text_tl $text_br rectangle $progress_tl $progress_br' ".$first{'widgets'}{'label'}{'file'}->get." $tmp_path.prev$x.png";
- system($com);
- &show_prev("$tmp_path.prev$x.png");
+ local $txt_tl_x = $theme{'boot_conf'}{'tx'}*$font_size{'w'};
+ local $txt_tl_y = $theme{'boot_conf'}{'ty'}*$font_size{'h'};
+ local $txt_width = $theme{'boot_conf'}{'tw'}*$font_size{'w'};
+ local $txt_height = $theme{'boot_conf'}{'th'}*$font_size{'h'};
+ local $prog_tl_x = $theme{'boot_conf'}{'px'};
+ local $prog_tl_y = $theme{'boot_conf'}{'py'};
+ local $prog_width = $theme{'boot_conf'}{'pw'};
+ local $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);
} );
- $first_vbox->add($boot_conf_frame{'frame'});
- #- check scales values are possibly correct
+ $boot_conf_frame{'frame'}->show_all;
+# - check scales values are possibly correct
#&set_scale_values;
foreach my $k ( keys %{$theme{'boot_conf'}}){
@@ -486,20 +489,34 @@ sub set_thm_values{
and $theme{'boot_conf'}{$_} = int(${$_.'_adj'}->get_value);
}
}
-
+
+
+#- 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);
+ undef($prev_pix);
+}
#- Desc => create a new window with a preview of splash screen
#- Args => $file (str) full path to preview file
sub show_prev{
- my ($file) = @_;
+ my ($file,$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 Gtk::Window('toplevel') and $prev_window->set_policy( 0, 1, 1 ) );
- #- must destroy and recreate or get a bug on refreshing the preview window!
- $pix
- and $pix->destroy;
- my $pic = gtkcreate_png_pixbuf($file);
- $pix = new Gtk::Pixmap($pic->render_pixmap_and_mask($pic),'');
- $prev_window->add($pix);
- $prev_window ->signal_connect(delete_event => sub{$prev_window->destroy ; undef($prev_window);} );
+ $prev_window->set_title(_("%s BootSplash (%s) preview",$theme{'name'},$theme{'res'}{'res'}));
+ $prev_pic = gtkcreate_png_pixbuf($file);
+ $prev_pic->scale_simple($theme{'res'}{'w'},$theme{'res'}{'h'},0);
+ $prev_pix = $prev_pic->render_pixmap_and_mask($prev_pic);
+ ( $prev_canvas and $prev_canvas->isa('Gtk::Widget') )
+ or ( $prev_canvas = new Gtk::DrawingArea() and $prev_window->add($prev_canvas) );
+ $prev_canvas->set_usize($theme{'res'}{'w'},$theme{'res'}{'h'});
+ $prev_canvas->signal_connect( expose_event => sub{
+ $prev_canvas->window->draw_pixmap( $prev_canvas->style->bg_gc('normal'),$prev_pix,0,0,0,0,$theme{'res'}{'w'},$theme{'res'}{'h'});
+ $prev_canvas->window->draw_rectangle( $prev_canvas->style->black_gc, $true,$txt_tl_x, $txt_tl_y,$txt_width,$txt_height );
+ $prev_canvas->window->draw_rectangle( $prev_canvas->style->black_gc, $true, $prog_tl_x,$prog_tl_y,$prog_width, $prog_height );
+ });
+ $prev_window ->signal_connect(delete_event => \&kill_preview );
$prev_window->show_all;
}