[gnome-builder] libide: use UPower Percentage property for energy detection
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: use UPower Percentage property for energy detection
- Date: Tue, 24 Mar 2015 00:10:21 +0000 (UTC)
commit 0bbc330f0cf7fe0f5373d06ffc93982e1b3ec940
Author: Christian Hergert <christian hergert me>
Date: Tue Mar 10 16:49:35 2015 -0700
libide: use UPower Percentage property for energy detection
libide/ide-battery-monitor.c | 10 ++++++----
libide/ide-battery-monitor.h | 6 +++---
2 files changed, 9 insertions(+), 7 deletions(-)
---
diff --git a/libide/ide-battery-monitor.c b/libide/ide-battery-monitor.c
index a073ec1..83590f5 100644
--- a/libide/ide-battery-monitor.c
+++ b/libide/ide-battery-monitor.c
@@ -20,6 +20,8 @@
#include "ide-battery-monitor.h"
+#define CONSERVE_THRESHOLD 50.0
+
static GDBusProxy *gUPowerProxy;
static GDBusProxy *gUPowerDeviceProxy;
@@ -115,7 +117,7 @@ ide_battery_monitor_get_on_battery (void)
}
gdouble
-ide_battery_monitor_get_energy (void)
+ide_battery_monitor_get_energy_percentage (void)
{
GDBusProxy *proxy;
gdouble ret = 0.0;
@@ -126,7 +128,7 @@ ide_battery_monitor_get_energy (void)
{
GVariant *prop;
- prop = g_dbus_proxy_get_cached_property (proxy, "Energy");
+ prop = g_dbus_proxy_get_cached_property (proxy, "Percentage");
if (prop)
ret = g_variant_get_double (prop);
g_object_unref (proxy);
@@ -144,8 +146,8 @@ ide_battery_monitor_get_should_conserve (void)
{
gdouble energy;
- energy = ide_battery_monitor_get_energy ();
- should_conserve = (energy != 0.0) && (energy < 0.50);
+ energy = ide_battery_monitor_get_energy_percentage ();
+ should_conserve = (energy != 0.0) && (energy < CONSERVE_THRESHOLD);
}
return should_conserve;
diff --git a/libide/ide-battery-monitor.h b/libide/ide-battery-monitor.h
index ecd4369..7b6f99a 100644
--- a/libide/ide-battery-monitor.h
+++ b/libide/ide-battery-monitor.h
@@ -23,9 +23,9 @@
G_BEGIN_DECLS
-gdouble ide_battery_monitor_get_energy (void);
-gboolean ide_battery_monitor_get_on_battery (void);
-gboolean ide_battery_monitor_get_should_conserve (void);
+gdouble ide_battery_monitor_get_energy_percentage (void);
+gboolean ide_battery_monitor_get_on_battery (void);
+gboolean ide_battery_monitor_get_should_conserve (void);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]