diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2004-02-04 23:24:37 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2004-02-04 23:24:37 +0000 |
commit | 941286437778eeb33c6dcc36cc70190f9a3f2635 (patch) | |
tree | 78c187873ba43aa46e48e997f21c320dee60492c | |
parent | 9fe81ce6b66aaeb05c51c78b7bf98925615e474b (diff) | |
download | drakx-941286437778eeb33c6dcc36cc70190f9a3f2635.tar drakx-941286437778eeb33c6dcc36cc70190f9a3f2635.tar.gz drakx-941286437778eeb33c6dcc36cc70190f9a3f2635.tar.bz2 drakx-941286437778eeb33c6dcc36cc70190f9a3f2635.tar.xz drakx-941286437778eeb33c6dcc36cc70190f9a3f2635.zip |
- rename $ugtk2::force_center used at install with $ugtk2::force_center_at_pos
the boolean $ugtk2::force_center value used standalone is kept as before
- deprecate $::noBorder (it was the same as !$::isInstall)
- deprecate $ugtk2::force_position (unused AFAIK)
- _create_window() now returns the created window, it doesn't assign {rwindow}
nor {window} anymore. It doesn't handle a Frame for the window
(it is now directly done by ugtk2->new which is the only function using _create_window())
- deprecate option no_interactive_objects (unused AFAIK)
- {rwindow} is a VBox for both isWizard and isEmbedded
(when isEmbedded, a HBox was created, replacing the create VBox)
- call ->set_title on $::WizardWindow so that the title is honored in non embedded wizard
- remove $draw2 and wiz_default_left.png which are unused
- remove ->set_uposition on $::WizardWindow for install. This is not needed
anymore since force_center_at_pos now works on $::WizardWindow
- hoist $::WizardTable creation
- explicitly set the size of the window during install. The chosen value is
the same as before +9 pixels for the height
(the size needs to be fixed since the advertising images must fit)
- remove the callbacks on expose_event and delete_event for non embedded wizard.
they are the same as the one in _create_window()
(except for the delete_event which explicitly destroy the window, is that ok??)
more questions:
- ->set_title on a plug may break, it needs testing
- flush() just after Gtk2::Plug->new, is it needed? (since there is another flush())
-rw-r--r-- | perl-install/ugtk2.pm | 129 |
1 files changed, 59 insertions, 70 deletions
diff --git a/perl-install/ugtk2.pm b/perl-install/ugtk2.pm index fcc8d66e4..c80b554bb 100644 --- a/perl-install/ugtk2.pm +++ b/perl-install/ugtk2.pm @@ -2,7 +2,7 @@ package ugtk2; use diagnostics; use strict; -use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK @icon_paths $force_center $force_focus $force_position $grab $pop_it $border); #- leave it on one line, for automatic removal of the line at package creation +use vars qw(@ISA %EXPORT_TAGS @EXPORT_OK @icon_paths $force_center_at_pos $force_center $force_focus $grab $pop_it $border); #- leave it on one line, for automatic removal of the line at package creation use lang; $::o = { locale => lang::read() } if !$::isInstall; @@ -866,40 +866,51 @@ sub new { my $o = bless { %opts }, $type; - $o->_create_window($title); while (my $e = shift @tempory::objects) { $e->destroy } - $o->{pop_it} ||= $pop_it || !$::isWizard && !$::isEmbedded || $::WizardTable && do { + $o->{isWizard} ||= $::isWizard; + $o->{isEmbedded} ||= $::isEmbedded; + + $o->{pop_it} ||= $pop_it || !$o->{isWizard} && !$o->{isEmbedded} || $::WizardTable && do { my @l = $::WizardTable->get_children; - pop @l if !$::isInstall && $::isWizard; #- don't take into account the DrawingArea + pop @l if !$::isInstall && $o->{isWizard}; #- don't take into account the DrawingArea any { $_->visible } @l; }; if ($o->{pop_it}) { + $o->{rwindow} = _create_window($o, $title); + + if ($::isInstall) { + gtkadd($o->{rwindow}, + gtkadd(gtkset_shadow_type(Gtk2::Frame->new(undef), 'out'), + $o->{window} = gtkset_border_width(gtkset_shadow_type(Gtk2::Frame->new(undef), 'none'), 3) + )); + } else { + $o->{window} = $o->{rwindow}; + } $o->{rwindow}->set_position('center_always') if - $::isStandalone && ($force_center || $o->{force_center}) || + $force_center || $o->{force_center} || @interactive::objects && $::isStandalone && !$o->{transient}; #- no need to center when set_transient is used - push @interactive::objects, $o if !$opts{no_interactive_objects}; $o->{rwindow}->set_modal(1) if ($grab || $o->{grab} || $o->{modal}) && !$::isInstall; $o->{rwindow}->set_transient_for($o->{transient}) if $o->{transient}; - } - if ($::isWizard && !$o->{pop_it}) { - $o->{isWizard} = 1; - $o->{window} = Gtk2::VBox->new(0,0); + } elsif ($o->{isWizard}) { + $o->{rwindow} = $o->{window} = Gtk2::VBox->new(0,0); $o->{window}->set_border_width($::Wizard_splash ? 0 : 10); - $o->{rwindow} = $o->{window}; set_main_window_size($o); - if (!defined($::WizardWindow) && !$::isEmbedded) { - $::WizardWindow = Gtk2::Window->new('toplevel'); - $::WizardWindow->signal_connect(delete_event => sub { die 'wizcancel' }); - $::WizardWindow->signal_connect(expose_event => \&_XSetInputFocus) if $force_focus || $o->{force_focus}; - $::WizardTable = Gtk2::Table->new(2, 2, 0); + $::WizardTable ||= Gtk2::Table->new(2, 2, 0); + + if (!$::Plug && $o->{isEmbedded}) { + $::Plug = $::WizardWindow = gtkshow(Gtk2::Plug->new($::XID)); + flush(); + $::Plug->add($::WizardTable); + } elsif (!$::WizardWindow) { + $::WizardWindow = _create_window($o, $title); + $::WizardWindow->add(gtkadd(gtkset_shadow_type(Gtk2::Frame->new, 'out'), $::WizardTable)); if ($::isInstall) { - $::WizardWindow->set_uposition($::stepswidth + $::windowwidth * 0.04 + ($::move && 50), $::logoheight + $::windowheight * ($::logoheight ? 0.12 : 0.05)); $::WizardWindow->signal_connect(key_press_event => sub { my (undef, $event) = @_; my $d = ${{ $Gtk2::Gdk::Keysyms{F2} => 'screenshot' }}{$event->keyval}; @@ -911,54 +922,30 @@ sub new { } 0; }); - } elsif (!$::isEmbedded) { + } elsif (!$o->{isEmbedded}) { my $draw1 = Gtk2::DrawingArea->new; $draw1->set_size_request(540, 100); - my $draw2 = Gtk2::DrawingArea->new; - $draw2->set_size_request(100, 300); my $pixbuf_up = gtkcreate_pixbuf($::Wizard_pix_up || "wiz_default_up.png"); - my $pixbuf_left = gtkcreate_pixbuf($::Wizard_pix_left || "wiz_default_left.png"); $draw1->modify_font(Gtk2::Pango::FontDescription->from_string(N("utopia 25"))); $draw1->signal_connect(expose_event => sub { my $height = $pixbuf_up->get_height; - for (my $i = 0; $i < 540/$height; $i++) { + for (my $i = 0; $i < 540 / $height; $i++) { $pixbuf_up->render_to_drawable($draw1->window, $draw1->style->bg_gc('normal'), - 0, 0, 0, $height*$i, -1, -1, 'none', 0, 0); + 0, 0, 0, $height * $i, -1, -1, 'none', 0, 0); my $layout = $draw1->create_pango_layout($::Wizard_title); $draw1->window->draw_layout($draw1->style->white_gc, 40, 62, $layout); } }); - $draw2->signal_connect(expose_event => sub { - my $height = $pixbuf_left->get_height; - for (my $i = 0; $i < 300/$height; $i++) { - $pixbuf_left->render_to_drawable($draw2->window, - $draw2->style->bg_gc('normal'), - 0, 0, 0, $height*$i, -1, -1, 'none', 0, 0); - } - }); $::WizardWindow->set_position('center_always') if !$::isStandalone; $::WizardTable->attach($draw1, 0, 2, 0, 1, 'fill', 'fill', 0, 0); } - $::WizardWindow->show_all; - flush(); - } - $::WizardTable->attach($o->{window}, 0, 2, 1, 2, ['fill', 'expand'], ['fill', 'expand'], 0, 0) if !$::isEmbedded; - } - - if ($::isEmbedded && !$o->{pop_it}) { - $o->{isEmbedded} = 1; - $o->{window} = new Gtk2::HBox(0,0); - $o->{rwindow} = $o->{window}; - if (!$::Plug) { - $::Plug = gtkshow(Gtk2::Plug->new($::XID)); - flush(); - $::WizardTable = Gtk2::Table->new(2, 2, 0); - $::Plug->add($::WizardTable); } + $::WizardWindow->set_title($title); + $::WizardWindow->show_all; + flush(); $::WizardTable->attach($o->{window}, 0, 2, 1, 2, ['fill', 'expand'], ['fill', 'expand'], 0, 0); - $::WizardTable->show; } $o->{rwindow}->signal_connect(destroy => sub { $o->{destroyed} = 1 }); @@ -966,9 +953,7 @@ sub new { } sub set_main_window_size { my ($o) = @_; - my ($width, $height) = - $::isInstall ? ($::windowwidth * 0.90, $::windowheight * ($::logoheight ? 0.73 : 0.9)) : - $o->{isWizard} ? (540, 360) : (600, 400); + my ($width, $height) = $::isInstall ? (576, 418) : $o->{isWizard} ? (540, 360) : (600, 400); $o->{window}->set_size_request($width, $height); } @@ -1016,16 +1001,19 @@ END { &exit() } sub _create_window($$) { my ($o, $title) = @_; my $w = Gtk2::Window->new('toplevel'); - my $inner = gtkadd(gtkset_shadow_type(Gtk2::Frame->new(undef), 'out'), - my $f = gtkset_border_width(gtkset_shadow_type(Gtk2::Frame->new(undef), 'none'), 3) - ); - gtkadd($w, $inner) if !$::noBorder; + $w->set_name("Title"); $w->set_title($title); - $w->signal_connect(expose_event => \&_XSetInputFocus) if $force_focus || $o->{force_focus}; - $w->signal_connect(delete_event => sub { if ($::isWizard) { $w->destroy; die 'wizcancel' } else { Gtk2->main_quit } }); - $w->set_uposition(@{$force_position || $o->{force_position}}) if $force_position || $o->{force_position}; + $w->signal_connect(expose_event => \&_XSetInputFocus) if $force_focus; + $w->signal_connect(delete_event => sub { + if ($::isWizard) { + $w->destroy; + die 'wizcancel'; + } else { + Gtk2->main_quit; + } + }); if ($::isInstall && $::o->{mouse}{unsafe}) { $w->add_events('pointer-motion-mask'); @@ -1037,20 +1025,21 @@ sub _create_window($$) { }); } - my ($wi, $he); - $w->signal_connect(size_allocate => sub { - my (undef, $event) = @_; - my @w_size = $event->values; - return if $w_size[2] == $wi && $w_size[3] == $he; #BUG - (undef, undef, $wi, $he) = @w_size; - - my ($X, $Y, $Wi, $He) = @{$force_center || $o->{force_center}}; - $w->set_uposition(max(0, $X + ($Wi - $wi) / 2), max(0, $Y + ($He - $he) / 2)); - - }) if $::isInstall && ($force_center || $o->{force_center}) && !($force_position || $o->{force_position}); + if ($force_center_at_pos) { + my ($wi, $he); + + $w->signal_connect(size_allocate => sub { + my (undef, $event) = @_; + my @w_size = $event->values; + return if $w_size[2] == $wi && $w_size[3] == $he; #BUG + (undef, undef, $wi, $he) = @w_size; + + my ($X, $Y, $Wi, $He) = @$force_center_at_pos; + $w->set_uposition(max(0, $X + ($Wi - $wi) / 2), max(0, $Y + ($He - $he) / 2)); + }); + } - $o->{window} = $::noBorder ? $w : $f; - $o->{rwindow} = $w; + $w; } sub _XSetInputFocus { |