[pve-devel] [RFC/PATCH v2 installer 2/3] Add minfree entry to ZFS grid

Stoiko Ivanov s.ivanov at proxmox.com
Thu Nov 15 18:02:02 CET 2018


by creating a GTKEntry widget, which shares its entrybuffer with the minfree
widget in the regular partitioning menu.

Move get_float sub up and use it for the new widget.

Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
 proxinstall | 41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/proxinstall b/proxinstall
index 18679c6..420da8a 100755
--- a/proxinstall
+++ b/proxinstall
@@ -2590,6 +2590,22 @@ my $create_raid_disk_grid = sub {
 #    &$create_label_widget_grid($disk_labeled_widgets)
 };
 
+my $get_float = sub {
+    my ($entry) = @_;
+
+    my $text = $entry->get_text();
+    return undef if !defined($text);
+
+    $text =~ s/^\s+//;
+    $text =~ s/\s+$//;
+
+    return undef if $text !~ m/^\d+(\.\d+)?$/;
+
+    return $text;
+};
+
+my $minfree_entry_buffer = Gtk3::EntryBuffer->new(undef, 1);
+
 my $create_raid_advanced_grid = sub {
     my $labeled_widgets = [];
     my $spinbutton_ashift = Gtk3::SpinButton->new_with_range(9,13,1);
@@ -2644,6 +2660,15 @@ my $create_raid_advanced_grid = sub {
     $spinbutton_copies->set_value($config_options->{copies});
     push @$labeled_widgets, "copies", $spinbutton_copies;
 
+    my $entry_minfree = Gtk3::Entry->new_with_buffer($minfree_entry_buffer);
+    $entry_minfree->set_tooltip_text("minimum free space (GB, left unpartitioned on all bootable devices)");
+    $entry_minfree->signal_connect (changed => sub{
+        my $w = shift;
+        $config_options->{minfree} = $get_float->($w);
+    });
+    $entry_minfree->set_text($config_options->{minfree}) if defined($config_options->{minfree});
+    push @$labeled_widgets, "minfree", $entry_minfree;
+
     return &$create_label_widget_grid($labeled_widgets);;
 };
 
@@ -2732,7 +2757,7 @@ sub create_hdoption_view {
 	push @$hdsize_labeled_widgets, "maxroot", $entry_maxroot;
     }
 
-    my $entry_minfree = Gtk3::Entry->new();
+    my $entry_minfree = Gtk3::Entry->new_with_buffer($minfree_entry_buffer);
     $entry_minfree->set_tooltip_text("minimum free LVM space (GB, required for LVM snapshots)");
     $entry_minfree->signal_connect (key_press_event => \&check_float);
     $entry_minfree->set_text($config_options->{minfree}) if defined($config_options->{minfree});
@@ -2797,20 +2822,6 @@ sub create_hdoption_view {
 
     $dialog->run();
 
-    my $get_float = sub {
-	my ($entry) = @_;
-
-	my $text = $entry->get_text();
-	return undef if !defined($text);
-
-	$text =~ s/^\s+//;
-	$text =~ s/\s+$//;
-
-	return undef if $text !~ m/^\d+(\.\d+)?$/;
-
-	return $text;
-    };
-
     my $tmp;
 
     if (($tmp = &$get_float($spinbutton_hdsize)) && ($tmp != $hdsize)) {
-- 
2.11.0





More information about the pve-devel mailing list