[PATCH] applet: fix wrong status for wireless toggle



When "state-changed" signal emits, there's a chance that wireless status has't
update yet, so the "Enable Wi-Fi" toggle shows the wrong status.

This can be solved by updating applet menu whenever "wireless-enabled" changes.

https://bugzilla.gnome.org/show_bug.cgi?id=770218
Signed-off-by: Kai-Heng Feng <kai heng feng canonical com>
---
 src/applet.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/src/applet.c b/src/applet.c
index 08be772..a8641bd 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -2291,6 +2291,13 @@ foo_manager_permission_changed (NMClient *client,
                applet->permissions[permission] = result;
 }
 
+static void
+foo_wireless_enabled_changed_cb (NMClient *client, GParamSpec *pspec, NMApplet *applet)
+{
+       applet_schedule_update_icon (applet);
+       applet_schedule_update_menu (applet);
+}
+
 static gboolean
 foo_set_initial_state (gpointer data)
 {
@@ -2340,6 +2347,14 @@ foo_client_setup (NMApplet *applet)
                          G_CALLBACK (foo_manager_permission_changed),
                          applet);
 
+    g_signal_connect (applet->nm_client, "notify::wireless-enabled",
+                         G_CALLBACK (foo_wireless_enabled_changed_cb),
+                         applet);
+
+    g_signal_connect (applet->nm_client, "notify::wwan-enabled",
+                         G_CALLBACK (foo_wireless_enabled_changed_cb),
+                         applet);
+
        /* Initialize permissions - the initial 'permission-changed' signal is emitted from NMClient 
constructor, and thus not caught */
        for (perm = NM_CLIENT_PERMISSION_NONE + 1; perm <= NM_CLIENT_PERMISSION_LAST; perm++) {
                applet->permissions[perm] = nm_client_get_permission_result (applet->nm_client, perm);
-- 
2.9.3



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]