From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 684371FF0B4 for ; Tue, 08 Sep 2026 12:18:39 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 065D9215D1; Tue, 08 Sep 2026 12:18:19 +0200 (CEST) From: Christoph Heiss To: pve-devel@lists.proxmox.com Subject: [PATCH installer 09/15] gui: network: factor out name pinning into advanced options dialog Date: Tue, 8 Sep 2026 12:16:23 +0200 Message-ID: <20260908101647.1057780-10-c.heiss@proxmox.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260908101647.1057780-1-c.heiss@proxmox.com> References: <20260908101647.1057780-1-c.heiss@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1788862657112 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.371 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: DP6CJD7YERJDCHUFFSQKIWJNY4YSQ675 X-Message-ID-Hash: DP6CJD7YERJDCHUFFSQKIWJNY4YSQ675 X-MailFrom: c.heiss@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This dialog can now be easily extended with additional frames for other, advanced network-related options. Signed-off-by: Christoph Heiss --- proxinstall | 183 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 110 insertions(+), 73 deletions(-) diff --git a/proxinstall b/proxinstall index 51efe79..e3a4b20 100755 --- a/proxinstall +++ b/proxinstall @@ -349,34 +349,55 @@ my $create_basic_grid = sub { return $grid; }; -my sub create_network_interface_pin_view { - my ($done_cb) = @_; +# takes an array ref of rows with [$label_text, $widget, $suffix_label] array refs as columns +# $suffix_label is optional +my $create_label_widget_grid = sub { + my ($labeled_widgets) = @_; - my $dialog = Gtk3::Dialog->new(); - $dialog->set_title('Interface Name Pinning Options'); - $dialog->add_button('_OK', 'ok'); + my $grid = &$create_basic_grid(); - my $content = $dialog->get_content_area(); + for (my $row = 0; $row < scalar($labeled_widgets->@*); $row++) { + my ($label_text, $widget, $suffix_label) = $labeled_widgets->[$row]->@*; - my $hbox = Gtk3::Box->new('horizontal', 0); - $content->pack_start($hbox, 1, 1, 5); + my $label = Gtk3::Label->new($label_text); + $label->set_visible(1); + $label->set_xalign(1.0); + $grid->attach($label, 0, $row, 1, 1); + + $widget->set_visible(1); + $grid->attach($widget, 1, $row, 1, 1); + + if ($suffix_label) { + my $suffix_label = Gtk3::Label->new($suffix_label); + $suffix_label->set_visible(1); + $suffix_label->set_xalign(1.0); + $grid->attach($suffix_label, 2, $row, 1, 1); + } + } + + return $grid; +}; + +my sub create_network_interface_pin_frame { + my ($on_enable_changed) = @_; + + my $frame = Gtk3::Frame->new('Interface Name Pinning'); + + my $vbox = Gtk3::Box->new('vertical', 5); + $frame->add($vbox); + $vbox->set_margin_start(10); + $vbox->set_margin_end(10); + $vbox->set_margin_top(5); + $vbox->set_margin_bottom(5); + + my $enable_checkbox = Gtk3::CheckButton->new('Pin network interface names'); + $enable_checkbox->set_active($gtk_state->{network_pinning_enabled}); + $vbox->pack_start($enable_checkbox, 1, 0, 5); my $grid = Gtk3::Grid->new(); $grid->set_column_spacing(10); $grid->set_row_spacing(10); - - # make the list scrollable, in case there are lots of interfaces - my $scrolled_window = Gtk3::ScrolledWindow->new(); - $scrolled_window->set_hexpand(1); - $scrolled_window->set_propagate_natural_height(1); - - $scrolled_window->add($grid); - $scrolled_window->set_policy('never', 'automatic'); - $scrolled_window->set_min_content_height(200); - $scrolled_window->set_margin_start(10); - $scrolled_window->set_margin_end(10); - - $hbox->pack_start($scrolled_window, 1, 0, 5); + $vbox->pack_start($grid, 1, 1, 5); my $interfaces = Proxmox::Install::RunEnv::get()->{network}->{interfaces}; my $mapping = Proxmox::Install::Config::get_network_interface_pin_map(); @@ -412,24 +433,83 @@ my sub create_network_interface_pin_view { $inputs->{ $iface->{mac} } = $input; } - $hbox->show_all(); + my $set_sensitive = sub { + my ($active) = @_; + $grid->foreach(sub { + $_[0]->set_sensitive($active); + }); + }; + + $set_sensitive->($gtk_state->{network_pinning_enabled}); + $enable_checkbox->signal_connect( + toggled => sub { + my $active = !!$enable_checkbox->get_active(); + + $gtk_state->{network_pinning_enabled} = $active; + $set_sensitive->($active); + + $on_enable_changed->($active); + }, + ); + + my $on_done = sub { + if (!$enable_checkbox->get_active()) { + Proxmox::Install::Config::set_network_interface_pin_map(); + return; + } + + my %new_mapping = map { $_ => $inputs->{$_}->get_text() } keys %$inputs; + + validate_link_pin_map(\%new_mapping); + Proxmox::Install::Config::set_network_interface_pin_map(\%new_mapping); + }; + + return ($frame, $on_done); +} + +my sub create_network_advanced_options_view { + my ($done_cb) = @_; + + my $dialog = Gtk3::Dialog->new(); + $dialog->set_title('Management Network Options'); + $dialog->add_button('_OK', 'ok'); + + my $content = $dialog->get_content_area(); + + my $scrolled_window = Gtk3::ScrolledWindow->new(); + $scrolled_window->set_hexpand(1); + $scrolled_window->set_vexpand(1); + $scrolled_window->set_propagate_natural_height(1); + $scrolled_window->set_policy('never', 'automatic'); + $scrolled_window->set_min_content_height(200); + + my $hbox = Gtk3::Box->new('vertical', 0); + + my ($pin_frame, $pin_on_done) = create_network_interface_pin_frame(sub {}); + + $hbox->pack_start($pin_frame, 0, 0, 10); + + $scrolled_window->add($hbox); + $content->pack_start($scrolled_window, 1, 1, 10); + + my $inputs = {}; $dialog->signal_connect( response => sub { - my %new_mapping = map { $_ => $inputs->{$_}->get_text() } keys %$inputs; - - eval { validate_link_pin_map(\%new_mapping); }; + eval { + $pin_on_done->(); + }; if ($@) { Proxmox::UI::message($@, $dialog); return; } - Proxmox::Install::Config::set_network_interface_pin_map(\%new_mapping); $dialog->destroy(); $done_cb->(); }, ); + $dialog->show_all(); $dialog->run(); } @@ -522,21 +602,10 @@ sub create_ipconf_view { $device_cb->set_active($active); }; - my $name_pin_opts_button = Gtk3::Button->new('Options'); - $name_pin_opts_button->set_sensitive($gtk_state->{network_pinning_enabled}); - $name_pin_opts_button->signal_connect( + my $advanced_opts_button = Gtk3::Button->new('Advanced Options'); + $advanced_opts_button->signal_connect( clicked => sub { - create_network_interface_pin_view($refresh_device_cb); - }, - ); - - my $name_pin_checkbox = Gtk3::CheckButton->new('Pin network interface names'); - $name_pin_checkbox->set_active($gtk_state->{network_pinning_enabled}); - $name_pin_checkbox->signal_connect( - toggled => sub { - $name_pin_opts_button->set_sensitive(!!$name_pin_checkbox->get_active()); - $gtk_state->{network_pinning_enabled} = !!$name_pin_checkbox->get_active(); - $refresh_device_cb->(); + create_network_advanced_options_view($refresh_device_cb); }, ); @@ -661,8 +730,7 @@ sub create_ipconf_view { $grid->attach($dns_label, 0, 4, 1, 1); $grid->attach($ipconf_entry_dns, 1, 4, 2, 1); - $grid->attach($name_pin_checkbox, 1, 5, 1, 1); - $grid->attach($name_pin_opts_button, 2, 5, 1, 1); + $grid->attach($advanced_opts_button, 1, 5, 2, 1); $gtk_state->{inbox}->show_all; set_next( @@ -730,8 +798,6 @@ sub create_ipconf_view { } Proxmox::Install::Config::set_dns($dns_ip); - $gtk_state->{network_pinning_enabled} = !!$name_pin_checkbox->get_active(); - #print STDERR "TEST $ipaddress/$netmask $gateway_ip $dns_ip\n"; $step_number++; @@ -1188,35 +1254,6 @@ my $target_hd_label; my $hdoption_first_setup = 1; -# takes an array ref of rows with [$label_text, $widget, $suffix_label] array refs as columns -# $suffix_label is optional -my $create_label_widget_grid = sub { - my ($labeled_widgets) = @_; - - my $grid = &$create_basic_grid(); - - for (my $row = 0; $row < scalar($labeled_widgets->@*); $row++) { - my ($label_text, $widget, $suffix_label) = $labeled_widgets->[$row]->@*; - - my $label = Gtk3::Label->new($label_text); - $label->set_visible(1); - $label->set_xalign(1.0); - $grid->attach($label, 0, $row, 1, 1); - - $widget->set_visible(1); - $grid->attach($widget, 1, $row, 1, 1); - - if ($suffix_label) { - my $suffix_label = Gtk3::Label->new($suffix_label); - $suffix_label->set_visible(1); - $suffix_label->set_xalign(1.0); - $grid->attach($suffix_label, 2, $row, 1, 1); - } - } - - return $grid; -}; - # only relevant for raid with its multipl diskX to diskY mappings. my $get_selected_hdsize = sub { my $hdsize = shift; -- 2.55.0