[gnome-settings-daemon] rfkill: Account for having zero rfkill switches for airplane mode



commit 6d5774bb62976f341c898547beab6e4a5dbf9e51
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Wed Aug 14 21:04:58 2013 -0400

    rfkill: Account for having zero rfkill switches for airplane mode
    
    This is the case in desktops and VMs.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=706041

 plugins/rfkill/gsd-rfkill-manager.c |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/plugins/rfkill/gsd-rfkill-manager.c b/plugins/rfkill/gsd-rfkill-manager.c
index 80c61c2..8f36517 100644
--- a/plugins/rfkill/gsd-rfkill-manager.c
+++ b/plugins/rfkill/gsd-rfkill-manager.c
@@ -96,28 +96,27 @@ gsd_rfkill_manager_init (GsdRfkillManager *manager)
 static gboolean
 engine_get_airplane_mode (GsdRfkillManager *manager)
 {
-       gboolean enabled;
        GHashTableIter iter;
        gpointer key, value;
 
-       enabled = TRUE;
+        /* If we have no killswitches, airplane mode is off. */
+        if (g_hash_table_size (manager->priv->killswitches) == 0) {
+                return FALSE;
+        }
 
        g_hash_table_iter_init (&iter, manager->priv->killswitches);
        while (g_hash_table_iter_next (&iter, &key, &value)) {
-               int idx, state;
+               gboolean state;
 
-               idx = GPOINTER_TO_INT (key);
                state = GPOINTER_TO_INT (value);
-               g_debug ("Killswitch %d is %s", idx, state ? "enabled" : "disabled");
 
-               /* A single device that's enabled? airplane mode is off */
-               if (state == FALSE) {
-                       enabled = FALSE;
-                       break;
-               }
+               /* A single rfkill switch that's disabled? Airplane mode is off */
+               if (!state) {
+                        return FALSE;
+                }
        }
 
-        return enabled;
+        return TRUE;
 }
 
 static void


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