File gnome-control-center-fix-mobile-switch-button.patch of Package gnome-control-center.10840

From 9d75c37158c3166513cbdaa4f0c1f3ca2a9ea0b0 Mon Sep 17 00:00:00 2001
From: Jonathan Kang <jonathan121537@gmail.com>
Date: Thu, 13 Oct 2016 10:05:03 +0800
Subject: [PATCH] network: Fix switch button in mobile broadband tab

https://bugzilla.gnome.org/show_bug.cgi?id=690361
---
 panels/network/net-device-mobile.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/panels/network/net-device-mobile.c b/panels/network/net-device-mobile.c
index 408b2dc..048a823 100644
--- a/panels/network/net-device-mobile.c
+++ b/panels/network/net-device-mobile.c
@@ -164,19 +164,35 @@ mobilebb_enabled_toggled (NMClient       *client,
                           NetDeviceMobile *device_mobile)
 {
         gboolean enabled;
+        gboolean switch_state;
         GtkSwitch *sw;
         NMDevice *device;
+        NMDeviceState state;
 
         device = net_device_get_nm_device (NET_DEVICE (device_mobile));
         if (nm_device_get_device_type (device) != NM_DEVICE_TYPE_MODEM)
                 return;
 
+        state = nm_device_get_state (device);
+        if (state == NM_DEVICE_STATE_UNKNOWN ||
+            state == NM_DEVICE_STATE_UNMANAGED ||
+            state == NM_DEVICE_STATE_UNAVAILABLE ||
+            state == NM_DEVICE_STATE_DISCONNECTED ||
+            state == NM_DEVICE_STATE_DEACTIVATING ||
+            state == NM_DEVICE_STATE_FAILED)
+                switch_state = FALSE;
+        else
+                switch_state = TRUE;
+
         enabled = nm_client_wwan_get_enabled (client);
         sw = GTK_SWITCH (gtk_builder_get_object (device_mobile->priv->builder,
                                                  "device_off_switch"));
 
         device_mobile->priv->updating_device = TRUE;
-        gtk_switch_set_active (sw, enabled);
+        if (enabled == FALSE)
+                gtk_switch_set_active (sw, enabled);
+        else
+                gtk_switch_set_active (sw, switch_state);
         device_mobile->priv->updating_device = FALSE;
 }
 
-- 
2.7.4