summaryrefslogtreecommitdiffstats
path: root/perl-install/standalone/drakfloppy
diff options
context:
space:
mode:
Diffstat (limited to 'perl-install/standalone/drakfloppy')
-rwxr-xr-xperl-install/standalone/drakfloppy216
1 files changed, 113 insertions, 103 deletions
diff --git a/perl-install/standalone/drakfloppy b/perl-install/standalone/drakfloppy
index 3a7333c06..eb41da794 100755
--- a/perl-install/standalone/drakfloppy
+++ b/perl-install/standalone/drakfloppy
@@ -40,15 +40,6 @@ require_root_capability();
my $expert_mode = $::expert;
-my $list_model = Gtk2::ListStore->new(("Glib::String") x 2);
-my $list = Gtk2::TreeView->new_with_model($list_model);
-each_index {
- $list->append_column(my $col = Gtk2::TreeViewColumn->new_with_attributes($_, Gtk2::CellRendererText->new, 'text' => $::i));
- $col->set_sort_column_id($::i);
- $col->set_min_width((200, 50)[$::i]);
- # $col->set_alignment(1.0) if $::i == 1;
-} (N("Module name"), N("Size"));
-
my $window = ugtk2->new('drakfloppy');
unless ($::isEmbedded) {
$window->{rwindow}->signal_connect(delete_event => sub { ugtk2->exit(0) });
@@ -65,6 +56,9 @@ unless ($::isEmbedded) {
}
+my ($output, @modules, @temp_modules, %buttons, %options, $tree_model, $tree, $list_model, $list);
+
+
######## up part
# device part
@@ -78,32 +72,11 @@ my $kernel_combo = new Gtk2::Combo();
$kernel_combo->disable_activate;
$kernel_combo->set_popdown_strings(sort grep { !/^\.\.?$/ } all("/lib/modules"));
$kernel_combo->entry->set_text(chomp_(`uname -r`));
-$kernel_combo->entry->signal_connect(changed => sub {
- change_tree($kernel_combo->entry->get_text);
- $list_model->clear;
- });
-
-
-# Create root tree
-my $tree_model = Gtk2::TreeStore->new(("Glib::String") x 2, "Glib::Int");
-my $tree = Gtk2::TreeView->new_with_model($tree_model);
-#$tree->get_selection->set_mode('browse');
-$tree->set_headers_visible(0);
-$tree->append_column(my $textcolumn = Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::CellRendererText->new, 'text' => 0));
-$tree->signal_connect('row-expanded', \&expand_tree);
-$tree->get_selection->signal_connect('changed' => \&selected_tree);
-
-
-fill_tree($kernel_combo->entry->get_text);
-###
-my ($output, @modules);
-
-
-# Create list box
-########################################################## from here my $list
+##########################################################
+my $tips = new Gtk2::Tooltips;
### main window
$window->{window}->add(
@@ -123,42 +96,14 @@ $window->{window}->add(
gtksignal_connect(Gtk2::Button->new("default"),
clicked => sub {
$kernel_combo->entry->set_text(chomp_(`uname -r`));
- $list_model->clear;
}),
),
),
),
- 1, gtkadd(my $expert_mod_frame = new Gtk2::Frame(N("Expert Area")),
- gtkpack_(gtkset_border_width(Gtk2::VBox->new(0, 5), 5),
- 0, gtkadd(Gtk2::Frame->new(N("mkinitrd optional arguments")),
- gtkpack__(Gtk2::HBox->new(0, 5),
- my $force_button = new Gtk2::ToggleButton(N("force")),
- my $raid_button = new Gtk2::ToggleButton(N("omit raid modules")),
- my $needed_button = new Gtk2::ToggleButton(N("if needed")),
- my $scsi_button = new Gtk2::ToggleButton(N("omit scsi modules")),
- ),
- ),
- 1, gtkadd(Gtk2::Frame->new(N("Add a module")),
- create_hpaned(
- gtkset_size_request(
- create_scrolled_window($tree),
- 200, $::isEmbedded ? 0 : 175),
- gtkpack_(Gtk2::VBox->new(0, 0),
- 1, gtkadd(Gtk2::ScrolledWindow->new,
- $list
- ),
- 0, gtksignal_connect(Gtk2::Button->new(N("Remove a module")),
- clicked => sub {
- my $iter = ($list->get_selection->get_selected)[1];
- return unless $iter;
- $list_model->remove($iter);
- }),
- ),
- ),
- ),
- ),
- ),
- 1, gtkadd(Gtk2::Frame->new(N("Output")),
+
+ 0, gtksignal_connect(gtkset_active(Gtk2::CheckButton->new(N("Expert Mode")), $expert_mode),
+ clicked => \&toggle_expert_button),
+ 1, gtkadd(my $expert_mod_frame = Gtk2::Frame->new(N("Output")),
gtkpack_(gtkset_size_request(
gtkset_border_width(
Gtk2::HBox->new(0, 0),
@@ -167,37 +112,111 @@ $window->{window}->add(
1, $output = gtkset_editable(Gtk2::TextView->new, 0),
),
),
- 0, gtkpack__(new Gtk2::HBox(0, 0),
- gtksignal_connect(Gtk2::Button->new(N("Cancel")),
+ 0, gtkpack__(new Gtk2::HButtonBox(),
+ gtksignal_connect(Gtk2::Button->new_from_stock('gtk-cancel'),
clicked => sub { ugtk2->exit(0) }
),
- gtksignal_connect(Gtk2::Button->new(N("Build the disk")),
+ gtksignal_connect(Gtk2::Button->new_from_stock('gtk-preferences'), clicked => \&pref_dialog),
+ gtksignal_connect(gtkset_tip($tips,
+ Gtk2::Button->new_from_stock('gtk-ok'),
+ N("Build the disk")),
clicked => \&build_it
),
- gtksignal_connect(my $expert_button = Gtk2::Button->new(""),
- clicked => sub {
- $expert_mode = !$expert_mode;
- toggle_expert_button();
- }),
),
),
);
$window->{rwindow}->show_all;
-toggle_expert_button();
+$expert_mod_frame->set_sensitive($expert_mode);
$window->main;
ugtk2->exit(0);
sub toggle_expert_button() {
- if ($expert_mode) {
- $expert_mod_frame->set_sensitive(1);
- $expert_button->child->set(N("Normal Mode"));
- } else {
- $expert_mod_frame->set_sensitive(0);
- $expert_button->child->set(N("Expert Mode"));
- }
+ my ($expert_button) = @_;
+ $expert_mode = $expert_button->get_active;
+ $expert_mod_frame->set_sensitive($expert_mode);
+}
+
+
+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;
+
+
+ # Create root tree:
+ $tree_model = Gtk2::TreeStore->new(("Glib::String") x 2, "Glib::Int");
+ $tree = Gtk2::TreeView->new_with_model($tree_model);
+ $tree->set_headers_visible(0);
+ $tree->append_column(my $textcolumn = Gtk2::TreeViewColumn->new_with_attributes(undef, Gtk2::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);
+ each_index {
+ $list->append_column(my $col = Gtk2::TreeViewColumn->new_with_attributes($_, Gtk2::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")),
+ ),
+ ),
+ 1, gtkadd(Gtk2::Frame->new(N("Add a module")),
+ create_hpaned(
+ gtkset_size_request(
+ create_scrolled_window($tree),
+ 200, $::isEmbedded ? 0 : 175),
+ gtkpack_(Gtk2::VBox->new(0, 0),
+ 1, gtkadd(Gtk2::ScrolledWindow->new,
+ $list
+ ),
+ 0, gtksignal_connect(Gtk2::Button->new(N("Remove a module")),
+ clicked => sub {
+ my $iter = ($list->get_selection->get_selected)[1];
+ return unless $iter;
+ my $removed = $list_model->get($iter, 2);
+ $list_model->remove($iter);
+ @temp_modules = grep { $_ ne $removed } @temp_modules;
+ }),
+ ),
+ ),
+ ),
+ );
+
+ # restore values:
+ $buttons{$_}->set_active($options{$_}) foreach keys %buttons;
+ fill_tree($kernel_combo->entry->get_text);
+ $list_model->append_set([ map_index { $::i => $_ } @$_ ]) foreach @modules;
+ @temp_modules = ();
+
+ gtkpack($dialog->action_area,
+ gtksignal_connect(Gtk2::Button->new_from_stock('gtk-cancel'), clicked => sub { $dialog->destroy }),
+ gtksignal_connect(Gtk2::Button->new_from_stock('gtk-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), $model->get($iter, 1), $model->get($iter, 2) ];
+ return 0;
+ }, $val);
+ $dialog->destroy;
+ }),
+ );
+ $dialog->show_all;
+ $dialog->run;
}
#-------------------------------------------------------------
@@ -215,10 +234,6 @@ sub fill_tree {
expand_tree($tree, $parent_iter, $tree_model->get_path($parent_iter)) if has_sub_trees($root_dir);
}
-sub change_tree {
- $tree_model->clear;
- fill_tree(@_);
-}
# Called whenever an item is clicked on the tree widget.
sub selected_tree {
@@ -231,10 +246,9 @@ sub selected_tree {
my $size = (lstat($file))[7];
- return if member($file, @modules);
- push @modules, $file;
- $file =~ s|/lib/modules/.*?/||g;
- $list_model->append_set([ 0 => $file, 1 => $size ]);
+ return if member($file, @temp_modules);
+ push @temp_modules, $file;
+ $list_model->append_set([ 0 => stripit($file), 1 => $size, 2 => $file ]);
}
# Callback for expanding a tree - find subdirectories, files and add them to tree
@@ -276,22 +290,12 @@ sub expand_tree {
# the function
#-------------------------------------------------------------
sub build_it() {
- my $y;
my $co = "/sbin/mkbootdisk --noprompt --verbose --device " . $device_combo->entry->get_text;
- if ($expert_mode) {
- $co .= " --mkinitrdargs -f" if $force_button->get_active;
- $co .= " --mkinitrdargs --ifneeded" if $needed_button->get_active;
- $co .= " --mkinitrdargs --omit-scsi-modules" if $scsi_button->get_active;
- $co .= " --mkinitrdargs --omit-raid-modules" if $raid_button->get_active;
- my $val;
- $list_model->foreach(sub {
- my ($model, $_path, $iter) = @_;
- my $module = $model->get($iter, 0);
- $module =~ s|.*?/||g;
- $co .= " --mkinitrdargs --with=" . $y; #. "/usr/lib/" . $kernel_combo->entry->get_text() . "/" . $y;
- return 0;
- }, $val);
- }
+ $co .= " --mkinitrdargs -f" if $options{force};
+ $co .= " --mkinitrdargs --ifneeded" if $options{needed};
+ $co .= " --mkinitrdargs --omit-scsi-modules" if $options{scsi};
+ $co .= " --mkinitrdargs --omit-raid-modules" if $options{raid};
+ $co .= join(" --mkinitrdargs --with=", map { $_->[0] } @modules);
$co .= " " . $kernel_combo->entry->get_text;
$co .= " 2>&1 |";
create_dialog(N("Warning"), N("Be sure a media is present for the device %s", $device_combo->entry->get_text), { cancel => 1 }) or return;
@@ -330,3 +334,9 @@ sub has_sub_trees {
return 0;
}
+
+sub stripit {
+ my ($file) = @_;
+ $file =~ s|/lib/modules/.*?/||g;
+ $file;
+}