diff options
Diffstat (limited to 'perl-install/standalone/drakfloppy')
| -rwxr-xr-x | perl-install/standalone/drakfloppy | 122 |
1 files changed, 64 insertions, 58 deletions
diff --git a/perl-install/standalone/drakfloppy b/perl-install/standalone/drakfloppy index e94ee0225..a864b678a 100755 --- a/perl-install/standalone/drakfloppy +++ b/perl-install/standalone/drakfloppy @@ -1,9 +1,8 @@ #!/usr/bin/perl # DrakFloppy -# $Id$ # -# Copyright (C) 2001-2004 Mandrakesoft +# Copyright (C) 2001-2008 Mandriva # Yves Duret # Thierry Vignaud # @@ -29,25 +28,33 @@ use lib qw(/usr/lib/libDrakX); use standalone; #- warning, standalone must be loaded very first, for 'explanations' use common; -use ugtk2 qw(:create :dialogs :helpers :wrappers); +use mygtk3 qw(gtknew); +use ugtk3 qw(:create :dialogs :helpers :wrappers); use detect_devices; -$ugtk2::wm_icon = "/usr/share/mcc/themes/default/drakfloppy-mdk.png"; +$ugtk3::wm_icon = "/usr/share/mcc/themes/default/drakfloppy-mdk.png"; require_root_capability(); -my $window = ugtk2->new('drakfloppy'); +my $window = ugtk3->new(N("Boot Floppy")); unless ($::isEmbedded) { - $window->{rwindow}->signal_connect(delete_event => sub { ugtk2->exit(0) }); - $window->{rwindow}->set_title(N("drakfloppy")); + $window->{rwindow}->signal_connect(delete_event => sub { ugtk3->exit(0) }); $window->{rwindow}->set_border_width(5); ### menus definition # the menus are not shown but they provides shiny shortcut like C-q - create_factory_menu($window->{rwindow}, ( - { path => N("/_File"), item_type => '<Branch>' }, - { path => N("/File/_Quit"), accelerator => N("<control>Q"), callback => sub { ugtk2->exit(0) } }, - ) - ); + my $ui = gtknew('UIManager', actions => [ + # [name, stock_id, value, label, accelerator, tooltip, callback] + [ 'FileMenu', undef, N("_File") ], + [ 'Quit', undef, N("_Quit"), N("<control>Q"), undef, sub { ugtk3->exit(0) } ], + ], + string => qq(<ui> + <menubar name='MenuBar'> + <menu action='FileMenu'> + <menuitem action='Quit'/> + </menu> + </menubar> +</ui>)); + $window->{rwindow}->add_accel_group($ui->get_accel_group); } @@ -63,97 +70,97 @@ eval { %options = getVarsFromSh($conffile) }; ######## up part # device part -my $device_combo = Gtk2::ComboBox->new_with_strings([ map { "/dev/" . $_->{device} } detect_devices::floppies() ]); +my $device_combo = gtknew('ComboBox', list => [ map { "/dev/$_" } detect_devices::floppies_dev() ]); $device_combo->set_active(0); # kernel part -my $kernel_combo = Gtk2::ComboBox->new_with_strings([ sort grep { !/^\.\.?$/ } sort(all("/lib/modules")) ], chomp_(`uname -r`)); +my $kernel_combo = gtknew('ComboBox', text => chomp_(`uname -r`), list => [ sort grep { !/^\.\.?$/ } sort(all("/lib/modules")) ]); ########################################################## ### main window $window->{window}->add( - gtkpack_(Gtk2::VBox->new, - if_($::isEmbedded, 0, Gtk2::Label->new(N("Boot disk creation"))), - 0, gtkadd(Gtk2::Frame->new(N("General")), - gtkpack__(Gtk2::VBox->new(0, 0), - gtkpack__(Gtk2::HBox->new(1, 0), - Gtk2::Label->new(N("Device")), + gtknew('VBox', children => [ + if_($::isEmbedded, 0, gtknew('Label', text => N("Boot disk creation"))), + 0, gtknew('Frame', text => N("General"), child => + gtknew('VBox', children_tight => [ + gtknew('HBox', homogenous => 1, children_tight => [ + gtknew('Label', text => N("Device")), $device_combo, - gtksignal_connect(Gtk2::Button->new(N("Default")), + gtknew('Button', text => N("Default"), clicked => sub { $device_combo->entry->set_text("/dev/fd0") }), - ), - gtkpack__(Gtk2::HBox->new(1, 0), - Gtk2::Label->new(N("Kernel version")), + ]), + gtknew('HBox', homogenous => 1, children_tight => [ + gtknew('Label', text => N("Kernel version")), $kernel_combo, - gtksignal_connect(Gtk2::Button->new(N("Default")), + gtknew('Button', text => N("Default"), clicked => sub { $kernel_combo->entry->set_text(chomp_(`uname -r`)); }), - ), - ), + ]), + ]), ), - 1, Gtk2::VBox->new, + 1, gtknew('VBox'), 0, create_okcancel({ - cancel_clicked => sub { ugtk2->exit(0) }, + cancel_clicked => sub { ugtk3->exit(0) }, ok_clicked => \&build_it, }, undef, undef, '', [ N("Preferences"), \&pref_dialog, 0 ], ), - ), + ]), ); $window->{rwindow}->show_all; $window->main; -ugtk2->exit(0); +ugtk3->exit(0); my $remove_but; sub pref_dialog() { my $dialog = gtkset_modal(gtkset_size_request(_create_dialog(N("Advanced preferences")), 600, -1), 1); - $dialog->set_transient_for($window->{rwindow}) unless $::isEmbedded; + $dialog->set_transient_for($window->{real_window}); # Create root tree: - $tree_model = Gtk2::TreeStore->new(("Glib::String") x 2, "Glib::Int"); - $tree = Gtk2::TreeView->new_with_model($tree_model); + $tree_model = Gtk3::TreeStore->new(("Glib::String") x 2, "Glib::Int"); + $tree = Gtk3::TreeView->new_with_model($tree_model); $tree->set_headers_visible(0); - $tree->append_column(Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0)); + $tree->append_column(Gtk3::TreeViewColumn->new_with_attributes("", Gtk3::CellRendererText->new, 'text' => 0)); $tree->signal_connect('row-expanded', \&expand_tree); $tree->get_selection->signal_connect('changed' => \&selected_tree); # Create modules list: - $list_model = Gtk2::ListStore->new(("Glib::String") x 3); # relative path, size, (hidden full path) - $list = Gtk2::TreeView->new_with_model($list_model); + $list_model = Gtk3::ListStore->new(("Glib::String") x 3); # relative path, size, (hidden full path) + $list = Gtk3::TreeView->new_with_model($list_model); each_index { - $list->append_column(my $col = Gtk2::TreeViewColumn->new_with_attributes($_, Gtk2::CellRendererText->new, 'text' => $::i)); + $list->append_column(my $col = Gtk3::TreeViewColumn->new_with_attributes($_, Gtk3::CellRendererText->new, 'text' => $::i)); $col->set_sort_column_id($::i); $col->set_min_width((200, 50)[$::i]); } (N("Module name"), N("Size")); - gtkpack_($dialog->vbox, - 0, gtkadd(Gtk2::Frame->new(N("Mkinitrd optional arguments")), - gtkpack__(Gtk2::VBox->new(0, 5), - $buttons{force} = Gtk2::CheckButton->new(N("force")), - $buttons{raid} = Gtk2::CheckButton->new(N("omit raid modules")), - $buttons{needed} = Gtk2::CheckButton->new(N("if needed")), - $buttons{scsi} = Gtk2::CheckButton->new(N("omit scsi modules")), - ), + gtkpack_($dialog->get_child, + 0, gtknew('Frame', text => N("Mkinitrd optional arguments"), child => + gtknew('VBox', spacing => 5, children_tight => [ + $buttons{force} = gtknew('CheckButton', text => N("force")), + $buttons{raid} = gtknew('CheckButton', text => N("omit raid modules")), + $buttons{needed} = gtknew('CheckButton', text => N("if needed")), + $buttons{scsi} = gtknew('CheckButton', text => N("omit scsi modules")), + ]), ), - 1, gtkadd(Gtk2::Frame->new(N("Add a module")), + 1, gtknew('Frame', text => N("Add a module"), child => create_hpaned( gtkset_size_request( - create_scrolled_window($tree), + gtknew('ScrolledWindow', child => $tree), 200, $::isEmbedded ? 0 : 175), - gtkpack_(Gtk2::VBox->new(0, 0), - 1, gtkadd(Gtk2::ScrolledWindow->new, + gtknew('VBox', children => [ + 1, gtkadd(Gtk3::ScrolledWindow->new, $list ), - 0, gtksignal_connect($remove_but = Gtk2::Button->new(N("Remove a module")), + 0, $remove_but = gtknew('Button', text => N("Remove a module"), clicked => sub { my $iter = ($list->get_selection->get_selected)[1]; return unless $iter; @@ -162,7 +169,7 @@ sub pref_dialog() { @temp_modules = grep { $_ ne $removed } @temp_modules; $remove_but->set_sensitive(scalar @temp_modules); }), - ), + ]), ), ), ); @@ -180,7 +187,7 @@ sub pref_dialog() { $remove_but->set_sensitive(scalar @modules); @temp_modules = (); - gtkadd($dialog->action_area, + gtkadd($dialog->get_action_area, create_okcancel({ cancel_clicked => sub { $dialog->destroy }, ok_clicked => sub { @@ -297,12 +304,11 @@ sub build_it() { err_dialog(N("Error"), N("There is no medium or it is write-protected for device %s.\nPlease insert one.", $device_combo->entry->get_text), { cancel => 1 }) ? goto test : return 0; } - local *STATUS; - open STATUS, $co or do { err_dialog(N("Error"), N("Unable to fork: %s", $!)); return }; - my $log = join('', <STATUS>); - if (close STATUS) { + open(my $STATUS, $co) or do { err_dialog(N("Error"), N("Unable to fork: %s", $!)); return }; + my $log = join('', <$STATUS>); + if (close $STATUS) { info_dialog(N("Floppy creation completed"), N("The creation of the boot floppy has been successfully completed \n")); - ugtk2->exit; + ugtk3->exit; } else { err_dialog(N("Error"), #-PO: Do not alter the <span ..> and </span> tags |
