network: Fix gateway entry visibility
From https://bugzilla.gnome.org/show_bug.cgi?id=765969 as explained by Dan Winship: " libnm-util/libnm-glib had a buggy data model, which nm-connection-editor (and then gnome-control-center) copied, in which each manually-configured IP address has an associated gateway address. In reality, NM always just took the first non-empty gateway value from the address array, and completely ignored any other gateway values. libnm represents this more accurately, by having a single gateway value which is separate from the address array. Ideally, the editors should show it this way as well (eg, like nmtui does). Failing that, it would be nice to at least make it so that only the first row in the address table can have a non-empty gateway value. " We went for the second option, only showing a gateway entry for the first address in the list. This isn't related to route-specific gateway addresses. https://bugzilla.gnome.org/show_bug.cgi?id=765969
This commit is contained in:
parent
ab2b13cacd
commit
d28ffc9902
1 changed files with 30 additions and 1 deletions
|
@ -119,6 +119,28 @@ update_row_sensitivity (CEPageIP4 *page, GtkWidget *list)
|
|||
g_list_free (children);
|
||||
}
|
||||
|
||||
static void
|
||||
update_row_gateway_visibility (CEPageIP4 *page)
|
||||
{
|
||||
GList *children, *l;
|
||||
gint rows = 0;
|
||||
|
||||
children = gtk_container_get_children (GTK_CONTAINER (page->address_list));
|
||||
for (l = children; l; l = l->next) {
|
||||
GtkWidget *row = l->data;
|
||||
GtkWidget *label, *entry;
|
||||
|
||||
label = GTK_WIDGET (g_object_get_data (G_OBJECT (row), "gateway-label"));
|
||||
entry = GTK_WIDGET (g_object_get_data (G_OBJECT (row), "gateway"));
|
||||
|
||||
gtk_widget_set_visible (label, (rows == 0));
|
||||
gtk_widget_set_visible (entry, (rows == 0));
|
||||
|
||||
rows++;
|
||||
}
|
||||
g_list_free (children);
|
||||
}
|
||||
|
||||
static void
|
||||
remove_row (GtkButton *button, CEPageIP4 *page)
|
||||
{
|
||||
|
@ -135,6 +157,8 @@ remove_row (GtkButton *button, CEPageIP4 *page)
|
|||
ce_page_changed (CE_PAGE (page));
|
||||
|
||||
update_row_sensitivity (page, list);
|
||||
if (list == page->address_list)
|
||||
update_row_gateway_visibility (page);
|
||||
}
|
||||
|
||||
static gint
|
||||
|
@ -205,6 +229,7 @@ add_address_row (CEPageIP4 *page,
|
|||
label = gtk_label_new (_("Gateway"));
|
||||
gtk_widget_set_halign (label, GTK_ALIGN_END);
|
||||
gtk_grid_attach (GTK_GRID (row_grid), label, 1, 3, 1, 1);
|
||||
g_object_set_data (G_OBJECT (row), "gateway-label", label);
|
||||
widget = gtk_entry_new ();
|
||||
gtk_label_set_mnemonic_widget (GTK_LABEL (label), widget);
|
||||
g_signal_connect_swapped (widget, "changed", G_CALLBACK (ce_page_changed), page);
|
||||
|
@ -215,6 +240,9 @@ add_address_row (CEPageIP4 *page,
|
|||
gtk_widget_set_hexpand (widget, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (row_grid), widget, 2, 3, 1, 1);
|
||||
|
||||
gtk_widget_set_no_show_all (label, TRUE);
|
||||
gtk_widget_set_no_show_all (widget, FALSE);
|
||||
|
||||
delete_button = gtk_button_new ();
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (delete_button), "image-button");
|
||||
g_signal_connect (delete_button, "clicked", G_CALLBACK (remove_row), page);
|
||||
|
@ -235,6 +263,7 @@ add_address_row (CEPageIP4 *page,
|
|||
gtk_widget_show_all (row);
|
||||
gtk_container_add (GTK_CONTAINER (page->address_list), row);
|
||||
|
||||
update_row_gateway_visibility (page);
|
||||
update_row_sensitivity (page, page->address_list);
|
||||
}
|
||||
|
||||
|
@ -314,7 +343,7 @@ add_address_section (CEPageIP4 *page)
|
|||
add_address_row (page,
|
||||
nm_ip_address_get_address (addr),
|
||||
network,
|
||||
nm_setting_ip_config_get_gateway (page->setting));
|
||||
i == 0 ? nm_setting_ip_config_get_gateway (page->setting) : "");
|
||||
}
|
||||
if (nm_setting_ip_config_get_num_addresses (page->setting) == 0)
|
||||
add_empty_address_row (page);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue