[network-manager-applet/bg/vpn-state-rh1442782: 4/4] applet: also react to vpn-state property changes
- From: Beniamino Galvani <bgalvani src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/bg/vpn-state-rh1442782: 4/4] applet: also react to vpn-state property changes
- Date: Wed, 19 Apr 2017 12:45:13 +0000 (UTC)
commit c5f05a559ba1079ef20b9442a5a160758d6e9f1b
Author: Beniamino Galvani <bgalvani redhat com>
Date: Wed Apr 19 14:11:53 2017 +0200
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.
src/applet.c | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/applet.c b/src/applet.c
index a19c6c7..bf19d23 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -907,7 +907,7 @@ make_active_failure_message (NMActiveConnection *active,
}
static void
-vpn_connection_state_changed (NMVpnConnection *vpn,
+vpn_active_connection_state_changed (NMVpnConnection *vpn,
NMActiveConnectionState state,
NMActiveConnectionStateReason reason,
gpointer user_data)
@@ -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));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]