summaryrefslogtreecommitdiffstats
path: root/drakpxelinux.pl
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2005-08-31 08:20:43 +0000
committerAntoine Ginies <aginies@mandriva.com>2005-08-31 08:20:43 +0000
commit52bf0f208a59a9e3bd9549664e322591d930d0b5 (patch)
tree222c69919899da2f21f0c646032acb61d6557ced /drakpxelinux.pl
parent3c26a6800291c2018dd456fafed226c3db868614 (diff)
downloaddrakpxelinux-52bf0f208a59a9e3bd9549664e322591d930d0b5.tar
drakpxelinux-52bf0f208a59a9e3bd9549664e322591d930d0b5.tar.gz
drakpxelinux-52bf0f208a59a9e3bd9549664e322591d930d0b5.tar.bz2
drakpxelinux-52bf0f208a59a9e3bd9549664e322591d930d0b5.tar.xz
drakpxelinux-52bf0f208a59a9e3bd9549664e322591d930d0b5.zip
fix write_conf
Diffstat (limited to 'drakpxelinux.pl')
-rw-r--r--drakpxelinux.pl143
1 files changed, 91 insertions, 52 deletions
diff --git a/drakpxelinux.pl b/drakpxelinux.pl
index 1850675..4fcb8ba 100644
--- a/drakpxelinux.pl
+++ b/drakpxelinux.pl
@@ -45,10 +45,8 @@ use run_program;
use IO::Socket;
use Data::Dumper;
-use constant FALSE => 0;
-use constant TRUE => 1;
-
-my ($treeview, $model);
+our $model = create_model();
+our $treeview = Gtk2::TreeView->new_with_model($model);
# ie of entry menu in PXE:
#label linux
@@ -182,8 +180,41 @@ my ($config_file, $help_file) = $profile && $type ?
($network::pxe::pxelinux_config_file, $network::pxe::pxelinux_help_file);
my $pxelinux_conf = network::pxe::read_pxelinux_conf($config_file, $help_file);
+
+sub update_pxelinux_conf_from_treeview {
+ my ($pxelinux_conf, $treeview) = @_;
+ my $profile = get_selected_profile();
+ ($config_file, $help_file) = network::pxe::get_pxelinux_profile_path($profile, 'boot');
+ my $model = $treeview->get_model;
+ my $iter = $model->get_iter_first;
+ splice @{$pxelinux_conf->{entries}};
+ while ($iter) {
+ my ($label, $info, $kernel, $initrd, $method, $interface, $network, $server, $directory, $ramdisk, $vga, $display, $option) = $model->get($iter, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12);
+ my $entry = {
+ label => $label,
+ info => $info,
+ kernel => $kernel,
+ initrd => $initrd,
+ method => $method,
+ interface => $interface,
+ network => $network,
+ server => $server,
+ directory => $directory,
+ ramdisk => $ramdisk,
+ vga => $network::pxe::vga_bios_to_resolution{$vga},
+ display => $display,
+ option => $option,
+ };
+ push @{$pxelinux_conf->{entries}}, $entry;
+ $iter = $model->iter_next($iter);
+ }
+}
+
+
+
sub write_conf {
- my ($pxelinux_conf) = @_;
+ my ($pxelinux_conf, $treeview) = @_;
+ update_pxelinux_conf_from_treeview($pxelinux_conf, $treeview);
network::pxe::write_pxelinux_conf($pxelinux_conf, $config_file);
}
@@ -367,7 +398,7 @@ sub edit_box_item {
my $dialog = new Gtk2::Dialog();
$dialog->set_modal(1);
- $dialog->set_resizable(FALSE);
+ $dialog->set_resizable(0);
$entry->{label} =~ /local/ and info_dialog(N("Local"), N("You can't modify local entry.")) and return 0;
my $label = Gtk2::Label->new($entry->{label});
@@ -382,7 +413,7 @@ sub edit_box_item {
my ($data, $test, $filetotest, $label) = @_;
chdir($network::pxe::pxelinux_client_root);
my $fd = new Gtk2::FileSelection(N("Selection"));
- $fd->set_modal(TRUE);
+ $fd->set_modal(1);
$fd->signal_connect("destroy", sub { $fd->hide });
$fd->ok_button->signal_connect(clicked => sub {
my $file = $fd->get_filename;
@@ -868,6 +899,13 @@ my $profiles = create_profiles_list;
my $systems = create_systems_list;
my $log_text = gtknew('TextView');
+sub get_selected_profile() {
+ my $model_profiles = $profiles->get_model;
+ my $iter = $profiles->get_selection->get_selected;
+ my $profile = $model_profiles->get($iter, 0);
+ return $profile;
+}
+
sub get_pxelinux_conf_from_profile() {
my $model_profiles = $profiles->get_model;
my $iter = $profiles->get_selection->get_selected;
@@ -943,8 +981,7 @@ sub add_profile() {
# Main Program
###############
# create model
-our $model = create_model();
-our $treeview = Gtk2::TreeView->new_with_model($model);
+
sub profile_selected {
my ($profile) = @_;
@@ -991,7 +1028,7 @@ my $w = ugtk2->new(N("Drakpxelinux"));
#$w->{rwindow}->set_size_request(800, 500) unless $::isEmbedded;
#my $treeview = Gtk2::TreeView->new_with_model($model);
-$treeview->set_rules_hint(TRUE);
+$treeview->set_rules_hint(1);
$treeview->get_selection->set_mode('single');
add_columns($treeview);
@@ -1029,17 +1066,17 @@ my $menu = $factory->get_widget('<main>');
my $okcancel = create_okcancel({
cancel_clicked => sub { ugtk2->exit },
ok_clicked => sub {
- write_conf(get_pxelinux_conf_from_profile());
+ write_conf(get_pxelinux_conf_from_profile(), $treeview);
ugtk2->exit },
},
);
# main interface
-gtkpack($w->{window},
- $menu,
- if_(!$::isEmbedded, Gtk2::Banner->new('drakgw', N("Drakpxelinux manage your PXE server"))),
- if_($::isEmbedded, Gtk2::Label->new("Here you can manage your PXE server.")),
- gtknew('Notebook', children => [
+gtkpack($w->{window}, gtknew('VBox', spacing => 0, children => [
+ 0, $menu,
+ if_(!$::isEmbedded, 0, Gtk2::Banner->new('drakgw', N("Drakpxelinux manage your PXE server"))),
+ if_($::isEmbedded, 0, Gtk2::Label->new("Here you can manage your PXE server.")),
+ 1, gtknew('Notebook', children => [
gtknew('Label', text => N("PXE configuration file")),
gtknew('VBox', spacing => 0, children => [
1, gtknew('HBox', spacing => 1, children => [
@@ -1061,41 +1098,42 @@ gtkpack($w->{window},
]),
]
),
- 0, gtknew('VBox', spacing => 1, children => [
- 0, gtknew('HButtonBox', layout => 'start', children => [
- 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Add PXE entry")), 'addpxe'), clicked => sub {
- my $pxelinux_conf = get_pxelinux_conf_from_profile();
- eval { wizard_add_entry($model, $treeview, $pxelinux_conf);
- write_conf($pxelinux_conf);
- };
- my $err = $@;
- $::WizardWindow->destroy if defined $::WizardWindow;
- undef $::WizardWindow;
- if ($err && $err !~ /wizcancel/) {
- err_dialog(N("Error"), N("The PXE entry wizard has unexpectedly failed:") . "\n\n" . $err);
- }
- }),
- 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Add PXE local")), 'addpxe'), clicked => sub {
- my $pxelinux_conf = get_pxelinux_conf_from_profile();
- add_local_entry($model, $treeview, $pxelinux_conf)
- }),
- 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Remove")), 'removepxe'), clicked => sub {
- my $pxelinux_conf = get_pxelinux_conf_from_profile();
- remove_item($model, $treeview, $pxelinux_conf);
- write_conf($pxelinux_conf);
- }),
- 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Edit")), 'editb'), clicked => sub {
- my $pxelinux_conf = get_pxelinux_conf_from_profile();
- edit_box_item($model, $treeview, $pxelinux_conf);
- write_conf($pxelinux_conf);
- }),
- #gtknew('Label', text => N("Default boot:")),
- #1, $labelscombo,
- ]
- ),
- ]),
- ]
- ),
+ 0, gtknew('HButtonBox', layout => 'start', children => [
+ 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Add an entry")), 'addpxe'), clicked => sub {
+ my $pxelinux_conf = get_pxelinux_conf_from_profile();
+ eval { wizard_add_entry($model, $treeview, $pxelinux_conf);
+ write_conf($pxelinux_conf, $treeview);
+ };
+ my $err = $@;
+ $::WizardWindow->destroy if defined $::WizardWindow;
+ undef $::WizardWindow;
+ if ($err && $err !~ /wizcancel/) {
+ err_dialog(N("Error"), N("The PXE entry wizard has unexpectedly failed:") . "\n\n" . $err);
+ }
+ }),
+ 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Add PXE local")), 'addpxe'), clicked => sub {
+ my $pxelinux_conf = get_pxelinux_conf_from_profile();
+ add_local_entry($model, $treeview, $pxelinux_conf);
+ write_conf($pxelinux_conf, $treeview);
+ }),
+ 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Remove Entry")), 'removepxe'), clicked => sub {
+ my $pxelinux_conf = get_pxelinux_conf_from_profile();
+ remove_item($model, $treeview, $pxelinux_conf);
+ write_conf($pxelinux_conf, $treeview);
+ }),
+ 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Edit Entry")), 'editb'), clicked => sub {
+ my $pxelinux_conf = get_pxelinux_conf_from_profile();
+ edit_box_item($model, $treeview, $pxelinux_conf);
+ write_conf($pxelinux_conf, $treeview);
+ }),
+ 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Apply to profile")), 'apply'), clicked => sub {
+ my $pxelinux_conf = get_pxelinux_conf_from_profile();
+ write_conf($pxelinux_conf, $treeview);
+ }),
+ #0, gtknew('Label', text => N("Default boot:")),
+ #0, $labelscombo,
+ ]),
+ ]),
gtknew('Label', text => N("Systems")),
gtknew('VBox', spacing => 1,
children => [
@@ -1121,7 +1159,8 @@ gtkpack($w->{window},
gtknew('ScrolledWindow', width => 600, height => 400, child => $log_text),
]),
]),
- $okcancel,
+ 0, $okcancel,
+ ]),
);
add_configured_mac_addresses();