[gnome-control-center] power: Hide device battery when !is_present



commit c3f9546952de3083d3d16a903dd0034064be3aa1
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Feb 3 23:08:24 2015 +0100

    power: Hide device battery when !is_present
    
    iDevice batteries might show up before they're actually available
    to read from, so check "is-present" before showing the device in the UI.

 panels/power/cc-power-panel.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 5deb3d7..5a2a1cb 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -522,6 +522,7 @@ add_device (CcPowerPanel *panel, UpDevice *device)
   gchar *name;
   gchar *s;
   gboolean show_caution = FALSE;
+  gboolean is_present;
 
   name = NULL;
   g_object_get (device,
@@ -529,8 +530,15 @@ add_device (CcPowerPanel *panel, UpDevice *device)
                 "percentage", &percentage,
                 "state", &state,
                 "model", &name,
+                "is-present", &is_present,
                 NULL);
 
+  if (!is_present)
+    {
+      g_free (name);
+      return;
+    }
+
   if (kind == UP_DEVICE_KIND_UPS)
     show_caution = TRUE;
 


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