network: update on/off switch button when vpn becomes active/inactive
https://bugzilla.gnome.org/show_bug.cgi?id=699275
This commit is contained in:
parent
8e1bfc521e
commit
94ce9bb9bc
1 changed files with 38 additions and 0 deletions
|
@ -39,6 +39,7 @@ struct _NetVpnPrivate
|
||||||
{
|
{
|
||||||
GtkBuilder *builder;
|
GtkBuilder *builder;
|
||||||
NMConnection *connection;
|
NMConnection *connection;
|
||||||
|
NMActiveConnection *active_connection;
|
||||||
gchar *service_type;
|
gchar *service_type;
|
||||||
gboolean valid;
|
gboolean valid;
|
||||||
gboolean updating_device;
|
gboolean updating_device;
|
||||||
|
@ -286,6 +287,14 @@ nm_device_refresh_vpn_ui (NetVpn *vpn)
|
||||||
gtk_label_set_label (GTK_LABEL (widget), title);
|
gtk_label_set_label (GTK_LABEL (widget), title);
|
||||||
g_free (title);
|
g_free (title);
|
||||||
|
|
||||||
|
if (priv->active_connection) {
|
||||||
|
g_signal_handlers_disconnect_by_func (vpn->priv->active_connection,
|
||||||
|
nm_device_refresh_vpn_ui,
|
||||||
|
vpn);
|
||||||
|
g_clear_object (&priv->active_connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* use status */
|
/* use status */
|
||||||
state = net_vpn_get_state (vpn);
|
state = net_vpn_get_state (vpn);
|
||||||
client = net_object_get_client (NET_OBJECT (vpn));
|
client = net_object_get_client (NET_OBJECT (vpn));
|
||||||
|
@ -297,6 +306,10 @@ nm_device_refresh_vpn_ui (NetVpn *vpn)
|
||||||
|
|
||||||
apath = nm_active_connection_get_connection (a);
|
apath = nm_active_connection_get_connection (a);
|
||||||
if (NM_IS_VPN_CONNECTION (a) && strcmp (apath, path) == 0) {
|
if (NM_IS_VPN_CONNECTION (a) && strcmp (apath, path) == 0) {
|
||||||
|
priv->active_connection = g_object_ref (a);
|
||||||
|
g_signal_connect_swapped (a, "notify::vpn-state",
|
||||||
|
G_CALLBACK (nm_device_refresh_vpn_ui),
|
||||||
|
vpn);
|
||||||
state = nm_vpn_connection_get_vpn_state (NM_VPN_CONNECTION (a));
|
state = nm_vpn_connection_get_vpn_state (NM_VPN_CONNECTION (a));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -339,6 +352,12 @@ nm_device_refresh_vpn_ui (NetVpn *vpn)
|
||||||
net_vpn_get_password (vpn));
|
net_vpn_get_password (vpn));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
nm_active_connections_changed (NetVpn *vpn)
|
||||||
|
{
|
||||||
|
nm_device_refresh_vpn_ui (vpn);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vpn_proxy_refresh (NetObject *object)
|
vpn_proxy_refresh (NetObject *object)
|
||||||
{
|
{
|
||||||
|
@ -471,10 +490,17 @@ static void
|
||||||
net_vpn_constructed (GObject *object)
|
net_vpn_constructed (GObject *object)
|
||||||
{
|
{
|
||||||
NetVpn *vpn = NET_VPN (object);
|
NetVpn *vpn = NET_VPN (object);
|
||||||
|
NMClient *client = net_object_get_client (NET_OBJECT (object));
|
||||||
|
|
||||||
G_OBJECT_CLASS (net_vpn_parent_class)->constructed (object);
|
G_OBJECT_CLASS (net_vpn_parent_class)->constructed (object);
|
||||||
|
|
||||||
nm_device_refresh_vpn_ui (vpn);
|
nm_device_refresh_vpn_ui (vpn);
|
||||||
|
|
||||||
|
g_signal_connect_swapped (client,
|
||||||
|
"notify::active-connections",
|
||||||
|
G_CALLBACK (nm_active_connections_changed),
|
||||||
|
vpn);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -482,6 +508,18 @@ net_vpn_finalize (GObject *object)
|
||||||
{
|
{
|
||||||
NetVpn *vpn = NET_VPN (object);
|
NetVpn *vpn = NET_VPN (object);
|
||||||
NetVpnPrivate *priv = vpn->priv;
|
NetVpnPrivate *priv = vpn->priv;
|
||||||
|
NMClient *client = net_object_get_client (NET_OBJECT (object));
|
||||||
|
|
||||||
|
g_signal_handlers_disconnect_by_func (client,
|
||||||
|
nm_active_connections_changed,
|
||||||
|
vpn);
|
||||||
|
|
||||||
|
if (priv->active_connection) {
|
||||||
|
g_signal_handlers_disconnect_by_func (priv->active_connection,
|
||||||
|
nm_device_refresh_vpn_ui,
|
||||||
|
vpn);
|
||||||
|
g_object_unref (priv->active_connection);
|
||||||
|
}
|
||||||
|
|
||||||
g_object_unref (priv->connection);
|
g_object_unref (priv->connection);
|
||||||
g_free (priv->service_type);
|
g_free (priv->service_type);
|
||||||
|
|
Loading…
Add table
Reference in a new issue