diff options
Diffstat (limited to 'perl-install/standalone/drakfloppy')
| -rwxr-xr-x | perl-install/standalone/drakfloppy | 187 | 
1 files changed, 95 insertions, 92 deletions
diff --git a/perl-install/standalone/drakfloppy b/perl-install/standalone/drakfloppy index 1bca87d5a..a864b678a 100755 --- a/perl-install/standalone/drakfloppy +++ b/perl-install/standalone/drakfloppy @@ -1,9 +1,8 @@  #!/usr/bin/perl  # DrakFloppy -# $Id$  #  -# Copyright (C) 2001-2003 MandrakeSoft +# Copyright (C) 2001-2008 Mandriva  # Yves Duret  # Thierry Vignaud  # @@ -29,139 +28,139 @@ 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; +$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);  } -my ($output, @modules, @temp_modules, %buttons, %options, $tree_model, $tree, $list_model, $list); +my (@modules, @temp_modules, %buttons, %options, $tree_model, $tree, $list_model, $list);  my $conffile = "/etc/sysconfig/drakfloppy";  # we must be robust against config file parsing -eval { %options = getVarsFromSh($conffile) } or warn N("Error while parsing \"MODULES\" line from %s", $conffile); +eval { %options = getVarsFromSh($conffile) };  @modules  = split(' ', $options{MODULES});  ######## up part  # device part -my $device_combo = new Gtk2::OptionMenu(); -$device_combo->set_popdown_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 = new Gtk2::OptionMenu(); -$kernel_combo->set_popdown_strings(sort grep { !/^\.\.?$/ } sort(all("/lib/modules"))); -$kernel_combo->entry->set_text(chomp_(`uname -r`)); +my $kernel_combo = gtknew('ComboBox', text => chomp_(`uname -r`), list => [ sort grep { !/^\.\.?$/ } sort(all("/lib/modules")) ]);  ########################################################## -my $tips = new Gtk2::Tooltips; -  ### main window  $window->{window}->add( -                       gtkpack_(Gtk2::VBox->new, -                                if_($::isEmbedded, 0, new Gtk2::Label(N("Boot disk creation"))), -                                0, gtkadd(Gtk2::Frame->new(N("General")), -                                          gtkpack__(new Gtk2::VBox(0, 0), -                                                    gtkpack__(new Gtk2::HBox(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__(new Gtk2::HBox(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`));                                                                                  }), -                                                             ), -                                                   ), +                                                             ]), +                                                   ]),                                           ), -                                 -                                0, gtkpack__(new Gtk2::HButtonBox(), -                                             gtksignal_connect(Gtk2::Button->new(N("Cancel")), -                                                               clicked => sub { ugtk2->exit(0) } -                                                              ), -                                             gtksignal_connect(Gtk2::Button->new(N("Preferences")), clicked => \&pref_dialog), -                                             gtksignal_connect(gtkset_tip($tips,  -                                                                          Gtk2::Button->new(N("Ok")), -                                                                          N("Build the disk")), -                                                               clicked => \&build_it -                                                              ), -                                            ), -                               ), +                                1, gtknew('VBox'), +                                0, create_okcancel({ +                                                    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} = new Gtk2::CheckButton(N("force")), -                                 $buttons{raid} = new Gtk2::CheckButton(N("omit raid modules")), -                                 $buttons{needed} = new Gtk2::CheckButton(N("if needed")), -                                 $buttons{scsi} = new Gtk2::CheckButton(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; @@ -170,7 +169,7 @@ sub pref_dialog() {                                                                         @temp_modules = grep { $_ ne $removed } @temp_modules;                                                                         $remove_but->set_sensitive(scalar @temp_modules);                                                                     }), -                                             ), +                                             ]),                                      ),                        ),                                        ); @@ -180,28 +179,31 @@ sub pref_dialog() {      fill_tree($kernel_combo->entry->get_text);      foreach my $module (@modules) {          my $full_path = join('/', "/lib/modules", $kernel_combo->entry->get_text, $module); -        my $size = get_file_size($full_path); +        $full_path =~ s/\.(ko|o)(|.gz)//; +        my $size = get_file_size(glob_("$full_path.*"));          $list_model->append_set(map_index { $::i => $_ } $module, $size, $full_path);      }      $remove_but->set_sensitive(scalar @modules);      @temp_modules = (); -    gtkpack($dialog->action_area, -            gtksignal_connect(Gtk2::Button->new(N("Cancel")), clicked => sub { $dialog->destroy }), -            gtksignal_connect(Gtk2::Button->new(N("Ok")), clicked => sub {  -                                  # save values: -                                  $options{$_} = $buttons{$_}->get_active foreach keys %buttons; -                                  my $val; -                                  @modules = (); -                                  $list_model->foreach(sub { -                                                           my ($model, $_path, $iter) = @_; -                                                           push @modules, $model->get($iter, 0); -                                                           return 0; -                                                       }, $val); -                                  $dialog->destroy; -                              }), -           ); +    gtkadd($dialog->get_action_area, +           create_okcancel({ +                            cancel_clicked => sub { $dialog->destroy }, +                            ok_clicked => sub {  +                                # save values: +                                $options{$_} = $buttons{$_}->get_active foreach keys %buttons; +                                my $val; +                                @modules = (); +                                $list_model->foreach(sub { +                                                         my ($model, $_path, $iter) = @_; +                                                         push @modules, $model->get($iter, 0); +                                                         return 0; +                                                     }, $val); +                                $dialog->destroy; +                            }, +                           }), +          );      $dialog->show_all;      $dialog->run;  } @@ -286,7 +288,7 @@ sub build_it() {                             if_($options{raid},   "--omit-raid-modules"),                             if_(@modules, map { my $i = $_; $i =~ s!.*/!!; "--with=$i" } @modules),                            ); -    $initrd_args = "--mkinitrdargs \"$initrd_args\"" if $initrd_args; +    $initrd_args = qq(--mkinitrdargs "$initrd_args") if $initrd_args;      my $co = join(' ', "/sbin/mkbootdisk --noprompt --verbose --device", $device_combo->entry->get_text, $initrd_args);      $options{MODULES} = join(' ', @modules);      setVarsInSh($conffile, \%options); @@ -302,14 +304,15 @@ 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"), N("Unable to properly close mkbootdisk:\n\n<span foreground=\"Red\"><tt>%s</tt></span>", $log), { use_markup => 1 }); +        err_dialog(N("Error"), +                   #-PO: Do not alter the <span ..> and </span> tags +                   N("Unable to properly close mkbootdisk:\n\n<span foreground=\"Red\"><tt>%s</tt></span>", $log), { use_markup => 1 });      }      return 0;  | 
