[gnome-battery-bench] Power supply: add name property for all supplies



commit 631998dae0c3165c3de0047d4452730c662a19ac
Author: Christian Kellner <christian kellner me>
Date:   Fri Mar 31 15:54:28 2017 +0200

    Power supply: add name property for all supplies

 src/power-supply.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/power-supply.c b/src/power-supply.c
index c4f34af..32c8bdc 100644
--- a/src/power-supply.c
+++ b/src/power-supply.c
@@ -11,11 +11,13 @@
 
 typedef struct _GbbPowerSupplyPrivate {
     GUdevDevice *udevice;
+    char        *id;
 } GbbPowerSupplyPrivate;
 
 enum {
     PROP_SUPPLY_0,
     PROP_UDEV_DEVICE,
+    PROP_NAME,
     PROP_SUPPLY_LAST
 };
 
@@ -46,12 +48,18 @@ gbb_power_supply_get_property(GObject    *object,
 {
     GbbPowerSupply *ps = GBB_POWER_SUPPLY(object);
     GbbPowerSupplyPrivate *priv = SUPPLY_GET_PRIV(ps);
+    const char *name;
 
     switch (prop_id) {
 
     case PROP_UDEV_DEVICE:
         g_value_set_object(value, priv->udevice);
         break;
+
+    case PROP_NAME:
+        name = g_udev_device_get_name(priv->udevice);
+        g_value_set_string(value, name);
+        break;
     }
 }
 
@@ -89,6 +97,12 @@ gbb_power_supply_class_init(GbbPowerSupplyClass *klass)
                             G_PARAM_CONSTRUCT_ONLY |
                             G_PARAM_STATIC_NAME);
 
+    supply_props[PROP_NAME] =
+        g_param_spec_string("name", NULL, NULL,
+                            NULL,
+                            G_PARAM_READABLE |
+                            G_PARAM_STATIC_NAME);
+
     g_object_class_install_properties(gobject_class,
                                       PROP_SUPPLY_LAST,
                                       supply_props);


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