[Xfce4-commits] <xfce4-power-manager:master> Better low level charge notification.
Ali Abdallah
noreply at xfce.org
Tue Feb 15 15:06:01 CET 2011
Updating branch refs/heads/master
to 03951f243b64868adc6082950ba121bd5c130672 (commit)
from 13f01e6f2477f0308416e694c31880db977568db (commit)
commit 03951f243b64868adc6082950ba121bd5c130672
Author: Ali Abdallah <aliov at xfce.org>
Date: Tue Feb 15 10:56:54 2011 +0100
Better low level charge notification.
src/xfpm-battery.c | 14 ++++++++++++++
src/xfpm-battery.h | 4 ++++
src/xfpm-power.c | 17 +++++++++++++++--
3 files changed, 33 insertions(+), 2 deletions(-)
diff --git a/src/xfpm-battery.c b/src/xfpm-battery.c
index c701f14..5e49938 100644
--- a/src/xfpm-battery.c
+++ b/src/xfpm-battery.c
@@ -881,3 +881,17 @@ XfpmBatteryCharge xfpm_battery_get_charge (XfpmBattery *battery)
return battery->priv->charge;
}
+
+const gchar *xfpm_battery_get_battery_name (XfpmBattery *battery)
+{
+ g_return_val_if_fail (XFPM_IS_BATTERY (battery), NULL);
+
+ return battery->priv->battery_name;
+}
+
+gchar *xfpm_battery_get_time_left (XfpmBattery *battery)
+{
+ g_return_val_if_fail (XFPM_IS_BATTERY (battery), NULL);
+
+ return xfpm_battery_get_time_string (battery->priv->time_to_empty);
+}
diff --git a/src/xfpm-battery.h b/src/xfpm-battery.h
index 58cb784..4d4ca34 100644
--- a/src/xfpm-battery.h
+++ b/src/xfpm-battery.h
@@ -64,6 +64,10 @@ XfpmDeviceType xfpm_battery_get_device_type (XfpmBattery *battery);
XfpmBatteryCharge xfpm_battery_get_charge (XfpmBattery *battery);
+const gchar *xfpm_battery_get_battery_name(XfpmBattery *battery);
+
+gchar *xfpm_battery_get_time_left (XfpmBattery *battery);
+
G_END_DECLS
#endif /* __XFPM_BATTERY_H */
diff --git a/src/xfpm-power.c b/src/xfpm-power.c
index 6f1b563..667beb8 100644
--- a/src/xfpm-power.c
+++ b/src/xfpm-power.c
@@ -871,16 +871,29 @@ xfpm_power_battery_charge_changed_cb (XfpmBattery *battery, XfpmPower *power)
}
else if ( battery_charge == XFPM_BATTERY_CHARGE_LOW )
{
-
if ( notify )
+ {
+ gchar *msg;
+ gchar *time_str;
+
+ const gchar *battery_name = xfpm_battery_get_battery_name (battery);
+
+ time_str = xfpm_battery_get_time_left (battery);
+
+ msg = g_strdup_printf (_("Your %s y charge level is low\nEstimated time left %s"), battery_name, time_str);
+
+
xfpm_notify_show_notification (power->priv->notify,
_("Power Manager"),
- _("Battery charge level is low"),
+ msg,
gtk_status_icon_get_icon_name (GTK_STATUS_ICON (battery)),
10000,
FALSE,
XFPM_NOTIFY_NORMAL,
GTK_STATUS_ICON (battery));
+ g_free (msg);
+ g_free (time_str);
+ }
}
}
More information about the Xfce4-commits
mailing list