[network-manager-applet] editor: correct on-the-fly color error indication for empty values



commit f22b86f4d1bc2b1c6dd0b384db2aa5d57c530518
Author: Jiří Klimeš <jklimes redhat com>
Date:   Tue Mar 3 16:40:22 2015 +0100

    editor: correct on-the-fly color error indication for empty values

 src/connection-editor/ip4-routes-dialog.c |    6 +++++-
 src/connection-editor/ip6-routes-dialog.c |    6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/src/connection-editor/ip4-routes-dialog.c b/src/connection-editor/ip4-routes-dialog.c
index 89e8424..e93c3c9 100644
--- a/src/connection-editor/ip4-routes-dialog.c
+++ b/src/connection-editor/ip4-routes-dialog.c
@@ -426,7 +426,7 @@ cell_changed_cb (GtkEditable *editable,
                /* Is it a prefix? */
                if (!strchr (cell_text, '.')) {
                        tmp_prefix = strtol (cell_text, NULL, 10);
-                       if (!errno && tmp_prefix <= 32)
+                       if (*cell_text && !errno && tmp_prefix <= 32)
                                value_valid = TRUE;
                } else {
                        struct in_addr tmp_addr;
@@ -449,6 +449,10 @@ cell_changed_cb (GtkEditable *editable,
 
                if (inet_pton (AF_INET, cell_text, &tmp_addr) > 0)
                        value_valid = TRUE;
+
+               /* Consider empty next_hop as valid */
+               if (!*cell_text && column == COL_NEXT_HOP)
+                       value_valid = TRUE;
        }
 
        /* Change cell's background color while editing */
diff --git a/src/connection-editor/ip6-routes-dialog.c b/src/connection-editor/ip6-routes-dialog.c
index 94be45d..9bad693 100644
--- a/src/connection-editor/ip6-routes-dialog.c
+++ b/src/connection-editor/ip6-routes-dialog.c
@@ -379,7 +379,7 @@ cell_changed_cb (GtkEditable *editable,
 
                errno = 0;
                tmp_int = strtol (cell_text, NULL, 10);
-               if (errno || tmp_int < 0 || tmp_int > 128)
+               if (!*cell_text || errno || tmp_int < 0 || tmp_int > 128)
                        value_valid = FALSE;
                else
                        value_valid = TRUE;
@@ -397,6 +397,10 @@ cell_changed_cb (GtkEditable *editable,
 
                if (inet_pton (AF_INET6, cell_text, &tmp_addr) > 0)
                        value_valid = TRUE;
+
+               /* Consider empty next_hop as valid */
+               if (!*cell_text && column == COL_NEXT_HOP)
+                       value_valid = TRUE;
        }
 
        /* Change cell's background color while editing */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]