GNOME Bugzilla – Bug 740017
tui: fix gateway editing
Last modified: 2014-12-01 11:05:28 UTC
Since adding NMSettingIPConfig:gateway, we were just binding that property to the Gateway entry as a string. But this caused two different problems: first, we were trying to set the :gateway property from the entry even when the IP address in the entry was incomplete (causing warnings), and second, we were no longer enforcing the rule that the gateway can only be set when there are static addresses configured. Fix this by adding back nm_editor_bind_ip_gateway_to_string(), but with new semantics reflecting the new way NMSettingIPConfig:addresses and :gateway work. (Besides just fixing the new bugs, this also makes the Gateway entry insensitive when there are no addresses; before, nmtui would allow you to type there, but the value would not be saved.) Fixes: Test263_nmtui_ipv4_addresses_delete_ip_and_back_to_auto
Created attachment 290519 [details] [review] tui: fix gateway editing
Looks correct and tests correct too. Only downside is that during one editing session, if you remove all addresses, the gateway field gets cleared. But if you add an address again, the gateway field stays empty. It would be very nice to fill the input field with the previous gateway value.
(In reply to comment #2) > Only downside is that during one editing session, if you remove all addresses, > the gateway field gets cleared. > But if you add an address again, the gateway field stays empty. That was true in 0.9.10 too > It would be very nice to fill the input field with the previous gateway value. Would it? It seems improbable that you'd have a connection with multiple IPs, and then you'd want to delete all of them and add new ones, while keeping the gateway the same. (If there's only a single IP then you would most likely just edit that IP address rather than delete it and re-add it, so the gateway wouldn't get deleted in that case.)
Review of attachment 290519 [details] [review]: ::: clients/tui/nm-editor-bindings.h @@ +41,3 @@ +void nm_editor_bind_ip_gateway_to_string (int family, + NMSettingIPConfig *source, + gpointer target, Sure you don't want a NmtNewtEntry here or something, instead of gpointer?
(In reply to comment #4) > Sure you don't want a NmtNewtEntry here or something, instead of gpointer? nm-editor-bindings.[ch] is client-agnostic. In particular, nm_editor_bind_ip_gateway_to_string() would work correctly with a GtkEntry as well.
Attachment 290519 [details] pushed as 29ed625 - tui: fix gateway editing