[gnome-control-center/wip/hadess/add-fake-ups] power: Add a fake UPS device



commit 909f5ee3a221b384c18272be3b8069b14f14e1d5
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Nov 13 14:05:01 2019 +0100

    power: Add a fake UPS device
    
    When a define is set.

 panels/power/cc-power-panel.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
---
diff --git a/panels/power/cc-power-panel.c b/panels/power/cc-power-panel.c
index 98b19d0db..0ac6deb08 100644
--- a/panels/power/cc-power-panel.c
+++ b/panels/power/cc-power-panel.c
@@ -47,6 +47,12 @@
  * #define TEST_FAKE_DEVICES
  */
 
+/* Uncomment this to test the behaviour of a desktop machine
+ * with a UPS
+ *
+ * #define TEST_UPS
+ */
+
 struct _CcPowerPanel
 {
   CcPanel        parent_instance;
@@ -872,6 +878,30 @@ up_client_changed (UpClient     *client,
   }
 #endif
 
+#ifdef TEST_UPS
+  {
+    static gboolean fake_devices_added = FALSE;
+
+    if (!fake_devices_added)
+      {
+        fake_devices_added = TRUE;
+        g_print ("adding fake UPS\n");
+        device = up_device_new ();
+        g_object_set (device,
+                      "kind", UP_DEVICE_KIND_UPS,
+                      "native-path", "dummy:usb-hiddev0",
+                      "model", "APC UPS",
+                      "percentage", 70.0,
+                      "state", UP_DEVICE_STATE_DISCHARGING,
+                      "is-present", TRUE,
+                      "power-supply", TRUE,
+                      "battery-level", UP_DEVICE_LEVEL_NONE,
+                      NULL);
+        g_ptr_array_add (self->devices, device);
+      }
+  }
+#endif
+
   on_ups = FALSE;
   n_batteries = 0;
   composite = up_client_get_display_device (self->up_client);


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