From 954e51dc037721f49e4979c7ef1c995c8aca1619 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Tue, 3 May 2005 11:45:08 +0000 Subject: new theme creation functions --- perl-install/bootsplash.pm | 110 ++++++++++++++++++++++++++++++++++----- perl-install/standalone/drakboot | 10 ++-- 2 files changed, 103 insertions(+), 17 deletions(-) diff --git a/perl-install/bootsplash.pm b/perl-install/bootsplash.pm index fe4af57ac..86f2e590e 100644 --- a/perl-install/bootsplash.pm +++ b/perl-install/bootsplash.pm @@ -4,10 +4,11 @@ use common; my $themes_dir = "$::prefix/usr/share/bootsplash/themes/"; my $sysconfig_file = '$::prefix/etc/sysconfig/bootsplash'; +my $bootsplash_scripts = "$::prefix/usr/share/bootsplash/scripts"; my $default_theme = 'Mandrivalinux'; our $default_thumbnail = '/usr/share/libDrakX/pixmaps/nosplash_thumb.png'; -sub read_theme_config { +sub themes_read_sysconfig { my ($res) = @_; my %theme = ( name => $default_theme, @@ -18,40 +19,59 @@ sub read_theme_config { local $_; foreach (cat_($sysconfig_file)) { /^SPLASH=no/ and $theme{enabled} = 0; - /^THEME=(.*)/ && -f get_theme_image($1, $res) and $theme{name} = $1; + /^THEME=(.*)/ && -f theme_get_image_for_resolution($1, $res) and $theme{name} = $1; /^LOGO_CONSOLE=(.*)/ and $theme{keep_logo} = $1 ne "no"; } } \%theme; } -sub get_theme_image { + +sub theme_get_image_for_resolution { my ($theme, $res) = @_; $themes_dir . $theme . '/images/bootsplash-' . $res . ".jpg"; } -sub list_themes { +sub theme_get_config_for_resolution { + my ($theme, $res) = @_; + $themes_dir . $theme . '/cfg/bootsplash-' . $res . ".cfg"; +} + +sub theme_get_global_config { + my ($theme) = @_; + $themes_dir . $theme . '/cfg/global.config'; +} + + +sub theme_exists_for_resolution { + my ($theme, $res) = @_; + -f theme_get_image_for_resolution($theme, $res); +} + +sub themes_list() { + grep { !/^\./ && -d $themes_dir } sort(all($themes_dir)); +} + +sub themes_list_for_resolution { my ($res) = @_; - grep { - !/^\./ && -d $themes_dir . $_ && -f get_theme_image($_, $res); - } sort(all($themes_dir)); + grep { theme_exists_for_resolution($_, $res) } themes_list(); } -sub switch_theme { +sub switch { my ($theme) = @_; if ($::testing) { print "enabling bootsplash theme $theme\n"; } else { #- theme scripts will update SPLASH value in sysconfig file - system("$::prefix/usr/share/bootsplash/scripts/switch-themes", $theme); + system($bootsplash_scripts . '/switch-themes', $theme); } } -sub remove_theme() { +sub remove() { if ($::testing) { - print "disabling bootplash theme\n"; + print "disabling bootsplash theme\n"; } else { - system("$::prefix/usr/share/bootsplash/scripts/remove-theme"); + system($bootsplash_scripts . '/remove-theme'); } } @@ -61,4 +81,70 @@ sub set_logo_console { substInFile { s/^LOGO_CONSOLE=.*/LOGO_CONSOLE=$logo_console/ } $sysconfig_file; } +sub theme_set_image_for_resolution { + my ($name, $source_image, $res) = @_; + my $dest_image = theme_get_image_for_resolution($name, $res); + system('convert', '-scale', $res, $source_image, $dest_image); + system($bootsplash_scripts . '/rewritejpeg', $dest_image); +} + +sub theme_read_config_for_resolution { + my ($theme, $res) = @_; + getVarsFromSh(theme_get_config_for_resolution($theme, $res)); +} + +sub theme_write_config_for_resolution { + my ($name, $res, $conf) = @_; + + my $global_config = theme_get_global_config($name); + my $config = theme_get_config_for_resolution($name, $res); + my $theme_config_dir = $themes_dir . $name . '/cfg/'; + -d $theme_config_dir or mkdir_p($theme_config_dir); + + 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 +# 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=$conf->{tx} + +# ty is the y coordinate of the text window in characters. default is 14 +ty=$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=$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=$conf->{th} + +# px is the progress bar x coordinate of its upper left corner +px=$conf->{px} + +# py is the progress bar y coordinate of its upper left corner +py=$conf->{py} + +# pw is the with of the progress bar +pw=$conf->{pw} + +# ph is the height of the progress bar +ph=$conf->{ph} + +# pc is the color of the progress bar +pc=$conf->{pc} +)); + + output($global_config, + qq(# Display logo on console. +LOGO_CONSOLE=$conf->{logo} + +# Make kernel message quiet by default. +QUIET=$conf->{quiet} +)); +} + + 1; diff --git a/perl-install/standalone/drakboot b/perl-install/standalone/drakboot index f51699e19..4953e6b1d 100755 --- a/perl-install/standalone/drakboot +++ b/perl-install/standalone/drakboot @@ -105,13 +105,13 @@ sub splash_choice() { $cur_res = '800x600'; } - my $theme = bootsplash::read_theme_config($cur_res); + my $theme = bootsplash::themes_read_sysconfig($cur_res); $no_bootsplash and $theme->{enabled} = 0; my $boot_pic = gtkcreate_img($bootsplash::default_thumbnail); change_image($boot_pic, $theme->{name}, $cur_res); - my $theme_combo = gtkset_size_request(Gtk2::ComboBox->new_with_strings([ bootsplash::list_themes($cur_res) ], $theme->{name}), 10, -1); + my $theme_combo = gtkset_size_request(Gtk2::ComboBox->new_with_strings([ bootsplash::themes_list_for_resolution($cur_res) ], $theme->{name}), 10, -1); $theme_combo->entry->signal_connect(changed => sub { $theme->{name} = $theme_combo->entry->get_text; change_image($boot_pic, $theme->{name}, $cur_res); @@ -155,9 +155,9 @@ sub splash_choice() { sub { bootsplash::set_logo_console($theme->{keep_logo}); if ($theme->{enabled}) { - bootsplash::switch_theme($theme->{name}); + bootsplash::switch($theme->{name}); } else { - bootsplash::remove_theme(); + bootsplash::remove(); } }); } @@ -234,7 +234,7 @@ sub lilo_choice() { sub change_image { my ($boot_pic, $theme, $res) = @_; - my $img_file = bootsplash::get_theme_image($theme, $res); + my $img_file = bootsplash::theme_get_image_for_resolution($theme, $res); -f $img_file or return; my $boot_pixbuf = gtkcreate_pixbuf($img_file); $boot_pixbuf = $boot_pixbuf->scale_simple(300, 200, 'nearest'); -- cgit v1.2.1