package install_gtk; # $Id$ use diagnostics; use strict; use ugtk2 qw(:wrappers :helpers :create); use common; use lang; use devices; #-##################################################################################### #-INTERN CONSTANT #-##################################################################################### my @background; #- if we're running for the doc team, we want screenshots with #- a good B&W contrast: we'll override values of our theme my $theme_overriding_for_doc = q(style "galaxy-default" { base[SELECTED] = "#E0E0FF" base[ACTIVE] = "#E0E0FF" base[PRELIGHT] = "#E0E0FF" bg[SELECTED] = "#E0E0FF" bg[ACTIVE] = "#E0E0FF" bg[PRELIGHT] = "#E0E0FF" text[ACTIVE] = "#000000" text[PRELIGHT] = "#000000" text[SELECTED] = "#000000" fg[SELECTED] = "#000000" } style "white-on-blue" { base[NORMAL] = { 0.93, 0.93, 0.93 } bg[NORMAL] = { 0.93, 0.93, 0.93 } text[NORMAL] = "#000000" fg[NORMAL] = "#000000" } style "background" { bg[NORMAL] = { 0.93, 0.93, 0.93 } } style "background-logo" { bg[NORMAL] = { 0.70, 0.70, 0.70 } } widget "*logo*" style "background-logo" ); #------------------------------------------------------------------------------ sub load_rc { my ($o, $name) = @_; if (my $f = -r $name ? $name : find { -r $_ } map { "$_/themes-$name.rc" } ("share", $ENV{SHARE_PATH}, dirname(__FILE__))) { my @contents = cat_($f); $o->{doc} and push @contents, $theme_overriding_for_doc; Gtk2::Rc->parse_string(join("\n", @contents)); foreach (@contents) { if (/style\s+"background"/ .. /^\s*$/) { @background = map { $_ * 256 * 257 } split ',', $1 if /NORMAL.*\{(.*)\}/; } } } if ($::move) { #- override selection color since we won't do inverse-video on the text when it's images Gtk2::Rc->parse_string(q( style "galaxy-default" { base[ACTIVE] = "#CECECE" base[SELECTED] = "#CECECE" text[ACTIVE] = "#000000" text[PRELIGHT] = "#000000" text[SELECTED] = "#000000" } )); } } #------------------------------------------------------------------------------ sub load_font { my ($o) = @_; if (lang::text_direction_rtl()) { Gtk2::Widget->set_default_direction('rtl'); my ($x, $y) = $::WizardWindow->get_position; my ($width) = $::WizardWindow->get_size; $::WizardWindow->move($::rootwidth - $width - $x, $y); } Gtk2::Rc->parse_string(q( style "default-font" { font_name = ") . lang::l2pango_font($o->{locale}{lang}) . q(" } widget "*" style "default-font" )); } #------------------------------------------------------------------------------ sub default_theme { my ($o) = @_; $::move ? '/usr/share/themes/Galaxy/gtk-2.0/gtkrc' : $o->{meta_class} eq 'firewall' ? 'mdk-Firewall' : $o->{simple_themes} || $o->{vga16} ? 'blue' : 'galaxy'; } sub install_theme { my ($o) = @_; load_rc($o, $o->{theme} ||= default_theme($o)); load_font($o); $::move or gtkset_background(@background); } #------------------------------------------------------------------------------ sub create_help_window { my ($o) = @_; my $w; if ($w = $o->{help_window}) { $w->{window}->foreach(sub { $_[0]->destroy }, undef); } else { $w = $o->{help_window} = bless {}, 'ugtk2'; $w->{rwindow} = $w->{window} = Gtk2::Window->new('toplevel'); $w->{rwindow}->set_uposition($::rootwidth - $::helpwidth, $::rootheight - $::helpheight); $w->{rwindow}->set_size_request($::helpwidth, $::helpheight); $w->{rwindow}->set_title('skip'); }; gtkadd($w->{window}, create_scrolled_window($o->{help_window_text} = Gtk2::TextView->new)); $w->show; } #------------------------------------------------------------------------------ my %steps; sub create_steps_window { my ($o) = @_; return if $::stepswidth == 0; $o->{steps_window} and $o->{steps_window}->destroy; my $w = bless {}, 'ugtk2'; $w->{rwindow} = $w->{window} = Gtk2::Window->new('toplevel'); $w->{rwindow}->set_uposition(lang::text_direction_rtl() ? ($::rootwidth - $::stepswidth - 8) : 8, 150); $w->{rwindow}->set_size_request($::stepswidth, -1); $w->{rwindow}->set_name('Steps'); $w->{rwindow}->set_title('skip'); $steps{$_} ||= gtkcreate_pixbuf("steps_$_") foreach qw(on off); my $category = sub { gtkset_markup(Gtk2::Label->new, $o->{doc} ? $_[0] : '' . $_[0] . '') }; gtkpack__(my $vb = Gtk2::VBox->new(0, 3), $steps{inst} = $category->(N("System installation")), ''); foreach (grep { !eval $o->{steps}{$_}{hidden} } @{$o->{orderedSteps}}) { $_ eq 'setRootPassword' and gtkpack__($vb, '', '', $steps{conf} = $category->(N("System configuration")), ''); $steps{steps}{$_} = { img => gtkcreate_img('steps_off.png'), txt => Gtk2::Label->new(translate($o->{steps}{$RTSP network address translation module