summaryrefslogtreecommitdiff
path: root/src/xfpm-supply.c
diff options
context:
space:
mode:
authorAli Abdallah <ali.slackware@gmail.com>2009-04-04 11:58:11 +0000
committerAli Abdallah <ali.slackware@gmail.com>2009-04-04 11:58:11 +0000
commit4ad9706e22ade75ced65bde4e4c9a639c0d268f5 (patch)
tree5b8041ce84ed01b9ceeedd89bd5d64a45d3cce2f /src/xfpm-supply.c
parent8928587625138a0287f256eb4bf59348e1cc6ad0 (diff)
downloadixfce4-power-manager-4ad9706e22ade75ced65bde4e4c9a639c0d268f5.tar.gz
Alpha2 release0.8.0alpha2
(Old svn revision: 7108)
Diffstat (limited to 'src/xfpm-supply.c')
-rw-r--r--src/xfpm-supply.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/xfpm-supply.c b/src/xfpm-supply.c
index 62cb9895..b06ac5da 100644
--- a/src/xfpm-supply.c
+++ b/src/xfpm-supply.c
@@ -66,6 +66,7 @@ struct XfpmSupplyPrivate
HalPower *power;
GHashTable *hash;
+ gboolean low_power;
gboolean adapter_present;
gboolean inhibited;
guint8 power_management;
@@ -105,7 +106,7 @@ xfpm_supply_class_init(XfpmSupplyClass *klass)
object_class->finalize = xfpm_supply_finalize;
- g_type_class_add_private(klass,sizeof(XfpmSupplyPrivate));
+ g_type_class_add_private (klass, sizeof (XfpmSupplyPrivate));
}
static void
@@ -121,6 +122,7 @@ xfpm_supply_init (XfpmSupply *supply)
supply->priv->tray = xfpm_tray_icon_new ();
supply->priv->inhibit = xfpm_inhibit_new ();
supply->priv->inhibited = FALSE;
+ supply->priv->low_power = FALSE;
xfpm_tray_icon_set_visible (supply->priv->tray, FALSE);
xfpm_tray_icon_set_icon (supply->priv->tray, "gpm-ac-adapter");
@@ -283,7 +285,7 @@ xfpm_supply_show_critical_action_inhibited (XfpmSupply *supply, XfpmBattery *bat
xfpm_supply_add_actions_to_notification (supply, battery, n);
- xfpm_notify_present_notification (supply->priv->notify, n, FALSE);
+ xfpm_notify_critical (supply->priv->notify, n);
}
static void
@@ -300,13 +302,12 @@ xfpm_supply_show_critical_action (XfpmSupply *supply, XfpmBattery *battery)
_("Xfce power manager"),
message,
xfpm_battery_get_icon_name (battery),
- 15000,
+ 20000,
XFPM_NOTIFY_CRITICAL,
xfpm_battery_get_status_icon (battery));
xfpm_supply_add_actions_to_notification (supply, battery, n);
-
- xfpm_notify_present_notification (supply->priv->notify, n, FALSE);
+ xfpm_notify_critical (supply->priv->notify, n);
}
static void
@@ -318,6 +319,7 @@ xfpm_supply_handle_primary_critical (XfpmSupply *supply, XfpmBattery *battery)
if ( xfpm_supply_on_low_power (supply) )
{
TRACE ("System is running on low power");
+ supply->priv->low_power = TRUE;
if ( supply->priv->inhibited )
{
xfpm_supply_show_critical_action_inhibited (supply, battery);
@@ -334,21 +336,24 @@ xfpm_supply_handle_primary_critical (XfpmSupply *supply, XfpmBattery *battery)
}
static void
-xfpm_supply_primary_critical (XfpmSupply *supply, XfpmBattery *battery, XfpmBatteryState state)
+xfpm_supply_battery_state_changed_cb (XfpmBattery *battery, XfpmBatteryState state, XfpmSupply *supply)
{
if ( state == BATTERY_CHARGE_CRITICAL )
- {
xfpm_supply_handle_primary_critical (supply, battery);
+ else if ( supply->priv->low_power == TRUE )
+ {
+ if ( xfpm_supply_on_low_power (supply) )
+ {
+ xfpm_supply_handle_primary_critical (supply, battery);
+ }
+ else
+ {
+ supply->priv->low_power = FALSE;
+ xfpm_notify_close_critical (supply->priv->notify);
+ }
}
}
-static void
-xfpm_supply_battery_state_changed_cb (XfpmBattery *battery, XfpmBatteryState state, XfpmSupply *supply)
-{
- if ( state == BATTERY_CHARGE_CRITICAL )
- xfpm_supply_primary_critical (supply, battery, state);
-}
-
static XfpmBattery *
xfpm_supply_get_battery (XfpmSupply *supply, const gchar *udi)
{