summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBeniamino Galvani <bgalvani@redhat.com>2017-04-19 14:11:53 +0200
committerBeniamino Galvani <bgalvani@redhat.com>2017-04-20 18:36:11 +0200
commit0b5e384f70d883816644e9203cb8d2dd2ac705da (patch)
tree0795d224a507a4b4923d974cda1f3fa88c808baa
parent2dad2bfecf003c7af1ae2eb9529c87d53d97ad2e (diff)
downloadnetwork-manager-applet-0b5e384f70d883816644e9203cb8d2dd2ac705da.tar.gz
applet: also react to vpn-state property changes
We use the 'state-changed' signal of active-connection to start and stop the icon animation and show notifications to user. In applet_update_icon() we also update the icon and tooltip based on the VPN state and thus it's necessary to react to changes in the 'vpn-state' property of the vpn-connection, otherwise the icon/tooltip would be out-of-sync with the real state.
-rw-r--r--src/applet.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/applet.c b/src/applet.c
index a19c6c70..6ea137a7 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -907,10 +907,10 @@ make_active_failure_message (NMActiveConnection *active,
}
static void
-vpn_connection_state_changed (NMVpnConnection *vpn,
- NMActiveConnectionState state,
- NMActiveConnectionStateReason reason,
- gpointer user_data)
+vpn_active_connection_state_changed (NMVpnConnection *vpn,
+ NMActiveConnectionState state,
+ NMActiveConnectionStateReason reason,
+ gpointer user_data)
{
NMApplet *applet = NM_APPLET (user_data);
const char *banner;
@@ -2268,6 +2268,17 @@ foo_manager_running_cb (NMClient *client,
applet_schedule_update_menu (applet);
}
+static void
+vpn_state_changed (NMActiveConnection *connection,
+ GParamSpec *pspec,
+ gpointer user_data)
+{
+ NMApplet *applet = NM_APPLET (user_data);
+
+ applet_schedule_update_icon (applet);
+ applet_schedule_update_menu (applet);
+}
+
#define VPN_STATE_ID_TAG "vpn-state-id"
static void
@@ -2289,8 +2300,13 @@ foo_active_connections_changed_cb (NMClient *client,
|| g_object_get_data (G_OBJECT (candidate), VPN_STATE_ID_TAG))
continue;
+ /* Start/stop animation when the AC state changes ... */
id = g_signal_connect (G_OBJECT (candidate), "state-changed",
- G_CALLBACK (vpn_connection_state_changed), applet);
+ G_CALLBACK (vpn_active_connection_state_changed), applet);
+ /* ... and also update icon/tooltip when the VPN state changes */
+ g_signal_connect (G_OBJECT (candidate), "notify::vpn-state",
+ G_CALLBACK (vpn_state_changed), applet);
+
g_object_set_data (G_OBJECT (candidate), VPN_STATE_ID_TAG, GUINT_TO_POINTER (id));
}