diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2005-01-11 15:04:21 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2005-01-11 15:04:21 +0000 |
commit | 62aacf365cfd1c466f9fb253d21d02979d7d8610 (patch) | |
tree | e533e6ac33f58f0291aedbd002936fd0aa9a1d52 | |
parent | 6412d705227eb1cfc27b0ef5182235f70266fba3 (diff) | |
download | drakx-62aacf365cfd1c466f9fb253d21d02979d7d8610.tar drakx-62aacf365cfd1c466f9fb253d21d02979d7d8610.tar.gz drakx-62aacf365cfd1c466f9fb253d21d02979d7d8610.tar.bz2 drakx-62aacf365cfd1c466f9fb253d21d02979d7d8610.tar.xz drakx-62aacf365cfd1c466f9fb253d21d02979d7d8610.zip |
create "MagicWindow" in mygtk2 out of ugtk2::new()
-rw-r--r-- | perl-install/interactive/gtk.pm | 2 | ||||
-rw-r--r-- | perl-install/mygtk2.pm | 71 | ||||
-rw-r--r-- | perl-install/ugtk2.pm | 62 |
3 files changed, 74 insertions, 61 deletions
diff --git a/perl-install/interactive/gtk.pm b/perl-install/interactive/gtk.pm index 7526c8a8b..226237e3a 100644 --- a/perl-install/interactive/gtk.pm +++ b/perl-install/interactive/gtk.pm @@ -596,7 +596,7 @@ sub ask_fromW { $mainw->{box_allow_grow} = 1; my $pack = create_box_with_title($mainw, @{$common->{messages}}); - ugtk2::set_main_window_size($mainw->{window}) if $mainw->{pop_it} && (@$l || $mainw->{box_size} == 200); + ugtk2::set_main_window_size($mainw->{rwindow}) if $mainw->{pop_it} && (@$l || $mainw->{box_size} == 200); my @before_widgets_advanced = ( (map { { grow => 0, real_w => Gtk2::WrappedLabel->new($_) } } @{$common->{advanced_messages}}), diff --git a/perl-install/mygtk2.pm b/perl-install/mygtk2.pm index d2b1340aa..763f55bf7 100644 --- a/perl-install/mygtk2.pm +++ b/perl-install/mygtk2.pm @@ -437,6 +437,56 @@ sub _gtk_any_Window { $w; } +sub _gtk__MagicWindow { + my ($w, $opts) = @_; + + my $pop_it = delete $opts->{pop_it} || !$::isWizard && !$::isEmbedded || $::WizardTable && do { + #- do not take into account the wizard banner + any { !$_->isa('Gtk2::DrawingArea') && $_->visible } $::WizardTable->get_children; + }; + + my $sub_child = delete $opts->{child} or internal_error("missing child"); + + if ($pop_it) { + $opts->{child} = $::isInstall ? + gtknew('Frame', shadow_type => 'out', + child => gtknew('Frame', shadow_type => 'none', border_width => 3, child => $sub_child)) : + $sub_child; + + $w = _create_Window($opts); + } else { + if (!$::WizardWindow) { + + my $banner; + if (!$::isEmbedded && !$::isInstall) { + $banner = Gtk2::Banner->new($opts->{icon_no_error}, $::Wizard_title) or log::l("ERROR: missing wizard banner"); + } + $::WizardTable = gtknew('VBox', if_($banner, children_tight => [ $banner ])); + + if ($::isEmbedded) { + add2hash($opts, { + socket_id => $::XID, + child => $::WizardTable, + }); + $::Plug = $::WizardWindow = _gtk(undef, 'Plug', 'gtknew', $opts); + sync($::WizardWindow); + } else { + add2hash($opts, { + child => gtknew('Frame', shadow_type => 'out', child => $::WizardTable), + }); + $::WizardWindow = _create_Window($opts); + $::WizardWindow->show; + } + } else { + %$opts = (); + } + + gtkset($::WizardTable, children_loose => [ $sub_child ]); + $w = $::WizardWindow; + } + $w; +} + sub _gtk__FileSelection { my ($w, $opts) = @_; @@ -559,21 +609,22 @@ sub _gtknew_handle_children { } sub _create_Window { - my (%options) = @_; + my ($opts) = @_; my $no_Window_Manager = !$::isStandalone; - my $w = gtknew('Window', - if_(!$::isInstall && !$::isWizard, border_width => 5), + add2hash($opts, { + if_(!$::isInstall && !$::isWizard, border_width => 5), - #- policy: during install, we need a special code to handle the weird centering, see below - position_policy => $::isInstall ? 'none' : $no_Window_Manager ? 'center-always' : 'center-on-parent', + #- policy: during install, we need a special code to handle the weird centering, see below + position_policy => $::isInstall ? 'none' : $no_Window_Manager ? 'center-always' : 'center-on-parent', - if_($::isInstall, position => [ - $::rootwidth - ($::windowwidth + $::real_windowwidth) / 2, - $::logoheight + ($::windowheight - $::real_windowheight) / 2, - ]), - %options); + if_($::isInstall, position => [ + $::rootwidth - ($::windowwidth + $::real_windowwidth) / 2, + $::logoheight + ($::windowheight - $::real_windowheight) / 2, + ]), + }); + my $w = _gtk(undef, 'Window', 'gtknew', $opts); #- when the window is closed using the window manager "X" button (or alt-f4) $w->signal_connect(delete_event => sub { diff --git a/perl-install/ugtk2.pm b/perl-install/ugtk2.pm index 8152b90f1..d0e42d711 100644 --- a/perl-install/ugtk2.pm +++ b/perl-install/ugtk2.pm @@ -830,61 +830,23 @@ sub new { my $o = bless { %opts }, $type; while (my $e = shift @tempory::objects) { $e->destroy } - $o->{pop_it} ||= !$::isWizard && !$::isEmbedded || $::WizardTable && do { - #- do not take into account the wizard banner - any { !$_->isa('Gtk2::DrawingArea') && $_->visible } $::WizardTable->get_children; - }; - - my %window_options = ( + my $window = gtknew( + 'MagicWindow', title => $title || '', + pop_it => $o->{pop_it}, + child => $o->{window} = gtknew('VBox'), + modal => $grab || $o->{grab} || $o->{modal}, if_(!$::isInstall, icon_no_error => wm_icon()), + if_($o->{transient} && $o->{transient} =~ /Gtk2::Window/, transient_for => $o->{transient}), ); - - if ($o->{pop_it}) { - $o->{rwindow} = mygtk2::_create_Window( - %window_options, - modal => $grab || $o->{grab} || $o->{modal}, - if_($o->{transient} && $o->{transient} =~ /Gtk2::Window/, transient_for => $o->{transient}), - ); - - if ($::isInstall) { - gtkadd($o->{rwindow}, - gtknew('Frame', shadow_type => 'out', child => - $o->{window} = gtknew('Frame', shadow_type => 'none', border_width => 3) - )); - } else { - $o->{window} = $o->{rwindow}; - } - } else { - if (!$::WizardWindow) { - my $banner; - if (!$::isEmbedded && !$::isInstall) { - $banner = Gtk2::Banner->new(wm_icon(), $::Wizard_title) or log::l("ERROR: missing wizard banner"); - } - $::WizardTable = gtknew('VBox', - if_($banner, children_tight => [ $banner ]), - ); - - if ($::isEmbedded) { - $::Plug = $::WizardWindow = gtknew('Plug', - socket_id => $::XID, - icon_no_error => wm_icon(), - child => $::WizardTable, - title => $title || '', - ); - mygtk2::sync($::WizardWindow); - } else { - $::WizardWindow = mygtk2::_create_Window( - %window_options, - child => gtknew('Frame', shadow_type => 'out', child => $::WizardTable), - ); - $::WizardWindow->show; - } - } - $o->{rwindow} = $o->{window} = gtknew('VBox', border_width => 10); + if ($window == $::WizardWindow) { + $o->{rwindow} = $o->{window}; set_main_window_size($o->{window}); - gtkpack($::WizardTable, $o->{window}); + $o->{window}->set_border_width(10); + } else { + $o->{rwindow} = $window; + $o->{pop_it} = 1; } $o; } |