Comment 135 for bug 531190

Revision history for this message
Michael (michaeljt) wrote :

On the offchance that my idea is right I am about to test the following patch to gnome-setting-deamon. If anyone has a clue about that code please take a look and tell me if it is correct or hopeless.

$ diff -ud ./plugins/power/gsd-power-manager.c.old ./plugins/power/gsd-power-manager.c
--- ./plugins/power/gsd-power-manager.c.old 2011-12-09 23:26:57.786558053 +0100
+++ ./plugins/power/gsd-power-manager.c 2011-12-09 23:30:02.812727359 +0100
@@ -375,9 +375,16 @@
 engine_get_warning_percentage (GsdPowerManager *manager, UpDevice *device)
 {
         gdouble percentage;
+ gboolean is_present;

         /* get device properties */
- g_object_get (device, "percentage", &percentage, NULL);
+ g_object_get (device,
+ "percentage", &percentage,
+ "is-present", &is_present,
+ NULL);
+
+ if (!is_present)
+ return WARNING_NONE;

         if (percentage <= manager->priv->action_percentage)
                 return WARNING_ACTION;
@@ -393,13 +400,18 @@
 {
         UpDeviceKind kind;
         gint64 time_to_empty;
+ gboolean is_present;

         /* get device properties */
         g_object_get (device,
                       "kind", &kind,
                       "time-to-empty", &time_to_empty,
+ "is-present", &is_present,
                       NULL);

+ if (!is_present)
+ return WARNING_NONE;
+
         /* this is probably an error condition */
         if (time_to_empty == 0) {
                 g_debug ("time zero, falling back to percentage for %s",