[pve-devel] [PATCH installer 1/6] refactor check_float to check_*

Fabian Grünbichler f.gruenbichler at proxmox.com
Fri Dec 2 09:55:13 CET 2016


Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
Needed for ashift entry in next patch

 proxinstall | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/proxinstall b/proxinstall
index b08a5d3..3b908f6 100755
--- a/proxinstall
+++ b/proxinstall
@@ -1643,13 +1643,25 @@ sub cleanup_view {
 
 # fixme: newer GTK3 has special properties to handle numbers with Entry
 # only allow floating point numbers with Gtk3::Entry
+
 sub check_float {
     my ($entry, $event) = @_;
 
+    return check_number($entry, $event, 1);
+}
+
+sub check_int {
+    my ($entry, $event) = @_;
+
+    return check_number($entry, $event, 0);
+}
+
+sub check_number {
+    my ($entry, $event, $float) = @_;
 
     my $val = $event->get_keyval;
 
-    if ($val == ord '.' ||
+    if (($float && $val == ord '.') ||
 	$val == Gtk3::Gdk::KEY_ISO_Left_Tab ||
 	$val == Gtk3::Gdk::KEY_Shift_L ||
 	$val == Gtk3::Gdk::KEY_Tab ||
-- 
2.1.4





More information about the pve-devel mailing list