summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2005-07-13 07:00:07 +0000
committerAntoine Ginies <aginies@mandriva.com>2005-07-13 07:00:07 +0000
commit759e48e8f749513b6116c4f201ad2dbf13505b4d (patch)
treeb7670858c6335b49c83e2c1d481fb8f26606a4af
parent9bae2ad2635da85d085f27d25d4945c8efe10e69 (diff)
downloaddrakpxelinux-759e48e8f749513b6116c4f201ad2dbf13505b4d.tar
drakpxelinux-759e48e8f749513b6116c4f201ad2dbf13505b4d.tar.gz
drakpxelinux-759e48e8f749513b6116c4f201ad2dbf13505b4d.tar.bz2
drakpxelinux-759e48e8f749513b6116c4f201ad2dbf13505b4d.tar.xz
drakpxelinux-759e48e8f749513b6116c4f201ad2dbf13505b4d.zip
add banner, add menu, add ok_cancel_button, remove 'instatn change', add
apply button, add require on PXE
-rw-r--r--drakpxelinux.pl58
1 files changed, 44 insertions, 14 deletions
diff --git a/drakpxelinux.pl b/drakpxelinux.pl
index 743718c..c5d3d91 100644
--- a/drakpxelinux.pl
+++ b/drakpxelinux.pl
@@ -42,11 +42,9 @@ use ugtk2 qw(:ask :helpers :wrappers :create :dialogs);
use constant FALSE => 0;
use constant TRUE => 1;
+my $in = 'interactive'->vnew('su');
+$in->do_pkgs->ensure_is_installed('pxe', '/usr/sbin/pxe') or return;
-unless ($> == 0) {
- err_dialog(N("Error!"), N("You are not root. Exiting..."));
- die unless $::testing;
-}
# ie of entry menu in PXE:
#label linux
@@ -97,10 +95,30 @@ my %help = (
'wizardsrv' => N("launches a wizard to setup a PXE server"),
'editb' => N("edits the PXE entry selected with a dialog box"),
'removepxe' => N("removes the selected PXE entry"),
+ 'apply' => N("apply change to configuration file"),
'addpxe' => N("launches a wizard to add a PXE entry "),
'helponline' => N("get help from online documentation"),
);
+sub get_items {
+ my @items = (
+ [ "/_File", undef, undef, undef, '<Branch>', ],
+ [ "/_File/_Write conf", undef, \&write_conf, 1, '<StockItem>', 'gtk-execute' ],
+ [ "/_File/_Exit", undef, sub { ugtk2->exit }, 1, '<StockItem>', 'gtk-quit' ],
+
+ [ "/_PXE Server", undef, undef, undef, '<Branch>', ],
+ [ "/_PXE Server/_Restart", undef, \&restart_dialog, 1, '<StockItem>', 'gtk-execute' ],
+ );
+ return @items;
+}
+
+sub restart_dialog {
+ my $cmd = "service pxe restart";
+ my $w = $in->wait_message(N("PXE server"), N("Restarting PXE server..."));
+ run_program::get_stdout($cmd) !~ /unknown|error/ or err_dialog(N("Error!"), N("Error Restarting PXE server")) and return;
+ undef $w;
+}
+
sub set_help_tip {
my ($entry, $key) = @_;
gtkset_tip(new Gtk2::Tooltips, $entry, formatAlaTeX($help{$key}));
@@ -247,7 +265,7 @@ sub wizard_add_entry {
};
push @{$pxelinux_conf->{entries}}, $entry;
set_pxelinux_entry_at_iter($model, $model->append, $entry);
- write_conf();
+# write_conf();
undef $w;
return;
},
@@ -295,7 +313,7 @@ sub remove_item {
}
$model->remove($iter);
splice @{$pxelinux_conf->{entries}}, $i, 1;
- write_conf();
+# write_conf();
}
}
@@ -522,7 +540,7 @@ sub edit_box_item {
# update value in cells
set_pxelinux_entry_at_iter($model, $iter, $entry);
$dialog->destroy;
- write_conf();
+# write_conf();
network::pxe::add_in_help($entry->{label}, $entry->{info});
},
},
@@ -611,7 +629,7 @@ sub cell_edited {
$entry->{option} = $new_text;
$model->set($iter, $column, $entry->{option});
}
- write_conf();
+# write_conf();
}
sub show_help() { info_dialog("help",
@@ -803,7 +821,7 @@ $::isWizard = 0;
my $model = create_model();
my $window = ugtk2->new("Drakpxelinux $version");
-$window->{rwindow}->set_size_request(800, 400) unless $::isEmbedded;
+$window->{rwindow}->set_size_request(800, 500) unless $::isEmbedded;
my $W = $window->{window};
$W->signal_connect(delete_event => sub { ugtk2->exit });
@@ -839,15 +857,23 @@ $treeview->signal_connect(button_press_event => sub {
}
});
+my @items = get_items();
+my $factory = Gtk2::ItemFactory->new('Gtk2::MenuBar', '<main>', undef);
+$factory->create_items('menu', @items);
+my $menu = $factory->get_widget('<main>');
+
my $okcancel = create_okcancel({
cancel_clicked => sub { ugtk2->exit },
- ok_clicked => \&write_conf,
+ ok_clicked => sub { write_conf; ugtk2->exit },
},
);
# main interface
$W->add(gtkpack_(Gtk2::VBox->new(0,0),
- 1, gtkpack_(gtkset_border_width(Gtk2::HBox->new, 0),
+ 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, gtkpack_(gtkset_border_width(Gtk2::HBox->new, 3),
1, create_scrolled_window($treeview),
0, gtkpack_(create_vbox('start'),
0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Add a PXE entry")), 'addpxe'), clicked => sub {
@@ -866,9 +892,13 @@ $W->add(gtkpack_(Gtk2::VBox->new(0,0),
0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Edit PXE entry")), 'editb'), clicked => sub {
edit_box_item($model, $treeview) }
),
- 0, Gtk2::Label->new(N("boot:")),
+ 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Apply")), 'apply'), clicked => sub {
+ write_conf }
+ ),
+ 0, Gtk2::HSeparator->new,
+ 0, Gtk2::Label->new(N("Default boot:")),
0, $labelscombo,
- 0, Gtk2::HSeparator->new,
+ 0, Gtk2::HSeparator->new,
# create_vbox('end'),
0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Reconfigure PXE Server")), 'wizardsrv'), clicked => sub {
eval { wizard_pxe_server() };
@@ -882,8 +912,8 @@ $W->add(gtkpack_(Gtk2::VBox->new(0,0),
}),
0, gtksignal_connect(new Gtk2::Button(N("Help")), clicked => \&show_help),
),
- if_($::isEmbedded, 0, $okcancel),
),
+ 0, $okcancel,
),
);
$W->show_all;