Network: properly track vpn connection state

We were not listening for state changes on the ActiveConnection
objects representing actual connections, but only listened for
active connections appearing or disappearing. This caused
the VPN tab to get stuck on 'Authentication required' or similar
'intermediate' states until you manually switch tabs and back.

Also keep the switch from jumping back to off while the
vpn auth dialog is up, by adjusting the states we consider 'off'.
This commit is contained in:
Matthias Clasen 2011-03-26 20:52:04 -04:00
parent 2c52e10d2f
commit 4576e48c19

View file

@ -1517,7 +1517,9 @@ nm_device_refresh_vpn_ui (CcNetworkPanel *panel, NetVpn *vpn)
status = panel_vpn_state_to_localized_string (state);
gtk_label_set_label (GTK_LABEL (widget), status);
priv->updating_device = TRUE;
gtk_switch_set_active (GTK_SWITCH (sw), state == NM_VPN_CONNECTION_STATE_ACTIVATED);
gtk_switch_set_active (GTK_SWITCH (sw),
state != NM_VPN_CONNECTION_STATE_FAILED &&
state != NM_VPN_CONNECTION_STATE_DISCONNECTED);
priv->updating_device = FALSE;
/* gateway */
@ -1667,6 +1669,12 @@ cc_network_panel_notify_enable_active_cb (GtkSwitch *sw,
nm_client_wireless_set_enabled (panel->priv->client, enable);
}
static void
connection_state_changed (NMActiveConnection *c, GParamSpec *pspec, CcNetworkPanel *panel)
{
refresh_ui (panel);
}
static void
active_connections_changed (NMClient *client, GParamSpec *pspec, gpointer user_data)
{
@ -1687,6 +1695,12 @@ active_connections_changed (NMClient *client, GParamSpec *pspec, gpointer user_d
g_debug (" %s", nm_device_get_udi (g_ptr_array_index (devices, j)));
if (NM_IS_VPN_CONNECTION (connection))
g_debug (" VPN base connection: %s", nm_active_connection_get_specific_object (connection));
if (g_object_get_data (G_OBJECT (connection), "has-state-changed-handler") == NULL) {
g_signal_connect_object (connection, "notify::state",
G_CALLBACK (connection_state_changed), panel, 0);
g_object_set_data (G_OBJECT (connection), "has-state-changed-handler", GINT_TO_POINTER (TRUE));
}
}
refresh_ui (panel);