From 095e4eca6a027fb11b6fefaf602d63d1b5dc7aab Mon Sep 17 00:00:00 2001 From: Antoine Ginies Date: Mon, 29 Aug 2005 22:29:20 +0000 Subject: various adjustement in GUI --- drakpxelinux.pl | 89 ++++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 59 insertions(+), 30 deletions(-) (limited to 'drakpxelinux.pl') diff --git a/drakpxelinux.pl b/drakpxelinux.pl index 688b52b..f023404 100644 --- a/drakpxelinux.pl +++ b/drakpxelinux.pl @@ -180,7 +180,6 @@ foreach (@ARGV) { my ($config_file, $help_file) = $profile && $type ? network::pxe::get_pxelinux_profile_path($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 write_conf() { @@ -211,11 +210,8 @@ sub create_model() { # my $model = Gtk2::ListStore->new(("Glib::String") x NUM_COLUMNS); my $model = Gtk2::ListStore->new("Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String", "Glib::String"); # set_pxelinux_entry_at_iter($model, $model->append, $_) foreach @{$pxelinux_conf->{entries}}; - return $model; -} - -sub fill_model() { set_pxelinux_entry_at_iter($model, $model->append, $_) foreach @{$pxelinux_conf->{entries}}; + return $model; } # wizard to add an entry in PXE menu @@ -818,25 +814,50 @@ sub add_columns { my $mac_regexp = '(?:[0-9a-f]{2}:){5}[0-9a-f]{2}'; my $profiles_conf = network::pxe::read_profiles(); -my $systems = Gtk2::SimpleList->new( - N("MAC address") => 'text', - N("Profil 1") => 'text', - N("Profil 2") => 'text', - ); -$systems->get_selection->set_mode('single'); -$systems->get_model->set_sort_column_id(0, 'ascending'); -#- don't let the user modify the "Installed" state -$systems->get_column(1)->get_cell_renderers->set_property('mode', 'inert'); - -my $profiles = Gtk2::SimpleList->new("Profile name" => 'text'); -$profiles->set_headers_visible(1); -$profiles->get_selection->set_mode('browse'); -$profiles->get_selection->signal_connect(changed => sub { - my ($models, $iter) = $_[0]->get_selected or return; - undef $model; - undef $treeview; - profile_selected($models->get($iter, 0)); - }); +sub create_systems_list() { + my $systems = Gtk2::SimpleList->new( + N("MAC address") => 'text', + N("Installed") => 'bool', + N("Profil 1") => 'text', + N("Profil 2") => 'text', + N("Computer Name") => 'text', + ); + foreach ($systems->get_columns) { $_->set_resizable(1); } + $systems->set_headers_clickable(1); + $systems->get_selection->set_mode('multiple'); +# $systems->get_model->set_sort_column_id(0, 'ascending'); + foreach (0..2) { + $systems->get_column($_)->signal_connect('clicked', \&sort_by_column, $systems->get_model); + $systems->get_column($_)->set_sort_column_id($_ == 0 ? 1 : $_ + 2); + } + #- don't let the user modify the "Installed" state + $systems->get_column(1)->get_cell_renderers->set_property('mode', 'inert'); + $systems->set_column_editable(4, 1); + $systems->set_rules_hint(1); + return $systems; +} + +sub sort_by_column { + my ($column, $model) = @_; + my $col_id = $column->get_sort_column_id; + my ($old_id, $old_order) = $model->get_sort_column_id; + $model->set_sort_column_id($col_id, $old_id == $col_id && $old_order ne 'descending' ? 'ascending' : 'descending'); +} + +sub create_profiles_list() { + my $profiles = Gtk2::SimpleList->new("Profile name" => 'text'); + $profiles->set_headers_visible(1); + $profiles->get_selection->set_mode('browse'); + $profiles->get_selection->signal_connect(changed => sub { + my ($models, $iter) = $_[0]->get_selected or return; + ($config_file, $help_file) = network::pxe::get_pxelinux_profile_path($models->get($iter, 0), 'boot'); + profile_selected($models->get($iter, 0)); + }); + return $profiles; +} + +my $profiles = create_profiles_list; +my $systems = create_systems_list; my $log_text = gtknew('TextView'); @@ -877,6 +898,8 @@ my ($profiles_combo, $install_button); sub refresh_profiles() { my @profiles = network::pxe::list_profiles($profiles_conf); mygtk2::gtkset($profiles_combo, list => [ '', @profiles ]); + # add default PXE menu + push @profiles, "default"; @{$profiles->{data}} = @profiles; } @@ -909,13 +932,19 @@ our $treeview = Gtk2::TreeView->new_with_model($model); sub profile_selected { my ($profile) = @_; $model->clear; - # force type = boot - my $type = "boot"; - my ($config_file, $help_file) = network::pxe::get_pxelinux_profile_path($profile, $type); - print "----- $config_file $help_file\n"; + if ($profile eq 'default') { + ($config_file, $help_file) = ($network::pxe::pxelinux_config_file, $network::pxe::pxelinux_help_file); + } else { + # force type = boot + my $type = "boot"; + ($config_file, $help_file) = network::pxe::get_pxelinux_profile_path($profile, $type); + print "----- $config_file $help_file\n"; + undef $pxelinux_conf; + } + print Dumper($pxelinux_conf); my $pxelinux_conf = network::pxe::read_pxelinux_conf($config_file, $help_file); - # print Dumper($pxelinux_conf); set_pxelinux_entry_at_iter($model, $model->append, $_) foreach (@{$pxelinux_conf->{entries}}); + return $pxelinux_conf; } @@ -1026,7 +1055,7 @@ gtkpack($w->{window}, 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Remove")), 'removepxe'), clicked => sub { remove_item($model, $treeview) }), 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Edit")), 'editb'), clicked => sub { edit_box_item($model, $treeview) }), - 0, gtksignal_connect(set_help_tip(Gtk2::Button->new(N("Apply")), 'apply'), clicked => sub { write_conf }), + #gtknew('Label', text => N("Default boot:")), #1, $labelscombo, ] -- cgit v1.2.1