diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2009-08-19 23:50:14 +0800 |
---|---|---|
committer | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2009-08-19 23:50:44 +0800 |
commit | c98e85dcf635914dc66755d6a8560e2d370cfffe (patch) | |
tree | 3aa9733ce27b1a93ed3179f85e3fb7bb7aafab50 /libempathy/empathy-connectivity.c | |
parent | c777b477a4003b4f49285500736f0c91767c76cb (diff) | |
download | gsoc2013-empathy-c98e85dcf635914dc66755d6a8560e2d370cfffe.tar gsoc2013-empathy-c98e85dcf635914dc66755d6a8560e2d370cfffe.tar.gz gsoc2013-empathy-c98e85dcf635914dc66755d6a8560e2d370cfffe.tar.bz2 gsoc2013-empathy-c98e85dcf635914dc66755d6a8560e2d370cfffe.tar.lz gsoc2013-empathy-c98e85dcf635914dc66755d6a8560e2d370cfffe.tar.xz gsoc2013-empathy-c98e85dcf635914dc66755d6a8560e2d370cfffe.tar.zst gsoc2013-empathy-c98e85dcf635914dc66755d6a8560e2d370cfffe.zip |
empathy-connectivity: only send the new state in the state-change signal
It can be assumed that the old state was always the opposite to the
new state, because the signal is only ever fired if the new state
differs from the old state.
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'libempathy/empathy-connectivity.c')
-rw-r--r-- | libempathy/empathy-connectivity.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/libempathy/empathy-connectivity.c b/libempathy/empathy-connectivity.c index 8c38cf2c3..82ac9c9cb 100644 --- a/libempathy/empathy-connectivity.c +++ b/libempathy/empathy-connectivity.c @@ -58,6 +58,23 @@ static EmpathyConnectivity *connectivity_singleton = NULL; G_DEFINE_TYPE (EmpathyConnectivity, empathy_connectivity, G_TYPE_OBJECT); +static void +connectivity_change_state (EmpathyConnectivity *connectivity, + gboolean new_state) +{ + EmpathyConnectivityPriv *priv; + + priv = GET_PRIV (connectivity); + + if (priv->connected == new_state) + return; + + priv->connected = new_state; + + g_signal_emit (connectivity, signals[STATE_CHANGE], 0, + priv->connected); +} + #ifdef HAVE_NM static void connectivity_nm_state_change_cb (NMClient *client, @@ -65,7 +82,6 @@ connectivity_nm_state_change_cb (NMClient *client, EmpathyConnectivity *connectivity) { EmpathyConnectivityPriv *priv; - gboolean old_nm_connected; gboolean new_nm_connected; NMState state; @@ -75,16 +91,12 @@ connectivity_nm_state_change_cb (NMClient *client, return; state = nm_client_get_state (priv->nm_client); - old_nm_connected = priv->connected; new_nm_connected = !(state == NM_STATE_CONNECTING || state == NM_STATE_DISCONNECTED); DEBUG ("New NetworkManager network state %d", state); - priv->connected = new_nm_connected; - - g_signal_emit (connectivity, signals[STATE_CHANGE], 0, - old_nm_connected, new_nm_connected); + connectivity_change_state (connectivity, new_nm_connected); } #endif @@ -223,9 +235,9 @@ empathy_connectivity_class_init (EmpathyConnectivityClass *klass) G_SIGNAL_RUN_LAST, 0, NULL, NULL, - _empathy_marshal_VOID__BOOLEAN_BOOLEAN, + _empathy_marshal_VOID__BOOLEAN, G_TYPE_NONE, - 2, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, NULL); + 1, G_TYPE_BOOLEAN, NULL); g_object_class_install_property (oclass, PROP_USE_CONN, @@ -294,8 +306,7 @@ empathy_connectivity_set_use_conn (EmpathyConnectivity *connectivity, } else { - g_signal_emit (connectivity, signals[STATE_CHANGE], 0, - FALSE, TRUE); + connectivity_change_state (connectivity, TRUE); } g_object_notify (G_OBJECT (connectivity), "use-conn"); |