summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-06-03 09:36:17 -0400
committerJiří Klimeš <jklimes@redhat.com>2014-06-03 16:06:35 +0200
commitd57795d474aaae7865d4d052605d5ddec65c429d (patch)
tree68891615e408dba5d2fb84ad64ef0a23b862d7f1
parent5ee85fe46e86fdc9e063c22700697802435503a6 (diff)
downloadNetworkManager-d57795d474aaae7865d4d052605d5ddec65c429d.tar.gz
tui: fix NmtMacEntry validation/display
NmtMacEntry would allow you to input 1 character more than it should have. Fix that. Also, the code to insert ":"s automatically was bumping against some weirdness in NmtNewtEntry that made it so that the ":" didn't get displayed until you typed one more character after the one where it got inserted. Hack around that by manually requesting a redraw. https://bugzilla.gnome.org/show_bug.cgi?id=731160
-rw-r--r--tui/nmt-mac-entry.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/tui/nmt-mac-entry.c b/tui/nmt-mac-entry.c
index b065640812..5e1c41743e 100644
--- a/tui/nmt-mac-entry.c
+++ b/tui/nmt-mac-entry.c
@@ -82,7 +82,7 @@ mac_filter (NmtNewtEntry *entry,
{
NmtMacEntryPrivate *priv = NMT_MAC_ENTRY_GET_PRIVATE (entry);
- if (position > priv->mac_str_length)
+ if (position >= priv->mac_str_length)
return FALSE;
return g_ascii_isxdigit (ch) || ch == ':';
@@ -116,8 +116,13 @@ mac_validator (NmtNewtEntry *entry,
if (g_ascii_isxdigit (p[0]) && !p[1]) {
char *fixed = g_strdup_printf ("%.*s:%c", (int)(p - text), text, *p);
- g_object_set (G_OBJECT (entry), "text", fixed, NULL);
- return TRUE;
+ nmt_newt_entry_set_text (entry, fixed);
+ g_free (fixed);
+
+ /* FIXME: NmtNewtEntry doesn't correctly deal with us calling set_text()
+ * from inside the validator.
+ */
+ nmt_newt_widget_needs_rebuild (NMT_NEWT_WIDGET (entry));
}
return FALSE;