diff options
Diffstat (limited to 'perl-install/install/gtk.pm')
| -rw-r--r-- | perl-install/install/gtk.pm | 127 | 
1 files changed, 56 insertions, 71 deletions
| diff --git a/perl-install/install/gtk.pm b/perl-install/install/gtk.pm index 6aa6a8c95..f878e42d9 100644 --- a/perl-install/install/gtk.pm +++ b/perl-install/install/gtk.pm @@ -1,18 +1,20 @@ -package install::gtk; # $Id$ +package install::gtk;  use diagnostics;  use strict; -use ugtk2; -use mygtk2; +use ugtk3; +use mygtk3;  use common;  use lang;  use devices; +use detect_devices;  #-#####################################################################################  #-INTERN CONSTANT  #-##################################################################################### +# FIXME: either drop 'doc' option or convert this to CSS!  #- 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" @@ -52,13 +54,15 @@ widget "*logo*" style "background-logo"  );  #------------------------------------------------------------------------------ -sub load_rc { +sub load_css {      my ($o, $name) = @_;      my $f = $name; -    -r $name or $f = find { -r $_ } map { "$_/themes-$name.rc" } ("share", $ENV{SHARE_PATH}, dirname(__FILE__) . '/..'); +    -r $name or $f = find { -r $_ } map { "$_/themes-$name.css" } ("share", $ENV{SHARE_PATH}, dirname(__FILE__) . '/..');      if ($f) { -	Gtk2::Rc->parse_string($o->{doc} ? $theme_overriding_for_doc : scalar cat_($f)); +	my $pl = Gtk3::CssProvider->new; +	$pl->load_from_data($o->{doc} ? $theme_overriding_for_doc : scalar cat_($f)); +	Gtk3::StyleContext::add_provider_for_screen(Gtk3::Gdk::Screen::get_default(), $pl, Gtk3::STYLE_PROVIDER_PRIORITY_APPLICATION);     }  } @@ -66,20 +70,21 @@ sub load_rc {  sub load_font {      my ($o) = @_; -    if (lang::text_direction_rtl()) { -	Gtk2::Widget->set_default_direction('rtl');  +    if (defined($::WizardWindow) && lang::text_direction_rtl()) { +	Gtk3::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" - +    my $font = lang::l2pango_font($o->{locale}{lang}); +    my $s = qq(gtk-font-name = $font); +    my $pl = Gtk3::CssProvider->new; +    $pl->load_from_data(sprintf("GtkWindow { %s }", lang::l2css_font($o->{locale}{lang}))); +    Gtk3::StyleContext::add_provider_for_screen(Gtk3::Gdk::Screen::get_default(), $pl, Gtk3::STYLE_PROVIDER_PRIORITY_APPLICATION); +    # FIXME: this should be done in /mnt too for forked app such as gurpmi{,.addmedia} (mga#67): +    output("/.config/gtk-3.0/settings.ini", qq([Settings] +$s  ));  } @@ -94,13 +99,12 @@ my $root_window;  sub install_theme {      my ($o) = @_; -    load_rc($o, $o->{theme} ||= default_theme($o)); +    load_css($o, $o->{theme} ||= default_theme($o));      load_font($o);      my $win = gtknew('Window', widget_name => 'background', title => 'root window');      $win->set_type_hint('desktop'); # for matchbox window manager      $win->realize; -    mygtk2::set_root_window_background_with_gc($win->style->bg_gc('normal'));      $root_window = $win;  } @@ -159,7 +163,8 @@ sub create_steps_window {                     ],               )      ); -         + +    $root_window->set_position('GTK_WIN_POS_CENTER_ALWAYS');      $root_window->show_all;  } @@ -171,7 +176,7 @@ sub update_steps_position {  	exists $steps{steps}{$_} or next;  	if ($o->{steps}{$_}{entered} && !$o->{steps}{$_}{done}) {              # we need to flush the X queue since else we got a temporary Y position of -1 when switching locales: -            mygtk2::flush(); #- for auto_installs which never go through the Gtk2 main loop +            mygtk3::flush(); #- for auto_installs which never go through the Gtk3 main loop              $o->{steps_widget}->move_selection($steps{steps}{$_}{text});              if ($last_step) { @@ -181,22 +186,19 @@ sub update_steps_position {  	}          $last_step = $_;      } -    mygtk2::flush(); #- for auto_installs which never go through the Gtk2 main loop -} - -#------------------------------------------------------------------------------ -sub create_logo { -    my ($o) = @_; - -    return if $::logowidth == 0; -    gtknew('Image', file => 'logo-mandriva.png'); +    mygtk3::flush(); #- for auto_installs which never go through the Gtk3 main loop  }  #------------------------------------------------------------------------------  sub init_gtk {      my ($o) = @_; -    symlink("/tmp/stage2/etc/$_", "/etc/$_") foreach qw(gtk-2.0 pango fonts); +    symlink("/tmp/stage2/etc/$_", "/etc/$_") foreach qw(gtk-3.0 pango fonts); + +    # Custom _global_ CSS: +    mkdir_p("/.config/gtk-3.0");  # TODO/FIXME: set ENV{HOME} ? +    # FIXME: this should be done in /mnt too for forked app such as gurpmi{,.addmedia} (mga#67): +    symlinkf('/usr/lib/libDrakX/gtk.css', '/.config/gtk-3.0/gtk.css');      if ($o->{vga16}) {          #- inactivate antialias in VGA16 because it makes fonts look worse @@ -209,18 +211,19 @@ q(<fontconfig>          $ENV{FONTCONFIG_FILE} = '/tmp/fonts.conf';      } -    Gtk2->init; -    Gtk2->set_locale; +    Gtk3->init; +    c::init_setlocale();  }  #------------------------------------------------------------------------------  sub init_sizes {      my ($o) = @_; -    ($::rootwidth,  $::rootheight)    = (Gtk2::Gdk->screen_width, Gtk2::Gdk->screen_height); +    ($::rootwidth,  $::rootheight)    = (Gtk3::Gdk::Screen::width, Gtk3::Gdk::Screen::height);      $::stepswidth = $::rootwidth <= 640 ? 0 : 196; -    ($::logowidth, $::logoheight) = $::rootwidth <= 640 ? (0, 0) : (800, 75);      ($o->{windowwidth}, $o->{windowheight}) = ($::rootwidth - $::stepswidth, $::rootheight); -    ($::real_windowwidth, $::real_windowheight) = (576, 465); +    # Adapt the window size to available screen width and height. +    $::real_windowwidth = $::rootwidth > 800 ? 800 : 576; +    $::real_windowheight = $::rootheight > 600 ? 633 : 465;  }  sub handle_unsafe_mouse { @@ -238,53 +241,39 @@ sub handle_unsafe_mouse {  sub special_shortcuts {      my (undef, $event) = @_; -    my $d = ${{ $Gtk2::Gdk::Keysyms{F2} => 'screenshot', $Gtk2::Gdk::Keysyms{Home} => 'restart' }}{$event->keyval}; +    my $d = ${{ Gtk3::Gdk::KEY_F2 => 'screenshot', Gtk3::Gdk::KEY_Home => 'restart' }}{$event->keyval};      if ($d eq 'screenshot') { +	# FIXME: should handle the fact it doesn't work when chrooted by urpmi during transaction:  	install::any::take_screenshot($::o);      } elsif ($d eq 'restart' && member('control-mask', @{$event->state}) && member('mod1-mask', @{$event->state})) {  	log::l("restarting install"); -	ugtk2->exit(0x35); +	ugtk3->exit(0x35);      }      0;  }  #------------------------------------------------------------------------------  sub createXconf { -    my ($file, $mouse_type, $mouse_dev, $_wacom_dev, $Driver) = @_; - -    $mouse_type = 'IMPS/2' if $mouse_type eq 'vboxmouse'; -    symlinkf(devices::make($mouse_dev), "/dev/mouse") if $mouse_dev ne 'none'; - -    #- needed for imlib to start on 8-bit depth visual. -    symlink("/tmp/stage2/etc/imrc", "/etc/imrc"); -    symlink("/tmp/stage2/etc/im_palette.pal", "/etc/im_palette.pal"); +    my ($file, $Driver) = @_;      #- remove "error opening security policy file" warning      symlink("/tmp/stage2/etc/X11", "/etc/X11"); -if ($Driver) { -     output($file, sprintf(<<'END', $mouse_type, $Driver, $Driver eq 'fbdev' ? '"default"' : '"800x600" "640x480"')); -Section "ServerFlags" -   Option "AutoAddDevices" "False" -EndSection +    return if !$Driver; -Section "Files" -   FontPath   "/usr/share/fonts:unscaled" +     # grub2-efi init framebuffer in 1024x768, we must stay in sync or loading fails +     my $resolution = $Driver eq 'fbdev' ? is_uefi() ? '"1024x768"' : '"default"' : '"800x600" "640x480"'; +     # efi framebuffer wants 24 bit +     my $depth = is_uefi() ? '24' : '16'; +     output($file, qq(Section "ServerFlags"  EndSection -Section "InputDevice" -    Identifier "Keyboard" -    Driver "keyboard" -    Option "XkbModel" "pc105" -    Option "XkbLayout" "us" +Section "Module" +      Disable "glx"  EndSection -Section "InputDevice" -    Identifier "Mouse" -    Driver "mouse" -    Option "Protocol" "%s" -    Option "Device" "/dev/mouse" -    Option "ZAxisMapping" "4 5" +Section "Files" +   FontPath   "/usr/share/fonts:unscaled"  EndSection  Section "Monitor" @@ -295,17 +284,17 @@ EndSection  Section "Device"      Identifier  "device" -    Driver      "%s" +    Driver      "$Driver"  EndSection  Section "Screen"      Identifier "screen"      Device "device"      Monitor "monitor" -    DefaultColorDepth 16 +    DefaultColorDepth $depth      Subsection "Display" -        Depth 16 -        Modes %s +        Depth $depth +        Modes $resolution      EndSubsection  EndSection @@ -316,12 +305,8 @@ Section "ServerLayout"      Option "OffTime"     "0"      Identifier "layout"      Screen "screen" -    InputDevice "Mouse" "CorePointer" -    InputDevice "Keyboard" "CoreKeyboard"  EndSection - -END - } +));  }  1; | 
